babylon.module.d.ts 6.4 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125138126138127138128138129138130138131138132138133138134138135138136138137138138138139138140138141138142138143138144138145138146138147138148138149138150138151138152138153138154138155138156138157138158138159138160138161138162138163138164138165138166138167138168138169138170138171138172138173138174138175138176138177138178138179138180138181138182138183138184138185138186138187138188138189138190138191138192138193138194138195138196138197138198138199138200138201138202138203138204138205138206138207138208138209138210138211138212138213138214138215138216138217138218138219138220138221138222138223138224138225138226138227138228138229138230138231138232138233138234138235138236138237138238138239138240138241138242138243138244138245138246138247138248138249138250138251138252138253138254138255138256138257138258138259138260138261138262138263138264138265138266138267138268138269138270138271138272138273138274138275138276138277138278138279138280138281138282138283138284138285138286138287138288138289138290138291138292138293138294138295138296138297138298138299138300138301138302138303138304138305138306138307138308138309138310138311138312138313138314138315138316138317138318138319138320138321138322138323138324138325138326138327138328138329138330138331138332138333138334138335138336138337138338138339138340138341138342138343138344138345138346138347138348138349138350138351138352138353138354138355138356138357138358138359138360138361138362138363138364138365138366138367138368138369138370138371138372138373138374138375138376138377138378138379138380138381138382138383138384138385138386138387138388138389138390138391138392138393138394138395138396138397138398138399138400138401138402138403138404138405138406138407138408138409138410138411138412138413138414138415138416138417138418138419138420138421138422138423138424138425138426138427138428138429138430138431138432138433138434138435138436138437138438138439138440138441138442138443138444138445138446138447138448138449138450138451138452138453138454138455138456138457138458138459138460138461138462138463138464138465138466138467138468138469138470138471138472138473138474138475138476138477138478138479138480138481138482138483138484138485138486138487138488138489138490138491138492138493138494138495138496138497138498138499138500138501138502138503138504138505138506138507138508138509138510138511138512138513138514138515138516138517138518138519138520138521138522138523138524138525138526138527138528138529138530138531138532138533138534138535138536138537138538138539138540138541138542138543138544138545138546138547138548138549138550138551138552138553138554138555138556138557138558138559138560138561138562138563138564138565138566138567138568138569138570138571138572138573138574138575138576138577138578138579138580138581138582138583138584138585138586138587138588138589138590138591138592138593138594138595138596138597138598138599138600138601138602138603138604138605138606138607138608138609138610138611138612138613138614138615138616138617138618138619138620138621138622138623138624138625138626138627138628138629138630138631138632138633138634138635138636138637138638138639138640138641138642138643138644138645138646138647138648138649138650138651138652138653138654138655138656138657138658138659138660138661138662138663138664138665138666138667138668138669138670138671138672138673138674138675138676138677138678138679138680138681138682138683138684138685138686138687138688138689138690138691138692138693138694138695138696138697138698138699138700138701138702138703138704138705138706138707138708138709138710138711138712138713138714138715138716138717138718138719138720138721138722138723138724138725138726138727138728138729138730138731138732138733138734138735138736138737138738138739138740138741138742138743138744138745138746138747138748138749138750138751138752138753138754138755138756138757138758138759138760138761138762138763138764138765138766138767138768138769138770138771138772138773138774138775138776138777138778138779138780138781138782138783138784138785138786138787138788138789138790138791138792138793138794138795138796138797138798138799138800138801138802138803138804138805138806138807138808138809138810138811138812138813138814138815138816138817138818138819138820138821138822138823138824138825138826138827138828138829138830138831138832138833138834138835138836138837138838138839138840138841138842138843138844138845138846138847138848138849138850138851138852138853138854138855138856138857138858138859138860138861138862138863138864138865138866138867138868138869138870138871138872138873138874138875138876138877138878138879138880138881138882138883138884138885138886138887138888138889138890138891138892138893138894138895138896138897138898138899138900138901138902138903138904138905138906138907138908138909138910138911138912138913138914138915138916138917138918138919138920138921138922138923138924138925138926138927138928138929138930138931138932138933138934138935138936138937138938138939138940138941138942138943138944138945138946138947138948138949138950138951138952138953138954138955138956138957138958138959138960138961138962138963138964138965138966138967138968138969138970138971138972138973138974138975138976138977138978138979138980138981138982138983138984138985138986138987138988138989138990138991138992138993138994138995138996138997138998138999139000139001139002139003139004139005139006139007139008139009139010139011139012139013139014139015139016139017139018139019139020139021139022139023139024139025139026139027139028139029139030139031139032139033139034139035139036139037139038139039139040139041139042139043139044139045139046139047139048139049139050139051139052139053139054139055139056139057139058139059139060139061139062139063139064139065139066139067139068139069139070139071139072139073139074139075139076139077139078139079139080139081139082139083139084139085139086139087139088139089139090139091139092139093139094139095139096139097139098139099139100139101139102139103139104139105139106139107139108139109139110139111139112139113139114139115139116139117139118139119139120139121139122139123139124139125139126139127139128139129139130139131139132139133139134139135139136139137139138139139139140139141139142139143139144139145139146139147139148139149139150139151139152139153139154139155139156139157139158139159139160139161139162139163139164139165139166139167139168139169139170139171139172139173139174139175139176139177139178139179139180139181139182139183139184139185139186139187139188139189139190139191139192139193139194139195139196139197139198139199139200139201139202139203139204139205139206139207139208139209139210139211139212139213139214139215139216139217139218139219139220139221139222139223139224139225139226139227139228139229139230139231139232139233139234139235139236139237139238139239139240139241139242139243139244139245139246139247139248139249139250139251139252139253139254139255139256139257139258139259139260139261139262139263139264139265139266139267139268139269139270139271139272139273139274139275139276139277139278139279139280139281139282139283139284139285139286139287139288139289139290139291139292139293139294139295139296139297139298139299139300139301139302139303139304139305139306139307139308139309139310139311139312139313139314139315139316139317139318139319139320139321139322139323139324139325139326139327139328139329139330139331139332139333139334139335139336139337139338139339139340139341139342139343139344139345139346139347139348139349139350139351139352139353139354139355139356139357139358139359139360139361139362139363139364139365139366139367139368139369139370139371139372139373139374139375139376139377139378139379139380139381139382139383139384139385139386139387139388139389139390139391139392139393139394139395139396139397139398139399139400139401139402139403139404139405139406139407139408139409139410139411139412139413139414139415139416139417139418139419139420139421139422139423139424139425139426139427139428139429139430139431139432139433139434139435139436139437139438139439139440139441139442139443139444139445139446139447139448139449139450139451139452139453139454139455139456139457139458139459139460139461139462139463139464139465139466139467139468139469139470139471139472139473139474139475139476139477139478139479139480139481139482139483139484139485139486139487139488139489139490139491139492139493139494139495139496139497139498139499139500139501139502139503139504139505139506139507139508139509139510139511139512139513139514139515139516139517139518139519139520139521139522139523139524139525139526139527139528139529139530139531139532139533139534139535139536139537139538139539139540139541139542139543139544139545139546139547139548139549139550139551139552139553139554139555139556139557139558139559139560139561139562139563139564139565139566139567139568139569139570139571139572139573139574139575139576139577139578139579139580139581139582139583139584139585139586139587139588139589139590139591139592139593139594139595139596139597139598139599139600139601139602139603139604139605139606139607139608139609139610139611139612139613139614139615139616139617139618139619139620139621139622139623139624139625139626139627139628139629139630139631139632139633139634139635139636139637139638139639139640139641139642139643139644139645139646139647139648139649139650139651139652139653139654139655139656139657139658139659139660139661139662139663139664139665139666139667139668139669139670139671139672139673139674139675139676139677139678139679139680139681139682139683139684139685139686139687139688139689139690139691139692139693139694139695139696139697139698139699139700139701139702139703139704139705139706139707139708139709139710139711139712139713139714139715139716139717139718139719139720139721139722139723139724139725139726139727139728139729139730139731139732139733139734139735139736139737139738139739139740139741139742139743139744139745139746139747139748139749139750139751139752139753139754139755139756139757139758139759139760139761139762139763139764139765139766139767139768139769139770139771139772139773139774139775139776139777139778139779139780139781139782139783139784139785139786139787139788139789139790139791139792139793139794139795139796139797139798139799139800139801139802139803139804139805139806139807139808139809139810139811139812139813139814139815139816139817139818139819139820139821139822139823139824139825139826139827139828139829139830139831139832139833139834139835139836139837139838139839139840139841139842139843139844139845139846139847139848139849139850139851139852139853139854139855139856139857139858139859139860139861139862139863139864139865139866139867139868139869139870139871139872139873139874139875139876139877139878139879139880139881139882139883139884139885139886139887139888139889139890139891139892139893139894139895139896139897139898139899139900139901139902139903139904139905139906139907139908139909139910139911139912139913139914139915139916139917139918139919139920139921139922139923139924139925139926139927139928139929139930139931139932139933139934139935139936139937139938139939139940139941139942139943139944139945139946139947139948139949139950139951139952139953139954139955139956139957139958139959139960139961139962139963139964139965139966139967139968139969139970139971139972139973139974139975139976139977139978139979139980139981139982139983139984139985139986139987139988139989139990139991139992139993139994139995139996139997139998139999140000140001140002140003140004140005140006140007140008140009140010140011140012140013140014140015140016140017140018140019140020140021140022140023140024140025140026140027140028140029140030140031140032140033140034140035140036140037140038140039140040140041140042140043140044140045140046140047140048140049140050140051140052140053140054140055140056140057140058140059140060140061140062140063140064140065140066140067140068140069140070140071140072140073140074140075140076140077140078140079140080140081140082140083140084140085140086140087140088140089140090140091140092140093140094140095140096140097140098140099140100140101140102140103140104140105140106140107140108140109140110140111140112140113140114140115140116140117140118140119140120140121140122140123140124140125140126140127140128140129140130140131140132140133140134140135140136140137140138140139140140140141140142140143140144140145140146140147140148140149140150140151140152140153140154140155140156140157140158140159140160140161140162140163140164140165140166140167140168140169140170140171140172140173140174140175140176140177140178140179140180140181140182140183140184140185140186140187140188140189140190140191140192140193140194140195140196140197140198140199140200140201140202140203140204140205140206140207140208140209140210140211140212140213140214140215140216140217140218140219140220140221140222140223140224140225140226140227140228140229140230140231140232140233140234140235140236140237140238140239140240140241140242140243140244140245140246140247140248140249140250140251140252140253140254140255140256140257140258140259140260140261140262140263140264140265140266140267140268140269140270140271140272140273140274140275140276140277140278140279140280140281140282140283140284140285140286140287140288140289140290140291140292140293140294140295140296140297140298140299140300140301140302140303140304140305140306140307140308140309140310140311140312140313140314140315140316140317140318140319140320140321140322140323140324140325140326140327140328140329140330140331140332140333140334140335140336140337140338140339140340140341140342140343140344140345140346140347140348140349140350140351140352140353140354140355140356140357140358140359140360140361140362140363140364140365140366140367140368140369140370140371140372140373140374140375140376140377140378140379140380140381140382140383140384140385140386140387140388140389140390140391140392140393140394140395140396140397140398140399140400140401140402140403140404140405140406140407140408140409140410140411140412140413140414140415140416140417140418140419140420140421140422140423140424140425140426140427140428140429140430140431140432140433140434140435140436140437140438140439140440140441140442140443140444140445140446140447140448140449140450140451140452140453140454140455140456140457140458140459140460140461140462140463140464140465140466140467140468140469140470140471140472140473140474140475140476140477140478140479140480140481140482140483140484140485140486140487140488140489140490140491140492140493140494140495140496140497140498140499140500140501140502140503140504140505140506140507140508140509140510140511140512140513140514140515140516140517140518140519140520140521140522140523140524140525140526140527140528140529140530140531140532140533140534140535140536140537140538140539140540140541140542140543140544140545140546140547140548140549140550140551140552140553140554140555140556140557140558140559140560140561140562140563140564140565140566140567140568140569140570140571140572140573140574140575140576140577140578140579140580140581140582140583140584140585140586140587140588140589140590140591140592140593140594140595140596140597140598140599140600140601140602140603140604140605140606140607140608140609140610140611140612140613140614140615140616140617140618140619140620140621140622140623140624140625140626140627140628140629140630140631140632140633140634140635140636140637140638140639140640140641140642140643140644140645140646140647140648140649140650140651140652140653140654140655140656140657140658140659140660140661140662140663140664140665140666140667140668140669140670140671140672140673140674140675140676140677140678140679140680140681140682140683140684140685140686140687140688140689140690140691140692140693140694140695140696140697140698140699140700140701140702140703140704140705140706140707140708140709140710140711140712140713140714140715140716140717140718140719140720140721140722140723140724140725140726140727140728140729140730140731140732140733140734140735140736140737140738140739140740140741140742140743140744140745140746140747140748140749140750140751140752140753140754140755140756140757140758140759140760140761140762140763140764140765140766140767140768140769140770140771140772140773140774140775140776140777140778140779140780140781140782140783140784140785140786140787140788140789140790140791140792140793140794140795140796140797140798140799140800140801140802140803140804140805140806140807140808140809140810140811140812140813140814140815140816140817140818140819140820140821140822140823140824140825140826140827140828140829140830140831140832140833140834140835140836140837140838140839140840140841140842140843140844140845140846140847140848140849140850140851140852140853140854140855140856140857140858140859140860140861140862140863140864140865140866140867140868140869140870140871140872140873140874140875140876140877140878140879140880140881140882140883140884140885140886140887140888140889140890140891140892140893140894140895140896140897140898140899140900140901140902140903140904140905140906140907140908140909140910140911140912140913140914140915140916140917140918140919140920140921140922140923140924140925140926140927140928140929140930140931140932140933140934140935140936140937140938140939140940140941140942140943140944140945140946140947140948140949140950140951140952140953140954140955140956140957140958140959140960140961140962140963140964140965140966140967140968140969140970140971140972140973140974140975140976140977140978140979140980140981140982140983140984140985140986140987140988140989140990140991140992140993140994140995140996140997140998140999141000141001141002141003141004141005141006141007141008141009141010141011141012141013141014141015141016141017141018141019141020141021141022141023141024141025141026141027141028141029141030141031141032141033141034141035141036141037141038141039141040141041141042141043141044141045141046141047141048141049141050141051141052141053141054141055141056141057141058141059141060141061141062141063141064141065141066141067141068141069141070141071141072141073141074141075141076141077141078141079141080141081141082141083141084141085141086141087141088141089141090141091141092141093141094141095141096141097141098141099141100141101141102141103141104141105141106141107141108141109141110141111141112141113141114141115141116141117141118141119141120141121141122141123141124141125141126141127141128141129141130141131141132141133141134141135141136141137141138141139141140141141141142141143141144141145141146141147141148141149141150141151141152141153141154141155141156141157141158141159141160141161141162141163141164141165141166141167141168141169141170141171141172141173141174141175141176141177141178141179141180141181141182141183141184141185141186141187141188141189141190141191141192141193141194141195141196141197141198141199141200141201141202141203141204141205141206141207141208141209141210141211141212141213141214141215141216141217141218141219141220141221141222141223141224141225141226141227141228141229141230141231141232141233141234141235141236141237141238141239141240141241141242141243141244141245141246141247141248141249141250141251141252141253141254141255141256141257141258141259141260141261141262141263141264141265141266141267141268141269141270141271141272141273141274141275141276141277141278141279141280141281141282141283141284141285141286141287141288141289141290141291141292141293141294141295141296141297141298141299141300141301141302141303141304141305141306141307141308141309141310141311141312141313141314141315141316141317141318141319141320141321141322141323141324141325141326141327141328141329141330141331141332141333141334141335141336141337141338141339141340141341141342141343141344141345141346141347141348141349141350141351141352141353141354141355141356141357141358141359141360141361141362141363141364141365141366141367141368141369141370141371141372141373141374141375141376141377141378141379141380141381141382141383141384141385141386141387141388141389141390141391141392141393141394141395141396141397141398141399141400141401141402141403141404141405141406141407141408141409141410141411141412141413141414141415141416141417141418141419141420141421141422141423141424141425141426141427141428141429141430141431141432141433141434141435141436141437141438141439141440141441141442141443141444141445141446141447141448141449141450141451141452141453141454141455141456141457141458141459141460141461141462141463141464141465141466141467141468141469141470141471141472141473141474141475141476141477141478141479141480141481141482141483141484141485141486141487141488141489141490141491141492141493141494141495141496141497141498141499141500141501141502141503141504141505141506141507141508141509141510141511141512141513141514141515141516141517141518141519141520141521141522141523141524141525141526141527141528141529141530141531141532141533141534141535141536141537141538141539141540141541141542141543141544141545141546141547141548141549141550141551141552141553141554141555141556141557141558141559141560141561141562141563141564141565141566141567141568141569141570141571141572141573141574141575141576141577141578141579141580141581141582141583141584141585141586141587141588141589141590141591141592141593141594141595141596141597141598141599141600141601141602141603141604141605141606141607141608141609141610141611141612141613141614141615141616141617141618141619141620141621141622141623141624141625141626141627141628141629141630141631141632141633141634141635141636141637141638141639141640141641141642141643141644141645141646141647141648141649141650141651141652141653141654141655141656141657141658141659141660141661141662141663141664141665141666141667141668141669141670141671141672141673141674141675141676141677141678141679141680141681141682141683141684141685141686141687141688141689141690141691141692141693141694141695141696141697141698141699141700141701141702141703141704141705141706141707141708141709141710141711141712141713141714141715141716141717141718141719141720141721141722141723141724141725141726141727141728141729141730141731141732141733141734141735141736141737141738141739141740141741141742141743141744141745141746141747141748141749141750141751141752141753141754141755141756141757141758141759141760141761141762141763141764141765141766141767141768141769141770141771141772141773141774141775141776141777141778141779141780141781141782141783141784141785141786141787141788141789141790141791141792141793141794141795141796141797141798141799141800141801141802141803141804141805141806141807141808141809141810141811141812141813141814141815141816141817141818141819141820141821141822141823141824141825141826141827141828141829141830141831141832141833141834141835141836141837141838141839141840141841141842141843141844141845141846141847141848141849141850141851141852141853141854141855141856141857141858141859141860141861141862141863141864141865141866141867141868141869141870141871141872141873141874141875141876141877141878141879141880141881141882141883141884141885141886141887141888141889141890141891141892141893141894141895141896141897141898141899141900141901141902141903141904141905141906141907141908141909141910141911141912141913141914141915141916141917141918141919141920141921141922141923141924141925141926141927141928141929141930141931141932141933141934141935141936141937141938141939141940141941141942141943141944141945141946141947141948141949141950141951141952141953141954141955141956141957141958141959141960141961141962141963141964141965141966141967141968141969141970141971141972141973141974141975141976141977141978141979141980141981141982141983141984141985141986141987141988141989141990141991141992141993141994141995141996141997141998141999142000142001142002142003142004142005142006142007142008142009142010142011142012142013142014142015142016142017142018142019142020142021142022142023142024142025142026142027142028142029142030142031142032142033142034142035142036142037142038142039142040142041142042142043142044142045142046142047142048142049142050142051142052142053142054142055142056142057142058142059142060142061142062142063142064142065142066142067142068142069142070142071142072142073142074142075142076142077142078142079142080142081142082142083142084142085142086142087142088142089142090142091142092142093142094142095142096142097142098142099142100142101142102142103142104142105142106142107142108142109142110142111142112142113142114142115142116142117142118142119142120142121142122142123142124142125142126142127142128142129142130142131142132142133142134142135142136142137142138142139142140142141142142142143142144142145142146142147142148142149142150142151142152142153142154142155142156142157142158142159142160142161142162142163142164142165142166142167142168142169142170142171142172142173142174142175142176142177142178142179142180142181142182142183142184142185142186142187142188142189142190142191142192142193142194142195142196142197142198142199142200142201142202142203142204142205142206142207142208142209142210142211142212142213142214142215142216142217142218142219142220142221142222142223142224142225142226142227142228142229142230142231142232142233142234142235142236142237142238142239142240142241142242142243142244142245142246142247142248142249142250142251142252142253142254142255142256142257142258142259142260142261142262142263142264142265142266142267142268142269142270142271142272142273142274142275142276142277142278142279142280142281142282142283142284142285142286142287142288142289142290142291142292142293142294142295142296142297142298142299142300142301142302142303142304142305142306142307142308142309142310142311142312142313142314142315142316142317142318142319142320142321142322142323142324142325142326142327142328142329142330142331142332142333142334142335142336142337142338142339142340142341142342142343142344142345142346142347142348142349142350142351142352142353142354142355142356142357142358142359142360142361142362142363142364142365142366142367142368142369142370142371142372142373142374142375142376142377142378142379142380142381142382142383142384142385142386142387142388142389142390142391142392142393142394142395142396142397142398142399142400142401142402142403142404142405142406142407142408142409142410142411142412142413142414142415142416142417142418142419142420142421142422142423142424142425142426142427142428142429142430142431142432142433142434142435142436142437142438142439142440142441142442142443142444142445142446142447142448142449142450142451142452142453142454142455142456142457142458142459142460142461142462142463142464142465142466142467142468142469142470142471142472142473142474142475142476142477142478142479142480142481142482142483142484142485142486142487142488142489142490142491142492142493142494142495142496142497142498142499142500142501142502142503142504142505142506142507142508142509142510142511142512142513142514142515142516142517142518142519142520142521142522142523142524142525142526142527142528142529142530142531142532142533142534142535142536142537142538142539142540142541142542142543142544142545142546142547142548142549142550142551142552142553142554142555142556142557142558142559142560142561142562142563142564142565142566142567142568142569142570142571142572142573142574142575142576142577142578142579142580142581142582142583142584142585142586142587142588142589142590142591142592142593142594142595142596142597142598142599142600142601142602142603142604142605142606142607142608142609142610142611142612142613142614142615142616142617142618142619142620142621142622142623142624142625142626142627142628142629142630142631142632142633142634142635142636142637142638142639142640142641142642142643142644142645142646142647142648142649142650142651142652142653142654142655142656142657142658142659142660142661142662142663142664142665142666142667142668142669142670142671142672142673142674142675142676142677142678142679142680142681142682142683142684142685142686142687142688142689142690142691142692142693142694142695142696142697142698142699142700142701142702142703142704142705142706142707142708142709142710142711142712142713142714142715142716142717142718142719142720142721142722142723142724142725142726142727142728142729142730142731142732142733142734142735142736142737142738142739142740142741142742142743142744142745142746142747142748142749142750142751142752142753142754142755142756142757142758142759142760142761142762142763142764142765142766142767142768142769142770142771142772142773142774142775142776142777142778142779142780142781142782142783142784142785142786142787142788142789142790142791142792142793142794142795142796142797142798142799142800142801142802142803142804142805142806142807142808142809142810142811142812142813142814142815142816142817142818142819142820142821142822142823142824142825142826142827142828142829142830142831142832142833142834142835142836142837142838142839142840142841142842142843142844142845142846142847142848142849142850142851142852142853142854142855142856142857142858142859142860142861142862142863142864142865142866142867142868142869142870142871142872142873142874142875142876142877142878142879142880142881142882142883142884142885142886142887142888142889142890142891142892142893142894142895142896142897142898142899142900142901142902142903142904142905142906142907142908142909142910142911142912142913142914142915142916142917142918142919142920142921142922142923142924142925142926142927142928142929142930142931142932142933142934142935142936142937142938142939142940142941142942142943142944142945142946142947142948142949142950142951142952142953142954142955142956142957142958142959142960142961142962142963142964142965142966142967142968142969142970142971142972142973142974142975142976142977142978142979142980142981142982142983142984142985142986142987142988142989142990142991142992142993142994142995142996142997142998142999143000143001143002143003143004143005143006143007143008143009143010143011143012143013143014143015143016143017143018143019143020143021143022143023143024143025143026143027143028143029143030143031143032143033143034143035143036143037143038143039143040143041143042143043143044143045143046143047143048143049143050143051143052143053143054143055143056143057143058143059143060143061143062143063143064143065143066143067143068143069143070143071143072143073143074143075143076143077143078143079143080143081143082143083143084143085143086143087143088143089143090143091143092143093143094143095143096143097143098143099143100143101143102143103143104143105143106143107143108143109143110143111143112143113143114143115143116143117143118143119143120143121143122143123143124143125143126143127143128143129143130143131143132143133143134143135143136143137143138143139143140143141143142143143143144143145143146143147143148143149143150143151143152143153143154143155143156143157143158143159143160143161143162143163143164143165143166143167143168143169143170143171143172143173143174143175143176143177143178143179143180143181143182143183143184143185143186143187143188143189143190143191143192143193143194143195143196143197143198143199143200143201143202143203143204143205143206143207143208143209143210143211143212143213143214143215143216143217143218143219143220143221143222143223143224143225143226143227143228143229143230143231143232143233143234143235143236143237143238143239143240143241143242143243143244143245143246143247143248143249143250143251143252143253143254143255143256143257143258143259143260143261143262143263143264143265143266143267143268143269143270143271143272143273143274143275143276143277143278143279143280143281143282143283143284143285143286143287143288143289143290143291143292143293143294143295143296143297143298143299143300143301143302143303143304143305143306143307143308143309143310143311143312143313143314143315143316143317143318143319143320143321143322143323143324143325143326143327143328143329143330143331143332143333143334143335143336143337143338143339143340143341143342143343143344143345143346143347143348143349143350143351143352143353143354143355143356143357143358143359143360143361143362143363143364143365143366143367143368143369143370143371143372143373143374143375143376143377143378143379143380143381143382143383143384143385143386143387143388143389143390143391143392143393143394143395143396143397143398143399143400143401143402143403143404143405143406143407143408143409143410143411143412143413143414143415143416143417143418143419143420143421143422143423143424143425143426143427143428143429143430143431143432143433143434143435143436143437143438143439143440143441143442143443143444143445143446143447143448143449143450143451143452143453143454143455143456143457143458143459143460143461143462143463143464143465143466143467143468143469143470143471143472143473143474143475143476143477143478143479143480143481143482143483143484143485143486143487143488143489143490143491143492143493143494143495143496143497143498143499143500143501143502143503143504143505143506143507143508143509143510143511143512143513143514143515143516143517143518143519143520143521143522143523143524143525143526143527143528143529143530143531143532143533143534143535143536143537143538143539143540143541143542143543143544143545143546143547143548143549143550143551143552143553143554143555143556143557143558143559143560143561143562143563143564143565143566143567143568143569143570143571143572143573143574143575143576143577143578143579143580143581143582143583143584143585143586143587143588143589143590143591143592143593143594143595143596143597143598143599143600143601143602143603143604143605143606143607143608143609143610143611143612143613143614143615143616143617143618143619143620143621143622143623143624143625143626143627143628143629143630143631143632143633143634143635143636143637143638143639143640143641143642143643143644143645143646143647143648143649143650143651143652143653143654143655143656143657143658143659143660143661143662143663143664143665143666143667143668143669143670143671143672143673143674143675143676143677143678143679143680143681143682143683143684143685143686143687143688143689143690143691143692143693143694143695143696143697143698143699143700143701143702143703143704143705143706143707143708143709143710143711143712143713143714143715143716143717143718143719143720143721143722143723143724143725143726143727143728143729143730143731143732143733143734143735143736143737143738143739143740143741143742143743143744143745143746143747143748143749143750143751143752143753143754143755143756143757143758143759143760143761143762143763143764143765143766143767143768143769143770143771143772143773143774143775143776143777143778143779143780143781143782143783143784143785143786143787143788143789143790143791143792143793143794143795143796143797143798143799143800143801143802143803143804143805143806143807143808143809143810143811143812143813143814143815143816143817143818143819143820143821143822143823143824143825143826143827143828143829143830143831143832143833143834143835143836143837143838143839143840143841143842143843143844143845143846143847143848143849143850143851143852143853143854143855143856143857143858143859143860143861143862143863143864143865143866143867143868143869143870143871143872143873143874143875143876143877143878143879143880143881143882143883143884143885143886143887143888143889143890143891143892143893143894143895143896143897143898143899143900143901143902143903143904143905143906143907143908143909143910143911143912143913143914143915143916143917143918143919143920143921143922143923143924143925143926143927143928143929143930143931143932143933143934143935143936143937143938143939143940143941143942143943143944143945143946143947143948143949143950143951143952143953143954143955143956143957143958143959143960143961143962143963143964143965143966143967143968143969143970143971143972143973143974143975143976143977143978143979143980143981143982143983143984143985143986143987143988143989143990143991143992143993143994143995143996143997143998143999144000144001144002144003144004144005144006144007144008144009144010144011144012144013144014144015144016144017144018144019144020144021144022144023144024144025144026144027144028144029144030144031144032144033144034144035144036144037144038144039144040144041144042144043144044144045144046144047144048144049144050144051144052144053144054144055144056144057144058144059144060144061144062144063144064144065144066144067144068144069144070144071144072144073144074144075144076144077144078144079144080144081144082144083144084144085144086144087144088144089144090144091144092144093144094144095144096144097144098144099144100144101144102144103144104144105144106144107144108144109144110144111144112144113144114144115144116144117144118144119144120144121144122144123144124144125144126144127144128144129144130144131144132144133144134144135144136144137144138144139144140144141144142144143144144144145144146144147144148144149144150144151144152144153144154144155144156144157144158144159144160144161144162144163144164144165144166144167144168144169144170144171144172144173144174144175144176144177144178144179144180144181144182144183144184144185144186144187144188144189144190144191144192144193144194144195144196144197144198144199144200144201144202144203144204144205144206144207144208144209144210144211144212144213144214144215144216144217144218144219144220144221144222144223144224144225144226144227144228144229144230144231144232144233144234144235144236144237144238144239144240144241144242144243144244144245144246144247144248144249144250144251144252144253144254144255144256144257144258144259144260144261144262144263144264144265144266144267144268144269144270144271144272144273144274144275144276144277144278144279144280144281144282144283144284144285144286144287144288144289144290144291144292144293144294144295144296144297144298144299144300144301144302144303144304144305144306144307144308144309144310144311144312144313144314144315144316144317144318144319144320144321144322144323144324144325144326144327144328144329144330144331144332144333144334144335144336144337144338144339144340144341144342144343144344144345144346144347144348144349144350144351144352144353144354144355144356144357144358144359144360144361144362144363144364144365144366144367144368144369144370144371144372144373144374144375144376144377144378144379144380144381144382144383144384144385144386144387144388144389144390144391144392144393144394144395144396144397144398144399144400144401144402144403144404144405144406144407144408144409144410144411144412144413144414144415144416144417144418144419144420144421144422144423144424144425144426144427144428144429144430144431144432144433144434144435144436144437144438144439144440144441144442144443144444144445144446144447144448144449144450144451144452144453144454144455144456144457144458144459144460144461144462144463144464144465144466144467144468144469144470144471144472144473144474144475144476144477144478144479144480144481144482144483144484144485144486144487144488144489144490144491144492144493144494144495144496144497144498144499144500144501144502144503144504144505144506144507144508144509144510144511144512144513144514144515144516144517144518144519144520144521144522144523144524144525144526144527144528144529144530144531144532144533144534144535144536144537144538144539144540144541144542144543144544144545144546144547144548144549144550144551144552144553144554144555144556144557144558144559144560144561144562144563144564144565144566144567144568144569144570144571144572144573144574144575144576144577144578144579144580144581144582144583144584144585144586144587144588144589144590144591144592144593144594144595144596144597144598144599144600144601144602144603144604144605144606144607144608144609144610144611144612144613144614144615144616144617144618144619144620144621144622144623144624144625144626144627144628144629144630144631144632144633144634144635144636144637144638144639144640144641144642144643144644144645144646144647144648144649144650144651144652144653144654144655144656144657144658144659144660144661144662144663144664144665144666144667144668144669144670144671144672144673144674144675144676144677144678144679144680144681144682144683144684144685144686144687144688144689144690144691144692144693144694144695144696144697144698144699144700144701144702144703144704144705144706144707144708144709144710144711144712144713144714144715144716144717144718144719144720144721144722144723144724144725144726144727144728144729144730144731144732144733144734144735144736144737144738144739144740144741144742144743144744144745144746144747144748144749144750144751144752144753144754144755144756144757144758144759144760144761144762144763144764144765144766144767144768144769144770144771144772144773144774144775144776144777144778144779144780144781144782144783144784144785144786144787144788144789144790144791144792144793144794144795144796144797144798144799144800144801144802144803144804144805144806144807144808144809144810144811144812144813144814144815144816144817144818144819144820144821144822144823144824144825144826144827144828144829144830144831144832144833144834144835144836144837144838144839144840144841144842144843144844144845144846144847144848144849144850144851144852144853144854144855144856144857144858144859144860144861144862144863144864144865144866144867144868144869144870144871144872144873144874144875144876144877144878144879144880144881144882144883144884144885144886144887144888144889144890144891144892144893144894144895144896144897144898144899144900144901144902144903144904144905144906144907144908144909144910144911144912144913144914144915144916144917144918144919144920144921144922144923144924144925144926144927144928144929144930144931144932144933144934144935144936144937144938144939144940144941144942144943144944144945144946144947144948144949144950144951144952144953144954144955144956144957144958144959144960144961144962144963144964144965144966144967144968144969144970144971144972144973144974144975144976144977144978144979144980144981144982144983144984144985144986144987144988144989144990144991144992144993144994144995144996144997144998144999145000145001145002145003145004145005145006145007145008145009145010145011145012145013145014145015145016145017145018145019145020145021145022145023145024145025145026145027145028145029145030145031145032145033145034145035145036145037145038145039145040145041145042145043145044145045145046145047145048145049145050145051145052145053145054145055145056145057145058145059145060145061145062145063145064145065145066145067145068145069145070145071145072145073145074145075145076145077145078145079145080145081145082145083145084145085145086145087145088145089145090145091145092145093145094145095145096145097145098145099145100145101145102145103145104145105145106145107145108145109145110145111145112145113145114145115145116145117145118145119145120145121145122145123145124145125145126145127145128145129145130145131145132145133145134145135145136145137145138145139145140145141145142145143145144145145145146145147145148145149145150145151145152145153145154145155145156145157145158145159145160145161145162145163145164145165145166145167145168145169145170145171145172145173145174145175145176145177145178145179145180145181145182145183145184145185145186145187145188145189145190145191145192145193145194145195145196145197145198145199145200145201145202145203145204145205145206145207145208145209145210145211145212145213145214145215145216145217145218145219145220145221145222145223145224145225145226145227145228145229145230145231145232145233145234145235145236145237145238145239145240145241145242145243145244145245145246145247145248145249145250145251145252145253145254145255145256145257145258145259145260145261145262145263145264145265145266145267145268145269145270145271145272145273145274145275145276145277145278145279145280145281145282145283145284145285145286145287145288145289145290145291145292145293145294145295145296145297145298145299145300145301145302145303145304145305145306145307145308145309145310145311145312145313145314145315145316145317145318145319145320145321145322145323145324145325145326145327145328145329145330145331145332145333145334145335145336145337145338145339145340145341145342145343145344145345145346145347145348145349145350145351145352145353145354145355145356145357145358145359145360145361145362145363145364145365145366145367145368145369145370145371145372145373145374145375145376145377145378145379145380145381145382145383145384145385145386145387145388145389145390145391145392145393145394145395145396145397145398145399145400145401145402145403145404145405145406145407145408145409145410145411145412145413145414145415145416145417145418145419145420145421145422145423145424145425145426145427145428145429145430145431145432145433145434145435145436145437145438145439145440145441145442145443145444145445145446145447145448145449145450145451145452145453145454145455145456145457145458145459145460145461145462145463145464145465145466145467145468145469145470145471145472145473145474145475145476145477145478145479145480145481145482145483145484145485145486145487145488145489145490145491145492145493145494145495145496145497145498145499145500145501145502145503145504145505145506145507145508145509145510145511145512145513145514145515145516145517145518145519145520145521145522145523145524145525145526145527145528145529145530145531145532145533145534145535145536145537145538145539145540145541145542145543145544145545145546145547145548145549145550145551145552145553145554145555145556145557145558145559145560145561145562145563145564145565145566145567145568145569145570145571145572145573145574145575145576145577145578145579145580145581145582145583145584145585145586145587145588145589145590145591145592145593145594145595145596145597145598145599145600145601145602145603145604145605145606145607145608145609145610145611145612145613145614145615145616145617145618145619145620145621145622145623145624145625145626145627145628145629145630145631145632145633145634145635145636145637145638145639145640145641145642145643145644145645145646145647145648145649145650145651145652145653145654145655145656145657145658145659145660145661145662145663145664145665145666145667145668145669145670145671145672145673145674145675145676145677145678145679145680145681145682145683145684145685145686145687145688145689145690145691145692145693145694145695145696145697145698145699145700145701145702145703145704145705145706145707145708145709145710145711145712145713145714145715145716145717145718145719145720145721145722145723145724145725145726145727145728145729145730145731145732145733145734145735145736145737145738145739145740145741145742145743145744145745145746145747145748145749145750145751145752145753145754145755145756145757145758145759145760145761145762145763145764145765145766145767145768145769145770145771145772145773145774145775145776145777145778145779145780145781145782145783145784145785145786145787145788145789145790145791145792145793145794145795145796145797145798145799145800145801145802145803145804145805145806145807145808145809145810145811145812145813145814145815145816145817145818145819145820145821145822145823145824145825145826145827145828145829145830145831145832145833145834145835145836145837145838145839145840145841145842145843145844145845145846145847145848145849145850145851145852145853145854145855145856145857145858145859145860145861145862145863145864145865145866145867145868145869145870145871145872145873145874145875145876145877145878145879145880145881145882145883145884145885145886145887145888145889145890145891145892145893145894145895145896145897145898145899145900145901145902145903145904145905145906145907145908145909145910145911145912145913145914145915145916145917145918145919145920145921145922145923145924145925145926145927145928145929145930145931145932145933145934145935145936145937145938145939145940145941145942145943145944145945145946145947145948145949145950145951145952145953145954145955145956145957145958145959145960145961145962145963145964145965145966145967145968145969145970145971145972145973145974145975145976145977145978145979145980145981145982145983145984145985145986145987145988145989145990145991145992145993145994145995145996145997145998145999146000146001146002146003146004146005146006146007146008146009146010146011146012146013146014146015146016146017146018146019146020146021146022146023146024146025146026146027146028146029146030146031146032146033146034146035146036146037146038146039146040146041146042146043146044146045146046146047146048146049146050146051146052146053146054146055146056146057146058146059146060146061146062146063146064146065146066146067146068146069146070146071146072146073146074146075146076146077146078146079146080146081146082146083146084146085146086146087146088146089146090146091146092146093146094146095146096146097146098146099146100146101146102146103146104146105146106146107146108146109146110146111146112146113146114146115146116146117146118146119146120146121146122146123146124146125146126146127146128146129146130146131146132146133146134146135146136146137146138146139146140146141146142146143146144146145146146146147146148146149146150146151146152146153146154146155146156146157146158146159146160146161146162146163146164146165146166146167146168146169146170146171146172146173146174146175146176146177146178146179146180146181146182146183146184146185146186146187146188146189146190146191146192146193146194146195146196146197146198146199146200146201146202146203146204146205146206146207146208146209146210146211146212146213146214146215146216146217146218146219146220146221146222146223146224146225146226146227146228146229146230146231146232146233146234146235146236146237146238146239146240146241146242146243146244146245146246146247146248146249146250146251146252146253146254146255146256146257146258146259146260146261146262146263146264146265146266146267146268146269146270146271146272146273146274146275146276146277146278146279146280146281146282146283146284146285146286146287146288146289146290146291146292146293146294146295146296146297146298146299146300146301146302146303146304146305146306146307146308146309146310146311146312146313146314146315146316146317146318146319146320146321146322146323146324146325146326146327146328146329146330146331146332146333146334146335146336146337146338146339146340146341146342146343146344146345146346146347146348146349146350146351146352146353146354146355146356146357146358146359146360146361146362146363146364146365146366146367146368146369146370146371146372146373146374146375146376146377146378146379146380146381146382146383146384146385146386146387146388146389146390146391146392146393146394146395146396146397146398146399146400146401146402146403146404146405146406146407146408146409146410146411146412146413146414146415146416146417146418146419146420146421146422146423146424146425146426146427146428146429146430146431146432146433146434146435146436146437146438146439146440146441146442146443146444146445146446146447146448146449146450146451146452146453146454146455146456146457146458146459146460146461146462146463146464146465146466146467146468146469146470146471146472146473146474146475146476146477146478146479146480146481146482146483146484146485146486146487146488146489146490146491146492146493146494146495146496146497146498146499146500146501146502146503146504146505146506146507146508146509146510146511146512146513146514146515146516146517146518146519146520146521146522146523146524146525146526146527146528146529146530146531146532146533146534146535146536146537146538146539146540146541146542146543146544146545146546146547146548146549146550146551146552146553146554146555146556146557146558146559146560146561146562146563146564146565146566146567146568146569146570146571146572146573146574146575146576146577146578146579146580146581146582146583146584146585146586146587146588146589146590146591146592146593146594146595146596146597146598146599146600146601146602146603146604146605146606146607146608146609146610146611146612146613146614146615146616146617146618146619146620146621146622146623146624146625146626146627146628146629146630146631146632146633146634146635146636146637146638146639146640146641146642146643146644146645146646146647146648146649146650146651146652146653146654146655146656146657146658146659146660146661146662146663146664146665146666146667146668146669146670146671146672146673146674146675146676146677146678146679146680146681146682146683146684146685146686146687146688146689146690146691146692146693146694146695146696146697146698146699146700146701146702146703146704146705146706146707146708146709146710146711146712146713146714146715146716146717146718146719146720146721146722146723146724146725146726146727146728146729146730146731146732146733146734146735146736146737146738146739146740146741146742146743146744146745146746146747146748146749146750146751146752146753146754146755146756146757146758146759146760146761146762146763146764146765146766146767146768146769146770146771146772146773146774146775146776146777146778146779146780146781146782146783146784146785146786146787146788146789146790146791146792146793146794146795146796146797146798146799146800146801146802146803146804146805146806146807146808146809146810146811146812146813146814146815146816146817146818146819146820146821146822146823146824146825146826146827146828146829146830146831146832146833146834146835146836146837146838146839146840146841146842146843146844146845146846146847146848146849146850146851146852146853146854146855146856146857146858146859146860146861146862146863146864146865146866146867146868146869146870146871146872146873146874146875146876146877146878146879146880146881146882146883146884146885146886146887146888146889146890146891146892146893146894146895146896146897146898146899146900146901146902146903146904146905146906146907146908146909146910146911146912146913146914146915146916146917146918146919146920146921146922146923146924146925146926146927146928146929146930146931146932146933146934146935146936146937146938146939146940146941146942146943146944146945146946146947146948146949146950146951146952146953146954146955146956146957146958146959146960146961146962146963146964146965146966146967146968146969146970146971146972146973146974146975146976146977146978146979146980146981146982146983146984146985146986146987146988146989146990146991146992146993146994146995146996146997146998146999147000147001147002147003147004147005147006147007147008147009147010147011147012147013147014147015147016147017147018147019147020147021147022147023147024147025147026147027147028147029147030147031147032147033147034147035147036147037147038147039147040147041147042147043147044147045147046147047147048147049147050147051147052147053147054147055147056147057147058147059147060147061147062147063147064147065147066147067147068147069147070147071147072147073147074147075147076147077147078147079147080147081147082147083147084147085147086147087147088147089147090147091147092147093147094147095147096147097147098147099147100147101147102147103147104147105147106147107147108147109147110147111147112147113147114147115147116147117147118147119147120147121147122147123147124147125147126147127147128147129147130147131147132147133147134147135147136147137147138147139147140147141147142147143147144147145147146147147147148147149147150147151147152147153147154147155147156147157147158147159147160147161147162147163147164147165147166147167147168147169147170147171147172147173147174147175147176147177147178147179147180147181147182147183147184147185147186147187147188147189147190147191147192147193147194147195147196147197147198147199147200147201147202147203147204147205147206147207147208147209147210147211147212147213147214147215147216147217147218147219147220147221147222147223147224147225147226147227147228147229147230147231147232147233147234147235147236147237147238147239147240147241147242147243147244147245147246147247147248147249147250147251147252147253147254147255147256147257147258147259147260147261147262147263147264147265147266147267147268147269147270147271147272147273147274147275147276147277147278147279147280147281147282147283147284147285147286147287147288147289147290147291147292147293147294147295147296147297147298147299147300147301147302147303147304147305147306147307147308147309147310147311147312147313147314147315147316147317147318147319147320147321147322147323147324147325147326147327147328147329147330147331147332147333147334147335147336147337147338147339147340147341147342147343147344147345147346147347147348147349147350147351147352147353147354147355147356147357147358147359147360147361147362147363147364147365147366147367147368147369147370147371147372147373147374147375147376147377147378147379147380147381147382147383147384147385147386147387147388147389147390147391147392147393147394147395147396147397147398147399147400147401147402147403147404147405147406147407147408147409147410147411147412147413147414147415147416147417147418147419147420147421147422147423147424147425147426147427147428147429147430147431147432147433147434147435147436147437147438147439147440147441147442147443147444147445147446147447147448147449147450147451147452147453147454147455147456147457147458147459147460147461147462147463147464147465147466147467147468147469147470147471147472147473147474147475147476147477147478147479147480147481147482147483147484147485147486147487147488147489147490147491147492147493147494147495147496147497147498147499147500147501147502147503147504147505147506147507147508147509147510147511147512147513147514147515147516147517147518147519147520147521147522147523147524147525147526147527147528147529147530147531147532147533147534147535147536147537147538147539147540147541147542147543147544147545147546147547147548147549147550147551147552147553147554147555147556147557147558147559147560147561147562147563147564147565147566147567147568147569147570147571147572147573147574147575147576147577147578147579147580147581147582147583147584147585147586147587147588147589147590147591147592147593147594147595147596147597147598147599147600147601147602147603147604147605147606147607147608147609147610147611147612147613147614147615147616147617147618147619147620147621147622147623147624147625147626147627147628147629147630147631147632147633147634147635147636147637147638147639147640147641147642147643147644147645147646147647147648147649147650147651147652147653147654147655147656147657147658147659147660147661147662147663147664147665147666147667147668147669147670147671147672147673147674147675147676147677147678147679147680147681147682147683147684147685147686147687147688147689147690147691147692147693147694147695147696147697147698147699147700147701147702147703147704147705147706147707147708147709147710147711147712147713147714147715147716147717147718147719147720147721147722147723147724147725147726147727147728147729147730147731147732147733147734147735147736147737147738147739147740147741147742147743147744147745147746147747147748147749147750147751147752147753147754147755147756147757147758147759147760147761147762147763147764147765147766147767147768147769147770147771147772147773147774147775147776147777147778147779147780147781147782147783147784147785147786147787147788147789147790147791147792147793147794147795147796147797147798147799147800147801147802147803147804147805147806147807147808147809147810147811147812147813147814147815147816147817147818147819147820147821147822147823147824147825147826147827147828147829147830147831147832147833147834147835147836147837147838147839147840147841147842147843147844147845147846147847147848147849147850147851147852147853147854147855147856147857147858147859147860147861147862147863147864147865147866147867147868147869147870147871147872147873147874147875147876147877147878147879147880147881147882147883147884147885147886147887147888147889147890147891147892147893147894147895147896147897147898147899147900147901147902147903147904147905147906147907147908147909147910147911147912147913147914147915147916147917147918147919147920147921147922147923147924147925147926147927147928147929147930147931147932147933147934147935147936147937147938147939147940147941147942147943147944147945147946147947147948147949147950147951147952147953147954147955147956147957147958147959147960147961147962147963147964147965147966147967147968147969147970147971147972147973147974147975147976147977147978147979147980147981147982147983147984147985147986147987147988147989147990147991147992147993147994147995147996147997147998147999148000148001148002148003148004148005148006148007148008148009148010148011148012148013148014148015148016148017148018148019148020148021148022148023148024148025148026148027148028148029148030148031148032148033148034148035148036148037148038148039148040148041148042148043148044148045148046148047148048148049148050148051148052148053148054148055148056148057148058148059148060148061148062148063148064148065148066148067148068148069148070148071148072148073148074148075148076148077148078148079148080148081148082148083148084148085148086148087148088148089148090148091148092148093148094148095148096148097148098148099148100148101148102148103148104148105148106148107148108148109148110148111148112148113148114148115148116148117148118148119148120148121148122148123148124148125148126148127148128148129148130148131148132148133148134148135148136148137148138148139148140148141148142148143148144148145148146148147148148148149148150148151148152148153148154148155148156148157148158148159148160148161148162148163148164148165148166148167148168148169148170148171148172148173148174148175148176148177148178148179148180148181148182148183148184148185148186148187148188148189148190148191148192148193148194148195148196148197148198148199148200148201148202148203148204148205148206148207148208148209148210148211148212148213148214148215148216148217148218148219148220148221148222148223148224148225148226148227148228148229148230148231148232148233148234148235148236148237148238148239148240148241148242148243148244148245148246148247148248148249148250148251148252148253148254148255148256148257148258148259148260148261148262148263148264148265148266148267148268148269148270148271148272148273148274148275148276148277148278148279148280148281148282148283148284148285148286148287148288148289148290148291148292148293148294148295148296148297148298148299148300148301148302148303148304148305148306148307148308148309148310148311148312148313148314148315148316148317148318148319148320148321148322148323148324148325148326148327148328148329148330148331148332148333148334148335148336148337148338148339148340148341148342148343148344148345148346148347148348148349148350148351148352148353148354148355148356148357148358148359148360148361148362148363148364148365148366148367148368148369148370148371148372148373148374148375148376148377148378148379148380148381148382148383148384148385148386148387148388148389148390148391148392148393148394148395148396148397148398148399148400148401148402148403148404148405148406148407148408148409148410148411148412148413148414148415148416148417148418148419148420148421148422148423148424148425148426148427148428148429148430148431148432148433148434148435148436148437148438148439148440148441148442148443148444148445148446148447148448148449148450148451148452148453148454148455148456148457148458148459148460148461148462148463148464148465148466148467148468148469148470148471148472148473148474148475148476148477148478148479148480148481148482148483148484148485148486148487148488148489148490148491148492148493148494148495148496148497148498148499148500148501148502148503148504148505148506148507148508148509148510148511148512148513148514148515148516148517148518148519148520148521148522148523148524148525148526148527148528148529148530148531148532148533148534148535148536148537148538148539148540148541148542148543148544148545148546148547148548148549148550148551148552148553148554148555148556148557148558148559148560148561148562148563148564148565148566148567148568148569148570148571148572148573148574148575148576148577148578148579148580148581148582148583148584148585148586148587148588148589148590148591148592148593148594148595148596148597148598148599148600148601148602148603148604148605148606148607148608148609148610148611148612148613148614148615148616148617148618148619148620148621148622148623148624148625148626148627148628148629148630148631148632148633148634148635148636148637148638148639148640148641148642148643148644148645148646148647148648148649148650148651148652148653148654148655148656148657148658148659148660148661148662148663148664148665148666148667148668148669148670148671148672148673148674148675148676148677148678148679148680148681148682148683148684148685148686148687148688148689148690148691148692148693148694148695148696148697148698148699148700148701148702148703148704148705148706148707148708148709148710148711148712148713148714148715148716148717148718148719148720148721148722148723148724148725148726148727148728148729148730148731148732148733148734148735148736148737148738148739148740148741148742148743148744148745148746148747148748148749148750148751148752148753148754148755148756148757148758148759148760148761148762148763148764148765148766148767148768148769148770148771148772148773148774148775148776148777148778148779148780148781148782148783148784148785148786148787148788148789148790148791148792148793148794148795148796148797148798148799148800148801148802148803148804148805148806148807148808148809148810148811148812148813148814148815148816148817148818148819148820148821148822148823148824148825148826148827148828148829148830148831148832148833148834148835148836148837148838148839148840148841148842148843148844148845148846148847148848148849148850148851148852148853148854148855148856148857148858148859148860148861148862148863148864148865148866148867148868148869148870148871148872148873148874148875148876148877148878148879148880148881148882148883148884148885148886148887148888148889148890148891148892148893148894148895148896148897148898148899148900148901148902148903148904148905148906148907148908148909148910148911148912148913148914148915148916148917148918148919148920148921148922148923148924148925148926148927148928148929148930148931148932148933148934148935148936148937148938148939148940148941148942148943148944148945148946148947148948148949148950148951148952148953148954148955148956148957148958148959148960148961148962148963148964148965148966148967148968148969148970148971148972148973148974148975148976148977148978148979148980148981148982148983148984148985148986148987148988148989148990148991148992148993148994148995148996148997148998148999149000149001149002149003149004149005149006149007149008149009149010149011149012149013149014149015149016149017149018149019149020149021149022149023149024149025149026149027149028149029149030149031149032149033149034149035149036149037149038149039149040149041149042149043149044149045149046149047149048149049149050149051149052149053149054149055149056149057149058149059149060149061149062149063149064149065149066149067149068149069149070149071149072149073149074149075149076149077149078149079149080149081149082149083149084149085149086149087149088149089149090149091149092149093149094149095149096149097149098149099149100149101149102149103149104149105149106149107149108149109149110149111149112149113149114149115149116149117149118149119149120149121149122149123149124149125149126149127149128149129149130149131149132149133149134149135149136149137149138149139149140149141149142149143149144149145149146149147149148149149149150149151149152149153149154149155149156149157149158149159149160149161149162149163149164149165149166149167149168149169149170149171149172149173149174149175149176149177149178149179149180149181149182149183149184149185149186149187149188149189149190149191149192149193149194149195149196149197149198149199149200149201149202149203149204149205149206149207149208149209149210149211149212149213149214149215149216149217149218149219149220149221149222149223149224149225149226149227149228149229149230149231149232149233149234149235149236149237149238149239149240149241149242149243149244149245149246149247149248149249149250149251149252149253149254149255149256149257149258149259149260149261149262149263149264149265149266149267149268149269149270149271149272149273149274149275149276149277149278149279149280149281149282149283149284149285149286149287149288149289149290149291149292149293149294149295149296149297149298149299149300149301149302149303149304149305149306149307149308149309149310149311149312149313149314149315149316149317149318149319149320149321149322149323149324149325149326149327149328149329149330149331149332149333149334149335149336149337149338149339149340149341149342149343149344149345149346149347149348149349149350149351149352149353149354149355149356149357149358149359149360149361149362149363149364149365149366149367149368149369149370149371149372149373149374149375149376149377149378149379149380149381149382149383149384149385149386149387149388149389149390149391149392149393149394149395149396149397149398149399149400149401149402149403149404149405149406149407149408149409149410149411149412149413149414149415149416149417149418149419149420149421149422149423149424149425149426149427149428149429149430149431149432149433149434149435149436149437149438149439149440149441149442149443149444149445149446149447149448149449149450149451149452149453149454149455149456149457149458149459149460149461149462149463149464149465149466149467149468149469149470149471149472149473149474149475149476149477149478149479149480149481149482149483149484149485149486149487149488149489149490149491149492149493149494149495149496149497149498149499149500149501149502149503149504149505149506149507149508149509149510149511149512149513149514149515149516149517149518149519149520149521149522149523149524149525149526149527149528149529149530149531149532149533149534149535149536149537149538149539149540149541149542149543149544149545149546149547149548149549149550149551149552149553149554149555149556149557149558149559149560149561149562149563149564149565149566149567149568149569149570149571149572149573149574149575149576149577149578149579149580149581149582149583149584149585149586149587149588149589149590149591149592149593149594149595149596149597149598149599149600149601149602149603149604149605149606149607149608149609149610149611149612149613149614149615149616149617149618149619149620149621149622149623149624149625149626149627149628149629149630149631149632149633149634149635149636149637149638149639149640149641149642149643149644149645149646149647149648149649149650149651149652149653149654149655149656149657149658149659149660149661149662149663149664149665149666149667149668149669149670149671149672149673149674149675149676149677149678149679149680149681149682149683149684149685149686149687149688149689149690149691149692149693149694149695149696149697149698149699149700149701149702149703149704149705149706149707149708149709149710149711149712149713149714149715149716149717149718149719149720149721149722149723149724149725149726149727149728149729149730149731149732149733149734149735149736149737149738149739149740149741149742149743149744149745149746149747149748149749149750149751149752149753149754149755149756149757149758149759149760149761149762149763149764149765149766149767149768149769149770149771149772149773149774149775149776149777149778149779149780149781149782149783149784149785149786149787149788149789149790149791149792149793149794149795149796149797149798149799149800149801149802149803149804149805149806149807149808149809149810149811149812149813149814149815149816149817149818149819149820149821149822149823149824149825149826149827149828149829149830149831149832149833149834149835149836149837149838149839149840149841149842149843149844149845149846149847149848149849149850149851149852149853149854149855149856149857149858149859149860149861149862149863149864149865149866149867149868149869149870149871149872149873149874149875149876149877149878149879149880149881149882149883149884149885149886149887149888149889149890149891149892149893149894149895149896149897149898149899149900149901149902149903149904149905149906149907149908149909149910149911149912149913149914149915149916149917149918149919149920149921149922149923149924149925149926149927149928149929149930149931149932149933149934149935149936149937149938149939149940149941149942149943149944149945149946149947149948149949149950149951149952149953149954149955149956149957149958149959149960149961149962149963149964149965149966149967149968149969149970149971149972149973149974149975149976149977149978149979149980149981149982149983149984149985149986149987149988149989149990149991149992149993149994149995149996149997149998149999150000150001150002150003150004150005150006150007150008150009150010150011150012150013150014150015150016150017150018150019150020150021150022150023150024150025150026150027150028150029150030150031150032150033150034150035150036150037150038150039150040150041150042150043150044150045150046150047150048150049150050150051150052150053150054150055150056150057150058150059150060150061150062150063150064150065150066150067150068150069150070150071150072150073150074150075150076150077150078150079150080150081150082150083150084150085150086150087150088150089150090150091150092150093150094150095150096150097150098150099150100150101150102150103150104150105150106150107150108150109150110150111150112150113150114150115150116150117150118150119150120150121150122150123150124150125150126150127150128150129150130150131150132150133150134150135150136150137150138150139150140150141150142150143150144150145150146150147150148150149150150150151150152150153150154150155150156150157150158150159150160150161150162150163150164150165150166150167150168150169150170150171150172150173150174150175150176150177150178150179150180150181150182150183150184150185150186150187150188150189150190150191150192150193150194150195150196150197150198150199150200150201150202150203150204150205150206150207150208150209150210150211150212150213150214150215150216150217150218150219150220150221150222150223150224150225150226150227150228150229150230150231150232150233150234150235150236150237150238150239150240150241150242150243150244150245150246150247150248150249150250150251150252150253150254150255150256150257150258150259150260150261150262150263150264150265150266150267150268150269150270150271150272150273150274150275150276150277150278150279150280150281150282150283150284150285150286150287150288150289150290150291150292150293150294150295150296150297150298150299150300150301150302150303150304150305150306150307150308150309150310150311150312150313150314150315150316150317150318150319150320150321150322150323150324150325150326150327150328150329150330150331150332150333150334150335150336150337150338150339150340150341150342150343150344150345150346150347150348150349150350150351150352150353150354150355150356150357150358150359150360150361150362150363150364150365150366150367150368150369150370150371150372150373150374150375150376150377150378150379150380150381150382150383150384150385150386150387150388150389150390150391150392150393150394150395150396150397150398150399150400150401150402150403150404150405150406150407150408150409150410150411150412150413150414150415150416150417150418150419150420150421150422150423150424150425150426150427150428150429150430150431150432150433150434150435150436150437150438150439150440150441150442150443150444150445150446150447150448150449150450150451150452150453150454150455150456150457150458150459150460150461150462150463150464150465150466150467150468150469150470150471150472150473150474150475150476150477150478150479150480150481150482150483150484150485150486150487150488150489150490150491150492150493150494150495150496150497150498150499150500150501150502150503150504150505150506150507150508150509150510150511150512150513150514150515150516150517150518150519150520150521150522150523150524150525150526150527150528150529150530150531150532150533150534150535150536150537150538150539150540150541150542150543150544150545150546150547150548150549150550150551150552150553150554150555150556150557150558150559150560150561150562150563150564150565150566150567150568150569150570150571150572150573150574150575150576150577150578150579150580150581150582150583150584150585150586150587150588
  1. declare module "babylonjs/types" {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module "babylonjs/Misc/observable" {
  51. import { Nullable } from "babylonjs/types";
  52. /**
  53. * A class serves as a medium between the observable and its observers
  54. */
  55. export class EventState {
  56. /**
  57. * Create a new EventState
  58. * @param mask defines the mask associated with this state
  59. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  60. * @param target defines the original target of the state
  61. * @param currentTarget defines the current target of the state
  62. */
  63. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  64. /**
  65. * Initialize the current event state
  66. * @param mask defines the mask associated with this state
  67. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  68. * @param target defines the original target of the state
  69. * @param currentTarget defines the current target of the state
  70. * @returns the current event state
  71. */
  72. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  73. /**
  74. * An Observer can set this property to true to prevent subsequent observers of being notified
  75. */
  76. skipNextObservers: boolean;
  77. /**
  78. * Get the mask value that were used to trigger the event corresponding to this EventState object
  79. */
  80. mask: number;
  81. /**
  82. * The object that originally notified the event
  83. */
  84. target?: any;
  85. /**
  86. * The current object in the bubbling phase
  87. */
  88. currentTarget?: any;
  89. /**
  90. * This will be populated with the return value of the last function that was executed.
  91. * If it is the first function in the callback chain it will be the event data.
  92. */
  93. lastReturnValue?: any;
  94. }
  95. /**
  96. * Represent an Observer registered to a given Observable object.
  97. */
  98. export class Observer<T> {
  99. /**
  100. * Defines the callback to call when the observer is notified
  101. */
  102. callback: (eventData: T, eventState: EventState) => void;
  103. /**
  104. * Defines the mask of the observer (used to filter notifications)
  105. */
  106. mask: number;
  107. /**
  108. * Defines the current scope used to restore the JS context
  109. */
  110. scope: any;
  111. /** @hidden */
  112. _willBeUnregistered: boolean;
  113. /**
  114. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  115. */
  116. unregisterOnNextCall: boolean;
  117. /**
  118. * Creates a new observer
  119. * @param callback defines the callback to call when the observer is notified
  120. * @param mask defines the mask of the observer (used to filter notifications)
  121. * @param scope defines the current scope used to restore the JS context
  122. */
  123. constructor(
  124. /**
  125. * Defines the callback to call when the observer is notified
  126. */
  127. callback: (eventData: T, eventState: EventState) => void,
  128. /**
  129. * Defines the mask of the observer (used to filter notifications)
  130. */
  131. mask: number,
  132. /**
  133. * Defines the current scope used to restore the JS context
  134. */
  135. scope?: any);
  136. }
  137. /**
  138. * Represent a list of observers registered to multiple Observables object.
  139. */
  140. export class MultiObserver<T> {
  141. private _observers;
  142. private _observables;
  143. /**
  144. * Release associated resources
  145. */
  146. dispose(): void;
  147. /**
  148. * Raise a callback when one of the observable will notify
  149. * @param observables defines a list of observables to watch
  150. * @param callback defines the callback to call on notification
  151. * @param mask defines the mask used to filter notifications
  152. * @param scope defines the current scope used to restore the JS context
  153. * @returns the new MultiObserver
  154. */
  155. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  156. }
  157. /**
  158. * The Observable class is a simple implementation of the Observable pattern.
  159. *
  160. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  161. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  162. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  163. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  164. */
  165. export class Observable<T> {
  166. private _observers;
  167. private _eventState;
  168. private _onObserverAdded;
  169. /**
  170. * Gets the list of observers
  171. */
  172. get observers(): Array<Observer<T>>;
  173. /**
  174. * Creates a new observable
  175. * @param onObserverAdded defines a callback to call when a new observer is added
  176. */
  177. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  178. /**
  179. * Create a new Observer with the specified callback
  180. * @param callback the callback that will be executed for that Observer
  181. * @param mask the mask used to filter observers
  182. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  183. * @param scope optional scope for the callback to be called from
  184. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  185. * @returns the new observer created for the callback
  186. */
  187. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  188. /**
  189. * Create a new Observer with the specified callback and unregisters after the next notification
  190. * @param callback the callback that will be executed for that Observer
  191. * @returns the new observer created for the callback
  192. */
  193. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  194. /**
  195. * Remove an Observer from the Observable object
  196. * @param observer the instance of the Observer to remove
  197. * @returns false if it doesn't belong to this Observable
  198. */
  199. remove(observer: Nullable<Observer<T>>): boolean;
  200. /**
  201. * Remove a callback from the Observable object
  202. * @param callback the callback to remove
  203. * @param scope optional scope. If used only the callbacks with this scope will be removed
  204. * @returns false if it doesn't belong to this Observable
  205. */
  206. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  207. private _deferUnregister;
  208. private _remove;
  209. /**
  210. * Moves the observable to the top of the observer list making it get called first when notified
  211. * @param observer the observer to move
  212. */
  213. makeObserverTopPriority(observer: Observer<T>): void;
  214. /**
  215. * Moves the observable to the bottom of the observer list making it get called last when notified
  216. * @param observer the observer to move
  217. */
  218. makeObserverBottomPriority(observer: Observer<T>): void;
  219. /**
  220. * Notify all Observers by calling their respective callback with the given data
  221. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  222. * @param eventData defines the data to send to all observers
  223. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  224. * @param target defines the original target of the state
  225. * @param currentTarget defines the current target of the state
  226. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  227. */
  228. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  229. /**
  230. * Calling this will execute each callback, expecting it to be a promise or return a value.
  231. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  232. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  233. * and it is crucial that all callbacks will be executed.
  234. * The order of the callbacks is kept, callbacks are not executed parallel.
  235. *
  236. * @param eventData The data to be sent to each callback
  237. * @param mask is used to filter observers defaults to -1
  238. * @param target defines the callback target (see EventState)
  239. * @param currentTarget defines he current object in the bubbling phase
  240. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  241. */
  242. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  243. /**
  244. * Notify a specific observer
  245. * @param observer defines the observer to notify
  246. * @param eventData defines the data to be sent to each callback
  247. * @param mask is used to filter observers defaults to -1
  248. */
  249. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  250. /**
  251. * Gets a boolean indicating if the observable has at least one observer
  252. * @returns true is the Observable has at least one Observer registered
  253. */
  254. hasObservers(): boolean;
  255. /**
  256. * Clear the list of observers
  257. */
  258. clear(): void;
  259. /**
  260. * Clone the current observable
  261. * @returns a new observable
  262. */
  263. clone(): Observable<T>;
  264. /**
  265. * Does this observable handles observer registered with a given mask
  266. * @param mask defines the mask to be tested
  267. * @return whether or not one observer registered with the given mask is handeled
  268. **/
  269. hasSpecificMask(mask?: number): boolean;
  270. }
  271. }
  272. declare module "babylonjs/Misc/domManagement" {
  273. /**
  274. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  275. * Babylon.js
  276. */
  277. export class DomManagement {
  278. /**
  279. * Checks if the window object exists
  280. * @returns true if the window object exists
  281. */
  282. static IsWindowObjectExist(): boolean;
  283. /**
  284. * Checks if the navigator object exists
  285. * @returns true if the navigator object exists
  286. */
  287. static IsNavigatorAvailable(): boolean;
  288. /**
  289. * Check if the document object exists
  290. * @returns true if the document object exists
  291. */
  292. static IsDocumentAvailable(): boolean;
  293. /**
  294. * Extracts text content from a DOM element hierarchy
  295. * @param element defines the root element
  296. * @returns a string
  297. */
  298. static GetDOMTextContent(element: HTMLElement): string;
  299. }
  300. }
  301. declare module "babylonjs/Misc/logger" {
  302. /**
  303. * Logger used througouht the application to allow configuration of
  304. * the log level required for the messages.
  305. */
  306. export class Logger {
  307. /**
  308. * No log
  309. */
  310. static readonly NoneLogLevel: number;
  311. /**
  312. * Only message logs
  313. */
  314. static readonly MessageLogLevel: number;
  315. /**
  316. * Only warning logs
  317. */
  318. static readonly WarningLogLevel: number;
  319. /**
  320. * Only error logs
  321. */
  322. static readonly ErrorLogLevel: number;
  323. /**
  324. * All logs
  325. */
  326. static readonly AllLogLevel: number;
  327. private static _LogCache;
  328. /**
  329. * Gets a value indicating the number of loading errors
  330. * @ignorenaming
  331. */
  332. static errorsCount: number;
  333. /**
  334. * Callback called when a new log is added
  335. */
  336. static OnNewCacheEntry: (entry: string) => void;
  337. private static _AddLogEntry;
  338. private static _FormatMessage;
  339. private static _LogDisabled;
  340. private static _LogEnabled;
  341. private static _WarnDisabled;
  342. private static _WarnEnabled;
  343. private static _ErrorDisabled;
  344. private static _ErrorEnabled;
  345. /**
  346. * Log a message to the console
  347. */
  348. static Log: (message: string) => void;
  349. /**
  350. * Write a warning message to the console
  351. */
  352. static Warn: (message: string) => void;
  353. /**
  354. * Write an error message to the console
  355. */
  356. static Error: (message: string) => void;
  357. /**
  358. * Gets current log cache (list of logs)
  359. */
  360. static get LogCache(): string;
  361. /**
  362. * Clears the log cache
  363. */
  364. static ClearLogCache(): void;
  365. /**
  366. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  367. */
  368. static set LogLevels(level: number);
  369. }
  370. }
  371. declare module "babylonjs/Misc/typeStore" {
  372. /** @hidden */
  373. export class _TypeStore {
  374. /** @hidden */
  375. static RegisteredTypes: {
  376. [key: string]: Object;
  377. };
  378. /** @hidden */
  379. static GetClass(fqdn: string): any;
  380. }
  381. }
  382. declare module "babylonjs/Misc/stringTools" {
  383. /**
  384. * Helper to manipulate strings
  385. */
  386. export class StringTools {
  387. /**
  388. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  389. * @param str Source string
  390. * @param suffix Suffix to search for in the source string
  391. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  392. */
  393. static EndsWith(str: string, suffix: string): boolean;
  394. /**
  395. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  396. * @param str Source string
  397. * @param suffix Suffix to search for in the source string
  398. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  399. */
  400. static StartsWith(str: string, suffix: string): boolean;
  401. /**
  402. * Decodes a buffer into a string
  403. * @param buffer The buffer to decode
  404. * @returns The decoded string
  405. */
  406. static Decode(buffer: Uint8Array | Uint16Array): string;
  407. /**
  408. * Encode a buffer to a base64 string
  409. * @param buffer defines the buffer to encode
  410. * @returns the encoded string
  411. */
  412. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  413. /**
  414. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  415. * @param num the number to convert and pad
  416. * @param length the expected length of the string
  417. * @returns the padded string
  418. */
  419. static PadNumber(num: number, length: number): string;
  420. }
  421. }
  422. declare module "babylonjs/Misc/deepCopier" {
  423. /**
  424. * Class containing a set of static utilities functions for deep copy.
  425. */
  426. export class DeepCopier {
  427. /**
  428. * Tries to copy an object by duplicating every property
  429. * @param source defines the source object
  430. * @param destination defines the target object
  431. * @param doNotCopyList defines a list of properties to avoid
  432. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  433. */
  434. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  435. }
  436. }
  437. declare module "babylonjs/Misc/precisionDate" {
  438. /**
  439. * Class containing a set of static utilities functions for precision date
  440. */
  441. export class PrecisionDate {
  442. /**
  443. * Gets either window.performance.now() if supported or Date.now() else
  444. */
  445. static get Now(): number;
  446. }
  447. }
  448. declare module "babylonjs/Misc/devTools" {
  449. /** @hidden */
  450. export class _DevTools {
  451. static WarnImport(name: string): string;
  452. }
  453. }
  454. declare module "babylonjs/Misc/interfaces/iWebRequest" {
  455. /**
  456. * Interface used to define the mechanism to get data from the network
  457. */
  458. export interface IWebRequest {
  459. /**
  460. * Returns client's response url
  461. */
  462. responseURL: string;
  463. /**
  464. * Returns client's status
  465. */
  466. status: number;
  467. /**
  468. * Returns client's status as a text
  469. */
  470. statusText: string;
  471. }
  472. }
  473. declare module "babylonjs/Misc/webRequest" {
  474. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  475. import { Nullable } from "babylonjs/types";
  476. /**
  477. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  478. */
  479. export class WebRequest implements IWebRequest {
  480. private _xhr;
  481. /**
  482. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  483. * i.e. when loading files, where the server/service expects an Authorization header
  484. */
  485. static CustomRequestHeaders: {
  486. [key: string]: string;
  487. };
  488. /**
  489. * Add callback functions in this array to update all the requests before they get sent to the network
  490. */
  491. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  492. private _injectCustomRequestHeaders;
  493. /**
  494. * Gets or sets a function to be called when loading progress changes
  495. */
  496. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  497. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  498. /**
  499. * Returns client's state
  500. */
  501. get readyState(): number;
  502. /**
  503. * Returns client's status
  504. */
  505. get status(): number;
  506. /**
  507. * Returns client's status as a text
  508. */
  509. get statusText(): string;
  510. /**
  511. * Returns client's response
  512. */
  513. get response(): any;
  514. /**
  515. * Returns client's response url
  516. */
  517. get responseURL(): string;
  518. /**
  519. * Returns client's response as text
  520. */
  521. get responseText(): string;
  522. /**
  523. * Gets or sets the expected response type
  524. */
  525. get responseType(): XMLHttpRequestResponseType;
  526. set responseType(value: XMLHttpRequestResponseType);
  527. /** @hidden */
  528. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  529. /** @hidden */
  530. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  531. /**
  532. * Cancels any network activity
  533. */
  534. abort(): void;
  535. /**
  536. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  537. * @param body defines an optional request body
  538. */
  539. send(body?: Document | BodyInit | null): void;
  540. /**
  541. * Sets the request method, request URL
  542. * @param method defines the method to use (GET, POST, etc..)
  543. * @param url defines the url to connect with
  544. */
  545. open(method: string, url: string): void;
  546. /**
  547. * Sets the value of a request header.
  548. * @param name The name of the header whose value is to be set
  549. * @param value The value to set as the body of the header
  550. */
  551. setRequestHeader(name: string, value: string): void;
  552. /**
  553. * Get the string containing the text of a particular header's value.
  554. * @param name The name of the header
  555. * @returns The string containing the text of the given header name
  556. */
  557. getResponseHeader(name: string): Nullable<string>;
  558. }
  559. }
  560. declare module "babylonjs/Misc/fileRequest" {
  561. import { Observable } from "babylonjs/Misc/observable";
  562. /**
  563. * File request interface
  564. */
  565. export interface IFileRequest {
  566. /**
  567. * Raised when the request is complete (success or error).
  568. */
  569. onCompleteObservable: Observable<IFileRequest>;
  570. /**
  571. * Aborts the request for a file.
  572. */
  573. abort: () => void;
  574. }
  575. }
  576. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  577. /**
  578. * Define options used to create a render target texture
  579. */
  580. export class RenderTargetCreationOptions {
  581. /**
  582. * Specifies is mipmaps must be generated
  583. */
  584. generateMipMaps?: boolean;
  585. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  586. generateDepthBuffer?: boolean;
  587. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  588. generateStencilBuffer?: boolean;
  589. /** Defines texture type (int by default) */
  590. type?: number;
  591. /** Defines sampling mode (trilinear by default) */
  592. samplingMode?: number;
  593. /** Defines format (RGBA by default) */
  594. format?: number;
  595. }
  596. }
  597. declare module "babylonjs/Engines/constants" {
  598. /** Defines the cross module used constants to avoid circular dependncies */
  599. export class Constants {
  600. /** Defines that alpha blending is disabled */
  601. static readonly ALPHA_DISABLE: number;
  602. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  603. static readonly ALPHA_ADD: number;
  604. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  605. static readonly ALPHA_COMBINE: number;
  606. /** Defines that alpha blending is DEST - SRC * DEST */
  607. static readonly ALPHA_SUBTRACT: number;
  608. /** Defines that alpha blending is SRC * DEST */
  609. static readonly ALPHA_MULTIPLY: number;
  610. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  611. static readonly ALPHA_MAXIMIZED: number;
  612. /** Defines that alpha blending is SRC + DEST */
  613. static readonly ALPHA_ONEONE: number;
  614. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  615. static readonly ALPHA_PREMULTIPLIED: number;
  616. /**
  617. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  618. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  619. */
  620. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  621. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  622. static readonly ALPHA_INTERPOLATE: number;
  623. /**
  624. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  625. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  626. */
  627. static readonly ALPHA_SCREENMODE: number;
  628. /**
  629. * Defines that alpha blending is SRC + DST
  630. * Alpha will be set to SRC ALPHA + DST ALPHA
  631. */
  632. static readonly ALPHA_ONEONE_ONEONE: number;
  633. /**
  634. * Defines that alpha blending is SRC * DST ALPHA + DST
  635. * Alpha will be set to 0
  636. */
  637. static readonly ALPHA_ALPHATOCOLOR: number;
  638. /**
  639. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  640. */
  641. static readonly ALPHA_REVERSEONEMINUS: number;
  642. /**
  643. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  644. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  645. */
  646. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  647. /**
  648. * Defines that alpha blending is SRC + DST
  649. * Alpha will be set to SRC ALPHA
  650. */
  651. static readonly ALPHA_ONEONE_ONEZERO: number;
  652. /**
  653. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  654. * Alpha will be set to DST ALPHA
  655. */
  656. static readonly ALPHA_EXCLUSION: number;
  657. /** Defines that alpha blending equation a SUM */
  658. static readonly ALPHA_EQUATION_ADD: number;
  659. /** Defines that alpha blending equation a SUBSTRACTION */
  660. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  661. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  662. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  663. /** Defines that alpha blending equation a MAX operation */
  664. static readonly ALPHA_EQUATION_MAX: number;
  665. /** Defines that alpha blending equation a MIN operation */
  666. static readonly ALPHA_EQUATION_MIN: number;
  667. /**
  668. * Defines that alpha blending equation a DARKEN operation:
  669. * It takes the min of the src and sums the alpha channels.
  670. */
  671. static readonly ALPHA_EQUATION_DARKEN: number;
  672. /** Defines that the ressource is not delayed*/
  673. static readonly DELAYLOADSTATE_NONE: number;
  674. /** Defines that the ressource was successfully delay loaded */
  675. static readonly DELAYLOADSTATE_LOADED: number;
  676. /** Defines that the ressource is currently delay loading */
  677. static readonly DELAYLOADSTATE_LOADING: number;
  678. /** Defines that the ressource is delayed and has not started loading */
  679. static readonly DELAYLOADSTATE_NOTLOADED: number;
  680. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  681. static readonly NEVER: number;
  682. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  683. static readonly ALWAYS: number;
  684. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  685. static readonly LESS: number;
  686. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  687. static readonly EQUAL: number;
  688. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  689. static readonly LEQUAL: number;
  690. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  691. static readonly GREATER: number;
  692. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  693. static readonly GEQUAL: number;
  694. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  695. static readonly NOTEQUAL: number;
  696. /** Passed to stencilOperation to specify that stencil value must be kept */
  697. static readonly KEEP: number;
  698. /** Passed to stencilOperation to specify that stencil value must be replaced */
  699. static readonly REPLACE: number;
  700. /** Passed to stencilOperation to specify that stencil value must be incremented */
  701. static readonly INCR: number;
  702. /** Passed to stencilOperation to specify that stencil value must be decremented */
  703. static readonly DECR: number;
  704. /** Passed to stencilOperation to specify that stencil value must be inverted */
  705. static readonly INVERT: number;
  706. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  707. static readonly INCR_WRAP: number;
  708. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  709. static readonly DECR_WRAP: number;
  710. /** Texture is not repeating outside of 0..1 UVs */
  711. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  712. /** Texture is repeating outside of 0..1 UVs */
  713. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  714. /** Texture is repeating and mirrored */
  715. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  716. /** ALPHA */
  717. static readonly TEXTUREFORMAT_ALPHA: number;
  718. /** LUMINANCE */
  719. static readonly TEXTUREFORMAT_LUMINANCE: number;
  720. /** LUMINANCE_ALPHA */
  721. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  722. /** RGB */
  723. static readonly TEXTUREFORMAT_RGB: number;
  724. /** RGBA */
  725. static readonly TEXTUREFORMAT_RGBA: number;
  726. /** RED */
  727. static readonly TEXTUREFORMAT_RED: number;
  728. /** RED (2nd reference) */
  729. static readonly TEXTUREFORMAT_R: number;
  730. /** RG */
  731. static readonly TEXTUREFORMAT_RG: number;
  732. /** RED_INTEGER */
  733. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  734. /** RED_INTEGER (2nd reference) */
  735. static readonly TEXTUREFORMAT_R_INTEGER: number;
  736. /** RG_INTEGER */
  737. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  738. /** RGB_INTEGER */
  739. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  740. /** RGBA_INTEGER */
  741. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  742. /** UNSIGNED_BYTE */
  743. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  744. /** UNSIGNED_BYTE (2nd reference) */
  745. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  746. /** FLOAT */
  747. static readonly TEXTURETYPE_FLOAT: number;
  748. /** HALF_FLOAT */
  749. static readonly TEXTURETYPE_HALF_FLOAT: number;
  750. /** BYTE */
  751. static readonly TEXTURETYPE_BYTE: number;
  752. /** SHORT */
  753. static readonly TEXTURETYPE_SHORT: number;
  754. /** UNSIGNED_SHORT */
  755. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  756. /** INT */
  757. static readonly TEXTURETYPE_INT: number;
  758. /** UNSIGNED_INT */
  759. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  760. /** UNSIGNED_SHORT_4_4_4_4 */
  761. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  762. /** UNSIGNED_SHORT_5_5_5_1 */
  763. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  764. /** UNSIGNED_SHORT_5_6_5 */
  765. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  766. /** UNSIGNED_INT_2_10_10_10_REV */
  767. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  768. /** UNSIGNED_INT_24_8 */
  769. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  770. /** UNSIGNED_INT_10F_11F_11F_REV */
  771. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  772. /** UNSIGNED_INT_5_9_9_9_REV */
  773. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  774. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  775. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  776. /** nearest is mag = nearest and min = nearest and no mip */
  777. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  778. /** mag = nearest and min = nearest and mip = none */
  779. static readonly TEXTURE_NEAREST_NEAREST: number;
  780. /** Bilinear is mag = linear and min = linear and no mip */
  781. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  782. /** mag = linear and min = linear and mip = none */
  783. static readonly TEXTURE_LINEAR_LINEAR: number;
  784. /** Trilinear is mag = linear and min = linear and mip = linear */
  785. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  786. /** Trilinear is mag = linear and min = linear and mip = linear */
  787. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  788. /** mag = nearest and min = nearest and mip = nearest */
  789. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  790. /** mag = nearest and min = linear and mip = nearest */
  791. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  792. /** mag = nearest and min = linear and mip = linear */
  793. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  794. /** mag = nearest and min = linear and mip = none */
  795. static readonly TEXTURE_NEAREST_LINEAR: number;
  796. /** nearest is mag = nearest and min = nearest and mip = linear */
  797. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  798. /** mag = linear and min = nearest and mip = nearest */
  799. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  800. /** mag = linear and min = nearest and mip = linear */
  801. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  802. /** Bilinear is mag = linear and min = linear and mip = nearest */
  803. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  804. /** mag = linear and min = nearest and mip = none */
  805. static readonly TEXTURE_LINEAR_NEAREST: number;
  806. /** Explicit coordinates mode */
  807. static readonly TEXTURE_EXPLICIT_MODE: number;
  808. /** Spherical coordinates mode */
  809. static readonly TEXTURE_SPHERICAL_MODE: number;
  810. /** Planar coordinates mode */
  811. static readonly TEXTURE_PLANAR_MODE: number;
  812. /** Cubic coordinates mode */
  813. static readonly TEXTURE_CUBIC_MODE: number;
  814. /** Projection coordinates mode */
  815. static readonly TEXTURE_PROJECTION_MODE: number;
  816. /** Skybox coordinates mode */
  817. static readonly TEXTURE_SKYBOX_MODE: number;
  818. /** Inverse Cubic coordinates mode */
  819. static readonly TEXTURE_INVCUBIC_MODE: number;
  820. /** Equirectangular coordinates mode */
  821. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  822. /** Equirectangular Fixed coordinates mode */
  823. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  824. /** Equirectangular Fixed Mirrored coordinates mode */
  825. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  826. /** Offline (baking) quality for texture filtering */
  827. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  828. /** High quality for texture filtering */
  829. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  830. /** Medium quality for texture filtering */
  831. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  832. /** Low quality for texture filtering */
  833. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  834. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  835. static readonly SCALEMODE_FLOOR: number;
  836. /** Defines that texture rescaling will look for the nearest power of 2 size */
  837. static readonly SCALEMODE_NEAREST: number;
  838. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  839. static readonly SCALEMODE_CEILING: number;
  840. /**
  841. * The dirty texture flag value
  842. */
  843. static readonly MATERIAL_TextureDirtyFlag: number;
  844. /**
  845. * The dirty light flag value
  846. */
  847. static readonly MATERIAL_LightDirtyFlag: number;
  848. /**
  849. * The dirty fresnel flag value
  850. */
  851. static readonly MATERIAL_FresnelDirtyFlag: number;
  852. /**
  853. * The dirty attribute flag value
  854. */
  855. static readonly MATERIAL_AttributesDirtyFlag: number;
  856. /**
  857. * The dirty misc flag value
  858. */
  859. static readonly MATERIAL_MiscDirtyFlag: number;
  860. /**
  861. * The all dirty flag value
  862. */
  863. static readonly MATERIAL_AllDirtyFlag: number;
  864. /**
  865. * Returns the triangle fill mode
  866. */
  867. static readonly MATERIAL_TriangleFillMode: number;
  868. /**
  869. * Returns the wireframe mode
  870. */
  871. static readonly MATERIAL_WireFrameFillMode: number;
  872. /**
  873. * Returns the point fill mode
  874. */
  875. static readonly MATERIAL_PointFillMode: number;
  876. /**
  877. * Returns the point list draw mode
  878. */
  879. static readonly MATERIAL_PointListDrawMode: number;
  880. /**
  881. * Returns the line list draw mode
  882. */
  883. static readonly MATERIAL_LineListDrawMode: number;
  884. /**
  885. * Returns the line loop draw mode
  886. */
  887. static readonly MATERIAL_LineLoopDrawMode: number;
  888. /**
  889. * Returns the line strip draw mode
  890. */
  891. static readonly MATERIAL_LineStripDrawMode: number;
  892. /**
  893. * Returns the triangle strip draw mode
  894. */
  895. static readonly MATERIAL_TriangleStripDrawMode: number;
  896. /**
  897. * Returns the triangle fan draw mode
  898. */
  899. static readonly MATERIAL_TriangleFanDrawMode: number;
  900. /**
  901. * Stores the clock-wise side orientation
  902. */
  903. static readonly MATERIAL_ClockWiseSideOrientation: number;
  904. /**
  905. * Stores the counter clock-wise side orientation
  906. */
  907. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  908. /**
  909. * Nothing
  910. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  911. */
  912. static readonly ACTION_NothingTrigger: number;
  913. /**
  914. * On pick
  915. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  916. */
  917. static readonly ACTION_OnPickTrigger: number;
  918. /**
  919. * On left pick
  920. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  921. */
  922. static readonly ACTION_OnLeftPickTrigger: number;
  923. /**
  924. * On right pick
  925. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  926. */
  927. static readonly ACTION_OnRightPickTrigger: number;
  928. /**
  929. * On center pick
  930. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  931. */
  932. static readonly ACTION_OnCenterPickTrigger: number;
  933. /**
  934. * On pick down
  935. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  936. */
  937. static readonly ACTION_OnPickDownTrigger: number;
  938. /**
  939. * On double pick
  940. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  941. */
  942. static readonly ACTION_OnDoublePickTrigger: number;
  943. /**
  944. * On pick up
  945. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  946. */
  947. static readonly ACTION_OnPickUpTrigger: number;
  948. /**
  949. * On pick out.
  950. * This trigger will only be raised if you also declared a OnPickDown
  951. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  952. */
  953. static readonly ACTION_OnPickOutTrigger: number;
  954. /**
  955. * On long press
  956. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  957. */
  958. static readonly ACTION_OnLongPressTrigger: number;
  959. /**
  960. * On pointer over
  961. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  962. */
  963. static readonly ACTION_OnPointerOverTrigger: number;
  964. /**
  965. * On pointer out
  966. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  967. */
  968. static readonly ACTION_OnPointerOutTrigger: number;
  969. /**
  970. * On every frame
  971. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  972. */
  973. static readonly ACTION_OnEveryFrameTrigger: number;
  974. /**
  975. * On intersection enter
  976. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  977. */
  978. static readonly ACTION_OnIntersectionEnterTrigger: number;
  979. /**
  980. * On intersection exit
  981. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  982. */
  983. static readonly ACTION_OnIntersectionExitTrigger: number;
  984. /**
  985. * On key down
  986. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  987. */
  988. static readonly ACTION_OnKeyDownTrigger: number;
  989. /**
  990. * On key up
  991. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  992. */
  993. static readonly ACTION_OnKeyUpTrigger: number;
  994. /**
  995. * Billboard mode will only apply to Y axis
  996. */
  997. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  998. /**
  999. * Billboard mode will apply to all axes
  1000. */
  1001. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  1002. /**
  1003. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  1004. */
  1005. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  1006. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  1007. * Test order :
  1008. * Is the bounding sphere outside the frustum ?
  1009. * If not, are the bounding box vertices outside the frustum ?
  1010. * It not, then the cullable object is in the frustum.
  1011. */
  1012. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  1013. /** Culling strategy : Bounding Sphere Only.
  1014. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1015. * It's also less accurate than the standard because some not visible objects can still be selected.
  1016. * Test : is the bounding sphere outside the frustum ?
  1017. * If not, then the cullable object is in the frustum.
  1018. */
  1019. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1020. /** Culling strategy : Optimistic Inclusion.
  1021. * This in an inclusion test first, then the standard exclusion test.
  1022. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1023. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  1024. * Anyway, it's as accurate as the standard strategy.
  1025. * Test :
  1026. * Is the cullable object bounding sphere center in the frustum ?
  1027. * If not, apply the default culling strategy.
  1028. */
  1029. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1030. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1031. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1032. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1033. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  1034. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1035. * Test :
  1036. * Is the cullable object bounding sphere center in the frustum ?
  1037. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1038. */
  1039. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1040. /**
  1041. * No logging while loading
  1042. */
  1043. static readonly SCENELOADER_NO_LOGGING: number;
  1044. /**
  1045. * Minimal logging while loading
  1046. */
  1047. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1048. /**
  1049. * Summary logging while loading
  1050. */
  1051. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1052. /**
  1053. * Detailled logging while loading
  1054. */
  1055. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1056. }
  1057. }
  1058. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  1059. import { Nullable } from "babylonjs/types";
  1060. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  1061. /**
  1062. * This represents the required contract to create a new type of texture loader.
  1063. */
  1064. export interface IInternalTextureLoader {
  1065. /**
  1066. * Defines wether the loader supports cascade loading the different faces.
  1067. */
  1068. supportCascades: boolean;
  1069. /**
  1070. * This returns if the loader support the current file information.
  1071. * @param extension defines the file extension of the file being loaded
  1072. * @returns true if the loader can load the specified file
  1073. */
  1074. canLoad(extension: string): boolean;
  1075. /**
  1076. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1077. * @param data contains the texture data
  1078. * @param texture defines the BabylonJS internal texture
  1079. * @param createPolynomials will be true if polynomials have been requested
  1080. * @param onLoad defines the callback to trigger once the texture is ready
  1081. * @param onError defines the callback to trigger in case of error
  1082. */
  1083. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1084. /**
  1085. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1086. * @param data contains the texture data
  1087. * @param texture defines the BabylonJS internal texture
  1088. * @param callback defines the method to call once ready to upload
  1089. */
  1090. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1091. }
  1092. }
  1093. declare module "babylonjs/Engines/IPipelineContext" {
  1094. /**
  1095. * Class used to store and describe the pipeline context associated with an effect
  1096. */
  1097. export interface IPipelineContext {
  1098. /**
  1099. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1100. */
  1101. isAsync: boolean;
  1102. /**
  1103. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1104. */
  1105. isReady: boolean;
  1106. /** @hidden */
  1107. _getVertexShaderCode(): string | null;
  1108. /** @hidden */
  1109. _getFragmentShaderCode(): string | null;
  1110. /** @hidden */
  1111. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1112. }
  1113. }
  1114. declare module "babylonjs/Meshes/dataBuffer" {
  1115. /**
  1116. * Class used to store gfx data (like WebGLBuffer)
  1117. */
  1118. export class DataBuffer {
  1119. /**
  1120. * Gets or sets the number of objects referencing this buffer
  1121. */
  1122. references: number;
  1123. /** Gets or sets the size of the underlying buffer */
  1124. capacity: number;
  1125. /**
  1126. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1127. */
  1128. is32Bits: boolean;
  1129. /**
  1130. * Gets the underlying buffer
  1131. */
  1132. get underlyingResource(): any;
  1133. }
  1134. }
  1135. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  1136. /** @hidden */
  1137. export interface IShaderProcessor {
  1138. attributeProcessor?: (attribute: string) => string;
  1139. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1140. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1141. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1142. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1143. lineProcessor?: (line: string, isFragment: boolean) => string;
  1144. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1145. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1146. }
  1147. }
  1148. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  1149. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  1150. /** @hidden */
  1151. export interface ProcessingOptions {
  1152. defines: string[];
  1153. indexParameters: any;
  1154. isFragment: boolean;
  1155. shouldUseHighPrecisionShader: boolean;
  1156. supportsUniformBuffers: boolean;
  1157. shadersRepository: string;
  1158. includesShadersStore: {
  1159. [key: string]: string;
  1160. };
  1161. processor?: IShaderProcessor;
  1162. version: string;
  1163. platformName: string;
  1164. lookForClosingBracketForUniformBuffer?: boolean;
  1165. }
  1166. }
  1167. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  1168. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1169. /** @hidden */
  1170. export class ShaderCodeNode {
  1171. line: string;
  1172. children: ShaderCodeNode[];
  1173. additionalDefineKey?: string;
  1174. additionalDefineValue?: string;
  1175. isValid(preprocessors: {
  1176. [key: string]: string;
  1177. }): boolean;
  1178. process(preprocessors: {
  1179. [key: string]: string;
  1180. }, options: ProcessingOptions): string;
  1181. }
  1182. }
  1183. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  1184. /** @hidden */
  1185. export class ShaderCodeCursor {
  1186. private _lines;
  1187. lineIndex: number;
  1188. get currentLine(): string;
  1189. get canRead(): boolean;
  1190. set lines(value: string[]);
  1191. }
  1192. }
  1193. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  1194. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1195. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1196. /** @hidden */
  1197. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1198. process(preprocessors: {
  1199. [key: string]: string;
  1200. }, options: ProcessingOptions): string;
  1201. }
  1202. }
  1203. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  1204. /** @hidden */
  1205. export class ShaderDefineExpression {
  1206. isTrue(preprocessors: {
  1207. [key: string]: string;
  1208. }): boolean;
  1209. private static _OperatorPriority;
  1210. private static _Stack;
  1211. static postfixToInfix(postfix: string[]): string;
  1212. static infixToPostfix(infix: string): string[];
  1213. }
  1214. }
  1215. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  1216. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1217. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1218. /** @hidden */
  1219. export class ShaderCodeTestNode extends ShaderCodeNode {
  1220. testExpression: ShaderDefineExpression;
  1221. isValid(preprocessors: {
  1222. [key: string]: string;
  1223. }): boolean;
  1224. }
  1225. }
  1226. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  1227. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1228. /** @hidden */
  1229. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1230. define: string;
  1231. not: boolean;
  1232. constructor(define: string, not?: boolean);
  1233. isTrue(preprocessors: {
  1234. [key: string]: string;
  1235. }): boolean;
  1236. }
  1237. }
  1238. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  1239. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1240. /** @hidden */
  1241. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1242. leftOperand: ShaderDefineExpression;
  1243. rightOperand: ShaderDefineExpression;
  1244. isTrue(preprocessors: {
  1245. [key: string]: string;
  1246. }): boolean;
  1247. }
  1248. }
  1249. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  1250. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1251. /** @hidden */
  1252. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1253. leftOperand: ShaderDefineExpression;
  1254. rightOperand: ShaderDefineExpression;
  1255. isTrue(preprocessors: {
  1256. [key: string]: string;
  1257. }): boolean;
  1258. }
  1259. }
  1260. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  1261. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1262. /** @hidden */
  1263. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1264. define: string;
  1265. operand: string;
  1266. testValue: string;
  1267. constructor(define: string, operand: string, testValue: string);
  1268. isTrue(preprocessors: {
  1269. [key: string]: string;
  1270. }): boolean;
  1271. }
  1272. }
  1273. declare module "babylonjs/Offline/IOfflineProvider" {
  1274. /**
  1275. * Class used to enable access to offline support
  1276. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1277. */
  1278. export interface IOfflineProvider {
  1279. /**
  1280. * Gets a boolean indicating if scene must be saved in the database
  1281. */
  1282. enableSceneOffline: boolean;
  1283. /**
  1284. * Gets a boolean indicating if textures must be saved in the database
  1285. */
  1286. enableTexturesOffline: boolean;
  1287. /**
  1288. * Open the offline support and make it available
  1289. * @param successCallback defines the callback to call on success
  1290. * @param errorCallback defines the callback to call on error
  1291. */
  1292. open(successCallback: () => void, errorCallback: () => void): void;
  1293. /**
  1294. * Loads an image from the offline support
  1295. * @param url defines the url to load from
  1296. * @param image defines the target DOM image
  1297. */
  1298. loadImage(url: string, image: HTMLImageElement): void;
  1299. /**
  1300. * Loads a file from offline support
  1301. * @param url defines the URL to load from
  1302. * @param sceneLoaded defines a callback to call on success
  1303. * @param progressCallBack defines a callback to call when progress changed
  1304. * @param errorCallback defines a callback to call on error
  1305. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1306. */
  1307. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1308. }
  1309. }
  1310. declare module "babylonjs/Misc/filesInputStore" {
  1311. /**
  1312. * Class used to help managing file picking and drag'n'drop
  1313. * File Storage
  1314. */
  1315. export class FilesInputStore {
  1316. /**
  1317. * List of files ready to be loaded
  1318. */
  1319. static FilesToLoad: {
  1320. [key: string]: File;
  1321. };
  1322. }
  1323. }
  1324. declare module "babylonjs/Misc/retryStrategy" {
  1325. import { WebRequest } from "babylonjs/Misc/webRequest";
  1326. /**
  1327. * Class used to define a retry strategy when error happens while loading assets
  1328. */
  1329. export class RetryStrategy {
  1330. /**
  1331. * Function used to defines an exponential back off strategy
  1332. * @param maxRetries defines the maximum number of retries (3 by default)
  1333. * @param baseInterval defines the interval between retries
  1334. * @returns the strategy function to use
  1335. */
  1336. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1337. }
  1338. }
  1339. declare module "babylonjs/Misc/baseError" {
  1340. /**
  1341. * @ignore
  1342. * Application error to support additional information when loading a file
  1343. */
  1344. export abstract class BaseError extends Error {
  1345. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1346. }
  1347. }
  1348. declare module "babylonjs/Misc/fileTools" {
  1349. import { WebRequest } from "babylonjs/Misc/webRequest";
  1350. import { Nullable } from "babylonjs/types";
  1351. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1352. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1353. import { BaseError } from "babylonjs/Misc/baseError";
  1354. /** @ignore */
  1355. export class LoadFileError extends BaseError {
  1356. request?: WebRequest;
  1357. file?: File;
  1358. /**
  1359. * Creates a new LoadFileError
  1360. * @param message defines the message of the error
  1361. * @param request defines the optional web request
  1362. * @param file defines the optional file
  1363. */
  1364. constructor(message: string, object?: WebRequest | File);
  1365. }
  1366. /** @ignore */
  1367. export class RequestFileError extends BaseError {
  1368. request: WebRequest;
  1369. /**
  1370. * Creates a new LoadFileError
  1371. * @param message defines the message of the error
  1372. * @param request defines the optional web request
  1373. */
  1374. constructor(message: string, request: WebRequest);
  1375. }
  1376. /** @ignore */
  1377. export class ReadFileError extends BaseError {
  1378. file: File;
  1379. /**
  1380. * Creates a new ReadFileError
  1381. * @param message defines the message of the error
  1382. * @param file defines the optional file
  1383. */
  1384. constructor(message: string, file: File);
  1385. }
  1386. /**
  1387. * @hidden
  1388. */
  1389. export class FileTools {
  1390. /**
  1391. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1392. */
  1393. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1394. /**
  1395. * Gets or sets the base URL to use to load assets
  1396. */
  1397. static BaseUrl: string;
  1398. /**
  1399. * Default behaviour for cors in the application.
  1400. * It can be a string if the expected behavior is identical in the entire app.
  1401. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1402. */
  1403. static CorsBehavior: string | ((url: string | string[]) => string);
  1404. /**
  1405. * Gets or sets a function used to pre-process url before using them to load assets
  1406. */
  1407. static PreprocessUrl: (url: string) => string;
  1408. /**
  1409. * Removes unwanted characters from an url
  1410. * @param url defines the url to clean
  1411. * @returns the cleaned url
  1412. */
  1413. private static _CleanUrl;
  1414. /**
  1415. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1416. * @param url define the url we are trying
  1417. * @param element define the dom element where to configure the cors policy
  1418. */
  1419. static SetCorsBehavior(url: string | string[], element: {
  1420. crossOrigin: string | null;
  1421. }): void;
  1422. /**
  1423. * Loads an image as an HTMLImageElement.
  1424. * @param input url string, ArrayBuffer, or Blob to load
  1425. * @param onLoad callback called when the image successfully loads
  1426. * @param onError callback called when the image fails to load
  1427. * @param offlineProvider offline provider for caching
  1428. * @param mimeType optional mime type
  1429. * @returns the HTMLImageElement of the loaded image
  1430. */
  1431. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  1432. /**
  1433. * Reads a file from a File object
  1434. * @param file defines the file to load
  1435. * @param onSuccess defines the callback to call when data is loaded
  1436. * @param onProgress defines the callback to call during loading process
  1437. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1438. * @param onError defines the callback to call when an error occurs
  1439. * @returns a file request object
  1440. */
  1441. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1442. /**
  1443. * Loads a file from a url
  1444. * @param url url to load
  1445. * @param onSuccess callback called when the file successfully loads
  1446. * @param onProgress callback called while file is loading (if the server supports this mode)
  1447. * @param offlineProvider defines the offline provider for caching
  1448. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1449. * @param onError callback called when the file fails to load
  1450. * @returns a file request object
  1451. */
  1452. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1453. /**
  1454. * Loads a file
  1455. * @param url url to load
  1456. * @param onSuccess callback called when the file successfully loads
  1457. * @param onProgress callback called while file is loading (if the server supports this mode)
  1458. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1459. * @param onError callback called when the file fails to load
  1460. * @param onOpened callback called when the web request is opened
  1461. * @returns a file request object
  1462. */
  1463. static RequestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (event: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  1464. /**
  1465. * Checks if the loaded document was accessed via `file:`-Protocol.
  1466. * @returns boolean
  1467. */
  1468. static IsFileURL(): boolean;
  1469. }
  1470. }
  1471. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  1472. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1473. import { WebRequest } from "babylonjs/Misc/webRequest";
  1474. import { LoadFileError } from "babylonjs/Misc/fileTools";
  1475. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1476. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1477. /** @hidden */
  1478. export class ShaderProcessor {
  1479. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1480. private static _ProcessPrecision;
  1481. private static _ExtractOperation;
  1482. private static _BuildSubExpression;
  1483. private static _BuildExpression;
  1484. private static _MoveCursorWithinIf;
  1485. private static _MoveCursor;
  1486. private static _EvaluatePreProcessors;
  1487. private static _PreparePreProcessors;
  1488. private static _ProcessShaderConversion;
  1489. private static _ProcessIncludes;
  1490. /**
  1491. * Loads a file from a url
  1492. * @param url url to load
  1493. * @param onSuccess callback called when the file successfully loads
  1494. * @param onProgress callback called while file is loading (if the server supports this mode)
  1495. * @param offlineProvider defines the offline provider for caching
  1496. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1497. * @param onError callback called when the file fails to load
  1498. * @returns a file request object
  1499. * @hidden
  1500. */
  1501. static _FileToolsLoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1502. }
  1503. }
  1504. declare module "babylonjs/Maths/math.like" {
  1505. import { float, int, DeepImmutable } from "babylonjs/types";
  1506. /**
  1507. * @hidden
  1508. */
  1509. export interface IColor4Like {
  1510. r: float;
  1511. g: float;
  1512. b: float;
  1513. a: float;
  1514. }
  1515. /**
  1516. * @hidden
  1517. */
  1518. export interface IColor3Like {
  1519. r: float;
  1520. g: float;
  1521. b: float;
  1522. }
  1523. /**
  1524. * @hidden
  1525. */
  1526. export interface IVector4Like {
  1527. x: float;
  1528. y: float;
  1529. z: float;
  1530. w: float;
  1531. }
  1532. /**
  1533. * @hidden
  1534. */
  1535. export interface IVector3Like {
  1536. x: float;
  1537. y: float;
  1538. z: float;
  1539. }
  1540. /**
  1541. * @hidden
  1542. */
  1543. export interface IVector2Like {
  1544. x: float;
  1545. y: float;
  1546. }
  1547. /**
  1548. * @hidden
  1549. */
  1550. export interface IMatrixLike {
  1551. toArray(): DeepImmutable<Float32Array>;
  1552. updateFlag: int;
  1553. }
  1554. /**
  1555. * @hidden
  1556. */
  1557. export interface IViewportLike {
  1558. x: float;
  1559. y: float;
  1560. width: float;
  1561. height: float;
  1562. }
  1563. /**
  1564. * @hidden
  1565. */
  1566. export interface IPlaneLike {
  1567. normal: IVector3Like;
  1568. d: float;
  1569. normalize(): void;
  1570. }
  1571. }
  1572. declare module "babylonjs/Materials/iEffectFallbacks" {
  1573. import { Effect } from "babylonjs/Materials/effect";
  1574. /**
  1575. * Interface used to define common properties for effect fallbacks
  1576. */
  1577. export interface IEffectFallbacks {
  1578. /**
  1579. * Removes the defines that should be removed when falling back.
  1580. * @param currentDefines defines the current define statements for the shader.
  1581. * @param effect defines the current effect we try to compile
  1582. * @returns The resulting defines with defines of the current rank removed.
  1583. */
  1584. reduce(currentDefines: string, effect: Effect): string;
  1585. /**
  1586. * Removes the fallback from the bound mesh.
  1587. */
  1588. unBindMesh(): void;
  1589. /**
  1590. * Checks to see if more fallbacks are still availible.
  1591. */
  1592. hasMoreFallbacks: boolean;
  1593. }
  1594. }
  1595. declare module "babylonjs/Misc/andOrNotEvaluator" {
  1596. /**
  1597. * Class used to evalaute queries containing `and` and `or` operators
  1598. */
  1599. export class AndOrNotEvaluator {
  1600. /**
  1601. * Evaluate a query
  1602. * @param query defines the query to evaluate
  1603. * @param evaluateCallback defines the callback used to filter result
  1604. * @returns true if the query matches
  1605. */
  1606. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1607. private static _HandleParenthesisContent;
  1608. private static _SimplifyNegation;
  1609. }
  1610. }
  1611. declare module "babylonjs/Misc/tags" {
  1612. /**
  1613. * Class used to store custom tags
  1614. */
  1615. export class Tags {
  1616. /**
  1617. * Adds support for tags on the given object
  1618. * @param obj defines the object to use
  1619. */
  1620. static EnableFor(obj: any): void;
  1621. /**
  1622. * Removes tags support
  1623. * @param obj defines the object to use
  1624. */
  1625. static DisableFor(obj: any): void;
  1626. /**
  1627. * Gets a boolean indicating if the given object has tags
  1628. * @param obj defines the object to use
  1629. * @returns a boolean
  1630. */
  1631. static HasTags(obj: any): boolean;
  1632. /**
  1633. * Gets the tags available on a given object
  1634. * @param obj defines the object to use
  1635. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1636. * @returns the tags
  1637. */
  1638. static GetTags(obj: any, asString?: boolean): any;
  1639. /**
  1640. * Adds tags to an object
  1641. * @param obj defines the object to use
  1642. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1643. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1644. */
  1645. static AddTagsTo(obj: any, tagsString: string): void;
  1646. /**
  1647. * @hidden
  1648. */
  1649. static _AddTagTo(obj: any, tag: string): void;
  1650. /**
  1651. * Removes specific tags from a specific object
  1652. * @param obj defines the object to use
  1653. * @param tagsString defines the tags to remove
  1654. */
  1655. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1656. /**
  1657. * @hidden
  1658. */
  1659. static _RemoveTagFrom(obj: any, tag: string): void;
  1660. /**
  1661. * Defines if tags hosted on an object match a given query
  1662. * @param obj defines the object to use
  1663. * @param tagsQuery defines the tag query
  1664. * @returns a boolean
  1665. */
  1666. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1667. }
  1668. }
  1669. declare module "babylonjs/Maths/math.scalar" {
  1670. /**
  1671. * Scalar computation library
  1672. */
  1673. export class Scalar {
  1674. /**
  1675. * Two pi constants convenient for computation.
  1676. */
  1677. static TwoPi: number;
  1678. /**
  1679. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1680. * @param a number
  1681. * @param b number
  1682. * @param epsilon (default = 1.401298E-45)
  1683. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1684. */
  1685. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1686. /**
  1687. * Returns a string : the upper case translation of the number i to hexadecimal.
  1688. * @param i number
  1689. * @returns the upper case translation of the number i to hexadecimal.
  1690. */
  1691. static ToHex(i: number): string;
  1692. /**
  1693. * Returns -1 if value is negative and +1 is value is positive.
  1694. * @param value the value
  1695. * @returns the value itself if it's equal to zero.
  1696. */
  1697. static Sign(value: number): number;
  1698. /**
  1699. * Returns the value itself if it's between min and max.
  1700. * Returns min if the value is lower than min.
  1701. * Returns max if the value is greater than max.
  1702. * @param value the value to clmap
  1703. * @param min the min value to clamp to (default: 0)
  1704. * @param max the max value to clamp to (default: 1)
  1705. * @returns the clamped value
  1706. */
  1707. static Clamp(value: number, min?: number, max?: number): number;
  1708. /**
  1709. * the log2 of value.
  1710. * @param value the value to compute log2 of
  1711. * @returns the log2 of value.
  1712. */
  1713. static Log2(value: number): number;
  1714. /**
  1715. * Loops the value, so that it is never larger than length and never smaller than 0.
  1716. *
  1717. * This is similar to the modulo operator but it works with floating point numbers.
  1718. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1719. * With t = 5 and length = 2.5, the result would be 0.0.
  1720. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1721. * @param value the value
  1722. * @param length the length
  1723. * @returns the looped value
  1724. */
  1725. static Repeat(value: number, length: number): number;
  1726. /**
  1727. * Normalize the value between 0.0 and 1.0 using min and max values
  1728. * @param value value to normalize
  1729. * @param min max to normalize between
  1730. * @param max min to normalize between
  1731. * @returns the normalized value
  1732. */
  1733. static Normalize(value: number, min: number, max: number): number;
  1734. /**
  1735. * Denormalize the value from 0.0 and 1.0 using min and max values
  1736. * @param normalized value to denormalize
  1737. * @param min max to denormalize between
  1738. * @param max min to denormalize between
  1739. * @returns the denormalized value
  1740. */
  1741. static Denormalize(normalized: number, min: number, max: number): number;
  1742. /**
  1743. * Calculates the shortest difference between two given angles given in degrees.
  1744. * @param current current angle in degrees
  1745. * @param target target angle in degrees
  1746. * @returns the delta
  1747. */
  1748. static DeltaAngle(current: number, target: number): number;
  1749. /**
  1750. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1751. * @param tx value
  1752. * @param length length
  1753. * @returns The returned value will move back and forth between 0 and length
  1754. */
  1755. static PingPong(tx: number, length: number): number;
  1756. /**
  1757. * Interpolates between min and max with smoothing at the limits.
  1758. *
  1759. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1760. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1761. * @param from from
  1762. * @param to to
  1763. * @param tx value
  1764. * @returns the smooth stepped value
  1765. */
  1766. static SmoothStep(from: number, to: number, tx: number): number;
  1767. /**
  1768. * Moves a value current towards target.
  1769. *
  1770. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1771. * Negative values of maxDelta pushes the value away from target.
  1772. * @param current current value
  1773. * @param target target value
  1774. * @param maxDelta max distance to move
  1775. * @returns resulting value
  1776. */
  1777. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1778. /**
  1779. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1780. *
  1781. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1782. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1783. * @param current current value
  1784. * @param target target value
  1785. * @param maxDelta max distance to move
  1786. * @returns resulting angle
  1787. */
  1788. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1789. /**
  1790. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1791. * @param start start value
  1792. * @param end target value
  1793. * @param amount amount to lerp between
  1794. * @returns the lerped value
  1795. */
  1796. static Lerp(start: number, end: number, amount: number): number;
  1797. /**
  1798. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1799. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1800. * @param start start value
  1801. * @param end target value
  1802. * @param amount amount to lerp between
  1803. * @returns the lerped value
  1804. */
  1805. static LerpAngle(start: number, end: number, amount: number): number;
  1806. /**
  1807. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1808. * @param a start value
  1809. * @param b target value
  1810. * @param value value between a and b
  1811. * @returns the inverseLerp value
  1812. */
  1813. static InverseLerp(a: number, b: number, value: number): number;
  1814. /**
  1815. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1816. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1817. * @param value1 spline value
  1818. * @param tangent1 spline value
  1819. * @param value2 spline value
  1820. * @param tangent2 spline value
  1821. * @param amount input value
  1822. * @returns hermite result
  1823. */
  1824. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1825. /**
  1826. * Returns a random float number between and min and max values
  1827. * @param min min value of random
  1828. * @param max max value of random
  1829. * @returns random value
  1830. */
  1831. static RandomRange(min: number, max: number): number;
  1832. /**
  1833. * This function returns percentage of a number in a given range.
  1834. *
  1835. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1836. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1837. * @param number to convert to percentage
  1838. * @param min min range
  1839. * @param max max range
  1840. * @returns the percentage
  1841. */
  1842. static RangeToPercent(number: number, min: number, max: number): number;
  1843. /**
  1844. * This function returns number that corresponds to the percentage in a given range.
  1845. *
  1846. * PercentToRange(0.34,0,100) will return 34.
  1847. * @param percent to convert to number
  1848. * @param min min range
  1849. * @param max max range
  1850. * @returns the number
  1851. */
  1852. static PercentToRange(percent: number, min: number, max: number): number;
  1853. /**
  1854. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1855. * @param angle The angle to normalize in radian.
  1856. * @return The converted angle.
  1857. */
  1858. static NormalizeRadians(angle: number): number;
  1859. }
  1860. }
  1861. declare module "babylonjs/Maths/math.constants" {
  1862. /**
  1863. * Constant used to convert a value to gamma space
  1864. * @ignorenaming
  1865. */
  1866. export const ToGammaSpace: number;
  1867. /**
  1868. * Constant used to convert a value to linear space
  1869. * @ignorenaming
  1870. */
  1871. export const ToLinearSpace = 2.2;
  1872. /**
  1873. * Constant used to define the minimal number value in Babylon.js
  1874. * @ignorenaming
  1875. */
  1876. let Epsilon: number;
  1877. export { Epsilon };
  1878. }
  1879. declare module "babylonjs/Maths/math.viewport" {
  1880. /**
  1881. * Class used to represent a viewport on screen
  1882. */
  1883. export class Viewport {
  1884. /** viewport left coordinate */
  1885. x: number;
  1886. /** viewport top coordinate */
  1887. y: number;
  1888. /**viewport width */
  1889. width: number;
  1890. /** viewport height */
  1891. height: number;
  1892. /**
  1893. * Creates a Viewport object located at (x, y) and sized (width, height)
  1894. * @param x defines viewport left coordinate
  1895. * @param y defines viewport top coordinate
  1896. * @param width defines the viewport width
  1897. * @param height defines the viewport height
  1898. */
  1899. constructor(
  1900. /** viewport left coordinate */
  1901. x: number,
  1902. /** viewport top coordinate */
  1903. y: number,
  1904. /**viewport width */
  1905. width: number,
  1906. /** viewport height */
  1907. height: number);
  1908. /**
  1909. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1910. * @param renderWidth defines the rendering width
  1911. * @param renderHeight defines the rendering height
  1912. * @returns a new Viewport
  1913. */
  1914. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1915. /**
  1916. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1917. * @param renderWidth defines the rendering width
  1918. * @param renderHeight defines the rendering height
  1919. * @param ref defines the target viewport
  1920. * @returns the current viewport
  1921. */
  1922. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1923. /**
  1924. * Returns a new Viewport copied from the current one
  1925. * @returns a new Viewport
  1926. */
  1927. clone(): Viewport;
  1928. }
  1929. }
  1930. declare module "babylonjs/Misc/arrayTools" {
  1931. /**
  1932. * Class containing a set of static utilities functions for arrays.
  1933. */
  1934. export class ArrayTools {
  1935. /**
  1936. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1937. * @param size the number of element to construct and put in the array
  1938. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1939. * @returns a new array filled with new objects
  1940. */
  1941. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1942. }
  1943. }
  1944. declare module "babylonjs/Maths/math.plane" {
  1945. import { DeepImmutable } from "babylonjs/types";
  1946. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  1947. /**
  1948. * Represens a plane by the equation ax + by + cz + d = 0
  1949. */
  1950. export class Plane {
  1951. private static _TmpMatrix;
  1952. /**
  1953. * Normal of the plane (a,b,c)
  1954. */
  1955. normal: Vector3;
  1956. /**
  1957. * d component of the plane
  1958. */
  1959. d: number;
  1960. /**
  1961. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  1962. * @param a a component of the plane
  1963. * @param b b component of the plane
  1964. * @param c c component of the plane
  1965. * @param d d component of the plane
  1966. */
  1967. constructor(a: number, b: number, c: number, d: number);
  1968. /**
  1969. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  1970. */
  1971. asArray(): number[];
  1972. /**
  1973. * @returns a new plane copied from the current Plane.
  1974. */
  1975. clone(): Plane;
  1976. /**
  1977. * @returns the string "Plane".
  1978. */
  1979. getClassName(): string;
  1980. /**
  1981. * @returns the Plane hash code.
  1982. */
  1983. getHashCode(): number;
  1984. /**
  1985. * Normalize the current Plane in place.
  1986. * @returns the updated Plane.
  1987. */
  1988. normalize(): Plane;
  1989. /**
  1990. * Applies a transformation the plane and returns the result
  1991. * @param transformation the transformation matrix to be applied to the plane
  1992. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  1993. */
  1994. transform(transformation: DeepImmutable<Matrix>): Plane;
  1995. /**
  1996. * Compute the dot product between the point and the plane normal
  1997. * @param point point to calculate the dot product with
  1998. * @returns the dot product (float) of the point coordinates and the plane normal.
  1999. */
  2000. dotCoordinate(point: DeepImmutable<Vector3>): number;
  2001. /**
  2002. * Updates the current Plane from the plane defined by the three given points.
  2003. * @param point1 one of the points used to contruct the plane
  2004. * @param point2 one of the points used to contruct the plane
  2005. * @param point3 one of the points used to contruct the plane
  2006. * @returns the updated Plane.
  2007. */
  2008. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2009. /**
  2010. * Checks if the plane is facing a given direction
  2011. * @param direction the direction to check if the plane is facing
  2012. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  2013. * @returns True is the vector "direction" is the same side than the plane normal.
  2014. */
  2015. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  2016. /**
  2017. * Calculates the distance to a point
  2018. * @param point point to calculate distance to
  2019. * @returns the signed distance (float) from the given point to the Plane.
  2020. */
  2021. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  2022. /**
  2023. * Creates a plane from an array
  2024. * @param array the array to create a plane from
  2025. * @returns a new Plane from the given array.
  2026. */
  2027. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  2028. /**
  2029. * Creates a plane from three points
  2030. * @param point1 point used to create the plane
  2031. * @param point2 point used to create the plane
  2032. * @param point3 point used to create the plane
  2033. * @returns a new Plane defined by the three given points.
  2034. */
  2035. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2036. /**
  2037. * Creates a plane from an origin point and a normal
  2038. * @param origin origin of the plane to be constructed
  2039. * @param normal normal of the plane to be constructed
  2040. * @returns a new Plane the normal vector to this plane at the given origin point.
  2041. * Note : the vector "normal" is updated because normalized.
  2042. */
  2043. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  2044. /**
  2045. * Calculates the distance from a plane and a point
  2046. * @param origin origin of the plane to be constructed
  2047. * @param normal normal of the plane to be constructed
  2048. * @param point point to calculate distance to
  2049. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  2050. */
  2051. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  2052. }
  2053. }
  2054. declare module "babylonjs/Maths/math.vector" {
  2055. import { Viewport } from "babylonjs/Maths/math.viewport";
  2056. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  2057. import { IPlaneLike } from "babylonjs/Maths/math.like";
  2058. import { Plane } from "babylonjs/Maths/math.plane";
  2059. /**
  2060. * Class representing a vector containing 2 coordinates
  2061. */
  2062. export class Vector2 {
  2063. /** defines the first coordinate */
  2064. x: number;
  2065. /** defines the second coordinate */
  2066. y: number;
  2067. /**
  2068. * Creates a new Vector2 from the given x and y coordinates
  2069. * @param x defines the first coordinate
  2070. * @param y defines the second coordinate
  2071. */
  2072. constructor(
  2073. /** defines the first coordinate */
  2074. x?: number,
  2075. /** defines the second coordinate */
  2076. y?: number);
  2077. /**
  2078. * Gets a string with the Vector2 coordinates
  2079. * @returns a string with the Vector2 coordinates
  2080. */
  2081. toString(): string;
  2082. /**
  2083. * Gets class name
  2084. * @returns the string "Vector2"
  2085. */
  2086. getClassName(): string;
  2087. /**
  2088. * Gets current vector hash code
  2089. * @returns the Vector2 hash code as a number
  2090. */
  2091. getHashCode(): number;
  2092. /**
  2093. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  2094. * @param array defines the source array
  2095. * @param index defines the offset in source array
  2096. * @returns the current Vector2
  2097. */
  2098. toArray(array: FloatArray, index?: number): Vector2;
  2099. /**
  2100. * Copy the current vector to an array
  2101. * @returns a new array with 2 elements: the Vector2 coordinates.
  2102. */
  2103. asArray(): number[];
  2104. /**
  2105. * Sets the Vector2 coordinates with the given Vector2 coordinates
  2106. * @param source defines the source Vector2
  2107. * @returns the current updated Vector2
  2108. */
  2109. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  2110. /**
  2111. * Sets the Vector2 coordinates with the given floats
  2112. * @param x defines the first coordinate
  2113. * @param y defines the second coordinate
  2114. * @returns the current updated Vector2
  2115. */
  2116. copyFromFloats(x: number, y: number): Vector2;
  2117. /**
  2118. * Sets the Vector2 coordinates with the given floats
  2119. * @param x defines the first coordinate
  2120. * @param y defines the second coordinate
  2121. * @returns the current updated Vector2
  2122. */
  2123. set(x: number, y: number): Vector2;
  2124. /**
  2125. * Add another vector with the current one
  2126. * @param otherVector defines the other vector
  2127. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2128. */
  2129. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2130. /**
  2131. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2132. * @param otherVector defines the other vector
  2133. * @param result defines the target vector
  2134. * @returns the unmodified current Vector2
  2135. */
  2136. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2137. /**
  2138. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2139. * @param otherVector defines the other vector
  2140. * @returns the current updated Vector2
  2141. */
  2142. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2143. /**
  2144. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2145. * @param otherVector defines the other vector
  2146. * @returns a new Vector2
  2147. */
  2148. addVector3(otherVector: Vector3): Vector2;
  2149. /**
  2150. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2151. * @param otherVector defines the other vector
  2152. * @returns a new Vector2
  2153. */
  2154. subtract(otherVector: Vector2): Vector2;
  2155. /**
  2156. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2157. * @param otherVector defines the other vector
  2158. * @param result defines the target vector
  2159. * @returns the unmodified current Vector2
  2160. */
  2161. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2162. /**
  2163. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2164. * @param otherVector defines the other vector
  2165. * @returns the current updated Vector2
  2166. */
  2167. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2168. /**
  2169. * Multiplies in place the current Vector2 coordinates by the given ones
  2170. * @param otherVector defines the other vector
  2171. * @returns the current updated Vector2
  2172. */
  2173. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2174. /**
  2175. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2176. * @param otherVector defines the other vector
  2177. * @returns a new Vector2
  2178. */
  2179. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2180. /**
  2181. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2182. * @param otherVector defines the other vector
  2183. * @param result defines the target vector
  2184. * @returns the unmodified current Vector2
  2185. */
  2186. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2187. /**
  2188. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2189. * @param x defines the first coordinate
  2190. * @param y defines the second coordinate
  2191. * @returns a new Vector2
  2192. */
  2193. multiplyByFloats(x: number, y: number): Vector2;
  2194. /**
  2195. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2196. * @param otherVector defines the other vector
  2197. * @returns a new Vector2
  2198. */
  2199. divide(otherVector: Vector2): Vector2;
  2200. /**
  2201. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2202. * @param otherVector defines the other vector
  2203. * @param result defines the target vector
  2204. * @returns the unmodified current Vector2
  2205. */
  2206. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2207. /**
  2208. * Divides the current Vector2 coordinates by the given ones
  2209. * @param otherVector defines the other vector
  2210. * @returns the current updated Vector2
  2211. */
  2212. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2213. /**
  2214. * Gets a new Vector2 with current Vector2 negated coordinates
  2215. * @returns a new Vector2
  2216. */
  2217. negate(): Vector2;
  2218. /**
  2219. * Negate this vector in place
  2220. * @returns this
  2221. */
  2222. negateInPlace(): Vector2;
  2223. /**
  2224. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2225. * @param result defines the Vector3 object where to store the result
  2226. * @returns the current Vector2
  2227. */
  2228. negateToRef(result: Vector2): Vector2;
  2229. /**
  2230. * Multiply the Vector2 coordinates by scale
  2231. * @param scale defines the scaling factor
  2232. * @returns the current updated Vector2
  2233. */
  2234. scaleInPlace(scale: number): Vector2;
  2235. /**
  2236. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2237. * @param scale defines the scaling factor
  2238. * @returns a new Vector2
  2239. */
  2240. scale(scale: number): Vector2;
  2241. /**
  2242. * Scale the current Vector2 values by a factor to a given Vector2
  2243. * @param scale defines the scale factor
  2244. * @param result defines the Vector2 object where to store the result
  2245. * @returns the unmodified current Vector2
  2246. */
  2247. scaleToRef(scale: number, result: Vector2): Vector2;
  2248. /**
  2249. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2250. * @param scale defines the scale factor
  2251. * @param result defines the Vector2 object where to store the result
  2252. * @returns the unmodified current Vector2
  2253. */
  2254. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2255. /**
  2256. * Gets a boolean if two vectors are equals
  2257. * @param otherVector defines the other vector
  2258. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2259. */
  2260. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2261. /**
  2262. * Gets a boolean if two vectors are equals (using an epsilon value)
  2263. * @param otherVector defines the other vector
  2264. * @param epsilon defines the minimal distance to consider equality
  2265. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2266. */
  2267. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2268. /**
  2269. * Gets a new Vector2 from current Vector2 floored values
  2270. * @returns a new Vector2
  2271. */
  2272. floor(): Vector2;
  2273. /**
  2274. * Gets a new Vector2 from current Vector2 floored values
  2275. * @returns a new Vector2
  2276. */
  2277. fract(): Vector2;
  2278. /**
  2279. * Gets the length of the vector
  2280. * @returns the vector length (float)
  2281. */
  2282. length(): number;
  2283. /**
  2284. * Gets the vector squared length
  2285. * @returns the vector squared length (float)
  2286. */
  2287. lengthSquared(): number;
  2288. /**
  2289. * Normalize the vector
  2290. * @returns the current updated Vector2
  2291. */
  2292. normalize(): Vector2;
  2293. /**
  2294. * Gets a new Vector2 copied from the Vector2
  2295. * @returns a new Vector2
  2296. */
  2297. clone(): Vector2;
  2298. /**
  2299. * Gets a new Vector2(0, 0)
  2300. * @returns a new Vector2
  2301. */
  2302. static Zero(): Vector2;
  2303. /**
  2304. * Gets a new Vector2(1, 1)
  2305. * @returns a new Vector2
  2306. */
  2307. static One(): Vector2;
  2308. /**
  2309. * Gets a new Vector2 set from the given index element of the given array
  2310. * @param array defines the data source
  2311. * @param offset defines the offset in the data source
  2312. * @returns a new Vector2
  2313. */
  2314. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2315. /**
  2316. * Sets "result" from the given index element of the given array
  2317. * @param array defines the data source
  2318. * @param offset defines the offset in the data source
  2319. * @param result defines the target vector
  2320. */
  2321. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2322. /**
  2323. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2324. * @param value1 defines 1st point of control
  2325. * @param value2 defines 2nd point of control
  2326. * @param value3 defines 3rd point of control
  2327. * @param value4 defines 4th point of control
  2328. * @param amount defines the interpolation factor
  2329. * @returns a new Vector2
  2330. */
  2331. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2332. /**
  2333. * Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max".
  2334. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2335. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2336. * @param value defines the value to clamp
  2337. * @param min defines the lower limit
  2338. * @param max defines the upper limit
  2339. * @returns a new Vector2
  2340. */
  2341. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2342. /**
  2343. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2344. * @param value1 defines the 1st control point
  2345. * @param tangent1 defines the outgoing tangent
  2346. * @param value2 defines the 2nd control point
  2347. * @param tangent2 defines the incoming tangent
  2348. * @param amount defines the interpolation factor
  2349. * @returns a new Vector2
  2350. */
  2351. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2352. /**
  2353. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2354. * @param start defines the start vector
  2355. * @param end defines the end vector
  2356. * @param amount defines the interpolation factor
  2357. * @returns a new Vector2
  2358. */
  2359. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2360. /**
  2361. * Gets the dot product of the vector "left" and the vector "right"
  2362. * @param left defines first vector
  2363. * @param right defines second vector
  2364. * @returns the dot product (float)
  2365. */
  2366. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2367. /**
  2368. * Returns a new Vector2 equal to the normalized given vector
  2369. * @param vector defines the vector to normalize
  2370. * @returns a new Vector2
  2371. */
  2372. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2373. /**
  2374. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2375. * @param left defines 1st vector
  2376. * @param right defines 2nd vector
  2377. * @returns a new Vector2
  2378. */
  2379. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2380. /**
  2381. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2382. * @param left defines 1st vector
  2383. * @param right defines 2nd vector
  2384. * @returns a new Vector2
  2385. */
  2386. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2387. /**
  2388. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2389. * @param vector defines the vector to transform
  2390. * @param transformation defines the matrix to apply
  2391. * @returns a new Vector2
  2392. */
  2393. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2394. /**
  2395. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2396. * @param vector defines the vector to transform
  2397. * @param transformation defines the matrix to apply
  2398. * @param result defines the target vector
  2399. */
  2400. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2401. /**
  2402. * Determines if a given vector is included in a triangle
  2403. * @param p defines the vector to test
  2404. * @param p0 defines 1st triangle point
  2405. * @param p1 defines 2nd triangle point
  2406. * @param p2 defines 3rd triangle point
  2407. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2408. */
  2409. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2410. /**
  2411. * Gets the distance between the vectors "value1" and "value2"
  2412. * @param value1 defines first vector
  2413. * @param value2 defines second vector
  2414. * @returns the distance between vectors
  2415. */
  2416. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2417. /**
  2418. * Returns the squared distance between the vectors "value1" and "value2"
  2419. * @param value1 defines first vector
  2420. * @param value2 defines second vector
  2421. * @returns the squared distance between vectors
  2422. */
  2423. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2424. /**
  2425. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2426. * @param value1 defines first vector
  2427. * @param value2 defines second vector
  2428. * @returns a new Vector2
  2429. */
  2430. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2431. /**
  2432. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2433. * @param p defines the middle point
  2434. * @param segA defines one point of the segment
  2435. * @param segB defines the other point of the segment
  2436. * @returns the shortest distance
  2437. */
  2438. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2439. }
  2440. /**
  2441. * Class used to store (x,y,z) vector representation
  2442. * A Vector3 is the main object used in 3D geometry
  2443. * It can represent etiher the coordinates of a point the space, either a direction
  2444. * Reminder: js uses a left handed forward facing system
  2445. */
  2446. export class Vector3 {
  2447. /**
  2448. * Defines the first coordinates (on X axis)
  2449. */
  2450. x: number;
  2451. /**
  2452. * Defines the second coordinates (on Y axis)
  2453. */
  2454. y: number;
  2455. /**
  2456. * Defines the third coordinates (on Z axis)
  2457. */
  2458. z: number;
  2459. private static _UpReadOnly;
  2460. private static _ZeroReadOnly;
  2461. /**
  2462. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2463. * @param x defines the first coordinates (on X axis)
  2464. * @param y defines the second coordinates (on Y axis)
  2465. * @param z defines the third coordinates (on Z axis)
  2466. */
  2467. constructor(
  2468. /**
  2469. * Defines the first coordinates (on X axis)
  2470. */
  2471. x?: number,
  2472. /**
  2473. * Defines the second coordinates (on Y axis)
  2474. */
  2475. y?: number,
  2476. /**
  2477. * Defines the third coordinates (on Z axis)
  2478. */
  2479. z?: number);
  2480. /**
  2481. * Creates a string representation of the Vector3
  2482. * @returns a string with the Vector3 coordinates.
  2483. */
  2484. toString(): string;
  2485. /**
  2486. * Gets the class name
  2487. * @returns the string "Vector3"
  2488. */
  2489. getClassName(): string;
  2490. /**
  2491. * Creates the Vector3 hash code
  2492. * @returns a number which tends to be unique between Vector3 instances
  2493. */
  2494. getHashCode(): number;
  2495. /**
  2496. * Creates an array containing three elements : the coordinates of the Vector3
  2497. * @returns a new array of numbers
  2498. */
  2499. asArray(): number[];
  2500. /**
  2501. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2502. * @param array defines the destination array
  2503. * @param index defines the offset in the destination array
  2504. * @returns the current Vector3
  2505. */
  2506. toArray(array: FloatArray, index?: number): Vector3;
  2507. /**
  2508. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2509. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2510. */
  2511. toQuaternion(): Quaternion;
  2512. /**
  2513. * Adds the given vector to the current Vector3
  2514. * @param otherVector defines the second operand
  2515. * @returns the current updated Vector3
  2516. */
  2517. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2518. /**
  2519. * Adds the given coordinates to the current Vector3
  2520. * @param x defines the x coordinate of the operand
  2521. * @param y defines the y coordinate of the operand
  2522. * @param z defines the z coordinate of the operand
  2523. * @returns the current updated Vector3
  2524. */
  2525. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2526. /**
  2527. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2528. * @param otherVector defines the second operand
  2529. * @returns the resulting Vector3
  2530. */
  2531. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2532. /**
  2533. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2534. * @param otherVector defines the second operand
  2535. * @param result defines the Vector3 object where to store the result
  2536. * @returns the current Vector3
  2537. */
  2538. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2539. /**
  2540. * Subtract the given vector from the current Vector3
  2541. * @param otherVector defines the second operand
  2542. * @returns the current updated Vector3
  2543. */
  2544. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2545. /**
  2546. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2547. * @param otherVector defines the second operand
  2548. * @returns the resulting Vector3
  2549. */
  2550. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2551. /**
  2552. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2553. * @param otherVector defines the second operand
  2554. * @param result defines the Vector3 object where to store the result
  2555. * @returns the current Vector3
  2556. */
  2557. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2558. /**
  2559. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2560. * @param x defines the x coordinate of the operand
  2561. * @param y defines the y coordinate of the operand
  2562. * @param z defines the z coordinate of the operand
  2563. * @returns the resulting Vector3
  2564. */
  2565. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2566. /**
  2567. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2568. * @param x defines the x coordinate of the operand
  2569. * @param y defines the y coordinate of the operand
  2570. * @param z defines the z coordinate of the operand
  2571. * @param result defines the Vector3 object where to store the result
  2572. * @returns the current Vector3
  2573. */
  2574. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2575. /**
  2576. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2577. * @returns a new Vector3
  2578. */
  2579. negate(): Vector3;
  2580. /**
  2581. * Negate this vector in place
  2582. * @returns this
  2583. */
  2584. negateInPlace(): Vector3;
  2585. /**
  2586. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2587. * @param result defines the Vector3 object where to store the result
  2588. * @returns the current Vector3
  2589. */
  2590. negateToRef(result: Vector3): Vector3;
  2591. /**
  2592. * Multiplies the Vector3 coordinates by the float "scale"
  2593. * @param scale defines the multiplier factor
  2594. * @returns the current updated Vector3
  2595. */
  2596. scaleInPlace(scale: number): Vector3;
  2597. /**
  2598. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2599. * @param scale defines the multiplier factor
  2600. * @returns a new Vector3
  2601. */
  2602. scale(scale: number): Vector3;
  2603. /**
  2604. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2605. * @param scale defines the multiplier factor
  2606. * @param result defines the Vector3 object where to store the result
  2607. * @returns the current Vector3
  2608. */
  2609. scaleToRef(scale: number, result: Vector3): Vector3;
  2610. /**
  2611. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2612. * @param scale defines the scale factor
  2613. * @param result defines the Vector3 object where to store the result
  2614. * @returns the unmodified current Vector3
  2615. */
  2616. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2617. /**
  2618. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2619. * @param origin defines the origin of the projection ray
  2620. * @param plane defines the plane to project to
  2621. * @returns the projected vector3
  2622. */
  2623. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  2624. /**
  2625. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2626. * @param origin defines the origin of the projection ray
  2627. * @param plane defines the plane to project to
  2628. * @param result defines the Vector3 where to store the result
  2629. */
  2630. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  2631. /**
  2632. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2633. * @param otherVector defines the second operand
  2634. * @returns true if both vectors are equals
  2635. */
  2636. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2637. /**
  2638. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2639. * @param otherVector defines the second operand
  2640. * @param epsilon defines the minimal distance to define values as equals
  2641. * @returns true if both vectors are distant less than epsilon
  2642. */
  2643. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2644. /**
  2645. * Returns true if the current Vector3 coordinates equals the given floats
  2646. * @param x defines the x coordinate of the operand
  2647. * @param y defines the y coordinate of the operand
  2648. * @param z defines the z coordinate of the operand
  2649. * @returns true if both vectors are equals
  2650. */
  2651. equalsToFloats(x: number, y: number, z: number): boolean;
  2652. /**
  2653. * Multiplies the current Vector3 coordinates by the given ones
  2654. * @param otherVector defines the second operand
  2655. * @returns the current updated Vector3
  2656. */
  2657. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2658. /**
  2659. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2660. * @param otherVector defines the second operand
  2661. * @returns the new Vector3
  2662. */
  2663. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2664. /**
  2665. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2666. * @param otherVector defines the second operand
  2667. * @param result defines the Vector3 object where to store the result
  2668. * @returns the current Vector3
  2669. */
  2670. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2671. /**
  2672. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2673. * @param x defines the x coordinate of the operand
  2674. * @param y defines the y coordinate of the operand
  2675. * @param z defines the z coordinate of the operand
  2676. * @returns the new Vector3
  2677. */
  2678. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2679. /**
  2680. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2681. * @param otherVector defines the second operand
  2682. * @returns the new Vector3
  2683. */
  2684. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2685. /**
  2686. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2687. * @param otherVector defines the second operand
  2688. * @param result defines the Vector3 object where to store the result
  2689. * @returns the current Vector3
  2690. */
  2691. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2692. /**
  2693. * Divides the current Vector3 coordinates by the given ones.
  2694. * @param otherVector defines the second operand
  2695. * @returns the current updated Vector3
  2696. */
  2697. divideInPlace(otherVector: Vector3): Vector3;
  2698. /**
  2699. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2700. * @param other defines the second operand
  2701. * @returns the current updated Vector3
  2702. */
  2703. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2704. /**
  2705. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2706. * @param other defines the second operand
  2707. * @returns the current updated Vector3
  2708. */
  2709. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2710. /**
  2711. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2712. * @param x defines the x coordinate of the operand
  2713. * @param y defines the y coordinate of the operand
  2714. * @param z defines the z coordinate of the operand
  2715. * @returns the current updated Vector3
  2716. */
  2717. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2718. /**
  2719. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2720. * @param x defines the x coordinate of the operand
  2721. * @param y defines the y coordinate of the operand
  2722. * @param z defines the z coordinate of the operand
  2723. * @returns the current updated Vector3
  2724. */
  2725. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2726. /**
  2727. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2728. * Check if is non uniform within a certain amount of decimal places to account for this
  2729. * @param epsilon the amount the values can differ
  2730. * @returns if the the vector is non uniform to a certain number of decimal places
  2731. */
  2732. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2733. /**
  2734. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2735. */
  2736. get isNonUniform(): boolean;
  2737. /**
  2738. * Gets a new Vector3 from current Vector3 floored values
  2739. * @returns a new Vector3
  2740. */
  2741. floor(): Vector3;
  2742. /**
  2743. * Gets a new Vector3 from current Vector3 floored values
  2744. * @returns a new Vector3
  2745. */
  2746. fract(): Vector3;
  2747. /**
  2748. * Gets the length of the Vector3
  2749. * @returns the length of the Vector3
  2750. */
  2751. length(): number;
  2752. /**
  2753. * Gets the squared length of the Vector3
  2754. * @returns squared length of the Vector3
  2755. */
  2756. lengthSquared(): number;
  2757. /**
  2758. * Normalize the current Vector3.
  2759. * Please note that this is an in place operation.
  2760. * @returns the current updated Vector3
  2761. */
  2762. normalize(): Vector3;
  2763. /**
  2764. * Reorders the x y z properties of the vector in place
  2765. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2766. * @returns the current updated vector
  2767. */
  2768. reorderInPlace(order: string): this;
  2769. /**
  2770. * Rotates the vector around 0,0,0 by a quaternion
  2771. * @param quaternion the rotation quaternion
  2772. * @param result vector to store the result
  2773. * @returns the resulting vector
  2774. */
  2775. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2776. /**
  2777. * Rotates a vector around a given point
  2778. * @param quaternion the rotation quaternion
  2779. * @param point the point to rotate around
  2780. * @param result vector to store the result
  2781. * @returns the resulting vector
  2782. */
  2783. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2784. /**
  2785. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2786. * The cross product is then orthogonal to both current and "other"
  2787. * @param other defines the right operand
  2788. * @returns the cross product
  2789. */
  2790. cross(other: Vector3): Vector3;
  2791. /**
  2792. * Normalize the current Vector3 with the given input length.
  2793. * Please note that this is an in place operation.
  2794. * @param len the length of the vector
  2795. * @returns the current updated Vector3
  2796. */
  2797. normalizeFromLength(len: number): Vector3;
  2798. /**
  2799. * Normalize the current Vector3 to a new vector
  2800. * @returns the new Vector3
  2801. */
  2802. normalizeToNew(): Vector3;
  2803. /**
  2804. * Normalize the current Vector3 to the reference
  2805. * @param reference define the Vector3 to update
  2806. * @returns the updated Vector3
  2807. */
  2808. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2809. /**
  2810. * Creates a new Vector3 copied from the current Vector3
  2811. * @returns the new Vector3
  2812. */
  2813. clone(): Vector3;
  2814. /**
  2815. * Copies the given vector coordinates to the current Vector3 ones
  2816. * @param source defines the source Vector3
  2817. * @returns the current updated Vector3
  2818. */
  2819. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2820. /**
  2821. * Copies the given floats to the current Vector3 coordinates
  2822. * @param x defines the x coordinate of the operand
  2823. * @param y defines the y coordinate of the operand
  2824. * @param z defines the z coordinate of the operand
  2825. * @returns the current updated Vector3
  2826. */
  2827. copyFromFloats(x: number, y: number, z: number): Vector3;
  2828. /**
  2829. * Copies the given floats to the current Vector3 coordinates
  2830. * @param x defines the x coordinate of the operand
  2831. * @param y defines the y coordinate of the operand
  2832. * @param z defines the z coordinate of the operand
  2833. * @returns the current updated Vector3
  2834. */
  2835. set(x: number, y: number, z: number): Vector3;
  2836. /**
  2837. * Copies the given float to the current Vector3 coordinates
  2838. * @param v defines the x, y and z coordinates of the operand
  2839. * @returns the current updated Vector3
  2840. */
  2841. setAll(v: number): Vector3;
  2842. /**
  2843. * Get the clip factor between two vectors
  2844. * @param vector0 defines the first operand
  2845. * @param vector1 defines the second operand
  2846. * @param axis defines the axis to use
  2847. * @param size defines the size along the axis
  2848. * @returns the clip factor
  2849. */
  2850. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2851. /**
  2852. * Get angle between two vectors
  2853. * @param vector0 angle between vector0 and vector1
  2854. * @param vector1 angle between vector0 and vector1
  2855. * @param normal direction of the normal
  2856. * @return the angle between vector0 and vector1
  2857. */
  2858. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2859. /**
  2860. * Returns a new Vector3 set from the index "offset" of the given array
  2861. * @param array defines the source array
  2862. * @param offset defines the offset in the source array
  2863. * @returns the new Vector3
  2864. */
  2865. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2866. /**
  2867. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2868. * @param array defines the source array
  2869. * @param offset defines the offset in the source array
  2870. * @returns the new Vector3
  2871. * @deprecated Please use FromArray instead.
  2872. */
  2873. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2874. /**
  2875. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2876. * @param array defines the source array
  2877. * @param offset defines the offset in the source array
  2878. * @param result defines the Vector3 where to store the result
  2879. */
  2880. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2881. /**
  2882. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2883. * @param array defines the source array
  2884. * @param offset defines the offset in the source array
  2885. * @param result defines the Vector3 where to store the result
  2886. * @deprecated Please use FromArrayToRef instead.
  2887. */
  2888. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2889. /**
  2890. * Sets the given vector "result" with the given floats.
  2891. * @param x defines the x coordinate of the source
  2892. * @param y defines the y coordinate of the source
  2893. * @param z defines the z coordinate of the source
  2894. * @param result defines the Vector3 where to store the result
  2895. */
  2896. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2897. /**
  2898. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2899. * @returns a new empty Vector3
  2900. */
  2901. static Zero(): Vector3;
  2902. /**
  2903. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2904. * @returns a new unit Vector3
  2905. */
  2906. static One(): Vector3;
  2907. /**
  2908. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2909. * @returns a new up Vector3
  2910. */
  2911. static Up(): Vector3;
  2912. /**
  2913. * Gets a up Vector3 that must not be updated
  2914. */
  2915. static get UpReadOnly(): DeepImmutable<Vector3>;
  2916. /**
  2917. * Gets a zero Vector3 that must not be updated
  2918. */
  2919. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2920. /**
  2921. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2922. * @returns a new down Vector3
  2923. */
  2924. static Down(): Vector3;
  2925. /**
  2926. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2927. * @param rightHandedSystem is the scene right-handed (negative z)
  2928. * @returns a new forward Vector3
  2929. */
  2930. static Forward(rightHandedSystem?: boolean): Vector3;
  2931. /**
  2932. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2933. * @param rightHandedSystem is the scene right-handed (negative-z)
  2934. * @returns a new forward Vector3
  2935. */
  2936. static Backward(rightHandedSystem?: boolean): Vector3;
  2937. /**
  2938. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2939. * @returns a new right Vector3
  2940. */
  2941. static Right(): Vector3;
  2942. /**
  2943. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2944. * @returns a new left Vector3
  2945. */
  2946. static Left(): Vector3;
  2947. /**
  2948. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2949. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2950. * @param vector defines the Vector3 to transform
  2951. * @param transformation defines the transformation matrix
  2952. * @returns the transformed Vector3
  2953. */
  2954. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2955. /**
  2956. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2957. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2958. * @param vector defines the Vector3 to transform
  2959. * @param transformation defines the transformation matrix
  2960. * @param result defines the Vector3 where to store the result
  2961. */
  2962. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2963. /**
  2964. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2965. * This method computes tranformed coordinates only, not transformed direction vectors
  2966. * @param x define the x coordinate of the source vector
  2967. * @param y define the y coordinate of the source vector
  2968. * @param z define the z coordinate of the source vector
  2969. * @param transformation defines the transformation matrix
  2970. * @param result defines the Vector3 where to store the result
  2971. */
  2972. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2973. /**
  2974. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2975. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2976. * @param vector defines the Vector3 to transform
  2977. * @param transformation defines the transformation matrix
  2978. * @returns the new Vector3
  2979. */
  2980. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2981. /**
  2982. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2983. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2984. * @param vector defines the Vector3 to transform
  2985. * @param transformation defines the transformation matrix
  2986. * @param result defines the Vector3 where to store the result
  2987. */
  2988. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2989. /**
  2990. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2991. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2992. * @param x define the x coordinate of the source vector
  2993. * @param y define the y coordinate of the source vector
  2994. * @param z define the z coordinate of the source vector
  2995. * @param transformation defines the transformation matrix
  2996. * @param result defines the Vector3 where to store the result
  2997. */
  2998. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2999. /**
  3000. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  3001. * @param value1 defines the first control point
  3002. * @param value2 defines the second control point
  3003. * @param value3 defines the third control point
  3004. * @param value4 defines the fourth control point
  3005. * @param amount defines the amount on the spline to use
  3006. * @returns the new Vector3
  3007. */
  3008. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  3009. /**
  3010. * Returns a new Vector3 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  3011. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3012. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3013. * @param value defines the current value
  3014. * @param min defines the lower range value
  3015. * @param max defines the upper range value
  3016. * @returns the new Vector3
  3017. */
  3018. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  3019. /**
  3020. * Sets the given vector "result" with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  3021. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3022. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3023. * @param value defines the current value
  3024. * @param min defines the lower range value
  3025. * @param max defines the upper range value
  3026. * @param result defines the Vector3 where to store the result
  3027. */
  3028. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  3029. /**
  3030. * Checks if a given vector is inside a specific range
  3031. * @param v defines the vector to test
  3032. * @param min defines the minimum range
  3033. * @param max defines the maximum range
  3034. */
  3035. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  3036. /**
  3037. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  3038. * @param value1 defines the first control point
  3039. * @param tangent1 defines the first tangent vector
  3040. * @param value2 defines the second control point
  3041. * @param tangent2 defines the second tangent vector
  3042. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  3043. * @returns the new Vector3
  3044. */
  3045. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  3046. /**
  3047. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  3048. * @param start defines the start value
  3049. * @param end defines the end value
  3050. * @param amount max defines amount between both (between 0 and 1)
  3051. * @returns the new Vector3
  3052. */
  3053. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  3054. /**
  3055. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  3056. * @param start defines the start value
  3057. * @param end defines the end value
  3058. * @param amount max defines amount between both (between 0 and 1)
  3059. * @param result defines the Vector3 where to store the result
  3060. */
  3061. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  3062. /**
  3063. * Returns the dot product (float) between the vectors "left" and "right"
  3064. * @param left defines the left operand
  3065. * @param right defines the right operand
  3066. * @returns the dot product
  3067. */
  3068. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  3069. /**
  3070. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  3071. * The cross product is then orthogonal to both "left" and "right"
  3072. * @param left defines the left operand
  3073. * @param right defines the right operand
  3074. * @returns the cross product
  3075. */
  3076. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3077. /**
  3078. * Sets the given vector "result" with the cross product of "left" and "right"
  3079. * The cross product is then orthogonal to both "left" and "right"
  3080. * @param left defines the left operand
  3081. * @param right defines the right operand
  3082. * @param result defines the Vector3 where to store the result
  3083. */
  3084. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  3085. /**
  3086. * Returns a new Vector3 as the normalization of the given vector
  3087. * @param vector defines the Vector3 to normalize
  3088. * @returns the new Vector3
  3089. */
  3090. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  3091. /**
  3092. * Sets the given vector "result" with the normalization of the given first vector
  3093. * @param vector defines the Vector3 to normalize
  3094. * @param result defines the Vector3 where to store the result
  3095. */
  3096. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  3097. /**
  3098. * Project a Vector3 onto screen space
  3099. * @param vector defines the Vector3 to project
  3100. * @param world defines the world matrix to use
  3101. * @param transform defines the transform (view x projection) matrix to use
  3102. * @param viewport defines the screen viewport to use
  3103. * @returns the new Vector3
  3104. */
  3105. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  3106. /** @hidden */
  3107. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  3108. /**
  3109. * Unproject from screen space to object space
  3110. * @param source defines the screen space Vector3 to use
  3111. * @param viewportWidth defines the current width of the viewport
  3112. * @param viewportHeight defines the current height of the viewport
  3113. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3114. * @param transform defines the transform (view x projection) matrix to use
  3115. * @returns the new Vector3
  3116. */
  3117. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  3118. /**
  3119. * Unproject from screen space to object space
  3120. * @param source defines the screen space Vector3 to use
  3121. * @param viewportWidth defines the current width of the viewport
  3122. * @param viewportHeight defines the current height of the viewport
  3123. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3124. * @param view defines the view matrix to use
  3125. * @param projection defines the projection matrix to use
  3126. * @returns the new Vector3
  3127. */
  3128. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  3129. /**
  3130. * Unproject from screen space to object space
  3131. * @param source defines the screen space Vector3 to use
  3132. * @param viewportWidth defines the current width of the viewport
  3133. * @param viewportHeight defines the current height of the viewport
  3134. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3135. * @param view defines the view matrix to use
  3136. * @param projection defines the projection matrix to use
  3137. * @param result defines the Vector3 where to store the result
  3138. */
  3139. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3140. /**
  3141. * Unproject from screen space to object space
  3142. * @param sourceX defines the screen space x coordinate to use
  3143. * @param sourceY defines the screen space y coordinate to use
  3144. * @param sourceZ defines the screen space z coordinate to use
  3145. * @param viewportWidth defines the current width of the viewport
  3146. * @param viewportHeight defines the current height of the viewport
  3147. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3148. * @param view defines the view matrix to use
  3149. * @param projection defines the projection matrix to use
  3150. * @param result defines the Vector3 where to store the result
  3151. */
  3152. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3153. /**
  3154. * Gets the minimal coordinate values between two Vector3
  3155. * @param left defines the first operand
  3156. * @param right defines the second operand
  3157. * @returns the new Vector3
  3158. */
  3159. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3160. /**
  3161. * Gets the maximal coordinate values between two Vector3
  3162. * @param left defines the first operand
  3163. * @param right defines the second operand
  3164. * @returns the new Vector3
  3165. */
  3166. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3167. /**
  3168. * Returns the distance between the vectors "value1" and "value2"
  3169. * @param value1 defines the first operand
  3170. * @param value2 defines the second operand
  3171. * @returns the distance
  3172. */
  3173. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3174. /**
  3175. * Returns the squared distance between the vectors "value1" and "value2"
  3176. * @param value1 defines the first operand
  3177. * @param value2 defines the second operand
  3178. * @returns the squared distance
  3179. */
  3180. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3181. /**
  3182. * Returns a new Vector3 located at the center between "value1" and "value2"
  3183. * @param value1 defines the first operand
  3184. * @param value2 defines the second operand
  3185. * @returns the new Vector3
  3186. */
  3187. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3188. /**
  3189. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3190. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3191. * to something in order to rotate it from its local system to the given target system
  3192. * Note: axis1, axis2 and axis3 are normalized during this operation
  3193. * @param axis1 defines the first axis
  3194. * @param axis2 defines the second axis
  3195. * @param axis3 defines the third axis
  3196. * @returns a new Vector3
  3197. */
  3198. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3199. /**
  3200. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3201. * @param axis1 defines the first axis
  3202. * @param axis2 defines the second axis
  3203. * @param axis3 defines the third axis
  3204. * @param ref defines the Vector3 where to store the result
  3205. */
  3206. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3207. }
  3208. /**
  3209. * Vector4 class created for EulerAngle class conversion to Quaternion
  3210. */
  3211. export class Vector4 {
  3212. /** x value of the vector */
  3213. x: number;
  3214. /** y value of the vector */
  3215. y: number;
  3216. /** z value of the vector */
  3217. z: number;
  3218. /** w value of the vector */
  3219. w: number;
  3220. /**
  3221. * Creates a Vector4 object from the given floats.
  3222. * @param x x value of the vector
  3223. * @param y y value of the vector
  3224. * @param z z value of the vector
  3225. * @param w w value of the vector
  3226. */
  3227. constructor(
  3228. /** x value of the vector */
  3229. x: number,
  3230. /** y value of the vector */
  3231. y: number,
  3232. /** z value of the vector */
  3233. z: number,
  3234. /** w value of the vector */
  3235. w: number);
  3236. /**
  3237. * Returns the string with the Vector4 coordinates.
  3238. * @returns a string containing all the vector values
  3239. */
  3240. toString(): string;
  3241. /**
  3242. * Returns the string "Vector4".
  3243. * @returns "Vector4"
  3244. */
  3245. getClassName(): string;
  3246. /**
  3247. * Returns the Vector4 hash code.
  3248. * @returns a unique hash code
  3249. */
  3250. getHashCode(): number;
  3251. /**
  3252. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3253. * @returns the resulting array
  3254. */
  3255. asArray(): number[];
  3256. /**
  3257. * Populates the given array from the given index with the Vector4 coordinates.
  3258. * @param array array to populate
  3259. * @param index index of the array to start at (default: 0)
  3260. * @returns the Vector4.
  3261. */
  3262. toArray(array: FloatArray, index?: number): Vector4;
  3263. /**
  3264. * Adds the given vector to the current Vector4.
  3265. * @param otherVector the vector to add
  3266. * @returns the updated Vector4.
  3267. */
  3268. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3269. /**
  3270. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3271. * @param otherVector the vector to add
  3272. * @returns the resulting vector
  3273. */
  3274. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3275. /**
  3276. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3277. * @param otherVector the vector to add
  3278. * @param result the vector to store the result
  3279. * @returns the current Vector4.
  3280. */
  3281. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3282. /**
  3283. * Subtract in place the given vector from the current Vector4.
  3284. * @param otherVector the vector to subtract
  3285. * @returns the updated Vector4.
  3286. */
  3287. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3288. /**
  3289. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3290. * @param otherVector the vector to add
  3291. * @returns the new vector with the result
  3292. */
  3293. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3294. /**
  3295. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3296. * @param otherVector the vector to subtract
  3297. * @param result the vector to store the result
  3298. * @returns the current Vector4.
  3299. */
  3300. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3301. /**
  3302. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3303. */
  3304. /**
  3305. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3306. * @param x value to subtract
  3307. * @param y value to subtract
  3308. * @param z value to subtract
  3309. * @param w value to subtract
  3310. * @returns new vector containing the result
  3311. */
  3312. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3313. /**
  3314. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3315. * @param x value to subtract
  3316. * @param y value to subtract
  3317. * @param z value to subtract
  3318. * @param w value to subtract
  3319. * @param result the vector to store the result in
  3320. * @returns the current Vector4.
  3321. */
  3322. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3323. /**
  3324. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3325. * @returns a new vector with the negated values
  3326. */
  3327. negate(): Vector4;
  3328. /**
  3329. * Negate this vector in place
  3330. * @returns this
  3331. */
  3332. negateInPlace(): Vector4;
  3333. /**
  3334. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3335. * @param result defines the Vector3 object where to store the result
  3336. * @returns the current Vector4
  3337. */
  3338. negateToRef(result: Vector4): Vector4;
  3339. /**
  3340. * Multiplies the current Vector4 coordinates by scale (float).
  3341. * @param scale the number to scale with
  3342. * @returns the updated Vector4.
  3343. */
  3344. scaleInPlace(scale: number): Vector4;
  3345. /**
  3346. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3347. * @param scale the number to scale with
  3348. * @returns a new vector with the result
  3349. */
  3350. scale(scale: number): Vector4;
  3351. /**
  3352. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3353. * @param scale the number to scale with
  3354. * @param result a vector to store the result in
  3355. * @returns the current Vector4.
  3356. */
  3357. scaleToRef(scale: number, result: Vector4): Vector4;
  3358. /**
  3359. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3360. * @param scale defines the scale factor
  3361. * @param result defines the Vector4 object where to store the result
  3362. * @returns the unmodified current Vector4
  3363. */
  3364. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3365. /**
  3366. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3367. * @param otherVector the vector to compare against
  3368. * @returns true if they are equal
  3369. */
  3370. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3371. /**
  3372. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3373. * @param otherVector vector to compare against
  3374. * @param epsilon (Default: very small number)
  3375. * @returns true if they are equal
  3376. */
  3377. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3378. /**
  3379. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3380. * @param x x value to compare against
  3381. * @param y y value to compare against
  3382. * @param z z value to compare against
  3383. * @param w w value to compare against
  3384. * @returns true if equal
  3385. */
  3386. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3387. /**
  3388. * Multiplies in place the current Vector4 by the given one.
  3389. * @param otherVector vector to multiple with
  3390. * @returns the updated Vector4.
  3391. */
  3392. multiplyInPlace(otherVector: Vector4): Vector4;
  3393. /**
  3394. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3395. * @param otherVector vector to multiple with
  3396. * @returns resulting new vector
  3397. */
  3398. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3399. /**
  3400. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3401. * @param otherVector vector to multiple with
  3402. * @param result vector to store the result
  3403. * @returns the current Vector4.
  3404. */
  3405. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3406. /**
  3407. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3408. * @param x x value multiply with
  3409. * @param y y value multiply with
  3410. * @param z z value multiply with
  3411. * @param w w value multiply with
  3412. * @returns resulting new vector
  3413. */
  3414. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3415. /**
  3416. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3417. * @param otherVector vector to devide with
  3418. * @returns resulting new vector
  3419. */
  3420. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3421. /**
  3422. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3423. * @param otherVector vector to devide with
  3424. * @param result vector to store the result
  3425. * @returns the current Vector4.
  3426. */
  3427. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3428. /**
  3429. * Divides the current Vector3 coordinates by the given ones.
  3430. * @param otherVector vector to devide with
  3431. * @returns the updated Vector3.
  3432. */
  3433. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3434. /**
  3435. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3436. * @param other defines the second operand
  3437. * @returns the current updated Vector4
  3438. */
  3439. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3440. /**
  3441. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3442. * @param other defines the second operand
  3443. * @returns the current updated Vector4
  3444. */
  3445. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3446. /**
  3447. * Gets a new Vector4 from current Vector4 floored values
  3448. * @returns a new Vector4
  3449. */
  3450. floor(): Vector4;
  3451. /**
  3452. * Gets a new Vector4 from current Vector3 floored values
  3453. * @returns a new Vector4
  3454. */
  3455. fract(): Vector4;
  3456. /**
  3457. * Returns the Vector4 length (float).
  3458. * @returns the length
  3459. */
  3460. length(): number;
  3461. /**
  3462. * Returns the Vector4 squared length (float).
  3463. * @returns the length squared
  3464. */
  3465. lengthSquared(): number;
  3466. /**
  3467. * Normalizes in place the Vector4.
  3468. * @returns the updated Vector4.
  3469. */
  3470. normalize(): Vector4;
  3471. /**
  3472. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3473. * @returns this converted to a new vector3
  3474. */
  3475. toVector3(): Vector3;
  3476. /**
  3477. * Returns a new Vector4 copied from the current one.
  3478. * @returns the new cloned vector
  3479. */
  3480. clone(): Vector4;
  3481. /**
  3482. * Updates the current Vector4 with the given one coordinates.
  3483. * @param source the source vector to copy from
  3484. * @returns the updated Vector4.
  3485. */
  3486. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3487. /**
  3488. * Updates the current Vector4 coordinates with the given floats.
  3489. * @param x float to copy from
  3490. * @param y float to copy from
  3491. * @param z float to copy from
  3492. * @param w float to copy from
  3493. * @returns the updated Vector4.
  3494. */
  3495. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3496. /**
  3497. * Updates the current Vector4 coordinates with the given floats.
  3498. * @param x float to set from
  3499. * @param y float to set from
  3500. * @param z float to set from
  3501. * @param w float to set from
  3502. * @returns the updated Vector4.
  3503. */
  3504. set(x: number, y: number, z: number, w: number): Vector4;
  3505. /**
  3506. * Copies the given float to the current Vector3 coordinates
  3507. * @param v defines the x, y, z and w coordinates of the operand
  3508. * @returns the current updated Vector3
  3509. */
  3510. setAll(v: number): Vector4;
  3511. /**
  3512. * Returns a new Vector4 set from the starting index of the given array.
  3513. * @param array the array to pull values from
  3514. * @param offset the offset into the array to start at
  3515. * @returns the new vector
  3516. */
  3517. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3518. /**
  3519. * Updates the given vector "result" from the starting index of the given array.
  3520. * @param array the array to pull values from
  3521. * @param offset the offset into the array to start at
  3522. * @param result the vector to store the result in
  3523. */
  3524. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3525. /**
  3526. * Updates the given vector "result" from the starting index of the given Float32Array.
  3527. * @param array the array to pull values from
  3528. * @param offset the offset into the array to start at
  3529. * @param result the vector to store the result in
  3530. */
  3531. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3532. /**
  3533. * Updates the given vector "result" coordinates from the given floats.
  3534. * @param x float to set from
  3535. * @param y float to set from
  3536. * @param z float to set from
  3537. * @param w float to set from
  3538. * @param result the vector to the floats in
  3539. */
  3540. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3541. /**
  3542. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3543. * @returns the new vector
  3544. */
  3545. static Zero(): Vector4;
  3546. /**
  3547. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3548. * @returns the new vector
  3549. */
  3550. static One(): Vector4;
  3551. /**
  3552. * Returns a new normalized Vector4 from the given one.
  3553. * @param vector the vector to normalize
  3554. * @returns the vector
  3555. */
  3556. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3557. /**
  3558. * Updates the given vector "result" from the normalization of the given one.
  3559. * @param vector the vector to normalize
  3560. * @param result the vector to store the result in
  3561. */
  3562. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3563. /**
  3564. * Returns a vector with the minimum values from the left and right vectors
  3565. * @param left left vector to minimize
  3566. * @param right right vector to minimize
  3567. * @returns a new vector with the minimum of the left and right vector values
  3568. */
  3569. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3570. /**
  3571. * Returns a vector with the maximum values from the left and right vectors
  3572. * @param left left vector to maximize
  3573. * @param right right vector to maximize
  3574. * @returns a new vector with the maximum of the left and right vector values
  3575. */
  3576. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3577. /**
  3578. * Returns the distance (float) between the vectors "value1" and "value2".
  3579. * @param value1 value to calulate the distance between
  3580. * @param value2 value to calulate the distance between
  3581. * @return the distance between the two vectors
  3582. */
  3583. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3584. /**
  3585. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3586. * @param value1 value to calulate the distance between
  3587. * @param value2 value to calulate the distance between
  3588. * @return the distance between the two vectors squared
  3589. */
  3590. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3591. /**
  3592. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3593. * @param value1 value to calulate the center between
  3594. * @param value2 value to calulate the center between
  3595. * @return the center between the two vectors
  3596. */
  3597. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3598. /**
  3599. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3600. * This methods computes transformed normalized direction vectors only.
  3601. * @param vector the vector to transform
  3602. * @param transformation the transformation matrix to apply
  3603. * @returns the new vector
  3604. */
  3605. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3606. /**
  3607. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3608. * This methods computes transformed normalized direction vectors only.
  3609. * @param vector the vector to transform
  3610. * @param transformation the transformation matrix to apply
  3611. * @param result the vector to store the result in
  3612. */
  3613. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3614. /**
  3615. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3616. * This methods computes transformed normalized direction vectors only.
  3617. * @param x value to transform
  3618. * @param y value to transform
  3619. * @param z value to transform
  3620. * @param w value to transform
  3621. * @param transformation the transformation matrix to apply
  3622. * @param result the vector to store the results in
  3623. */
  3624. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3625. /**
  3626. * Creates a new Vector4 from a Vector3
  3627. * @param source defines the source data
  3628. * @param w defines the 4th component (default is 0)
  3629. * @returns a new Vector4
  3630. */
  3631. static FromVector3(source: Vector3, w?: number): Vector4;
  3632. }
  3633. /**
  3634. * Class used to store quaternion data
  3635. * @see https://en.wikipedia.org/wiki/Quaternion
  3636. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3637. */
  3638. export class Quaternion {
  3639. /** defines the first component (0 by default) */
  3640. x: number;
  3641. /** defines the second component (0 by default) */
  3642. y: number;
  3643. /** defines the third component (0 by default) */
  3644. z: number;
  3645. /** defines the fourth component (1.0 by default) */
  3646. w: number;
  3647. /**
  3648. * Creates a new Quaternion from the given floats
  3649. * @param x defines the first component (0 by default)
  3650. * @param y defines the second component (0 by default)
  3651. * @param z defines the third component (0 by default)
  3652. * @param w defines the fourth component (1.0 by default)
  3653. */
  3654. constructor(
  3655. /** defines the first component (0 by default) */
  3656. x?: number,
  3657. /** defines the second component (0 by default) */
  3658. y?: number,
  3659. /** defines the third component (0 by default) */
  3660. z?: number,
  3661. /** defines the fourth component (1.0 by default) */
  3662. w?: number);
  3663. /**
  3664. * Gets a string representation for the current quaternion
  3665. * @returns a string with the Quaternion coordinates
  3666. */
  3667. toString(): string;
  3668. /**
  3669. * Gets the class name of the quaternion
  3670. * @returns the string "Quaternion"
  3671. */
  3672. getClassName(): string;
  3673. /**
  3674. * Gets a hash code for this quaternion
  3675. * @returns the quaternion hash code
  3676. */
  3677. getHashCode(): number;
  3678. /**
  3679. * Copy the quaternion to an array
  3680. * @returns a new array populated with 4 elements from the quaternion coordinates
  3681. */
  3682. asArray(): number[];
  3683. /**
  3684. * Check if two quaternions are equals
  3685. * @param otherQuaternion defines the second operand
  3686. * @return true if the current quaternion and the given one coordinates are strictly equals
  3687. */
  3688. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3689. /**
  3690. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3691. * @param otherQuaternion defines the other quaternion
  3692. * @param epsilon defines the minimal distance to consider equality
  3693. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3694. */
  3695. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3696. /**
  3697. * Clone the current quaternion
  3698. * @returns a new quaternion copied from the current one
  3699. */
  3700. clone(): Quaternion;
  3701. /**
  3702. * Copy a quaternion to the current one
  3703. * @param other defines the other quaternion
  3704. * @returns the updated current quaternion
  3705. */
  3706. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3707. /**
  3708. * Updates the current quaternion with the given float coordinates
  3709. * @param x defines the x coordinate
  3710. * @param y defines the y coordinate
  3711. * @param z defines the z coordinate
  3712. * @param w defines the w coordinate
  3713. * @returns the updated current quaternion
  3714. */
  3715. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3716. /**
  3717. * Updates the current quaternion from the given float coordinates
  3718. * @param x defines the x coordinate
  3719. * @param y defines the y coordinate
  3720. * @param z defines the z coordinate
  3721. * @param w defines the w coordinate
  3722. * @returns the updated current quaternion
  3723. */
  3724. set(x: number, y: number, z: number, w: number): Quaternion;
  3725. /**
  3726. * Adds two quaternions
  3727. * @param other defines the second operand
  3728. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3729. */
  3730. add(other: DeepImmutable<Quaternion>): Quaternion;
  3731. /**
  3732. * Add a quaternion to the current one
  3733. * @param other defines the quaternion to add
  3734. * @returns the current quaternion
  3735. */
  3736. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3737. /**
  3738. * Subtract two quaternions
  3739. * @param other defines the second operand
  3740. * @returns a new quaternion as the subtraction result of the given one from the current one
  3741. */
  3742. subtract(other: Quaternion): Quaternion;
  3743. /**
  3744. * Multiplies the current quaternion by a scale factor
  3745. * @param value defines the scale factor
  3746. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3747. */
  3748. scale(value: number): Quaternion;
  3749. /**
  3750. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3751. * @param scale defines the scale factor
  3752. * @param result defines the Quaternion object where to store the result
  3753. * @returns the unmodified current quaternion
  3754. */
  3755. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3756. /**
  3757. * Multiplies in place the current quaternion by a scale factor
  3758. * @param value defines the scale factor
  3759. * @returns the current modified quaternion
  3760. */
  3761. scaleInPlace(value: number): Quaternion;
  3762. /**
  3763. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3764. * @param scale defines the scale factor
  3765. * @param result defines the Quaternion object where to store the result
  3766. * @returns the unmodified current quaternion
  3767. */
  3768. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3769. /**
  3770. * Multiplies two quaternions
  3771. * @param q1 defines the second operand
  3772. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3773. */
  3774. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3775. /**
  3776. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3777. * @param q1 defines the second operand
  3778. * @param result defines the target quaternion
  3779. * @returns the current quaternion
  3780. */
  3781. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3782. /**
  3783. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3784. * @param q1 defines the second operand
  3785. * @returns the currentupdated quaternion
  3786. */
  3787. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3788. /**
  3789. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3790. * @param ref defines the target quaternion
  3791. * @returns the current quaternion
  3792. */
  3793. conjugateToRef(ref: Quaternion): Quaternion;
  3794. /**
  3795. * Conjugates in place (1-q) the current quaternion
  3796. * @returns the current updated quaternion
  3797. */
  3798. conjugateInPlace(): Quaternion;
  3799. /**
  3800. * Conjugates in place (1-q) the current quaternion
  3801. * @returns a new quaternion
  3802. */
  3803. conjugate(): Quaternion;
  3804. /**
  3805. * Gets length of current quaternion
  3806. * @returns the quaternion length (float)
  3807. */
  3808. length(): number;
  3809. /**
  3810. * Normalize in place the current quaternion
  3811. * @returns the current updated quaternion
  3812. */
  3813. normalize(): Quaternion;
  3814. /**
  3815. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3816. * @param order is a reserved parameter and is ignore for now
  3817. * @returns a new Vector3 containing the Euler angles
  3818. */
  3819. toEulerAngles(order?: string): Vector3;
  3820. /**
  3821. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3822. * @param result defines the vector which will be filled with the Euler angles
  3823. * @param order is a reserved parameter and is ignore for now
  3824. * @returns the current unchanged quaternion
  3825. */
  3826. toEulerAnglesToRef(result: Vector3): Quaternion;
  3827. /**
  3828. * Updates the given rotation matrix with the current quaternion values
  3829. * @param result defines the target matrix
  3830. * @returns the current unchanged quaternion
  3831. */
  3832. toRotationMatrix(result: Matrix): Quaternion;
  3833. /**
  3834. * Updates the current quaternion from the given rotation matrix values
  3835. * @param matrix defines the source matrix
  3836. * @returns the current updated quaternion
  3837. */
  3838. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3839. /**
  3840. * Creates a new quaternion from a rotation matrix
  3841. * @param matrix defines the source matrix
  3842. * @returns a new quaternion created from the given rotation matrix values
  3843. */
  3844. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3845. /**
  3846. * Updates the given quaternion with the given rotation matrix values
  3847. * @param matrix defines the source matrix
  3848. * @param result defines the target quaternion
  3849. */
  3850. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3851. /**
  3852. * Returns the dot product (float) between the quaternions "left" and "right"
  3853. * @param left defines the left operand
  3854. * @param right defines the right operand
  3855. * @returns the dot product
  3856. */
  3857. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3858. /**
  3859. * Checks if the two quaternions are close to each other
  3860. * @param quat0 defines the first quaternion to check
  3861. * @param quat1 defines the second quaternion to check
  3862. * @returns true if the two quaternions are close to each other
  3863. */
  3864. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3865. /**
  3866. * Creates an empty quaternion
  3867. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3868. */
  3869. static Zero(): Quaternion;
  3870. /**
  3871. * Inverse a given quaternion
  3872. * @param q defines the source quaternion
  3873. * @returns a new quaternion as the inverted current quaternion
  3874. */
  3875. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3876. /**
  3877. * Inverse a given quaternion
  3878. * @param q defines the source quaternion
  3879. * @param result the quaternion the result will be stored in
  3880. * @returns the result quaternion
  3881. */
  3882. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3883. /**
  3884. * Creates an identity quaternion
  3885. * @returns the identity quaternion
  3886. */
  3887. static Identity(): Quaternion;
  3888. /**
  3889. * Gets a boolean indicating if the given quaternion is identity
  3890. * @param quaternion defines the quaternion to check
  3891. * @returns true if the quaternion is identity
  3892. */
  3893. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3894. /**
  3895. * Creates a quaternion from a rotation around an axis
  3896. * @param axis defines the axis to use
  3897. * @param angle defines the angle to use
  3898. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3899. */
  3900. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3901. /**
  3902. * Creates a rotation around an axis and stores it into the given quaternion
  3903. * @param axis defines the axis to use
  3904. * @param angle defines the angle to use
  3905. * @param result defines the target quaternion
  3906. * @returns the target quaternion
  3907. */
  3908. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3909. /**
  3910. * Creates a new quaternion from data stored into an array
  3911. * @param array defines the data source
  3912. * @param offset defines the offset in the source array where the data starts
  3913. * @returns a new quaternion
  3914. */
  3915. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3916. /**
  3917. * Updates the given quaternion "result" from the starting index of the given array.
  3918. * @param array the array to pull values from
  3919. * @param offset the offset into the array to start at
  3920. * @param result the quaternion to store the result in
  3921. */
  3922. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  3923. /**
  3924. * Create a quaternion from Euler rotation angles
  3925. * @param x Pitch
  3926. * @param y Yaw
  3927. * @param z Roll
  3928. * @returns the new Quaternion
  3929. */
  3930. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3931. /**
  3932. * Updates a quaternion from Euler rotation angles
  3933. * @param x Pitch
  3934. * @param y Yaw
  3935. * @param z Roll
  3936. * @param result the quaternion to store the result
  3937. * @returns the updated quaternion
  3938. */
  3939. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3940. /**
  3941. * Create a quaternion from Euler rotation vector
  3942. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3943. * @returns the new Quaternion
  3944. */
  3945. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3946. /**
  3947. * Updates a quaternion from Euler rotation vector
  3948. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3949. * @param result the quaternion to store the result
  3950. * @returns the updated quaternion
  3951. */
  3952. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3953. /**
  3954. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3955. * @param yaw defines the rotation around Y axis
  3956. * @param pitch defines the rotation around X axis
  3957. * @param roll defines the rotation around Z axis
  3958. * @returns the new quaternion
  3959. */
  3960. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3961. /**
  3962. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3963. * @param yaw defines the rotation around Y axis
  3964. * @param pitch defines the rotation around X axis
  3965. * @param roll defines the rotation around Z axis
  3966. * @param result defines the target quaternion
  3967. */
  3968. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3969. /**
  3970. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3971. * @param alpha defines the rotation around first axis
  3972. * @param beta defines the rotation around second axis
  3973. * @param gamma defines the rotation around third axis
  3974. * @returns the new quaternion
  3975. */
  3976. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3977. /**
  3978. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3979. * @param alpha defines the rotation around first axis
  3980. * @param beta defines the rotation around second axis
  3981. * @param gamma defines the rotation around third axis
  3982. * @param result defines the target quaternion
  3983. */
  3984. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3985. /**
  3986. * Creates a new quaternion containing the rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation)
  3987. * @param axis1 defines the first axis
  3988. * @param axis2 defines the second axis
  3989. * @param axis3 defines the third axis
  3990. * @returns the new quaternion
  3991. */
  3992. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3993. /**
  3994. * Creates a rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation) and stores it in the target quaternion
  3995. * @param axis1 defines the first axis
  3996. * @param axis2 defines the second axis
  3997. * @param axis3 defines the third axis
  3998. * @param ref defines the target quaternion
  3999. */
  4000. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  4001. /**
  4002. * Interpolates between two quaternions
  4003. * @param left defines first quaternion
  4004. * @param right defines second quaternion
  4005. * @param amount defines the gradient to use
  4006. * @returns the new interpolated quaternion
  4007. */
  4008. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4009. /**
  4010. * Interpolates between two quaternions and stores it into a target quaternion
  4011. * @param left defines first quaternion
  4012. * @param right defines second quaternion
  4013. * @param amount defines the gradient to use
  4014. * @param result defines the target quaternion
  4015. */
  4016. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  4017. /**
  4018. * Interpolate between two quaternions using Hermite interpolation
  4019. * @param value1 defines first quaternion
  4020. * @param tangent1 defines the incoming tangent
  4021. * @param value2 defines second quaternion
  4022. * @param tangent2 defines the outgoing tangent
  4023. * @param amount defines the target quaternion
  4024. * @returns the new interpolated quaternion
  4025. */
  4026. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4027. }
  4028. /**
  4029. * Class used to store matrix data (4x4)
  4030. */
  4031. export class Matrix {
  4032. private static _updateFlagSeed;
  4033. private static _identityReadOnly;
  4034. private _isIdentity;
  4035. private _isIdentityDirty;
  4036. private _isIdentity3x2;
  4037. private _isIdentity3x2Dirty;
  4038. /**
  4039. * Gets the update flag of the matrix which is an unique number for the matrix.
  4040. * It will be incremented every time the matrix data change.
  4041. * You can use it to speed the comparison between two versions of the same matrix.
  4042. */
  4043. updateFlag: number;
  4044. private readonly _m;
  4045. /**
  4046. * Gets the internal data of the matrix
  4047. */
  4048. get m(): DeepImmutable<Float32Array>;
  4049. /** @hidden */
  4050. _markAsUpdated(): void;
  4051. /** @hidden */
  4052. private _updateIdentityStatus;
  4053. /**
  4054. * Creates an empty matrix (filled with zeros)
  4055. */
  4056. constructor();
  4057. /**
  4058. * Check if the current matrix is identity
  4059. * @returns true is the matrix is the identity matrix
  4060. */
  4061. isIdentity(): boolean;
  4062. /**
  4063. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  4064. * @returns true is the matrix is the identity matrix
  4065. */
  4066. isIdentityAs3x2(): boolean;
  4067. /**
  4068. * Gets the determinant of the matrix
  4069. * @returns the matrix determinant
  4070. */
  4071. determinant(): number;
  4072. /**
  4073. * Returns the matrix as a Float32Array
  4074. * @returns the matrix underlying array
  4075. */
  4076. toArray(): DeepImmutable<Float32Array>;
  4077. /**
  4078. * Returns the matrix as a Float32Array
  4079. * @returns the matrix underlying array.
  4080. */
  4081. asArray(): DeepImmutable<Float32Array>;
  4082. /**
  4083. * Inverts the current matrix in place
  4084. * @returns the current inverted matrix
  4085. */
  4086. invert(): Matrix;
  4087. /**
  4088. * Sets all the matrix elements to zero
  4089. * @returns the current matrix
  4090. */
  4091. reset(): Matrix;
  4092. /**
  4093. * Adds the current matrix with a second one
  4094. * @param other defines the matrix to add
  4095. * @returns a new matrix as the addition of the current matrix and the given one
  4096. */
  4097. add(other: DeepImmutable<Matrix>): Matrix;
  4098. /**
  4099. * Sets the given matrix "result" to the addition of the current matrix and the given one
  4100. * @param other defines the matrix to add
  4101. * @param result defines the target matrix
  4102. * @returns the current matrix
  4103. */
  4104. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4105. /**
  4106. * Adds in place the given matrix to the current matrix
  4107. * @param other defines the second operand
  4108. * @returns the current updated matrix
  4109. */
  4110. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  4111. /**
  4112. * Sets the given matrix to the current inverted Matrix
  4113. * @param other defines the target matrix
  4114. * @returns the unmodified current matrix
  4115. */
  4116. invertToRef(other: Matrix): Matrix;
  4117. /**
  4118. * add a value at the specified position in the current Matrix
  4119. * @param index the index of the value within the matrix. between 0 and 15.
  4120. * @param value the value to be added
  4121. * @returns the current updated matrix
  4122. */
  4123. addAtIndex(index: number, value: number): Matrix;
  4124. /**
  4125. * mutiply the specified position in the current Matrix by a value
  4126. * @param index the index of the value within the matrix. between 0 and 15.
  4127. * @param value the value to be added
  4128. * @returns the current updated matrix
  4129. */
  4130. multiplyAtIndex(index: number, value: number): Matrix;
  4131. /**
  4132. * Inserts the translation vector (using 3 floats) in the current matrix
  4133. * @param x defines the 1st component of the translation
  4134. * @param y defines the 2nd component of the translation
  4135. * @param z defines the 3rd component of the translation
  4136. * @returns the current updated matrix
  4137. */
  4138. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4139. /**
  4140. * Adds the translation vector (using 3 floats) in the current matrix
  4141. * @param x defines the 1st component of the translation
  4142. * @param y defines the 2nd component of the translation
  4143. * @param z defines the 3rd component of the translation
  4144. * @returns the current updated matrix
  4145. */
  4146. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4147. /**
  4148. * Inserts the translation vector in the current matrix
  4149. * @param vector3 defines the translation to insert
  4150. * @returns the current updated matrix
  4151. */
  4152. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4153. /**
  4154. * Gets the translation value of the current matrix
  4155. * @returns a new Vector3 as the extracted translation from the matrix
  4156. */
  4157. getTranslation(): Vector3;
  4158. /**
  4159. * Fill a Vector3 with the extracted translation from the matrix
  4160. * @param result defines the Vector3 where to store the translation
  4161. * @returns the current matrix
  4162. */
  4163. getTranslationToRef(result: Vector3): Matrix;
  4164. /**
  4165. * Remove rotation and scaling part from the matrix
  4166. * @returns the updated matrix
  4167. */
  4168. removeRotationAndScaling(): Matrix;
  4169. /**
  4170. * Multiply two matrices
  4171. * @param other defines the second operand
  4172. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4173. */
  4174. multiply(other: DeepImmutable<Matrix>): Matrix;
  4175. /**
  4176. * Copy the current matrix from the given one
  4177. * @param other defines the source matrix
  4178. * @returns the current updated matrix
  4179. */
  4180. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4181. /**
  4182. * Populates the given array from the starting index with the current matrix values
  4183. * @param array defines the target array
  4184. * @param offset defines the offset in the target array where to start storing values
  4185. * @returns the current matrix
  4186. */
  4187. copyToArray(array: Float32Array, offset?: number): Matrix;
  4188. /**
  4189. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4190. * @param other defines the second operand
  4191. * @param result defines the matrix where to store the multiplication
  4192. * @returns the current matrix
  4193. */
  4194. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4195. /**
  4196. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4197. * @param other defines the second operand
  4198. * @param result defines the array where to store the multiplication
  4199. * @param offset defines the offset in the target array where to start storing values
  4200. * @returns the current matrix
  4201. */
  4202. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  4203. /**
  4204. * Check equality between this matrix and a second one
  4205. * @param value defines the second matrix to compare
  4206. * @returns true is the current matrix and the given one values are strictly equal
  4207. */
  4208. equals(value: DeepImmutable<Matrix>): boolean;
  4209. /**
  4210. * Clone the current matrix
  4211. * @returns a new matrix from the current matrix
  4212. */
  4213. clone(): Matrix;
  4214. /**
  4215. * Returns the name of the current matrix class
  4216. * @returns the string "Matrix"
  4217. */
  4218. getClassName(): string;
  4219. /**
  4220. * Gets the hash code of the current matrix
  4221. * @returns the hash code
  4222. */
  4223. getHashCode(): number;
  4224. /**
  4225. * Decomposes the current Matrix into a translation, rotation and scaling components
  4226. * @param scale defines the scale vector3 given as a reference to update
  4227. * @param rotation defines the rotation quaternion given as a reference to update
  4228. * @param translation defines the translation vector3 given as a reference to update
  4229. * @returns true if operation was successful
  4230. */
  4231. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4232. /**
  4233. * Gets specific row of the matrix
  4234. * @param index defines the number of the row to get
  4235. * @returns the index-th row of the current matrix as a new Vector4
  4236. */
  4237. getRow(index: number): Nullable<Vector4>;
  4238. /**
  4239. * Sets the index-th row of the current matrix to the vector4 values
  4240. * @param index defines the number of the row to set
  4241. * @param row defines the target vector4
  4242. * @returns the updated current matrix
  4243. */
  4244. setRow(index: number, row: Vector4): Matrix;
  4245. /**
  4246. * Compute the transpose of the matrix
  4247. * @returns the new transposed matrix
  4248. */
  4249. transpose(): Matrix;
  4250. /**
  4251. * Compute the transpose of the matrix and store it in a given matrix
  4252. * @param result defines the target matrix
  4253. * @returns the current matrix
  4254. */
  4255. transposeToRef(result: Matrix): Matrix;
  4256. /**
  4257. * Sets the index-th row of the current matrix with the given 4 x float values
  4258. * @param index defines the row index
  4259. * @param x defines the x component to set
  4260. * @param y defines the y component to set
  4261. * @param z defines the z component to set
  4262. * @param w defines the w component to set
  4263. * @returns the updated current matrix
  4264. */
  4265. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4266. /**
  4267. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4268. * @param scale defines the scale factor
  4269. * @returns a new matrix
  4270. */
  4271. scale(scale: number): Matrix;
  4272. /**
  4273. * Scale the current matrix values by a factor to a given result matrix
  4274. * @param scale defines the scale factor
  4275. * @param result defines the matrix to store the result
  4276. * @returns the current matrix
  4277. */
  4278. scaleToRef(scale: number, result: Matrix): Matrix;
  4279. /**
  4280. * Scale the current matrix values by a factor and add the result to a given matrix
  4281. * @param scale defines the scale factor
  4282. * @param result defines the Matrix to store the result
  4283. * @returns the current matrix
  4284. */
  4285. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4286. /**
  4287. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4288. * @param ref matrix to store the result
  4289. */
  4290. toNormalMatrix(ref: Matrix): void;
  4291. /**
  4292. * Gets only rotation part of the current matrix
  4293. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4294. */
  4295. getRotationMatrix(): Matrix;
  4296. /**
  4297. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4298. * @param result defines the target matrix to store data to
  4299. * @returns the current matrix
  4300. */
  4301. getRotationMatrixToRef(result: Matrix): Matrix;
  4302. /**
  4303. * Toggles model matrix from being right handed to left handed in place and vice versa
  4304. */
  4305. toggleModelMatrixHandInPlace(): void;
  4306. /**
  4307. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4308. */
  4309. toggleProjectionMatrixHandInPlace(): void;
  4310. /**
  4311. * Creates a matrix from an array
  4312. * @param array defines the source array
  4313. * @param offset defines an offset in the source array
  4314. * @returns a new Matrix set from the starting index of the given array
  4315. */
  4316. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4317. /**
  4318. * Copy the content of an array into a given matrix
  4319. * @param array defines the source array
  4320. * @param offset defines an offset in the source array
  4321. * @param result defines the target matrix
  4322. */
  4323. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4324. /**
  4325. * Stores an array into a matrix after having multiplied each component by a given factor
  4326. * @param array defines the source array
  4327. * @param offset defines the offset in the source array
  4328. * @param scale defines the scaling factor
  4329. * @param result defines the target matrix
  4330. */
  4331. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4332. /**
  4333. * Gets an identity matrix that must not be updated
  4334. */
  4335. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4336. /**
  4337. * Stores a list of values (16) inside a given matrix
  4338. * @param initialM11 defines 1st value of 1st row
  4339. * @param initialM12 defines 2nd value of 1st row
  4340. * @param initialM13 defines 3rd value of 1st row
  4341. * @param initialM14 defines 4th value of 1st row
  4342. * @param initialM21 defines 1st value of 2nd row
  4343. * @param initialM22 defines 2nd value of 2nd row
  4344. * @param initialM23 defines 3rd value of 2nd row
  4345. * @param initialM24 defines 4th value of 2nd row
  4346. * @param initialM31 defines 1st value of 3rd row
  4347. * @param initialM32 defines 2nd value of 3rd row
  4348. * @param initialM33 defines 3rd value of 3rd row
  4349. * @param initialM34 defines 4th value of 3rd row
  4350. * @param initialM41 defines 1st value of 4th row
  4351. * @param initialM42 defines 2nd value of 4th row
  4352. * @param initialM43 defines 3rd value of 4th row
  4353. * @param initialM44 defines 4th value of 4th row
  4354. * @param result defines the target matrix
  4355. */
  4356. static FromValuesToRef(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number, result: Matrix): void;
  4357. /**
  4358. * Creates new matrix from a list of values (16)
  4359. * @param initialM11 defines 1st value of 1st row
  4360. * @param initialM12 defines 2nd value of 1st row
  4361. * @param initialM13 defines 3rd value of 1st row
  4362. * @param initialM14 defines 4th value of 1st row
  4363. * @param initialM21 defines 1st value of 2nd row
  4364. * @param initialM22 defines 2nd value of 2nd row
  4365. * @param initialM23 defines 3rd value of 2nd row
  4366. * @param initialM24 defines 4th value of 2nd row
  4367. * @param initialM31 defines 1st value of 3rd row
  4368. * @param initialM32 defines 2nd value of 3rd row
  4369. * @param initialM33 defines 3rd value of 3rd row
  4370. * @param initialM34 defines 4th value of 3rd row
  4371. * @param initialM41 defines 1st value of 4th row
  4372. * @param initialM42 defines 2nd value of 4th row
  4373. * @param initialM43 defines 3rd value of 4th row
  4374. * @param initialM44 defines 4th value of 4th row
  4375. * @returns the new matrix
  4376. */
  4377. static FromValues(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number): Matrix;
  4378. /**
  4379. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4380. * @param scale defines the scale vector3
  4381. * @param rotation defines the rotation quaternion
  4382. * @param translation defines the translation vector3
  4383. * @returns a new matrix
  4384. */
  4385. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4386. /**
  4387. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4388. * @param scale defines the scale vector3
  4389. * @param rotation defines the rotation quaternion
  4390. * @param translation defines the translation vector3
  4391. * @param result defines the target matrix
  4392. */
  4393. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4394. /**
  4395. * Creates a new identity matrix
  4396. * @returns a new identity matrix
  4397. */
  4398. static Identity(): Matrix;
  4399. /**
  4400. * Creates a new identity matrix and stores the result in a given matrix
  4401. * @param result defines the target matrix
  4402. */
  4403. static IdentityToRef(result: Matrix): void;
  4404. /**
  4405. * Creates a new zero matrix
  4406. * @returns a new zero matrix
  4407. */
  4408. static Zero(): Matrix;
  4409. /**
  4410. * Creates a new rotation matrix for "angle" radians around the X axis
  4411. * @param angle defines the angle (in radians) to use
  4412. * @return the new matrix
  4413. */
  4414. static RotationX(angle: number): Matrix;
  4415. /**
  4416. * Creates a new matrix as the invert of a given matrix
  4417. * @param source defines the source matrix
  4418. * @returns the new matrix
  4419. */
  4420. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4421. /**
  4422. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4423. * @param angle defines the angle (in radians) to use
  4424. * @param result defines the target matrix
  4425. */
  4426. static RotationXToRef(angle: number, result: Matrix): void;
  4427. /**
  4428. * Creates a new rotation matrix for "angle" radians around the Y axis
  4429. * @param angle defines the angle (in radians) to use
  4430. * @return the new matrix
  4431. */
  4432. static RotationY(angle: number): Matrix;
  4433. /**
  4434. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4435. * @param angle defines the angle (in radians) to use
  4436. * @param result defines the target matrix
  4437. */
  4438. static RotationYToRef(angle: number, result: Matrix): void;
  4439. /**
  4440. * Creates a new rotation matrix for "angle" radians around the Z axis
  4441. * @param angle defines the angle (in radians) to use
  4442. * @return the new matrix
  4443. */
  4444. static RotationZ(angle: number): Matrix;
  4445. /**
  4446. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4447. * @param angle defines the angle (in radians) to use
  4448. * @param result defines the target matrix
  4449. */
  4450. static RotationZToRef(angle: number, result: Matrix): void;
  4451. /**
  4452. * Creates a new rotation matrix for "angle" radians around the given axis
  4453. * @param axis defines the axis to use
  4454. * @param angle defines the angle (in radians) to use
  4455. * @return the new matrix
  4456. */
  4457. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4458. /**
  4459. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4460. * @param axis defines the axis to use
  4461. * @param angle defines the angle (in radians) to use
  4462. * @param result defines the target matrix
  4463. */
  4464. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4465. /**
  4466. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4467. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4468. * @param from defines the vector to align
  4469. * @param to defines the vector to align to
  4470. * @param result defines the target matrix
  4471. */
  4472. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4473. /**
  4474. * Creates a rotation matrix
  4475. * @param yaw defines the yaw angle in radians (Y axis)
  4476. * @param pitch defines the pitch angle in radians (X axis)
  4477. * @param roll defines the roll angle in radians (X axis)
  4478. * @returns the new rotation matrix
  4479. */
  4480. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4481. /**
  4482. * Creates a rotation matrix and stores it in a given matrix
  4483. * @param yaw defines the yaw angle in radians (Y axis)
  4484. * @param pitch defines the pitch angle in radians (X axis)
  4485. * @param roll defines the roll angle in radians (X axis)
  4486. * @param result defines the target matrix
  4487. */
  4488. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4489. /**
  4490. * Creates a scaling matrix
  4491. * @param x defines the scale factor on X axis
  4492. * @param y defines the scale factor on Y axis
  4493. * @param z defines the scale factor on Z axis
  4494. * @returns the new matrix
  4495. */
  4496. static Scaling(x: number, y: number, z: number): Matrix;
  4497. /**
  4498. * Creates a scaling matrix and stores it in a given matrix
  4499. * @param x defines the scale factor on X axis
  4500. * @param y defines the scale factor on Y axis
  4501. * @param z defines the scale factor on Z axis
  4502. * @param result defines the target matrix
  4503. */
  4504. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4505. /**
  4506. * Creates a translation matrix
  4507. * @param x defines the translation on X axis
  4508. * @param y defines the translation on Y axis
  4509. * @param z defines the translationon Z axis
  4510. * @returns the new matrix
  4511. */
  4512. static Translation(x: number, y: number, z: number): Matrix;
  4513. /**
  4514. * Creates a translation matrix and stores it in a given matrix
  4515. * @param x defines the translation on X axis
  4516. * @param y defines the translation on Y axis
  4517. * @param z defines the translationon Z axis
  4518. * @param result defines the target matrix
  4519. */
  4520. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4521. /**
  4522. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4523. * @param startValue defines the start value
  4524. * @param endValue defines the end value
  4525. * @param gradient defines the gradient factor
  4526. * @returns the new matrix
  4527. */
  4528. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4529. /**
  4530. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4531. * @param startValue defines the start value
  4532. * @param endValue defines the end value
  4533. * @param gradient defines the gradient factor
  4534. * @param result defines the Matrix object where to store data
  4535. */
  4536. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4537. /**
  4538. * Builds a new matrix whose values are computed by:
  4539. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4540. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4541. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4542. * @param startValue defines the first matrix
  4543. * @param endValue defines the second matrix
  4544. * @param gradient defines the gradient between the two matrices
  4545. * @returns the new matrix
  4546. */
  4547. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4548. /**
  4549. * Update a matrix to values which are computed by:
  4550. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4551. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4552. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4553. * @param startValue defines the first matrix
  4554. * @param endValue defines the second matrix
  4555. * @param gradient defines the gradient between the two matrices
  4556. * @param result defines the target matrix
  4557. */
  4558. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4559. /**
  4560. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  4561. * This function works in left handed mode
  4562. * @param eye defines the final position of the entity
  4563. * @param target defines where the entity should look at
  4564. * @param up defines the up vector for the entity
  4565. * @returns the new matrix
  4566. */
  4567. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4568. /**
  4569. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  4570. * This function works in left handed mode
  4571. * @param eye defines the final position of the entity
  4572. * @param target defines where the entity should look at
  4573. * @param up defines the up vector for the entity
  4574. * @param result defines the target matrix
  4575. */
  4576. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4577. /**
  4578. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  4579. * This function works in right handed mode
  4580. * @param eye defines the final position of the entity
  4581. * @param target defines where the entity should look at
  4582. * @param up defines the up vector for the entity
  4583. * @returns the new matrix
  4584. */
  4585. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4586. /**
  4587. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  4588. * This function works in right handed mode
  4589. * @param eye defines the final position of the entity
  4590. * @param target defines where the entity should look at
  4591. * @param up defines the up vector for the entity
  4592. * @param result defines the target matrix
  4593. */
  4594. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4595. /**
  4596. * Create a left-handed orthographic projection matrix
  4597. * @param width defines the viewport width
  4598. * @param height defines the viewport height
  4599. * @param znear defines the near clip plane
  4600. * @param zfar defines the far clip plane
  4601. * @returns a new matrix as a left-handed orthographic projection matrix
  4602. */
  4603. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4604. /**
  4605. * Store a left-handed orthographic projection to a given matrix
  4606. * @param width defines the viewport width
  4607. * @param height defines the viewport height
  4608. * @param znear defines the near clip plane
  4609. * @param zfar defines the far clip plane
  4610. * @param result defines the target matrix
  4611. */
  4612. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4613. /**
  4614. * Create a left-handed orthographic projection matrix
  4615. * @param left defines the viewport left coordinate
  4616. * @param right defines the viewport right coordinate
  4617. * @param bottom defines the viewport bottom coordinate
  4618. * @param top defines the viewport top coordinate
  4619. * @param znear defines the near clip plane
  4620. * @param zfar defines the far clip plane
  4621. * @returns a new matrix as a left-handed orthographic projection matrix
  4622. */
  4623. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4624. /**
  4625. * Stores a left-handed orthographic projection into a given matrix
  4626. * @param left defines the viewport left coordinate
  4627. * @param right defines the viewport right coordinate
  4628. * @param bottom defines the viewport bottom coordinate
  4629. * @param top defines the viewport top coordinate
  4630. * @param znear defines the near clip plane
  4631. * @param zfar defines the far clip plane
  4632. * @param result defines the target matrix
  4633. */
  4634. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4635. /**
  4636. * Creates a right-handed orthographic projection matrix
  4637. * @param left defines the viewport left coordinate
  4638. * @param right defines the viewport right coordinate
  4639. * @param bottom defines the viewport bottom coordinate
  4640. * @param top defines the viewport top coordinate
  4641. * @param znear defines the near clip plane
  4642. * @param zfar defines the far clip plane
  4643. * @returns a new matrix as a right-handed orthographic projection matrix
  4644. */
  4645. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4646. /**
  4647. * Stores a right-handed orthographic projection into a given matrix
  4648. * @param left defines the viewport left coordinate
  4649. * @param right defines the viewport right coordinate
  4650. * @param bottom defines the viewport bottom coordinate
  4651. * @param top defines the viewport top coordinate
  4652. * @param znear defines the near clip plane
  4653. * @param zfar defines the far clip plane
  4654. * @param result defines the target matrix
  4655. */
  4656. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4657. /**
  4658. * Creates a left-handed perspective projection matrix
  4659. * @param width defines the viewport width
  4660. * @param height defines the viewport height
  4661. * @param znear defines the near clip plane
  4662. * @param zfar defines the far clip plane
  4663. * @returns a new matrix as a left-handed perspective projection matrix
  4664. */
  4665. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4666. /**
  4667. * Creates a left-handed perspective projection matrix
  4668. * @param fov defines the horizontal field of view
  4669. * @param aspect defines the aspect ratio
  4670. * @param znear defines the near clip plane
  4671. * @param zfar defines the far clip plane
  4672. * @returns a new matrix as a left-handed perspective projection matrix
  4673. */
  4674. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4675. /**
  4676. * Stores a left-handed perspective projection into a given matrix
  4677. * @param fov defines the horizontal field of view
  4678. * @param aspect defines the aspect ratio
  4679. * @param znear defines the near clip plane
  4680. * @param zfar defines the far clip plane
  4681. * @param result defines the target matrix
  4682. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4683. */
  4684. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4685. /**
  4686. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4687. * @param fov defines the horizontal field of view
  4688. * @param aspect defines the aspect ratio
  4689. * @param znear defines the near clip plane
  4690. * @param zfar not used as infinity is used as far clip
  4691. * @param result defines the target matrix
  4692. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4693. */
  4694. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4695. /**
  4696. * Creates a right-handed perspective projection matrix
  4697. * @param fov defines the horizontal field of view
  4698. * @param aspect defines the aspect ratio
  4699. * @param znear defines the near clip plane
  4700. * @param zfar defines the far clip plane
  4701. * @returns a new matrix as a right-handed perspective projection matrix
  4702. */
  4703. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4704. /**
  4705. * Stores a right-handed perspective projection into a given matrix
  4706. * @param fov defines the horizontal field of view
  4707. * @param aspect defines the aspect ratio
  4708. * @param znear defines the near clip plane
  4709. * @param zfar defines the far clip plane
  4710. * @param result defines the target matrix
  4711. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4712. */
  4713. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4714. /**
  4715. * Stores a right-handed perspective projection into a given matrix
  4716. * @param fov defines the horizontal field of view
  4717. * @param aspect defines the aspect ratio
  4718. * @param znear defines the near clip plane
  4719. * @param zfar not used as infinity is used as far clip
  4720. * @param result defines the target matrix
  4721. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4722. */
  4723. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4724. /**
  4725. * Stores a perspective projection for WebVR info a given matrix
  4726. * @param fov defines the field of view
  4727. * @param znear defines the near clip plane
  4728. * @param zfar defines the far clip plane
  4729. * @param result defines the target matrix
  4730. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4731. */
  4732. static PerspectiveFovWebVRToRef(fov: {
  4733. upDegrees: number;
  4734. downDegrees: number;
  4735. leftDegrees: number;
  4736. rightDegrees: number;
  4737. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4738. /**
  4739. * Computes a complete transformation matrix
  4740. * @param viewport defines the viewport to use
  4741. * @param world defines the world matrix
  4742. * @param view defines the view matrix
  4743. * @param projection defines the projection matrix
  4744. * @param zmin defines the near clip plane
  4745. * @param zmax defines the far clip plane
  4746. * @returns the transformation matrix
  4747. */
  4748. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4749. /**
  4750. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4751. * @param matrix defines the matrix to use
  4752. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4753. */
  4754. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4755. /**
  4756. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4757. * @param matrix defines the matrix to use
  4758. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4759. */
  4760. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4761. /**
  4762. * Compute the transpose of a given matrix
  4763. * @param matrix defines the matrix to transpose
  4764. * @returns the new matrix
  4765. */
  4766. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4767. /**
  4768. * Compute the transpose of a matrix and store it in a target matrix
  4769. * @param matrix defines the matrix to transpose
  4770. * @param result defines the target matrix
  4771. */
  4772. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4773. /**
  4774. * Computes a reflection matrix from a plane
  4775. * @param plane defines the reflection plane
  4776. * @returns a new matrix
  4777. */
  4778. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4779. /**
  4780. * Computes a reflection matrix from a plane
  4781. * @param plane defines the reflection plane
  4782. * @param result defines the target matrix
  4783. */
  4784. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4785. /**
  4786. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4787. * @param xaxis defines the value of the 1st axis
  4788. * @param yaxis defines the value of the 2nd axis
  4789. * @param zaxis defines the value of the 3rd axis
  4790. * @param result defines the target matrix
  4791. */
  4792. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4793. /**
  4794. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4795. * @param quat defines the quaternion to use
  4796. * @param result defines the target matrix
  4797. */
  4798. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4799. }
  4800. /**
  4801. * @hidden
  4802. */
  4803. export class TmpVectors {
  4804. static Vector2: Vector2[];
  4805. static Vector3: Vector3[];
  4806. static Vector4: Vector4[];
  4807. static Quaternion: Quaternion[];
  4808. static Matrix: Matrix[];
  4809. }
  4810. }
  4811. declare module "babylonjs/Maths/math.path" {
  4812. import { DeepImmutable, Nullable } from "babylonjs/types";
  4813. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  4814. /**
  4815. * Defines potential orientation for back face culling
  4816. */
  4817. export enum Orientation {
  4818. /**
  4819. * Clockwise
  4820. */
  4821. CW = 0,
  4822. /** Counter clockwise */
  4823. CCW = 1
  4824. }
  4825. /** Class used to represent a Bezier curve */
  4826. export class BezierCurve {
  4827. /**
  4828. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4829. * @param t defines the time
  4830. * @param x1 defines the left coordinate on X axis
  4831. * @param y1 defines the left coordinate on Y axis
  4832. * @param x2 defines the right coordinate on X axis
  4833. * @param y2 defines the right coordinate on Y axis
  4834. * @returns the interpolated value
  4835. */
  4836. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4837. }
  4838. /**
  4839. * Defines angle representation
  4840. */
  4841. export class Angle {
  4842. private _radians;
  4843. /**
  4844. * Creates an Angle object of "radians" radians (float).
  4845. * @param radians the angle in radians
  4846. */
  4847. constructor(radians: number);
  4848. /**
  4849. * Get value in degrees
  4850. * @returns the Angle value in degrees (float)
  4851. */
  4852. degrees(): number;
  4853. /**
  4854. * Get value in radians
  4855. * @returns the Angle value in radians (float)
  4856. */
  4857. radians(): number;
  4858. /**
  4859. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4860. * @param a defines first vector
  4861. * @param b defines second vector
  4862. * @returns a new Angle
  4863. */
  4864. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4865. /**
  4866. * Gets a new Angle object from the given float in radians
  4867. * @param radians defines the angle value in radians
  4868. * @returns a new Angle
  4869. */
  4870. static FromRadians(radians: number): Angle;
  4871. /**
  4872. * Gets a new Angle object from the given float in degrees
  4873. * @param degrees defines the angle value in degrees
  4874. * @returns a new Angle
  4875. */
  4876. static FromDegrees(degrees: number): Angle;
  4877. }
  4878. /**
  4879. * This represents an arc in a 2d space.
  4880. */
  4881. export class Arc2 {
  4882. /** Defines the start point of the arc */
  4883. startPoint: Vector2;
  4884. /** Defines the mid point of the arc */
  4885. midPoint: Vector2;
  4886. /** Defines the end point of the arc */
  4887. endPoint: Vector2;
  4888. /**
  4889. * Defines the center point of the arc.
  4890. */
  4891. centerPoint: Vector2;
  4892. /**
  4893. * Defines the radius of the arc.
  4894. */
  4895. radius: number;
  4896. /**
  4897. * Defines the angle of the arc (from mid point to end point).
  4898. */
  4899. angle: Angle;
  4900. /**
  4901. * Defines the start angle of the arc (from start point to middle point).
  4902. */
  4903. startAngle: Angle;
  4904. /**
  4905. * Defines the orientation of the arc (clock wise/counter clock wise).
  4906. */
  4907. orientation: Orientation;
  4908. /**
  4909. * Creates an Arc object from the three given points : start, middle and end.
  4910. * @param startPoint Defines the start point of the arc
  4911. * @param midPoint Defines the midlle point of the arc
  4912. * @param endPoint Defines the end point of the arc
  4913. */
  4914. constructor(
  4915. /** Defines the start point of the arc */
  4916. startPoint: Vector2,
  4917. /** Defines the mid point of the arc */
  4918. midPoint: Vector2,
  4919. /** Defines the end point of the arc */
  4920. endPoint: Vector2);
  4921. }
  4922. /**
  4923. * Represents a 2D path made up of multiple 2D points
  4924. */
  4925. export class Path2 {
  4926. private _points;
  4927. private _length;
  4928. /**
  4929. * If the path start and end point are the same
  4930. */
  4931. closed: boolean;
  4932. /**
  4933. * Creates a Path2 object from the starting 2D coordinates x and y.
  4934. * @param x the starting points x value
  4935. * @param y the starting points y value
  4936. */
  4937. constructor(x: number, y: number);
  4938. /**
  4939. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4940. * @param x the added points x value
  4941. * @param y the added points y value
  4942. * @returns the updated Path2.
  4943. */
  4944. addLineTo(x: number, y: number): Path2;
  4945. /**
  4946. * Adds _numberOfSegments_ segments according to the arc definition (middle point coordinates, end point coordinates, the arc start point being the current Path2 last point) to the current Path2.
  4947. * @param midX middle point x value
  4948. * @param midY middle point y value
  4949. * @param endX end point x value
  4950. * @param endY end point y value
  4951. * @param numberOfSegments (default: 36)
  4952. * @returns the updated Path2.
  4953. */
  4954. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4955. /**
  4956. * Closes the Path2.
  4957. * @returns the Path2.
  4958. */
  4959. close(): Path2;
  4960. /**
  4961. * Gets the sum of the distance between each sequential point in the path
  4962. * @returns the Path2 total length (float).
  4963. */
  4964. length(): number;
  4965. /**
  4966. * Gets the points which construct the path
  4967. * @returns the Path2 internal array of points.
  4968. */
  4969. getPoints(): Vector2[];
  4970. /**
  4971. * Retreives the point at the distance aways from the starting point
  4972. * @param normalizedLengthPosition the length along the path to retreive the point from
  4973. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4974. */
  4975. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4976. /**
  4977. * Creates a new path starting from an x and y position
  4978. * @param x starting x value
  4979. * @param y starting y value
  4980. * @returns a new Path2 starting at the coordinates (x, y).
  4981. */
  4982. static StartingAt(x: number, y: number): Path2;
  4983. }
  4984. /**
  4985. * Represents a 3D path made up of multiple 3D points
  4986. */
  4987. export class Path3D {
  4988. /**
  4989. * an array of Vector3, the curve axis of the Path3D
  4990. */
  4991. path: Vector3[];
  4992. private _curve;
  4993. private _distances;
  4994. private _tangents;
  4995. private _normals;
  4996. private _binormals;
  4997. private _raw;
  4998. private _alignTangentsWithPath;
  4999. private readonly _pointAtData;
  5000. /**
  5001. * new Path3D(path, normal, raw)
  5002. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5003. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5004. * @param path an array of Vector3, the curve axis of the Path3D
  5005. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5006. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5007. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  5008. */
  5009. constructor(
  5010. /**
  5011. * an array of Vector3, the curve axis of the Path3D
  5012. */
  5013. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  5014. /**
  5015. * Returns the Path3D array of successive Vector3 designing its curve.
  5016. * @returns the Path3D array of successive Vector3 designing its curve.
  5017. */
  5018. getCurve(): Vector3[];
  5019. /**
  5020. * Returns the Path3D array of successive Vector3 designing its curve.
  5021. * @returns the Path3D array of successive Vector3 designing its curve.
  5022. */
  5023. getPoints(): Vector3[];
  5024. /**
  5025. * @returns the computed length (float) of the path.
  5026. */
  5027. length(): number;
  5028. /**
  5029. * Returns an array populated with tangent vectors on each Path3D curve point.
  5030. * @returns an array populated with tangent vectors on each Path3D curve point.
  5031. */
  5032. getTangents(): Vector3[];
  5033. /**
  5034. * Returns an array populated with normal vectors on each Path3D curve point.
  5035. * @returns an array populated with normal vectors on each Path3D curve point.
  5036. */
  5037. getNormals(): Vector3[];
  5038. /**
  5039. * Returns an array populated with binormal vectors on each Path3D curve point.
  5040. * @returns an array populated with binormal vectors on each Path3D curve point.
  5041. */
  5042. getBinormals(): Vector3[];
  5043. /**
  5044. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5045. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5046. */
  5047. getDistances(): number[];
  5048. /**
  5049. * Returns an interpolated point along this path
  5050. * @param position the position of the point along this path, from 0.0 to 1.0
  5051. * @returns a new Vector3 as the point
  5052. */
  5053. getPointAt(position: number): Vector3;
  5054. /**
  5055. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5056. * @param position the position of the point along this path, from 0.0 to 1.0
  5057. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  5058. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  5059. */
  5060. getTangentAt(position: number, interpolated?: boolean): Vector3;
  5061. /**
  5062. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5063. * @param position the position of the point along this path, from 0.0 to 1.0
  5064. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  5065. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  5066. */
  5067. getNormalAt(position: number, interpolated?: boolean): Vector3;
  5068. /**
  5069. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  5070. * @param position the position of the point along this path, from 0.0 to 1.0
  5071. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  5072. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  5073. */
  5074. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  5075. /**
  5076. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  5077. * @param position the position of the point along this path, from 0.0 to 1.0
  5078. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  5079. */
  5080. getDistanceAt(position: number): number;
  5081. /**
  5082. * Returns the array index of the previous point of an interpolated point along this path
  5083. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5084. * @returns the array index
  5085. */
  5086. getPreviousPointIndexAt(position: number): number;
  5087. /**
  5088. * Returns the position of an interpolated point relative to the two path points it lies between, from 0.0 (point A) to 1.0 (point B)
  5089. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5090. * @returns the sub position
  5091. */
  5092. getSubPositionAt(position: number): number;
  5093. /**
  5094. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  5095. * @param target the vector of which to get the closest position to
  5096. * @returns the position of the closest virtual point on this path to the target vector
  5097. */
  5098. getClosestPositionTo(target: Vector3): number;
  5099. /**
  5100. * Returns a sub path (slice) of this path
  5101. * @param start the position of the fist path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  5102. * @param end the position of the last path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  5103. * @returns a sub path (slice) of this path
  5104. */
  5105. slice(start?: number, end?: number): Path3D;
  5106. /**
  5107. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5108. * @param path path which all values are copied into the curves points
  5109. * @param firstNormal which should be projected onto the curve
  5110. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  5111. * @returns the same object updated.
  5112. */
  5113. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  5114. private _compute;
  5115. private _getFirstNonNullVector;
  5116. private _getLastNonNullVector;
  5117. private _normalVector;
  5118. /**
  5119. * Updates the point at data for an interpolated point along this curve
  5120. * @param position the position of the point along this curve, from 0.0 to 1.0
  5121. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  5122. * @returns the (updated) point at data
  5123. */
  5124. private _updatePointAtData;
  5125. /**
  5126. * Updates the point at data from the specified parameters
  5127. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  5128. * @param point the interpolated point
  5129. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  5130. */
  5131. private _setPointAtData;
  5132. /**
  5133. * Updates the point at interpolation matrix for the tangents, normals and binormals
  5134. */
  5135. private _updateInterpolationMatrix;
  5136. }
  5137. /**
  5138. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5139. * A Curve3 is designed from a series of successive Vector3.
  5140. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5141. */
  5142. export class Curve3 {
  5143. private _points;
  5144. private _length;
  5145. /**
  5146. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5147. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5148. * @param v1 (Vector3) the control point
  5149. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5150. * @param nbPoints (integer) the wanted number of points in the curve
  5151. * @returns the created Curve3
  5152. */
  5153. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5154. /**
  5155. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5156. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5157. * @param v1 (Vector3) the first control point
  5158. * @param v2 (Vector3) the second control point
  5159. * @param v3 (Vector3) the end point of the Cubic Bezier
  5160. * @param nbPoints (integer) the wanted number of points in the curve
  5161. * @returns the created Curve3
  5162. */
  5163. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5164. /**
  5165. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5166. * @param p1 (Vector3) the origin point of the Hermite Spline
  5167. * @param t1 (Vector3) the tangent vector at the origin point
  5168. * @param p2 (Vector3) the end point of the Hermite Spline
  5169. * @param t2 (Vector3) the tangent vector at the end point
  5170. * @param nbPoints (integer) the wanted number of points in the curve
  5171. * @returns the created Curve3
  5172. */
  5173. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5174. /**
  5175. * Returns a Curve3 object along a CatmullRom Spline curve :
  5176. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5177. * @param nbPoints (integer) the wanted number of points between each curve control points
  5178. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5179. * @returns the created Curve3
  5180. */
  5181. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5182. /**
  5183. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5184. * A Curve3 is designed from a series of successive Vector3.
  5185. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5186. * @param points points which make up the curve
  5187. */
  5188. constructor(points: Vector3[]);
  5189. /**
  5190. * @returns the Curve3 stored array of successive Vector3
  5191. */
  5192. getPoints(): Vector3[];
  5193. /**
  5194. * @returns the computed length (float) of the curve.
  5195. */
  5196. length(): number;
  5197. /**
  5198. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5199. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5200. * curveA and curveB keep unchanged.
  5201. * @param curve the curve to continue from this curve
  5202. * @returns the newly constructed curve
  5203. */
  5204. continue(curve: DeepImmutable<Curve3>): Curve3;
  5205. private _computeLength;
  5206. }
  5207. }
  5208. declare module "babylonjs/Animations/easing" {
  5209. /**
  5210. * This represents the main contract an easing function should follow.
  5211. * Easing functions are used throughout the animation system.
  5212. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5213. */
  5214. export interface IEasingFunction {
  5215. /**
  5216. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5217. * of the easing function.
  5218. * The link below provides some of the most common examples of easing functions.
  5219. * @see https://easings.net/
  5220. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5221. * @returns the corresponding value on the curve defined by the easing function
  5222. */
  5223. ease(gradient: number): number;
  5224. }
  5225. /**
  5226. * Base class used for every default easing function.
  5227. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5228. */
  5229. export class EasingFunction implements IEasingFunction {
  5230. /**
  5231. * Interpolation follows the mathematical formula associated with the easing function.
  5232. */
  5233. static readonly EASINGMODE_EASEIN: number;
  5234. /**
  5235. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5236. */
  5237. static readonly EASINGMODE_EASEOUT: number;
  5238. /**
  5239. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5240. */
  5241. static readonly EASINGMODE_EASEINOUT: number;
  5242. private _easingMode;
  5243. /**
  5244. * Sets the easing mode of the current function.
  5245. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5246. */
  5247. setEasingMode(easingMode: number): void;
  5248. /**
  5249. * Gets the current easing mode.
  5250. * @returns the easing mode
  5251. */
  5252. getEasingMode(): number;
  5253. /**
  5254. * @hidden
  5255. */
  5256. easeInCore(gradient: number): number;
  5257. /**
  5258. * Given an input gradient between 0 and 1, this returns the corresponding value
  5259. * of the easing function.
  5260. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5261. * @returns the corresponding value on the curve defined by the easing function
  5262. */
  5263. ease(gradient: number): number;
  5264. }
  5265. /**
  5266. * Easing function with a circle shape (see link below).
  5267. * @see https://easings.net/#easeInCirc
  5268. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5269. */
  5270. export class CircleEase extends EasingFunction implements IEasingFunction {
  5271. /** @hidden */
  5272. easeInCore(gradient: number): number;
  5273. }
  5274. /**
  5275. * Easing function with a ease back shape (see link below).
  5276. * @see https://easings.net/#easeInBack
  5277. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5278. */
  5279. export class BackEase extends EasingFunction implements IEasingFunction {
  5280. /** Defines the amplitude of the function */
  5281. amplitude: number;
  5282. /**
  5283. * Instantiates a back ease easing
  5284. * @see https://easings.net/#easeInBack
  5285. * @param amplitude Defines the amplitude of the function
  5286. */
  5287. constructor(
  5288. /** Defines the amplitude of the function */
  5289. amplitude?: number);
  5290. /** @hidden */
  5291. easeInCore(gradient: number): number;
  5292. }
  5293. /**
  5294. * Easing function with a bouncing shape (see link below).
  5295. * @see https://easings.net/#easeInBounce
  5296. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5297. */
  5298. export class BounceEase extends EasingFunction implements IEasingFunction {
  5299. /** Defines the number of bounces */
  5300. bounces: number;
  5301. /** Defines the amplitude of the bounce */
  5302. bounciness: number;
  5303. /**
  5304. * Instantiates a bounce easing
  5305. * @see https://easings.net/#easeInBounce
  5306. * @param bounces Defines the number of bounces
  5307. * @param bounciness Defines the amplitude of the bounce
  5308. */
  5309. constructor(
  5310. /** Defines the number of bounces */
  5311. bounces?: number,
  5312. /** Defines the amplitude of the bounce */
  5313. bounciness?: number);
  5314. /** @hidden */
  5315. easeInCore(gradient: number): number;
  5316. }
  5317. /**
  5318. * Easing function with a power of 3 shape (see link below).
  5319. * @see https://easings.net/#easeInCubic
  5320. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5321. */
  5322. export class CubicEase extends EasingFunction implements IEasingFunction {
  5323. /** @hidden */
  5324. easeInCore(gradient: number): number;
  5325. }
  5326. /**
  5327. * Easing function with an elastic shape (see link below).
  5328. * @see https://easings.net/#easeInElastic
  5329. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5330. */
  5331. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5332. /** Defines the number of oscillations*/
  5333. oscillations: number;
  5334. /** Defines the amplitude of the oscillations*/
  5335. springiness: number;
  5336. /**
  5337. * Instantiates an elastic easing function
  5338. * @see https://easings.net/#easeInElastic
  5339. * @param oscillations Defines the number of oscillations
  5340. * @param springiness Defines the amplitude of the oscillations
  5341. */
  5342. constructor(
  5343. /** Defines the number of oscillations*/
  5344. oscillations?: number,
  5345. /** Defines the amplitude of the oscillations*/
  5346. springiness?: number);
  5347. /** @hidden */
  5348. easeInCore(gradient: number): number;
  5349. }
  5350. /**
  5351. * Easing function with an exponential shape (see link below).
  5352. * @see https://easings.net/#easeInExpo
  5353. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5354. */
  5355. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5356. /** Defines the exponent of the function */
  5357. exponent: number;
  5358. /**
  5359. * Instantiates an exponential easing function
  5360. * @see https://easings.net/#easeInExpo
  5361. * @param exponent Defines the exponent of the function
  5362. */
  5363. constructor(
  5364. /** Defines the exponent of the function */
  5365. exponent?: number);
  5366. /** @hidden */
  5367. easeInCore(gradient: number): number;
  5368. }
  5369. /**
  5370. * Easing function with a power shape (see link below).
  5371. * @see https://easings.net/#easeInQuad
  5372. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5373. */
  5374. export class PowerEase extends EasingFunction implements IEasingFunction {
  5375. /** Defines the power of the function */
  5376. power: number;
  5377. /**
  5378. * Instantiates an power base easing function
  5379. * @see https://easings.net/#easeInQuad
  5380. * @param power Defines the power of the function
  5381. */
  5382. constructor(
  5383. /** Defines the power of the function */
  5384. power?: number);
  5385. /** @hidden */
  5386. easeInCore(gradient: number): number;
  5387. }
  5388. /**
  5389. * Easing function with a power of 2 shape (see link below).
  5390. * @see https://easings.net/#easeInQuad
  5391. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5392. */
  5393. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5394. /** @hidden */
  5395. easeInCore(gradient: number): number;
  5396. }
  5397. /**
  5398. * Easing function with a power of 4 shape (see link below).
  5399. * @see https://easings.net/#easeInQuart
  5400. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5401. */
  5402. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5403. /** @hidden */
  5404. easeInCore(gradient: number): number;
  5405. }
  5406. /**
  5407. * Easing function with a power of 5 shape (see link below).
  5408. * @see https://easings.net/#easeInQuint
  5409. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5410. */
  5411. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5412. /** @hidden */
  5413. easeInCore(gradient: number): number;
  5414. }
  5415. /**
  5416. * Easing function with a sin shape (see link below).
  5417. * @see https://easings.net/#easeInSine
  5418. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5419. */
  5420. export class SineEase extends EasingFunction implements IEasingFunction {
  5421. /** @hidden */
  5422. easeInCore(gradient: number): number;
  5423. }
  5424. /**
  5425. * Easing function with a bezier shape (see link below).
  5426. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5427. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5428. */
  5429. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5430. /** Defines the x component of the start tangent in the bezier curve */
  5431. x1: number;
  5432. /** Defines the y component of the start tangent in the bezier curve */
  5433. y1: number;
  5434. /** Defines the x component of the end tangent in the bezier curve */
  5435. x2: number;
  5436. /** Defines the y component of the end tangent in the bezier curve */
  5437. y2: number;
  5438. /**
  5439. * Instantiates a bezier function
  5440. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5441. * @param x1 Defines the x component of the start tangent in the bezier curve
  5442. * @param y1 Defines the y component of the start tangent in the bezier curve
  5443. * @param x2 Defines the x component of the end tangent in the bezier curve
  5444. * @param y2 Defines the y component of the end tangent in the bezier curve
  5445. */
  5446. constructor(
  5447. /** Defines the x component of the start tangent in the bezier curve */
  5448. x1?: number,
  5449. /** Defines the y component of the start tangent in the bezier curve */
  5450. y1?: number,
  5451. /** Defines the x component of the end tangent in the bezier curve */
  5452. x2?: number,
  5453. /** Defines the y component of the end tangent in the bezier curve */
  5454. y2?: number);
  5455. /** @hidden */
  5456. easeInCore(gradient: number): number;
  5457. }
  5458. }
  5459. declare module "babylonjs/Maths/math.color" {
  5460. import { DeepImmutable, FloatArray } from "babylonjs/types";
  5461. /**
  5462. * Class used to hold a RBG color
  5463. */
  5464. export class Color3 {
  5465. /**
  5466. * Defines the red component (between 0 and 1, default is 0)
  5467. */
  5468. r: number;
  5469. /**
  5470. * Defines the green component (between 0 and 1, default is 0)
  5471. */
  5472. g: number;
  5473. /**
  5474. * Defines the blue component (between 0 and 1, default is 0)
  5475. */
  5476. b: number;
  5477. /**
  5478. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5479. * @param r defines the red component (between 0 and 1, default is 0)
  5480. * @param g defines the green component (between 0 and 1, default is 0)
  5481. * @param b defines the blue component (between 0 and 1, default is 0)
  5482. */
  5483. constructor(
  5484. /**
  5485. * Defines the red component (between 0 and 1, default is 0)
  5486. */
  5487. r?: number,
  5488. /**
  5489. * Defines the green component (between 0 and 1, default is 0)
  5490. */
  5491. g?: number,
  5492. /**
  5493. * Defines the blue component (between 0 and 1, default is 0)
  5494. */
  5495. b?: number);
  5496. /**
  5497. * Creates a string with the Color3 current values
  5498. * @returns the string representation of the Color3 object
  5499. */
  5500. toString(): string;
  5501. /**
  5502. * Returns the string "Color3"
  5503. * @returns "Color3"
  5504. */
  5505. getClassName(): string;
  5506. /**
  5507. * Compute the Color3 hash code
  5508. * @returns an unique number that can be used to hash Color3 objects
  5509. */
  5510. getHashCode(): number;
  5511. /**
  5512. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5513. * @param array defines the array where to store the r,g,b components
  5514. * @param index defines an optional index in the target array to define where to start storing values
  5515. * @returns the current Color3 object
  5516. */
  5517. toArray(array: FloatArray, index?: number): Color3;
  5518. /**
  5519. * Returns a new Color4 object from the current Color3 and the given alpha
  5520. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5521. * @returns a new Color4 object
  5522. */
  5523. toColor4(alpha?: number): Color4;
  5524. /**
  5525. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5526. * @returns the new array
  5527. */
  5528. asArray(): number[];
  5529. /**
  5530. * Returns the luminance value
  5531. * @returns a float value
  5532. */
  5533. toLuminance(): number;
  5534. /**
  5535. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5536. * @param otherColor defines the second operand
  5537. * @returns the new Color3 object
  5538. */
  5539. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5540. /**
  5541. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5542. * @param otherColor defines the second operand
  5543. * @param result defines the Color3 object where to store the result
  5544. * @returns the current Color3
  5545. */
  5546. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5547. /**
  5548. * Determines equality between Color3 objects
  5549. * @param otherColor defines the second operand
  5550. * @returns true if the rgb values are equal to the given ones
  5551. */
  5552. equals(otherColor: DeepImmutable<Color3>): boolean;
  5553. /**
  5554. * Determines equality between the current Color3 object and a set of r,b,g values
  5555. * @param r defines the red component to check
  5556. * @param g defines the green component to check
  5557. * @param b defines the blue component to check
  5558. * @returns true if the rgb values are equal to the given ones
  5559. */
  5560. equalsFloats(r: number, g: number, b: number): boolean;
  5561. /**
  5562. * Multiplies in place each rgb value by scale
  5563. * @param scale defines the scaling factor
  5564. * @returns the updated Color3
  5565. */
  5566. scale(scale: number): Color3;
  5567. /**
  5568. * Multiplies the rgb values by scale and stores the result into "result"
  5569. * @param scale defines the scaling factor
  5570. * @param result defines the Color3 object where to store the result
  5571. * @returns the unmodified current Color3
  5572. */
  5573. scaleToRef(scale: number, result: Color3): Color3;
  5574. /**
  5575. * Scale the current Color3 values by a factor and add the result to a given Color3
  5576. * @param scale defines the scale factor
  5577. * @param result defines color to store the result into
  5578. * @returns the unmodified current Color3
  5579. */
  5580. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5581. /**
  5582. * Clamps the rgb values by the min and max values and stores the result into "result"
  5583. * @param min defines minimum clamping value (default is 0)
  5584. * @param max defines maximum clamping value (default is 1)
  5585. * @param result defines color to store the result into
  5586. * @returns the original Color3
  5587. */
  5588. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5589. /**
  5590. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5591. * @param otherColor defines the second operand
  5592. * @returns the new Color3
  5593. */
  5594. add(otherColor: DeepImmutable<Color3>): Color3;
  5595. /**
  5596. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5597. * @param otherColor defines the second operand
  5598. * @param result defines Color3 object to store the result into
  5599. * @returns the unmodified current Color3
  5600. */
  5601. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5602. /**
  5603. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5604. * @param otherColor defines the second operand
  5605. * @returns the new Color3
  5606. */
  5607. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5608. /**
  5609. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5610. * @param otherColor defines the second operand
  5611. * @param result defines Color3 object to store the result into
  5612. * @returns the unmodified current Color3
  5613. */
  5614. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5615. /**
  5616. * Copy the current object
  5617. * @returns a new Color3 copied the current one
  5618. */
  5619. clone(): Color3;
  5620. /**
  5621. * Copies the rgb values from the source in the current Color3
  5622. * @param source defines the source Color3 object
  5623. * @returns the updated Color3 object
  5624. */
  5625. copyFrom(source: DeepImmutable<Color3>): Color3;
  5626. /**
  5627. * Updates the Color3 rgb values from the given floats
  5628. * @param r defines the red component to read from
  5629. * @param g defines the green component to read from
  5630. * @param b defines the blue component to read from
  5631. * @returns the current Color3 object
  5632. */
  5633. copyFromFloats(r: number, g: number, b: number): Color3;
  5634. /**
  5635. * Updates the Color3 rgb values from the given floats
  5636. * @param r defines the red component to read from
  5637. * @param g defines the green component to read from
  5638. * @param b defines the blue component to read from
  5639. * @returns the current Color3 object
  5640. */
  5641. set(r: number, g: number, b: number): Color3;
  5642. /**
  5643. * Compute the Color3 hexadecimal code as a string
  5644. * @returns a string containing the hexadecimal representation of the Color3 object
  5645. */
  5646. toHexString(): string;
  5647. /**
  5648. * Computes a new Color3 converted from the current one to linear space
  5649. * @returns a new Color3 object
  5650. */
  5651. toLinearSpace(): Color3;
  5652. /**
  5653. * Converts current color in rgb space to HSV values
  5654. * @returns a new color3 representing the HSV values
  5655. */
  5656. toHSV(): Color3;
  5657. /**
  5658. * Converts current color in rgb space to HSV values
  5659. * @param result defines the Color3 where to store the HSV values
  5660. */
  5661. toHSVToRef(result: Color3): void;
  5662. /**
  5663. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5664. * @param convertedColor defines the Color3 object where to store the linear space version
  5665. * @returns the unmodified Color3
  5666. */
  5667. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5668. /**
  5669. * Computes a new Color3 converted from the current one to gamma space
  5670. * @returns a new Color3 object
  5671. */
  5672. toGammaSpace(): Color3;
  5673. /**
  5674. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5675. * @param convertedColor defines the Color3 object where to store the gamma space version
  5676. * @returns the unmodified Color3
  5677. */
  5678. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5679. private static _BlackReadOnly;
  5680. /**
  5681. * Convert Hue, saturation and value to a Color3 (RGB)
  5682. * @param hue defines the hue
  5683. * @param saturation defines the saturation
  5684. * @param value defines the value
  5685. * @param result defines the Color3 where to store the RGB values
  5686. */
  5687. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5688. /**
  5689. * Creates a new Color3 from the string containing valid hexadecimal values
  5690. * @param hex defines a string containing valid hexadecimal values
  5691. * @returns a new Color3 object
  5692. */
  5693. static FromHexString(hex: string): Color3;
  5694. /**
  5695. * Creates a new Color3 from the starting index of the given array
  5696. * @param array defines the source array
  5697. * @param offset defines an offset in the source array
  5698. * @returns a new Color3 object
  5699. */
  5700. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5701. /**
  5702. * Creates a new Color3 from integer values (< 256)
  5703. * @param r defines the red component to read from (value between 0 and 255)
  5704. * @param g defines the green component to read from (value between 0 and 255)
  5705. * @param b defines the blue component to read from (value between 0 and 255)
  5706. * @returns a new Color3 object
  5707. */
  5708. static FromInts(r: number, g: number, b: number): Color3;
  5709. /**
  5710. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5711. * @param start defines the start Color3 value
  5712. * @param end defines the end Color3 value
  5713. * @param amount defines the gradient value between start and end
  5714. * @returns a new Color3 object
  5715. */
  5716. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5717. /**
  5718. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5719. * @param left defines the start value
  5720. * @param right defines the end value
  5721. * @param amount defines the gradient factor
  5722. * @param result defines the Color3 object where to store the result
  5723. */
  5724. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5725. /**
  5726. * Returns a Color3 value containing a red color
  5727. * @returns a new Color3 object
  5728. */
  5729. static Red(): Color3;
  5730. /**
  5731. * Returns a Color3 value containing a green color
  5732. * @returns a new Color3 object
  5733. */
  5734. static Green(): Color3;
  5735. /**
  5736. * Returns a Color3 value containing a blue color
  5737. * @returns a new Color3 object
  5738. */
  5739. static Blue(): Color3;
  5740. /**
  5741. * Returns a Color3 value containing a black color
  5742. * @returns a new Color3 object
  5743. */
  5744. static Black(): Color3;
  5745. /**
  5746. * Gets a Color3 value containing a black color that must not be updated
  5747. */
  5748. static get BlackReadOnly(): DeepImmutable<Color3>;
  5749. /**
  5750. * Returns a Color3 value containing a white color
  5751. * @returns a new Color3 object
  5752. */
  5753. static White(): Color3;
  5754. /**
  5755. * Returns a Color3 value containing a purple color
  5756. * @returns a new Color3 object
  5757. */
  5758. static Purple(): Color3;
  5759. /**
  5760. * Returns a Color3 value containing a magenta color
  5761. * @returns a new Color3 object
  5762. */
  5763. static Magenta(): Color3;
  5764. /**
  5765. * Returns a Color3 value containing a yellow color
  5766. * @returns a new Color3 object
  5767. */
  5768. static Yellow(): Color3;
  5769. /**
  5770. * Returns a Color3 value containing a gray color
  5771. * @returns a new Color3 object
  5772. */
  5773. static Gray(): Color3;
  5774. /**
  5775. * Returns a Color3 value containing a teal color
  5776. * @returns a new Color3 object
  5777. */
  5778. static Teal(): Color3;
  5779. /**
  5780. * Returns a Color3 value containing a random color
  5781. * @returns a new Color3 object
  5782. */
  5783. static Random(): Color3;
  5784. }
  5785. /**
  5786. * Class used to hold a RBGA color
  5787. */
  5788. export class Color4 {
  5789. /**
  5790. * Defines the red component (between 0 and 1, default is 0)
  5791. */
  5792. r: number;
  5793. /**
  5794. * Defines the green component (between 0 and 1, default is 0)
  5795. */
  5796. g: number;
  5797. /**
  5798. * Defines the blue component (between 0 and 1, default is 0)
  5799. */
  5800. b: number;
  5801. /**
  5802. * Defines the alpha component (between 0 and 1, default is 1)
  5803. */
  5804. a: number;
  5805. /**
  5806. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5807. * @param r defines the red component (between 0 and 1, default is 0)
  5808. * @param g defines the green component (between 0 and 1, default is 0)
  5809. * @param b defines the blue component (between 0 and 1, default is 0)
  5810. * @param a defines the alpha component (between 0 and 1, default is 1)
  5811. */
  5812. constructor(
  5813. /**
  5814. * Defines the red component (between 0 and 1, default is 0)
  5815. */
  5816. r?: number,
  5817. /**
  5818. * Defines the green component (between 0 and 1, default is 0)
  5819. */
  5820. g?: number,
  5821. /**
  5822. * Defines the blue component (between 0 and 1, default is 0)
  5823. */
  5824. b?: number,
  5825. /**
  5826. * Defines the alpha component (between 0 and 1, default is 1)
  5827. */
  5828. a?: number);
  5829. /**
  5830. * Adds in place the given Color4 values to the current Color4 object
  5831. * @param right defines the second operand
  5832. * @returns the current updated Color4 object
  5833. */
  5834. addInPlace(right: DeepImmutable<Color4>): Color4;
  5835. /**
  5836. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5837. * @returns the new array
  5838. */
  5839. asArray(): number[];
  5840. /**
  5841. * Stores from the starting index in the given array the Color4 successive values
  5842. * @param array defines the array where to store the r,g,b components
  5843. * @param index defines an optional index in the target array to define where to start storing values
  5844. * @returns the current Color4 object
  5845. */
  5846. toArray(array: number[], index?: number): Color4;
  5847. /**
  5848. * Determines equality between Color4 objects
  5849. * @param otherColor defines the second operand
  5850. * @returns true if the rgba values are equal to the given ones
  5851. */
  5852. equals(otherColor: DeepImmutable<Color4>): boolean;
  5853. /**
  5854. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5855. * @param right defines the second operand
  5856. * @returns a new Color4 object
  5857. */
  5858. add(right: DeepImmutable<Color4>): Color4;
  5859. /**
  5860. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5861. * @param right defines the second operand
  5862. * @returns a new Color4 object
  5863. */
  5864. subtract(right: DeepImmutable<Color4>): Color4;
  5865. /**
  5866. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5867. * @param right defines the second operand
  5868. * @param result defines the Color4 object where to store the result
  5869. * @returns the current Color4 object
  5870. */
  5871. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5872. /**
  5873. * Creates a new Color4 with the current Color4 values multiplied by scale
  5874. * @param scale defines the scaling factor to apply
  5875. * @returns a new Color4 object
  5876. */
  5877. scale(scale: number): Color4;
  5878. /**
  5879. * Multiplies the current Color4 values by scale and stores the result in "result"
  5880. * @param scale defines the scaling factor to apply
  5881. * @param result defines the Color4 object where to store the result
  5882. * @returns the current unmodified Color4
  5883. */
  5884. scaleToRef(scale: number, result: Color4): Color4;
  5885. /**
  5886. * Scale the current Color4 values by a factor and add the result to a given Color4
  5887. * @param scale defines the scale factor
  5888. * @param result defines the Color4 object where to store the result
  5889. * @returns the unmodified current Color4
  5890. */
  5891. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5892. /**
  5893. * Clamps the rgb values by the min and max values and stores the result into "result"
  5894. * @param min defines minimum clamping value (default is 0)
  5895. * @param max defines maximum clamping value (default is 1)
  5896. * @param result defines color to store the result into.
  5897. * @returns the cuurent Color4
  5898. */
  5899. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5900. /**
  5901. * Multipy an Color4 value by another and return a new Color4 object
  5902. * @param color defines the Color4 value to multiply by
  5903. * @returns a new Color4 object
  5904. */
  5905. multiply(color: Color4): Color4;
  5906. /**
  5907. * Multipy a Color4 value by another and push the result in a reference value
  5908. * @param color defines the Color4 value to multiply by
  5909. * @param result defines the Color4 to fill the result in
  5910. * @returns the result Color4
  5911. */
  5912. multiplyToRef(color: Color4, result: Color4): Color4;
  5913. /**
  5914. * Creates a string with the Color4 current values
  5915. * @returns the string representation of the Color4 object
  5916. */
  5917. toString(): string;
  5918. /**
  5919. * Returns the string "Color4"
  5920. * @returns "Color4"
  5921. */
  5922. getClassName(): string;
  5923. /**
  5924. * Compute the Color4 hash code
  5925. * @returns an unique number that can be used to hash Color4 objects
  5926. */
  5927. getHashCode(): number;
  5928. /**
  5929. * Creates a new Color4 copied from the current one
  5930. * @returns a new Color4 object
  5931. */
  5932. clone(): Color4;
  5933. /**
  5934. * Copies the given Color4 values into the current one
  5935. * @param source defines the source Color4 object
  5936. * @returns the current updated Color4 object
  5937. */
  5938. copyFrom(source: Color4): Color4;
  5939. /**
  5940. * Copies the given float values into the current one
  5941. * @param r defines the red component to read from
  5942. * @param g defines the green component to read from
  5943. * @param b defines the blue component to read from
  5944. * @param a defines the alpha component to read from
  5945. * @returns the current updated Color4 object
  5946. */
  5947. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5948. /**
  5949. * Copies the given float values into the current one
  5950. * @param r defines the red component to read from
  5951. * @param g defines the green component to read from
  5952. * @param b defines the blue component to read from
  5953. * @param a defines the alpha component to read from
  5954. * @returns the current updated Color4 object
  5955. */
  5956. set(r: number, g: number, b: number, a: number): Color4;
  5957. /**
  5958. * Compute the Color4 hexadecimal code as a string
  5959. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  5960. * @returns a string containing the hexadecimal representation of the Color4 object
  5961. */
  5962. toHexString(returnAsColor3?: boolean): string;
  5963. /**
  5964. * Computes a new Color4 converted from the current one to linear space
  5965. * @returns a new Color4 object
  5966. */
  5967. toLinearSpace(): Color4;
  5968. /**
  5969. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5970. * @param convertedColor defines the Color4 object where to store the linear space version
  5971. * @returns the unmodified Color4
  5972. */
  5973. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5974. /**
  5975. * Computes a new Color4 converted from the current one to gamma space
  5976. * @returns a new Color4 object
  5977. */
  5978. toGammaSpace(): Color4;
  5979. /**
  5980. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5981. * @param convertedColor defines the Color4 object where to store the gamma space version
  5982. * @returns the unmodified Color4
  5983. */
  5984. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5985. /**
  5986. * Creates a new Color4 from the string containing valid hexadecimal values
  5987. * @param hex defines a string containing valid hexadecimal values
  5988. * @returns a new Color4 object
  5989. */
  5990. static FromHexString(hex: string): Color4;
  5991. /**
  5992. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5993. * @param left defines the start value
  5994. * @param right defines the end value
  5995. * @param amount defines the gradient factor
  5996. * @returns a new Color4 object
  5997. */
  5998. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5999. /**
  6000. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6001. * @param left defines the start value
  6002. * @param right defines the end value
  6003. * @param amount defines the gradient factor
  6004. * @param result defines the Color4 object where to store data
  6005. */
  6006. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  6007. /**
  6008. * Creates a new Color4 from a Color3 and an alpha value
  6009. * @param color3 defines the source Color3 to read from
  6010. * @param alpha defines the alpha component (1.0 by default)
  6011. * @returns a new Color4 object
  6012. */
  6013. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  6014. /**
  6015. * Creates a new Color4 from the starting index element of the given array
  6016. * @param array defines the source array to read from
  6017. * @param offset defines the offset in the source array
  6018. * @returns a new Color4 object
  6019. */
  6020. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6021. /**
  6022. * Creates a new Color3 from integer values (< 256)
  6023. * @param r defines the red component to read from (value between 0 and 255)
  6024. * @param g defines the green component to read from (value between 0 and 255)
  6025. * @param b defines the blue component to read from (value between 0 and 255)
  6026. * @param a defines the alpha component to read from (value between 0 and 255)
  6027. * @returns a new Color3 object
  6028. */
  6029. static FromInts(r: number, g: number, b: number, a: number): Color4;
  6030. /**
  6031. * Check the content of a given array and convert it to an array containing RGBA data
  6032. * If the original array was already containing count * 4 values then it is returned directly
  6033. * @param colors defines the array to check
  6034. * @param count defines the number of RGBA data to expect
  6035. * @returns an array containing count * 4 values (RGBA)
  6036. */
  6037. static CheckColors4(colors: number[], count: number): number[];
  6038. }
  6039. /**
  6040. * @hidden
  6041. */
  6042. export class TmpColors {
  6043. static Color3: Color3[];
  6044. static Color4: Color4[];
  6045. }
  6046. }
  6047. declare module "babylonjs/Animations/animationKey" {
  6048. /**
  6049. * Defines an interface which represents an animation key frame
  6050. */
  6051. export interface IAnimationKey {
  6052. /**
  6053. * Frame of the key frame
  6054. */
  6055. frame: number;
  6056. /**
  6057. * Value at the specifies key frame
  6058. */
  6059. value: any;
  6060. /**
  6061. * The input tangent for the cubic hermite spline
  6062. */
  6063. inTangent?: any;
  6064. /**
  6065. * The output tangent for the cubic hermite spline
  6066. */
  6067. outTangent?: any;
  6068. /**
  6069. * The animation interpolation type
  6070. */
  6071. interpolation?: AnimationKeyInterpolation;
  6072. }
  6073. /**
  6074. * Enum for the animation key frame interpolation type
  6075. */
  6076. export enum AnimationKeyInterpolation {
  6077. /**
  6078. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6079. */
  6080. STEP = 1
  6081. }
  6082. }
  6083. declare module "babylonjs/Animations/animationRange" {
  6084. /**
  6085. * Represents the range of an animation
  6086. */
  6087. export class AnimationRange {
  6088. /**The name of the animation range**/
  6089. name: string;
  6090. /**The starting frame of the animation */
  6091. from: number;
  6092. /**The ending frame of the animation*/
  6093. to: number;
  6094. /**
  6095. * Initializes the range of an animation
  6096. * @param name The name of the animation range
  6097. * @param from The starting frame of the animation
  6098. * @param to The ending frame of the animation
  6099. */
  6100. constructor(
  6101. /**The name of the animation range**/
  6102. name: string,
  6103. /**The starting frame of the animation */
  6104. from: number,
  6105. /**The ending frame of the animation*/
  6106. to: number);
  6107. /**
  6108. * Makes a copy of the animation range
  6109. * @returns A copy of the animation range
  6110. */
  6111. clone(): AnimationRange;
  6112. }
  6113. }
  6114. declare module "babylonjs/Animations/animationEvent" {
  6115. /**
  6116. * Composed of a frame, and an action function
  6117. */
  6118. export class AnimationEvent {
  6119. /** The frame for which the event is triggered **/
  6120. frame: number;
  6121. /** The event to perform when triggered **/
  6122. action: (currentFrame: number) => void;
  6123. /** Specifies if the event should be triggered only once**/
  6124. onlyOnce?: boolean | undefined;
  6125. /**
  6126. * Specifies if the animation event is done
  6127. */
  6128. isDone: boolean;
  6129. /**
  6130. * Initializes the animation event
  6131. * @param frame The frame for which the event is triggered
  6132. * @param action The event to perform when triggered
  6133. * @param onlyOnce Specifies if the event should be triggered only once
  6134. */
  6135. constructor(
  6136. /** The frame for which the event is triggered **/
  6137. frame: number,
  6138. /** The event to perform when triggered **/
  6139. action: (currentFrame: number) => void,
  6140. /** Specifies if the event should be triggered only once**/
  6141. onlyOnce?: boolean | undefined);
  6142. /** @hidden */
  6143. _clone(): AnimationEvent;
  6144. }
  6145. }
  6146. declare module "babylonjs/Behaviors/behavior" {
  6147. import { Nullable } from "babylonjs/types";
  6148. /**
  6149. * Interface used to define a behavior
  6150. */
  6151. export interface Behavior<T> {
  6152. /** gets or sets behavior's name */
  6153. name: string;
  6154. /**
  6155. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6156. */
  6157. init(): void;
  6158. /**
  6159. * Called when the behavior is attached to a target
  6160. * @param target defines the target where the behavior is attached to
  6161. */
  6162. attach(target: T): void;
  6163. /**
  6164. * Called when the behavior is detached from its target
  6165. */
  6166. detach(): void;
  6167. }
  6168. /**
  6169. * Interface implemented by classes supporting behaviors
  6170. */
  6171. export interface IBehaviorAware<T> {
  6172. /**
  6173. * Attach a behavior
  6174. * @param behavior defines the behavior to attach
  6175. * @returns the current host
  6176. */
  6177. addBehavior(behavior: Behavior<T>): T;
  6178. /**
  6179. * Remove a behavior from the current object
  6180. * @param behavior defines the behavior to detach
  6181. * @returns the current host
  6182. */
  6183. removeBehavior(behavior: Behavior<T>): T;
  6184. /**
  6185. * Gets a behavior using its name to search
  6186. * @param name defines the name to search
  6187. * @returns the behavior or null if not found
  6188. */
  6189. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6190. }
  6191. }
  6192. declare module "babylonjs/Misc/smartArray" {
  6193. /**
  6194. * Defines an array and its length.
  6195. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6196. */
  6197. export interface ISmartArrayLike<T> {
  6198. /**
  6199. * The data of the array.
  6200. */
  6201. data: Array<T>;
  6202. /**
  6203. * The active length of the array.
  6204. */
  6205. length: number;
  6206. }
  6207. /**
  6208. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6209. */
  6210. export class SmartArray<T> implements ISmartArrayLike<T> {
  6211. /**
  6212. * The full set of data from the array.
  6213. */
  6214. data: Array<T>;
  6215. /**
  6216. * The active length of the array.
  6217. */
  6218. length: number;
  6219. protected _id: number;
  6220. /**
  6221. * Instantiates a Smart Array.
  6222. * @param capacity defines the default capacity of the array.
  6223. */
  6224. constructor(capacity: number);
  6225. /**
  6226. * Pushes a value at the end of the active data.
  6227. * @param value defines the object to push in the array.
  6228. */
  6229. push(value: T): void;
  6230. /**
  6231. * Iterates over the active data and apply the lambda to them.
  6232. * @param func defines the action to apply on each value.
  6233. */
  6234. forEach(func: (content: T) => void): void;
  6235. /**
  6236. * Sorts the full sets of data.
  6237. * @param compareFn defines the comparison function to apply.
  6238. */
  6239. sort(compareFn: (a: T, b: T) => number): void;
  6240. /**
  6241. * Resets the active data to an empty array.
  6242. */
  6243. reset(): void;
  6244. /**
  6245. * Releases all the data from the array as well as the array.
  6246. */
  6247. dispose(): void;
  6248. /**
  6249. * Concats the active data with a given array.
  6250. * @param array defines the data to concatenate with.
  6251. */
  6252. concat(array: any): void;
  6253. /**
  6254. * Returns the position of a value in the active data.
  6255. * @param value defines the value to find the index for
  6256. * @returns the index if found in the active data otherwise -1
  6257. */
  6258. indexOf(value: T): number;
  6259. /**
  6260. * Returns whether an element is part of the active data.
  6261. * @param value defines the value to look for
  6262. * @returns true if found in the active data otherwise false
  6263. */
  6264. contains(value: T): boolean;
  6265. private static _GlobalId;
  6266. }
  6267. /**
  6268. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6269. * The data in this array can only be present once
  6270. */
  6271. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6272. private _duplicateId;
  6273. /**
  6274. * Pushes a value at the end of the active data.
  6275. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6276. * @param value defines the object to push in the array.
  6277. */
  6278. push(value: T): void;
  6279. /**
  6280. * Pushes a value at the end of the active data.
  6281. * If the data is already present, it won t be added again
  6282. * @param value defines the object to push in the array.
  6283. * @returns true if added false if it was already present
  6284. */
  6285. pushNoDuplicate(value: T): boolean;
  6286. /**
  6287. * Resets the active data to an empty array.
  6288. */
  6289. reset(): void;
  6290. /**
  6291. * Concats the active data with a given array.
  6292. * This ensures no dupplicate will be present in the result.
  6293. * @param array defines the data to concatenate with.
  6294. */
  6295. concatWithNoDuplicate(array: any): void;
  6296. }
  6297. }
  6298. declare module "babylonjs/Cameras/cameraInputsManager" {
  6299. import { Nullable } from "babylonjs/types";
  6300. import { Camera } from "babylonjs/Cameras/camera";
  6301. /**
  6302. * @ignore
  6303. * This is a list of all the different input types that are available in the application.
  6304. * Fo instance: ArcRotateCameraGamepadInput...
  6305. */
  6306. export var CameraInputTypes: {};
  6307. /**
  6308. * This is the contract to implement in order to create a new input class.
  6309. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6310. */
  6311. export interface ICameraInput<TCamera extends Camera> {
  6312. /**
  6313. * Defines the camera the input is attached to.
  6314. */
  6315. camera: Nullable<TCamera>;
  6316. /**
  6317. * Gets the class name of the current intput.
  6318. * @returns the class name
  6319. */
  6320. getClassName(): string;
  6321. /**
  6322. * Get the friendly name associated with the input class.
  6323. * @returns the input friendly name
  6324. */
  6325. getSimpleName(): string;
  6326. /**
  6327. * Attach the input controls to a specific dom element to get the input from.
  6328. * @param element Defines the element the controls should be listened from
  6329. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6330. */
  6331. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6332. /**
  6333. * Detach the current controls from the specified dom element.
  6334. * @param element Defines the element to stop listening the inputs from
  6335. */
  6336. detachControl(element: Nullable<HTMLElement>): void;
  6337. /**
  6338. * Update the current camera state depending on the inputs that have been used this frame.
  6339. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6340. */
  6341. checkInputs?: () => void;
  6342. }
  6343. /**
  6344. * Represents a map of input types to input instance or input index to input instance.
  6345. */
  6346. export interface CameraInputsMap<TCamera extends Camera> {
  6347. /**
  6348. * Accessor to the input by input type.
  6349. */
  6350. [name: string]: ICameraInput<TCamera>;
  6351. /**
  6352. * Accessor to the input by input index.
  6353. */
  6354. [idx: number]: ICameraInput<TCamera>;
  6355. }
  6356. /**
  6357. * This represents the input manager used within a camera.
  6358. * It helps dealing with all the different kind of input attached to a camera.
  6359. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6360. */
  6361. export class CameraInputsManager<TCamera extends Camera> {
  6362. /**
  6363. * Defines the list of inputs attahed to the camera.
  6364. */
  6365. attached: CameraInputsMap<TCamera>;
  6366. /**
  6367. * Defines the dom element the camera is collecting inputs from.
  6368. * This is null if the controls have not been attached.
  6369. */
  6370. attachedElement: Nullable<HTMLElement>;
  6371. /**
  6372. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6373. */
  6374. noPreventDefault: boolean;
  6375. /**
  6376. * Defined the camera the input manager belongs to.
  6377. */
  6378. camera: TCamera;
  6379. /**
  6380. * Update the current camera state depending on the inputs that have been used this frame.
  6381. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6382. */
  6383. checkInputs: () => void;
  6384. /**
  6385. * Instantiate a new Camera Input Manager.
  6386. * @param camera Defines the camera the input manager blongs to
  6387. */
  6388. constructor(camera: TCamera);
  6389. /**
  6390. * Add an input method to a camera
  6391. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6392. * @param input camera input method
  6393. */
  6394. add(input: ICameraInput<TCamera>): void;
  6395. /**
  6396. * Remove a specific input method from a camera
  6397. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6398. * @param inputToRemove camera input method
  6399. */
  6400. remove(inputToRemove: ICameraInput<TCamera>): void;
  6401. /**
  6402. * Remove a specific input type from a camera
  6403. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6404. * @param inputType the type of the input to remove
  6405. */
  6406. removeByType(inputType: string): void;
  6407. private _addCheckInputs;
  6408. /**
  6409. * Attach the input controls to the currently attached dom element to listen the events from.
  6410. * @param input Defines the input to attach
  6411. */
  6412. attachInput(input: ICameraInput<TCamera>): void;
  6413. /**
  6414. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6415. * @param element Defines the dom element to collect the events from
  6416. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6417. */
  6418. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6419. /**
  6420. * Detach the current manager inputs controls from a specific dom element.
  6421. * @param element Defines the dom element to collect the events from
  6422. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6423. */
  6424. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6425. /**
  6426. * Rebuild the dynamic inputCheck function from the current list of
  6427. * defined inputs in the manager.
  6428. */
  6429. rebuildInputCheck(): void;
  6430. /**
  6431. * Remove all attached input methods from a camera
  6432. */
  6433. clear(): void;
  6434. /**
  6435. * Serialize the current input manager attached to a camera.
  6436. * This ensures than once parsed,
  6437. * the input associated to the camera will be identical to the current ones
  6438. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6439. */
  6440. serialize(serializedCamera: any): void;
  6441. /**
  6442. * Parses an input manager serialized JSON to restore the previous list of inputs
  6443. * and states associated to a camera.
  6444. * @param parsedCamera Defines the JSON to parse
  6445. */
  6446. parse(parsedCamera: any): void;
  6447. }
  6448. }
  6449. declare module "babylonjs/Meshes/buffer" {
  6450. import { Nullable, DataArray } from "babylonjs/types";
  6451. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  6452. /**
  6453. * Class used to store data that will be store in GPU memory
  6454. */
  6455. export class Buffer {
  6456. private _engine;
  6457. private _buffer;
  6458. /** @hidden */
  6459. _data: Nullable<DataArray>;
  6460. private _updatable;
  6461. private _instanced;
  6462. private _divisor;
  6463. /**
  6464. * Gets the byte stride.
  6465. */
  6466. readonly byteStride: number;
  6467. /**
  6468. * Constructor
  6469. * @param engine the engine
  6470. * @param data the data to use for this buffer
  6471. * @param updatable whether the data is updatable
  6472. * @param stride the stride (optional)
  6473. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6474. * @param instanced whether the buffer is instanced (optional)
  6475. * @param useBytes set to true if the stride in in bytes (optional)
  6476. * @param divisor sets an optional divisor for instances (1 by default)
  6477. */
  6478. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6479. /**
  6480. * Create a new VertexBuffer based on the current buffer
  6481. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6482. * @param offset defines offset in the buffer (0 by default)
  6483. * @param size defines the size in floats of attributes (position is 3 for instance)
  6484. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6485. * @param instanced defines if the vertex buffer contains indexed data
  6486. * @param useBytes defines if the offset and stride are in bytes *
  6487. * @param divisor sets an optional divisor for instances (1 by default)
  6488. * @returns the new vertex buffer
  6489. */
  6490. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6491. /**
  6492. * Gets a boolean indicating if the Buffer is updatable?
  6493. * @returns true if the buffer is updatable
  6494. */
  6495. isUpdatable(): boolean;
  6496. /**
  6497. * Gets current buffer's data
  6498. * @returns a DataArray or null
  6499. */
  6500. getData(): Nullable<DataArray>;
  6501. /**
  6502. * Gets underlying native buffer
  6503. * @returns underlying native buffer
  6504. */
  6505. getBuffer(): Nullable<DataBuffer>;
  6506. /**
  6507. * Gets the stride in float32 units (i.e. byte stride / 4).
  6508. * May not be an integer if the byte stride is not divisible by 4.
  6509. * @returns the stride in float32 units
  6510. * @deprecated Please use byteStride instead.
  6511. */
  6512. getStrideSize(): number;
  6513. /**
  6514. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6515. * @param data defines the data to store
  6516. */
  6517. create(data?: Nullable<DataArray>): void;
  6518. /** @hidden */
  6519. _rebuild(): void;
  6520. /**
  6521. * Update current buffer data
  6522. * @param data defines the data to store
  6523. */
  6524. update(data: DataArray): void;
  6525. /**
  6526. * Updates the data directly.
  6527. * @param data the new data
  6528. * @param offset the new offset
  6529. * @param vertexCount the vertex count (optional)
  6530. * @param useBytes set to true if the offset is in bytes
  6531. */
  6532. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6533. /**
  6534. * Release all resources
  6535. */
  6536. dispose(): void;
  6537. }
  6538. /**
  6539. * Specialized buffer used to store vertex data
  6540. */
  6541. export class VertexBuffer {
  6542. /** @hidden */
  6543. _buffer: Buffer;
  6544. private _kind;
  6545. private _size;
  6546. private _ownsBuffer;
  6547. private _instanced;
  6548. private _instanceDivisor;
  6549. /**
  6550. * The byte type.
  6551. */
  6552. static readonly BYTE: number;
  6553. /**
  6554. * The unsigned byte type.
  6555. */
  6556. static readonly UNSIGNED_BYTE: number;
  6557. /**
  6558. * The short type.
  6559. */
  6560. static readonly SHORT: number;
  6561. /**
  6562. * The unsigned short type.
  6563. */
  6564. static readonly UNSIGNED_SHORT: number;
  6565. /**
  6566. * The integer type.
  6567. */
  6568. static readonly INT: number;
  6569. /**
  6570. * The unsigned integer type.
  6571. */
  6572. static readonly UNSIGNED_INT: number;
  6573. /**
  6574. * The float type.
  6575. */
  6576. static readonly FLOAT: number;
  6577. /**
  6578. * Gets or sets the instance divisor when in instanced mode
  6579. */
  6580. get instanceDivisor(): number;
  6581. set instanceDivisor(value: number);
  6582. /**
  6583. * Gets the byte stride.
  6584. */
  6585. readonly byteStride: number;
  6586. /**
  6587. * Gets the byte offset.
  6588. */
  6589. readonly byteOffset: number;
  6590. /**
  6591. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6592. */
  6593. readonly normalized: boolean;
  6594. /**
  6595. * Gets the data type of each component in the array.
  6596. */
  6597. readonly type: number;
  6598. /**
  6599. * Constructor
  6600. * @param engine the engine
  6601. * @param data the data to use for this vertex buffer
  6602. * @param kind the vertex buffer kind
  6603. * @param updatable whether the data is updatable
  6604. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6605. * @param stride the stride (optional)
  6606. * @param instanced whether the buffer is instanced (optional)
  6607. * @param offset the offset of the data (optional)
  6608. * @param size the number of components (optional)
  6609. * @param type the type of the component (optional)
  6610. * @param normalized whether the data contains normalized data (optional)
  6611. * @param useBytes set to true if stride and offset are in bytes (optional)
  6612. * @param divisor defines the instance divisor to use (1 by default)
  6613. */
  6614. constructor(engine: any, data: DataArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number, type?: number, normalized?: boolean, useBytes?: boolean, divisor?: number);
  6615. /** @hidden */
  6616. _rebuild(): void;
  6617. /**
  6618. * Returns the kind of the VertexBuffer (string)
  6619. * @returns a string
  6620. */
  6621. getKind(): string;
  6622. /**
  6623. * Gets a boolean indicating if the VertexBuffer is updatable?
  6624. * @returns true if the buffer is updatable
  6625. */
  6626. isUpdatable(): boolean;
  6627. /**
  6628. * Gets current buffer's data
  6629. * @returns a DataArray or null
  6630. */
  6631. getData(): Nullable<DataArray>;
  6632. /**
  6633. * Gets underlying native buffer
  6634. * @returns underlying native buffer
  6635. */
  6636. getBuffer(): Nullable<DataBuffer>;
  6637. /**
  6638. * Gets the stride in float32 units (i.e. byte stride / 4).
  6639. * May not be an integer if the byte stride is not divisible by 4.
  6640. * @returns the stride in float32 units
  6641. * @deprecated Please use byteStride instead.
  6642. */
  6643. getStrideSize(): number;
  6644. /**
  6645. * Returns the offset as a multiple of the type byte length.
  6646. * @returns the offset in bytes
  6647. * @deprecated Please use byteOffset instead.
  6648. */
  6649. getOffset(): number;
  6650. /**
  6651. * Returns the number of components per vertex attribute (integer)
  6652. * @returns the size in float
  6653. */
  6654. getSize(): number;
  6655. /**
  6656. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6657. * @returns true if this buffer is instanced
  6658. */
  6659. getIsInstanced(): boolean;
  6660. /**
  6661. * Returns the instancing divisor, zero for non-instanced (integer).
  6662. * @returns a number
  6663. */
  6664. getInstanceDivisor(): number;
  6665. /**
  6666. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6667. * @param data defines the data to store
  6668. */
  6669. create(data?: DataArray): void;
  6670. /**
  6671. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6672. * This function will create a new buffer if the current one is not updatable
  6673. * @param data defines the data to store
  6674. */
  6675. update(data: DataArray): void;
  6676. /**
  6677. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6678. * Returns the directly updated WebGLBuffer.
  6679. * @param data the new data
  6680. * @param offset the new offset
  6681. * @param useBytes set to true if the offset is in bytes
  6682. */
  6683. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6684. /**
  6685. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6686. */
  6687. dispose(): void;
  6688. /**
  6689. * Enumerates each value of this vertex buffer as numbers.
  6690. * @param count the number of values to enumerate
  6691. * @param callback the callback function called for each value
  6692. */
  6693. forEach(count: number, callback: (value: number, index: number) => void): void;
  6694. /**
  6695. * Positions
  6696. */
  6697. static readonly PositionKind: string;
  6698. /**
  6699. * Normals
  6700. */
  6701. static readonly NormalKind: string;
  6702. /**
  6703. * Tangents
  6704. */
  6705. static readonly TangentKind: string;
  6706. /**
  6707. * Texture coordinates
  6708. */
  6709. static readonly UVKind: string;
  6710. /**
  6711. * Texture coordinates 2
  6712. */
  6713. static readonly UV2Kind: string;
  6714. /**
  6715. * Texture coordinates 3
  6716. */
  6717. static readonly UV3Kind: string;
  6718. /**
  6719. * Texture coordinates 4
  6720. */
  6721. static readonly UV4Kind: string;
  6722. /**
  6723. * Texture coordinates 5
  6724. */
  6725. static readonly UV5Kind: string;
  6726. /**
  6727. * Texture coordinates 6
  6728. */
  6729. static readonly UV6Kind: string;
  6730. /**
  6731. * Colors
  6732. */
  6733. static readonly ColorKind: string;
  6734. /**
  6735. * Matrix indices (for bones)
  6736. */
  6737. static readonly MatricesIndicesKind: string;
  6738. /**
  6739. * Matrix weights (for bones)
  6740. */
  6741. static readonly MatricesWeightsKind: string;
  6742. /**
  6743. * Additional matrix indices (for bones)
  6744. */
  6745. static readonly MatricesIndicesExtraKind: string;
  6746. /**
  6747. * Additional matrix weights (for bones)
  6748. */
  6749. static readonly MatricesWeightsExtraKind: string;
  6750. /**
  6751. * Deduces the stride given a kind.
  6752. * @param kind The kind string to deduce
  6753. * @returns The deduced stride
  6754. */
  6755. static DeduceStride(kind: string): number;
  6756. /**
  6757. * Gets the byte length of the given type.
  6758. * @param type the type
  6759. * @returns the number of bytes
  6760. */
  6761. static GetTypeByteLength(type: number): number;
  6762. /**
  6763. * Enumerates each value of the given parameters as numbers.
  6764. * @param data the data to enumerate
  6765. * @param byteOffset the byte offset of the data
  6766. * @param byteStride the byte stride of the data
  6767. * @param componentCount the number of components per element
  6768. * @param componentType the type of the component
  6769. * @param count the number of values to enumerate
  6770. * @param normalized whether the data is normalized
  6771. * @param callback the callback function called for each value
  6772. */
  6773. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6774. private static _GetFloatValue;
  6775. }
  6776. }
  6777. declare module "babylonjs/Collisions/intersectionInfo" {
  6778. import { Nullable } from "babylonjs/types";
  6779. /**
  6780. * @hidden
  6781. */
  6782. export class IntersectionInfo {
  6783. bu: Nullable<number>;
  6784. bv: Nullable<number>;
  6785. distance: number;
  6786. faceId: number;
  6787. subMeshId: number;
  6788. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6789. }
  6790. }
  6791. declare module "babylonjs/Culling/boundingSphere" {
  6792. import { DeepImmutable } from "babylonjs/types";
  6793. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6794. import { Plane } from "babylonjs/Maths/math.plane";
  6795. /**
  6796. * Class used to store bounding sphere information
  6797. */
  6798. export class BoundingSphere {
  6799. /**
  6800. * Gets the center of the bounding sphere in local space
  6801. */
  6802. readonly center: Vector3;
  6803. /**
  6804. * Radius of the bounding sphere in local space
  6805. */
  6806. radius: number;
  6807. /**
  6808. * Gets the center of the bounding sphere in world space
  6809. */
  6810. readonly centerWorld: Vector3;
  6811. /**
  6812. * Radius of the bounding sphere in world space
  6813. */
  6814. radiusWorld: number;
  6815. /**
  6816. * Gets the minimum vector in local space
  6817. */
  6818. readonly minimum: Vector3;
  6819. /**
  6820. * Gets the maximum vector in local space
  6821. */
  6822. readonly maximum: Vector3;
  6823. private _worldMatrix;
  6824. private static readonly TmpVector3;
  6825. /**
  6826. * Creates a new bounding sphere
  6827. * @param min defines the minimum vector (in local space)
  6828. * @param max defines the maximum vector (in local space)
  6829. * @param worldMatrix defines the new world matrix
  6830. */
  6831. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6832. /**
  6833. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6834. * @param min defines the new minimum vector (in local space)
  6835. * @param max defines the new maximum vector (in local space)
  6836. * @param worldMatrix defines the new world matrix
  6837. */
  6838. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6839. /**
  6840. * Scale the current bounding sphere by applying a scale factor
  6841. * @param factor defines the scale factor to apply
  6842. * @returns the current bounding box
  6843. */
  6844. scale(factor: number): BoundingSphere;
  6845. /**
  6846. * Gets the world matrix of the bounding box
  6847. * @returns a matrix
  6848. */
  6849. getWorldMatrix(): DeepImmutable<Matrix>;
  6850. /** @hidden */
  6851. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6852. /**
  6853. * Tests if the bounding sphere is intersecting the frustum planes
  6854. * @param frustumPlanes defines the frustum planes to test
  6855. * @returns true if there is an intersection
  6856. */
  6857. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6858. /**
  6859. * Tests if the bounding sphere center is in between the frustum planes.
  6860. * Used for optimistic fast inclusion.
  6861. * @param frustumPlanes defines the frustum planes to test
  6862. * @returns true if the sphere center is in between the frustum planes
  6863. */
  6864. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6865. /**
  6866. * Tests if a point is inside the bounding sphere
  6867. * @param point defines the point to test
  6868. * @returns true if the point is inside the bounding sphere
  6869. */
  6870. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6871. /**
  6872. * Checks if two sphere intersct
  6873. * @param sphere0 sphere 0
  6874. * @param sphere1 sphere 1
  6875. * @returns true if the speres intersect
  6876. */
  6877. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6878. }
  6879. }
  6880. declare module "babylonjs/Culling/boundingBox" {
  6881. import { DeepImmutable } from "babylonjs/types";
  6882. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6883. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6884. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6885. import { Plane } from "babylonjs/Maths/math.plane";
  6886. /**
  6887. * Class used to store bounding box information
  6888. */
  6889. export class BoundingBox implements ICullable {
  6890. /**
  6891. * Gets the 8 vectors representing the bounding box in local space
  6892. */
  6893. readonly vectors: Vector3[];
  6894. /**
  6895. * Gets the center of the bounding box in local space
  6896. */
  6897. readonly center: Vector3;
  6898. /**
  6899. * Gets the center of the bounding box in world space
  6900. */
  6901. readonly centerWorld: Vector3;
  6902. /**
  6903. * Gets the extend size in local space
  6904. */
  6905. readonly extendSize: Vector3;
  6906. /**
  6907. * Gets the extend size in world space
  6908. */
  6909. readonly extendSizeWorld: Vector3;
  6910. /**
  6911. * Gets the OBB (object bounding box) directions
  6912. */
  6913. readonly directions: Vector3[];
  6914. /**
  6915. * Gets the 8 vectors representing the bounding box in world space
  6916. */
  6917. readonly vectorsWorld: Vector3[];
  6918. /**
  6919. * Gets the minimum vector in world space
  6920. */
  6921. readonly minimumWorld: Vector3;
  6922. /**
  6923. * Gets the maximum vector in world space
  6924. */
  6925. readonly maximumWorld: Vector3;
  6926. /**
  6927. * Gets the minimum vector in local space
  6928. */
  6929. readonly minimum: Vector3;
  6930. /**
  6931. * Gets the maximum vector in local space
  6932. */
  6933. readonly maximum: Vector3;
  6934. private _worldMatrix;
  6935. private static readonly TmpVector3;
  6936. /**
  6937. * @hidden
  6938. */
  6939. _tag: number;
  6940. /**
  6941. * Creates a new bounding box
  6942. * @param min defines the minimum vector (in local space)
  6943. * @param max defines the maximum vector (in local space)
  6944. * @param worldMatrix defines the new world matrix
  6945. */
  6946. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6947. /**
  6948. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6949. * @param min defines the new minimum vector (in local space)
  6950. * @param max defines the new maximum vector (in local space)
  6951. * @param worldMatrix defines the new world matrix
  6952. */
  6953. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6954. /**
  6955. * Scale the current bounding box by applying a scale factor
  6956. * @param factor defines the scale factor to apply
  6957. * @returns the current bounding box
  6958. */
  6959. scale(factor: number): BoundingBox;
  6960. /**
  6961. * Gets the world matrix of the bounding box
  6962. * @returns a matrix
  6963. */
  6964. getWorldMatrix(): DeepImmutable<Matrix>;
  6965. /** @hidden */
  6966. _update(world: DeepImmutable<Matrix>): void;
  6967. /**
  6968. * Tests if the bounding box is intersecting the frustum planes
  6969. * @param frustumPlanes defines the frustum planes to test
  6970. * @returns true if there is an intersection
  6971. */
  6972. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6973. /**
  6974. * Tests if the bounding box is entirely inside the frustum planes
  6975. * @param frustumPlanes defines the frustum planes to test
  6976. * @returns true if there is an inclusion
  6977. */
  6978. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6979. /**
  6980. * Tests if a point is inside the bounding box
  6981. * @param point defines the point to test
  6982. * @returns true if the point is inside the bounding box
  6983. */
  6984. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6985. /**
  6986. * Tests if the bounding box intersects with a bounding sphere
  6987. * @param sphere defines the sphere to test
  6988. * @returns true if there is an intersection
  6989. */
  6990. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6991. /**
  6992. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6993. * @param min defines the min vector to use
  6994. * @param max defines the max vector to use
  6995. * @returns true if there is an intersection
  6996. */
  6997. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6998. /**
  6999. * Tests if two bounding boxes are intersections
  7000. * @param box0 defines the first box to test
  7001. * @param box1 defines the second box to test
  7002. * @returns true if there is an intersection
  7003. */
  7004. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7005. /**
  7006. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7007. * @param minPoint defines the minimum vector of the bounding box
  7008. * @param maxPoint defines the maximum vector of the bounding box
  7009. * @param sphereCenter defines the sphere center
  7010. * @param sphereRadius defines the sphere radius
  7011. * @returns true if there is an intersection
  7012. */
  7013. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7014. /**
  7015. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7016. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7017. * @param frustumPlanes defines the frustum planes to test
  7018. * @return true if there is an inclusion
  7019. */
  7020. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7021. /**
  7022. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7023. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7024. * @param frustumPlanes defines the frustum planes to test
  7025. * @return true if there is an intersection
  7026. */
  7027. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7028. }
  7029. }
  7030. declare module "babylonjs/Collisions/collider" {
  7031. import { Nullable, IndicesArray } from "babylonjs/types";
  7032. import { Vector3 } from "babylonjs/Maths/math.vector";
  7033. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7034. import { Plane } from "babylonjs/Maths/math.plane";
  7035. /** @hidden */
  7036. export class Collider {
  7037. /** Define if a collision was found */
  7038. collisionFound: boolean;
  7039. /**
  7040. * Define last intersection point in local space
  7041. */
  7042. intersectionPoint: Vector3;
  7043. /**
  7044. * Define last collided mesh
  7045. */
  7046. collidedMesh: Nullable<AbstractMesh>;
  7047. private _collisionPoint;
  7048. private _planeIntersectionPoint;
  7049. private _tempVector;
  7050. private _tempVector2;
  7051. private _tempVector3;
  7052. private _tempVector4;
  7053. private _edge;
  7054. private _baseToVertex;
  7055. private _destinationPoint;
  7056. private _slidePlaneNormal;
  7057. private _displacementVector;
  7058. /** @hidden */
  7059. _radius: Vector3;
  7060. /** @hidden */
  7061. _retry: number;
  7062. private _velocity;
  7063. private _basePoint;
  7064. private _epsilon;
  7065. /** @hidden */
  7066. _velocityWorldLength: number;
  7067. /** @hidden */
  7068. _basePointWorld: Vector3;
  7069. private _velocityWorld;
  7070. private _normalizedVelocity;
  7071. /** @hidden */
  7072. _initialVelocity: Vector3;
  7073. /** @hidden */
  7074. _initialPosition: Vector3;
  7075. private _nearestDistance;
  7076. private _collisionMask;
  7077. get collisionMask(): number;
  7078. set collisionMask(mask: number);
  7079. /**
  7080. * Gets the plane normal used to compute the sliding response (in local space)
  7081. */
  7082. get slidePlaneNormal(): Vector3;
  7083. /** @hidden */
  7084. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7085. /** @hidden */
  7086. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7087. /** @hidden */
  7088. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7089. /** @hidden */
  7090. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7091. /** @hidden */
  7092. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7093. /** @hidden */
  7094. _getResponse(pos: Vector3, vel: Vector3): void;
  7095. }
  7096. }
  7097. declare module "babylonjs/Culling/boundingInfo" {
  7098. import { DeepImmutable } from "babylonjs/types";
  7099. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7100. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7101. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7102. import { Plane } from "babylonjs/Maths/math.plane";
  7103. import { Collider } from "babylonjs/Collisions/collider";
  7104. /**
  7105. * Interface for cullable objects
  7106. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7107. */
  7108. export interface ICullable {
  7109. /**
  7110. * Checks if the object or part of the object is in the frustum
  7111. * @param frustumPlanes Camera near/planes
  7112. * @returns true if the object is in frustum otherwise false
  7113. */
  7114. isInFrustum(frustumPlanes: Plane[]): boolean;
  7115. /**
  7116. * Checks if a cullable object (mesh...) is in the camera frustum
  7117. * Unlike isInFrustum this cheks the full bounding box
  7118. * @param frustumPlanes Camera near/planes
  7119. * @returns true if the object is in frustum otherwise false
  7120. */
  7121. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7122. }
  7123. /**
  7124. * Info for a bounding data of a mesh
  7125. */
  7126. export class BoundingInfo implements ICullable {
  7127. /**
  7128. * Bounding box for the mesh
  7129. */
  7130. readonly boundingBox: BoundingBox;
  7131. /**
  7132. * Bounding sphere for the mesh
  7133. */
  7134. readonly boundingSphere: BoundingSphere;
  7135. private _isLocked;
  7136. private static readonly TmpVector3;
  7137. /**
  7138. * Constructs bounding info
  7139. * @param minimum min vector of the bounding box/sphere
  7140. * @param maximum max vector of the bounding box/sphere
  7141. * @param worldMatrix defines the new world matrix
  7142. */
  7143. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7144. /**
  7145. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7146. * @param min defines the new minimum vector (in local space)
  7147. * @param max defines the new maximum vector (in local space)
  7148. * @param worldMatrix defines the new world matrix
  7149. */
  7150. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7151. /**
  7152. * min vector of the bounding box/sphere
  7153. */
  7154. get minimum(): Vector3;
  7155. /**
  7156. * max vector of the bounding box/sphere
  7157. */
  7158. get maximum(): Vector3;
  7159. /**
  7160. * If the info is locked and won't be updated to avoid perf overhead
  7161. */
  7162. get isLocked(): boolean;
  7163. set isLocked(value: boolean);
  7164. /**
  7165. * Updates the bounding sphere and box
  7166. * @param world world matrix to be used to update
  7167. */
  7168. update(world: DeepImmutable<Matrix>): void;
  7169. /**
  7170. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7171. * @param center New center of the bounding info
  7172. * @param extend New extend of the bounding info
  7173. * @returns the current bounding info
  7174. */
  7175. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7176. /**
  7177. * Scale the current bounding info by applying a scale factor
  7178. * @param factor defines the scale factor to apply
  7179. * @returns the current bounding info
  7180. */
  7181. scale(factor: number): BoundingInfo;
  7182. /**
  7183. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7184. * @param frustumPlanes defines the frustum to test
  7185. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7186. * @returns true if the bounding info is in the frustum planes
  7187. */
  7188. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7189. /**
  7190. * Gets the world distance between the min and max points of the bounding box
  7191. */
  7192. get diagonalLength(): number;
  7193. /**
  7194. * Checks if a cullable object (mesh...) is in the camera frustum
  7195. * Unlike isInFrustum this cheks the full bounding box
  7196. * @param frustumPlanes Camera near/planes
  7197. * @returns true if the object is in frustum otherwise false
  7198. */
  7199. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7200. /** @hidden */
  7201. _checkCollision(collider: Collider): boolean;
  7202. /**
  7203. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7204. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7205. * @param point the point to check intersection with
  7206. * @returns if the point intersects
  7207. */
  7208. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7209. /**
  7210. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7211. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7212. * @param boundingInfo the bounding info to check intersection with
  7213. * @param precise if the intersection should be done using OBB
  7214. * @returns if the bounding info intersects
  7215. */
  7216. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7217. }
  7218. }
  7219. declare module "babylonjs/Maths/math.functions" {
  7220. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7221. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7222. /**
  7223. * Extracts minimum and maximum values from a list of indexed positions
  7224. * @param positions defines the positions to use
  7225. * @param indices defines the indices to the positions
  7226. * @param indexStart defines the start index
  7227. * @param indexCount defines the end index
  7228. * @param bias defines bias value to add to the result
  7229. * @return minimum and maximum values
  7230. */
  7231. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7232. minimum: Vector3;
  7233. maximum: Vector3;
  7234. };
  7235. /**
  7236. * Extracts minimum and maximum values from a list of positions
  7237. * @param positions defines the positions to use
  7238. * @param start defines the start index in the positions array
  7239. * @param count defines the number of positions to handle
  7240. * @param bias defines bias value to add to the result
  7241. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7242. * @return minimum and maximum values
  7243. */
  7244. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7245. minimum: Vector3;
  7246. maximum: Vector3;
  7247. };
  7248. }
  7249. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  7250. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7251. /** @hidden */
  7252. export class WebGLDataBuffer extends DataBuffer {
  7253. private _buffer;
  7254. constructor(resource: WebGLBuffer);
  7255. get underlyingResource(): any;
  7256. }
  7257. }
  7258. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  7259. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7260. import { Nullable } from "babylonjs/types";
  7261. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7262. /** @hidden */
  7263. export class WebGLPipelineContext implements IPipelineContext {
  7264. engine: ThinEngine;
  7265. program: Nullable<WebGLProgram>;
  7266. context?: WebGLRenderingContext;
  7267. vertexShader?: WebGLShader;
  7268. fragmentShader?: WebGLShader;
  7269. isParallelCompiled: boolean;
  7270. onCompiled?: () => void;
  7271. transformFeedback?: WebGLTransformFeedback | null;
  7272. vertexCompilationError: Nullable<string>;
  7273. fragmentCompilationError: Nullable<string>;
  7274. programLinkError: Nullable<string>;
  7275. programValidationError: Nullable<string>;
  7276. get isAsync(): boolean;
  7277. get isReady(): boolean;
  7278. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7279. _getVertexShaderCode(): string | null;
  7280. _getFragmentShaderCode(): string | null;
  7281. }
  7282. }
  7283. declare module "babylonjs/Engines/Extensions/engine.uniformBuffer" {
  7284. import { FloatArray, Nullable } from "babylonjs/types";
  7285. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7286. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7287. module "babylonjs/Engines/thinEngine" {
  7288. interface ThinEngine {
  7289. /**
  7290. * Create an uniform buffer
  7291. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7292. * @param elements defines the content of the uniform buffer
  7293. * @returns the webGL uniform buffer
  7294. */
  7295. createUniformBuffer(elements: FloatArray): DataBuffer;
  7296. /**
  7297. * Create a dynamic uniform buffer
  7298. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7299. * @param elements defines the content of the uniform buffer
  7300. * @returns the webGL uniform buffer
  7301. */
  7302. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7303. /**
  7304. * Update an existing uniform buffer
  7305. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7306. * @param uniformBuffer defines the target uniform buffer
  7307. * @param elements defines the content to update
  7308. * @param offset defines the offset in the uniform buffer where update should start
  7309. * @param count defines the size of the data to update
  7310. */
  7311. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7312. /**
  7313. * Bind an uniform buffer to the current webGL context
  7314. * @param buffer defines the buffer to bind
  7315. */
  7316. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7317. /**
  7318. * Bind a buffer to the current webGL context at a given location
  7319. * @param buffer defines the buffer to bind
  7320. * @param location defines the index where to bind the buffer
  7321. */
  7322. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7323. /**
  7324. * Bind a specific block at a given index in a specific shader program
  7325. * @param pipelineContext defines the pipeline context to use
  7326. * @param blockName defines the block name
  7327. * @param index defines the index where to bind the block
  7328. */
  7329. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7330. }
  7331. }
  7332. }
  7333. declare module "babylonjs/Materials/uniformBuffer" {
  7334. import { Nullable, FloatArray } from "babylonjs/types";
  7335. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  7336. import { Engine } from "babylonjs/Engines/engine";
  7337. import { Effect } from "babylonjs/Materials/effect";
  7338. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7339. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7340. import { Color3 } from "babylonjs/Maths/math.color";
  7341. import "babylonjs/Engines/Extensions/engine.uniformBuffer";
  7342. /**
  7343. * Uniform buffer objects.
  7344. *
  7345. * Handles blocks of uniform on the GPU.
  7346. *
  7347. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7348. *
  7349. * For more information, please refer to :
  7350. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7351. */
  7352. export class UniformBuffer {
  7353. private _engine;
  7354. private _buffer;
  7355. private _data;
  7356. private _bufferData;
  7357. private _dynamic?;
  7358. private _uniformLocations;
  7359. private _uniformSizes;
  7360. private _uniformLocationPointer;
  7361. private _needSync;
  7362. private _noUBO;
  7363. private _currentEffect;
  7364. /** @hidden */
  7365. _alreadyBound: boolean;
  7366. private static _MAX_UNIFORM_SIZE;
  7367. private static _tempBuffer;
  7368. /**
  7369. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7370. * This is dynamic to allow compat with webgl 1 and 2.
  7371. * You will need to pass the name of the uniform as well as the value.
  7372. */
  7373. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7374. /**
  7375. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7376. * This is dynamic to allow compat with webgl 1 and 2.
  7377. * You will need to pass the name of the uniform as well as the value.
  7378. */
  7379. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7380. /**
  7381. * Lambda to Update a single float in a uniform buffer.
  7382. * This is dynamic to allow compat with webgl 1 and 2.
  7383. * You will need to pass the name of the uniform as well as the value.
  7384. */
  7385. updateFloat: (name: string, x: number) => void;
  7386. /**
  7387. * Lambda to Update a vec2 of float in a uniform buffer.
  7388. * This is dynamic to allow compat with webgl 1 and 2.
  7389. * You will need to pass the name of the uniform as well as the value.
  7390. */
  7391. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7392. /**
  7393. * Lambda to Update a vec3 of float in a uniform buffer.
  7394. * This is dynamic to allow compat with webgl 1 and 2.
  7395. * You will need to pass the name of the uniform as well as the value.
  7396. */
  7397. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7398. /**
  7399. * Lambda to Update a vec4 of float in a uniform buffer.
  7400. * This is dynamic to allow compat with webgl 1 and 2.
  7401. * You will need to pass the name of the uniform as well as the value.
  7402. */
  7403. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7404. /**
  7405. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7406. * This is dynamic to allow compat with webgl 1 and 2.
  7407. * You will need to pass the name of the uniform as well as the value.
  7408. */
  7409. updateMatrix: (name: string, mat: Matrix) => void;
  7410. /**
  7411. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7412. * This is dynamic to allow compat with webgl 1 and 2.
  7413. * You will need to pass the name of the uniform as well as the value.
  7414. */
  7415. updateVector3: (name: string, vector: Vector3) => void;
  7416. /**
  7417. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7418. * This is dynamic to allow compat with webgl 1 and 2.
  7419. * You will need to pass the name of the uniform as well as the value.
  7420. */
  7421. updateVector4: (name: string, vector: Vector4) => void;
  7422. /**
  7423. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7424. * This is dynamic to allow compat with webgl 1 and 2.
  7425. * You will need to pass the name of the uniform as well as the value.
  7426. */
  7427. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7428. /**
  7429. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7430. * This is dynamic to allow compat with webgl 1 and 2.
  7431. * You will need to pass the name of the uniform as well as the value.
  7432. */
  7433. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7434. /**
  7435. * Instantiates a new Uniform buffer objects.
  7436. *
  7437. * Handles blocks of uniform on the GPU.
  7438. *
  7439. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7440. *
  7441. * For more information, please refer to :
  7442. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7443. * @param engine Define the engine the buffer is associated with
  7444. * @param data Define the data contained in the buffer
  7445. * @param dynamic Define if the buffer is updatable
  7446. */
  7447. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7448. /**
  7449. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7450. * or just falling back on setUniformXXX calls.
  7451. */
  7452. get useUbo(): boolean;
  7453. /**
  7454. * Indicates if the WebGL underlying uniform buffer is in sync
  7455. * with the javascript cache data.
  7456. */
  7457. get isSync(): boolean;
  7458. /**
  7459. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7460. * Also, a dynamic UniformBuffer will disable cache verification and always
  7461. * update the underlying WebGL uniform buffer to the GPU.
  7462. * @returns if Dynamic, otherwise false
  7463. */
  7464. isDynamic(): boolean;
  7465. /**
  7466. * The data cache on JS side.
  7467. * @returns the underlying data as a float array
  7468. */
  7469. getData(): Float32Array;
  7470. /**
  7471. * The underlying WebGL Uniform buffer.
  7472. * @returns the webgl buffer
  7473. */
  7474. getBuffer(): Nullable<DataBuffer>;
  7475. /**
  7476. * std140 layout specifies how to align data within an UBO structure.
  7477. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7478. * for specs.
  7479. */
  7480. private _fillAlignment;
  7481. /**
  7482. * Adds an uniform in the buffer.
  7483. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7484. * for the layout to be correct !
  7485. * @param name Name of the uniform, as used in the uniform block in the shader.
  7486. * @param size Data size, or data directly.
  7487. */
  7488. addUniform(name: string, size: number | number[]): void;
  7489. /**
  7490. * Adds a Matrix 4x4 to the uniform buffer.
  7491. * @param name Name of the uniform, as used in the uniform block in the shader.
  7492. * @param mat A 4x4 matrix.
  7493. */
  7494. addMatrix(name: string, mat: Matrix): void;
  7495. /**
  7496. * Adds a vec2 to the uniform buffer.
  7497. * @param name Name of the uniform, as used in the uniform block in the shader.
  7498. * @param x Define the x component value of the vec2
  7499. * @param y Define the y component value of the vec2
  7500. */
  7501. addFloat2(name: string, x: number, y: number): void;
  7502. /**
  7503. * Adds a vec3 to the uniform buffer.
  7504. * @param name Name of the uniform, as used in the uniform block in the shader.
  7505. * @param x Define the x component value of the vec3
  7506. * @param y Define the y component value of the vec3
  7507. * @param z Define the z component value of the vec3
  7508. */
  7509. addFloat3(name: string, x: number, y: number, z: number): void;
  7510. /**
  7511. * Adds a vec3 to the uniform buffer.
  7512. * @param name Name of the uniform, as used in the uniform block in the shader.
  7513. * @param color Define the vec3 from a Color
  7514. */
  7515. addColor3(name: string, color: Color3): void;
  7516. /**
  7517. * Adds a vec4 to the uniform buffer.
  7518. * @param name Name of the uniform, as used in the uniform block in the shader.
  7519. * @param color Define the rgb components from a Color
  7520. * @param alpha Define the a component of the vec4
  7521. */
  7522. addColor4(name: string, color: Color3, alpha: number): void;
  7523. /**
  7524. * Adds a vec3 to the uniform buffer.
  7525. * @param name Name of the uniform, as used in the uniform block in the shader.
  7526. * @param vector Define the vec3 components from a Vector
  7527. */
  7528. addVector3(name: string, vector: Vector3): void;
  7529. /**
  7530. * Adds a Matrix 3x3 to the uniform buffer.
  7531. * @param name Name of the uniform, as used in the uniform block in the shader.
  7532. */
  7533. addMatrix3x3(name: string): void;
  7534. /**
  7535. * Adds a Matrix 2x2 to the uniform buffer.
  7536. * @param name Name of the uniform, as used in the uniform block in the shader.
  7537. */
  7538. addMatrix2x2(name: string): void;
  7539. /**
  7540. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7541. */
  7542. create(): void;
  7543. /** @hidden */
  7544. _rebuild(): void;
  7545. /**
  7546. * Updates the WebGL Uniform Buffer on the GPU.
  7547. * If the `dynamic` flag is set to true, no cache comparison is done.
  7548. * Otherwise, the buffer will be updated only if the cache differs.
  7549. */
  7550. update(): void;
  7551. /**
  7552. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7553. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7554. * @param data Define the flattened data
  7555. * @param size Define the size of the data.
  7556. */
  7557. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7558. private _valueCache;
  7559. private _cacheMatrix;
  7560. private _updateMatrix3x3ForUniform;
  7561. private _updateMatrix3x3ForEffect;
  7562. private _updateMatrix2x2ForEffect;
  7563. private _updateMatrix2x2ForUniform;
  7564. private _updateFloatForEffect;
  7565. private _updateFloatForUniform;
  7566. private _updateFloat2ForEffect;
  7567. private _updateFloat2ForUniform;
  7568. private _updateFloat3ForEffect;
  7569. private _updateFloat3ForUniform;
  7570. private _updateFloat4ForEffect;
  7571. private _updateFloat4ForUniform;
  7572. private _updateMatrixForEffect;
  7573. private _updateMatrixForUniform;
  7574. private _updateVector3ForEffect;
  7575. private _updateVector3ForUniform;
  7576. private _updateVector4ForEffect;
  7577. private _updateVector4ForUniform;
  7578. private _updateColor3ForEffect;
  7579. private _updateColor3ForUniform;
  7580. private _updateColor4ForEffect;
  7581. private _updateColor4ForUniform;
  7582. /**
  7583. * Sets a sampler uniform on the effect.
  7584. * @param name Define the name of the sampler.
  7585. * @param texture Define the texture to set in the sampler
  7586. */
  7587. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7588. /**
  7589. * Directly updates the value of the uniform in the cache AND on the GPU.
  7590. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7591. * @param data Define the flattened data
  7592. */
  7593. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7594. /**
  7595. * Binds this uniform buffer to an effect.
  7596. * @param effect Define the effect to bind the buffer to
  7597. * @param name Name of the uniform block in the shader.
  7598. */
  7599. bindToEffect(effect: Effect, name: string): void;
  7600. /**
  7601. * Disposes the uniform buffer.
  7602. */
  7603. dispose(): void;
  7604. }
  7605. }
  7606. declare module "babylonjs/Misc/iInspectable" {
  7607. /**
  7608. * Enum that determines the text-wrapping mode to use.
  7609. */
  7610. export enum InspectableType {
  7611. /**
  7612. * Checkbox for booleans
  7613. */
  7614. Checkbox = 0,
  7615. /**
  7616. * Sliders for numbers
  7617. */
  7618. Slider = 1,
  7619. /**
  7620. * Vector3
  7621. */
  7622. Vector3 = 2,
  7623. /**
  7624. * Quaternions
  7625. */
  7626. Quaternion = 3,
  7627. /**
  7628. * Color3
  7629. */
  7630. Color3 = 4,
  7631. /**
  7632. * String
  7633. */
  7634. String = 5
  7635. }
  7636. /**
  7637. * Interface used to define custom inspectable properties.
  7638. * This interface is used by the inspector to display custom property grids
  7639. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7640. */
  7641. export interface IInspectable {
  7642. /**
  7643. * Gets the label to display
  7644. */
  7645. label: string;
  7646. /**
  7647. * Gets the name of the property to edit
  7648. */
  7649. propertyName: string;
  7650. /**
  7651. * Gets the type of the editor to use
  7652. */
  7653. type: InspectableType;
  7654. /**
  7655. * Gets the minimum value of the property when using in "slider" mode
  7656. */
  7657. min?: number;
  7658. /**
  7659. * Gets the maximum value of the property when using in "slider" mode
  7660. */
  7661. max?: number;
  7662. /**
  7663. * Gets the setp to use when using in "slider" mode
  7664. */
  7665. step?: number;
  7666. }
  7667. }
  7668. declare module "babylonjs/Misc/timingTools" {
  7669. /**
  7670. * Class used to provide helper for timing
  7671. */
  7672. export class TimingTools {
  7673. /**
  7674. * Polyfill for setImmediate
  7675. * @param action defines the action to execute after the current execution block
  7676. */
  7677. static SetImmediate(action: () => void): void;
  7678. }
  7679. }
  7680. declare module "babylonjs/Misc/instantiationTools" {
  7681. /**
  7682. * Class used to enable instatition of objects by class name
  7683. */
  7684. export class InstantiationTools {
  7685. /**
  7686. * Use this object to register external classes like custom textures or material
  7687. * to allow the laoders to instantiate them
  7688. */
  7689. static RegisteredExternalClasses: {
  7690. [key: string]: Object;
  7691. };
  7692. /**
  7693. * Tries to instantiate a new object from a given class name
  7694. * @param className defines the class name to instantiate
  7695. * @returns the new object or null if the system was not able to do the instantiation
  7696. */
  7697. static Instantiate(className: string): any;
  7698. }
  7699. }
  7700. declare module "babylonjs/Engines/depthTextureCreationOptions" {
  7701. /**
  7702. * Define options used to create a depth texture
  7703. */
  7704. export class DepthTextureCreationOptions {
  7705. /** Specifies whether or not a stencil should be allocated in the texture */
  7706. generateStencil?: boolean;
  7707. /** Specifies whether or not bilinear filtering is enable on the texture */
  7708. bilinearFiltering?: boolean;
  7709. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7710. comparisonFunction?: number;
  7711. /** Specifies if the created texture is a cube texture */
  7712. isCube?: boolean;
  7713. }
  7714. }
  7715. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7716. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7717. import { Nullable } from "babylonjs/types";
  7718. import { Scene } from "babylonjs/scene";
  7719. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  7720. module "babylonjs/Engines/thinEngine" {
  7721. interface ThinEngine {
  7722. /**
  7723. * Creates a depth stencil cube texture.
  7724. * This is only available in WebGL 2.
  7725. * @param size The size of face edge in the cube texture.
  7726. * @param options The options defining the cube texture.
  7727. * @returns The cube texture
  7728. */
  7729. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7730. /**
  7731. * Creates a cube texture
  7732. * @param rootUrl defines the url where the files to load is located
  7733. * @param scene defines the current scene
  7734. * @param files defines the list of files to load (1 per face)
  7735. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7736. * @param onLoad defines an optional callback raised when the texture is loaded
  7737. * @param onError defines an optional callback raised if there is an issue to load the texture
  7738. * @param format defines the format of the data
  7739. * @param forcedExtension defines the extension to use to pick the right loader
  7740. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7741. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7742. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7743. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7744. * @returns the cube texture as an InternalTexture
  7745. */
  7746. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>): InternalTexture;
  7747. /**
  7748. * Creates a cube texture
  7749. * @param rootUrl defines the url where the files to load is located
  7750. * @param scene defines the current scene
  7751. * @param files defines the list of files to load (1 per face)
  7752. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7753. * @param onLoad defines an optional callback raised when the texture is loaded
  7754. * @param onError defines an optional callback raised if there is an issue to load the texture
  7755. * @param format defines the format of the data
  7756. * @param forcedExtension defines the extension to use to pick the right loader
  7757. * @returns the cube texture as an InternalTexture
  7758. */
  7759. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any): InternalTexture;
  7760. /**
  7761. * Creates a cube texture
  7762. * @param rootUrl defines the url where the files to load is located
  7763. * @param scene defines the current scene
  7764. * @param files defines the list of files to load (1 per face)
  7765. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7766. * @param onLoad defines an optional callback raised when the texture is loaded
  7767. * @param onError defines an optional callback raised if there is an issue to load the texture
  7768. * @param format defines the format of the data
  7769. * @param forcedExtension defines the extension to use to pick the right loader
  7770. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7771. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7772. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7773. * @returns the cube texture as an InternalTexture
  7774. */
  7775. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number): InternalTexture;
  7776. /** @hidden */
  7777. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7778. /** @hidden */
  7779. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7780. /** @hidden */
  7781. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7782. /** @hidden */
  7783. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7784. /**
  7785. * @hidden
  7786. */
  7787. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7788. }
  7789. }
  7790. }
  7791. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7792. import { Nullable } from "babylonjs/types";
  7793. import { Scene } from "babylonjs/scene";
  7794. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7795. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7796. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7797. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7798. import { Observable } from "babylonjs/Misc/observable";
  7799. /**
  7800. * Class for creating a cube texture
  7801. */
  7802. export class CubeTexture extends BaseTexture {
  7803. private _delayedOnLoad;
  7804. /**
  7805. * Observable triggered once the texture has been loaded.
  7806. */
  7807. onLoadObservable: Observable<CubeTexture>;
  7808. /**
  7809. * The url of the texture
  7810. */
  7811. url: string;
  7812. /**
  7813. * Gets or sets the center of the bounding box associated with the cube texture.
  7814. * It must define where the camera used to render the texture was set
  7815. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7816. */
  7817. boundingBoxPosition: Vector3;
  7818. private _boundingBoxSize;
  7819. /**
  7820. * Gets or sets the size of the bounding box associated with the cube texture
  7821. * When defined, the cubemap will switch to local mode
  7822. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7823. * @example https://www.babylonjs-playground.com/#RNASML
  7824. */
  7825. set boundingBoxSize(value: Vector3);
  7826. /**
  7827. * Returns the bounding box size
  7828. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7829. */
  7830. get boundingBoxSize(): Vector3;
  7831. protected _rotationY: number;
  7832. /**
  7833. * Sets texture matrix rotation angle around Y axis in radians.
  7834. */
  7835. set rotationY(value: number);
  7836. /**
  7837. * Gets texture matrix rotation angle around Y axis radians.
  7838. */
  7839. get rotationY(): number;
  7840. /**
  7841. * Are mip maps generated for this texture or not.
  7842. */
  7843. get noMipmap(): boolean;
  7844. private _noMipmap;
  7845. private _files;
  7846. protected _forcedExtension: Nullable<string>;
  7847. private _extensions;
  7848. private _textureMatrix;
  7849. private _format;
  7850. private _createPolynomials;
  7851. /**
  7852. * Creates a cube texture from an array of image urls
  7853. * @param files defines an array of image urls
  7854. * @param scene defines the hosting scene
  7855. * @param noMipmap specifies if mip maps are not used
  7856. * @returns a cube texture
  7857. */
  7858. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7859. /**
  7860. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7861. * @param url defines the url of the prefiltered texture
  7862. * @param scene defines the scene the texture is attached to
  7863. * @param forcedExtension defines the extension of the file if different from the url
  7864. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7865. * @return the prefiltered texture
  7866. */
  7867. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7868. /**
  7869. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7870. * as prefiltered data.
  7871. * @param rootUrl defines the url of the texture or the root name of the six images
  7872. * @param null defines the scene or engine the texture is attached to
  7873. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7874. * @param noMipmap defines if mipmaps should be created or not
  7875. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7876. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7877. * @param onError defines a callback triggered in case of error during load
  7878. * @param format defines the internal format to use for the texture once loaded
  7879. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7880. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7881. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7882. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7883. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7884. * @return the cube texture
  7885. */
  7886. constructor(rootUrl: string, sceneOrEngine: Scene | ThinEngine, extensions?: Nullable<string[]>, noMipmap?: boolean, files?: Nullable<string[]>, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, prefiltered?: boolean, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number);
  7887. /**
  7888. * Get the current class name of the texture useful for serialization or dynamic coding.
  7889. * @returns "CubeTexture"
  7890. */
  7891. getClassName(): string;
  7892. /**
  7893. * Update the url (and optional buffer) of this texture if url was null during construction.
  7894. * @param url the url of the texture
  7895. * @param forcedExtension defines the extension to use
  7896. * @param onLoad callback called when the texture is loaded (defaults to null)
  7897. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7898. */
  7899. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7900. /**
  7901. * Delays loading of the cube texture
  7902. * @param forcedExtension defines the extension to use
  7903. */
  7904. delayLoad(forcedExtension?: string): void;
  7905. /**
  7906. * Returns the reflection texture matrix
  7907. * @returns the reflection texture matrix
  7908. */
  7909. getReflectionTextureMatrix(): Matrix;
  7910. /**
  7911. * Sets the reflection texture matrix
  7912. * @param value Reflection texture matrix
  7913. */
  7914. setReflectionTextureMatrix(value: Matrix): void;
  7915. /**
  7916. * Parses text to create a cube texture
  7917. * @param parsedTexture define the serialized text to read from
  7918. * @param scene defines the hosting scene
  7919. * @param rootUrl defines the root url of the cube texture
  7920. * @returns a cube texture
  7921. */
  7922. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7923. /**
  7924. * Makes a clone, or deep copy, of the cube texture
  7925. * @returns a new cube texture
  7926. */
  7927. clone(): CubeTexture;
  7928. }
  7929. }
  7930. declare module "babylonjs/Materials/materialDefines" {
  7931. /**
  7932. * Manages the defines for the Material
  7933. */
  7934. export class MaterialDefines {
  7935. /** @hidden */
  7936. protected _keys: string[];
  7937. private _isDirty;
  7938. /** @hidden */
  7939. _renderId: number;
  7940. /** @hidden */
  7941. _areLightsDirty: boolean;
  7942. /** @hidden */
  7943. _areLightsDisposed: boolean;
  7944. /** @hidden */
  7945. _areAttributesDirty: boolean;
  7946. /** @hidden */
  7947. _areTexturesDirty: boolean;
  7948. /** @hidden */
  7949. _areFresnelDirty: boolean;
  7950. /** @hidden */
  7951. _areMiscDirty: boolean;
  7952. /** @hidden */
  7953. _areImageProcessingDirty: boolean;
  7954. /** @hidden */
  7955. _normals: boolean;
  7956. /** @hidden */
  7957. _uvs: boolean;
  7958. /** @hidden */
  7959. _needNormals: boolean;
  7960. /** @hidden */
  7961. _needUVs: boolean;
  7962. [id: string]: any;
  7963. /**
  7964. * Specifies if the material needs to be re-calculated
  7965. */
  7966. get isDirty(): boolean;
  7967. /**
  7968. * Marks the material to indicate that it has been re-calculated
  7969. */
  7970. markAsProcessed(): void;
  7971. /**
  7972. * Marks the material to indicate that it needs to be re-calculated
  7973. */
  7974. markAsUnprocessed(): void;
  7975. /**
  7976. * Marks the material to indicate all of its defines need to be re-calculated
  7977. */
  7978. markAllAsDirty(): void;
  7979. /**
  7980. * Marks the material to indicate that image processing needs to be re-calculated
  7981. */
  7982. markAsImageProcessingDirty(): void;
  7983. /**
  7984. * Marks the material to indicate the lights need to be re-calculated
  7985. * @param disposed Defines whether the light is dirty due to dispose or not
  7986. */
  7987. markAsLightDirty(disposed?: boolean): void;
  7988. /**
  7989. * Marks the attribute state as changed
  7990. */
  7991. markAsAttributesDirty(): void;
  7992. /**
  7993. * Marks the texture state as changed
  7994. */
  7995. markAsTexturesDirty(): void;
  7996. /**
  7997. * Marks the fresnel state as changed
  7998. */
  7999. markAsFresnelDirty(): void;
  8000. /**
  8001. * Marks the misc state as changed
  8002. */
  8003. markAsMiscDirty(): void;
  8004. /**
  8005. * Rebuilds the material defines
  8006. */
  8007. rebuild(): void;
  8008. /**
  8009. * Specifies if two material defines are equal
  8010. * @param other - A material define instance to compare to
  8011. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  8012. */
  8013. isEqual(other: MaterialDefines): boolean;
  8014. /**
  8015. * Clones this instance's defines to another instance
  8016. * @param other - material defines to clone values to
  8017. */
  8018. cloneTo(other: MaterialDefines): void;
  8019. /**
  8020. * Resets the material define values
  8021. */
  8022. reset(): void;
  8023. /**
  8024. * Converts the material define values to a string
  8025. * @returns - String of material define information
  8026. */
  8027. toString(): string;
  8028. }
  8029. }
  8030. declare module "babylonjs/Materials/colorCurves" {
  8031. import { Effect } from "babylonjs/Materials/effect";
  8032. /**
  8033. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  8034. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  8035. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  8036. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  8037. */
  8038. export class ColorCurves {
  8039. private _dirty;
  8040. private _tempColor;
  8041. private _globalCurve;
  8042. private _highlightsCurve;
  8043. private _midtonesCurve;
  8044. private _shadowsCurve;
  8045. private _positiveCurve;
  8046. private _negativeCurve;
  8047. private _globalHue;
  8048. private _globalDensity;
  8049. private _globalSaturation;
  8050. private _globalExposure;
  8051. /**
  8052. * Gets the global Hue value.
  8053. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8054. */
  8055. get globalHue(): number;
  8056. /**
  8057. * Sets the global Hue value.
  8058. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8059. */
  8060. set globalHue(value: number);
  8061. /**
  8062. * Gets the global Density value.
  8063. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8064. * Values less than zero provide a filter of opposite hue.
  8065. */
  8066. get globalDensity(): number;
  8067. /**
  8068. * Sets the global Density value.
  8069. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8070. * Values less than zero provide a filter of opposite hue.
  8071. */
  8072. set globalDensity(value: number);
  8073. /**
  8074. * Gets the global Saturation value.
  8075. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8076. */
  8077. get globalSaturation(): number;
  8078. /**
  8079. * Sets the global Saturation value.
  8080. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8081. */
  8082. set globalSaturation(value: number);
  8083. /**
  8084. * Gets the global Exposure value.
  8085. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8086. */
  8087. get globalExposure(): number;
  8088. /**
  8089. * Sets the global Exposure value.
  8090. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8091. */
  8092. set globalExposure(value: number);
  8093. private _highlightsHue;
  8094. private _highlightsDensity;
  8095. private _highlightsSaturation;
  8096. private _highlightsExposure;
  8097. /**
  8098. * Gets the highlights Hue value.
  8099. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8100. */
  8101. get highlightsHue(): number;
  8102. /**
  8103. * Sets the highlights Hue value.
  8104. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8105. */
  8106. set highlightsHue(value: number);
  8107. /**
  8108. * Gets the highlights Density value.
  8109. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8110. * Values less than zero provide a filter of opposite hue.
  8111. */
  8112. get highlightsDensity(): number;
  8113. /**
  8114. * Sets the highlights Density value.
  8115. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8116. * Values less than zero provide a filter of opposite hue.
  8117. */
  8118. set highlightsDensity(value: number);
  8119. /**
  8120. * Gets the highlights Saturation value.
  8121. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8122. */
  8123. get highlightsSaturation(): number;
  8124. /**
  8125. * Sets the highlights Saturation value.
  8126. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8127. */
  8128. set highlightsSaturation(value: number);
  8129. /**
  8130. * Gets the highlights Exposure value.
  8131. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8132. */
  8133. get highlightsExposure(): number;
  8134. /**
  8135. * Sets the highlights Exposure value.
  8136. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8137. */
  8138. set highlightsExposure(value: number);
  8139. private _midtonesHue;
  8140. private _midtonesDensity;
  8141. private _midtonesSaturation;
  8142. private _midtonesExposure;
  8143. /**
  8144. * Gets the midtones Hue value.
  8145. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8146. */
  8147. get midtonesHue(): number;
  8148. /**
  8149. * Sets the midtones Hue value.
  8150. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8151. */
  8152. set midtonesHue(value: number);
  8153. /**
  8154. * Gets the midtones Density value.
  8155. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8156. * Values less than zero provide a filter of opposite hue.
  8157. */
  8158. get midtonesDensity(): number;
  8159. /**
  8160. * Sets the midtones Density value.
  8161. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8162. * Values less than zero provide a filter of opposite hue.
  8163. */
  8164. set midtonesDensity(value: number);
  8165. /**
  8166. * Gets the midtones Saturation value.
  8167. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8168. */
  8169. get midtonesSaturation(): number;
  8170. /**
  8171. * Sets the midtones Saturation value.
  8172. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8173. */
  8174. set midtonesSaturation(value: number);
  8175. /**
  8176. * Gets the midtones Exposure value.
  8177. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8178. */
  8179. get midtonesExposure(): number;
  8180. /**
  8181. * Sets the midtones Exposure value.
  8182. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8183. */
  8184. set midtonesExposure(value: number);
  8185. private _shadowsHue;
  8186. private _shadowsDensity;
  8187. private _shadowsSaturation;
  8188. private _shadowsExposure;
  8189. /**
  8190. * Gets the shadows Hue value.
  8191. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8192. */
  8193. get shadowsHue(): number;
  8194. /**
  8195. * Sets the shadows Hue value.
  8196. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8197. */
  8198. set shadowsHue(value: number);
  8199. /**
  8200. * Gets the shadows Density value.
  8201. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8202. * Values less than zero provide a filter of opposite hue.
  8203. */
  8204. get shadowsDensity(): number;
  8205. /**
  8206. * Sets the shadows Density value.
  8207. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8208. * Values less than zero provide a filter of opposite hue.
  8209. */
  8210. set shadowsDensity(value: number);
  8211. /**
  8212. * Gets the shadows Saturation value.
  8213. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8214. */
  8215. get shadowsSaturation(): number;
  8216. /**
  8217. * Sets the shadows Saturation value.
  8218. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8219. */
  8220. set shadowsSaturation(value: number);
  8221. /**
  8222. * Gets the shadows Exposure value.
  8223. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8224. */
  8225. get shadowsExposure(): number;
  8226. /**
  8227. * Sets the shadows Exposure value.
  8228. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8229. */
  8230. set shadowsExposure(value: number);
  8231. /**
  8232. * Returns the class name
  8233. * @returns The class name
  8234. */
  8235. getClassName(): string;
  8236. /**
  8237. * Binds the color curves to the shader.
  8238. * @param colorCurves The color curve to bind
  8239. * @param effect The effect to bind to
  8240. * @param positiveUniform The positive uniform shader parameter
  8241. * @param neutralUniform The neutral uniform shader parameter
  8242. * @param negativeUniform The negative uniform shader parameter
  8243. */
  8244. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8245. /**
  8246. * Prepare the list of uniforms associated with the ColorCurves effects.
  8247. * @param uniformsList The list of uniforms used in the effect
  8248. */
  8249. static PrepareUniforms(uniformsList: string[]): void;
  8250. /**
  8251. * Returns color grading data based on a hue, density, saturation and exposure value.
  8252. * @param filterHue The hue of the color filter.
  8253. * @param filterDensity The density of the color filter.
  8254. * @param saturation The saturation.
  8255. * @param exposure The exposure.
  8256. * @param result The result data container.
  8257. */
  8258. private getColorGradingDataToRef;
  8259. /**
  8260. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8261. * @param value The input slider value in range [-100,100].
  8262. * @returns Adjusted value.
  8263. */
  8264. private static applyColorGradingSliderNonlinear;
  8265. /**
  8266. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8267. * @param hue The hue (H) input.
  8268. * @param saturation The saturation (S) input.
  8269. * @param brightness The brightness (B) input.
  8270. * @result An RGBA color represented as Vector4.
  8271. */
  8272. private static fromHSBToRef;
  8273. /**
  8274. * Returns a value clamped between min and max
  8275. * @param value The value to clamp
  8276. * @param min The minimum of value
  8277. * @param max The maximum of value
  8278. * @returns The clamped value.
  8279. */
  8280. private static clamp;
  8281. /**
  8282. * Clones the current color curve instance.
  8283. * @return The cloned curves
  8284. */
  8285. clone(): ColorCurves;
  8286. /**
  8287. * Serializes the current color curve instance to a json representation.
  8288. * @return a JSON representation
  8289. */
  8290. serialize(): any;
  8291. /**
  8292. * Parses the color curve from a json representation.
  8293. * @param source the JSON source to parse
  8294. * @return The parsed curves
  8295. */
  8296. static Parse(source: any): ColorCurves;
  8297. }
  8298. }
  8299. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8300. import { Observable } from "babylonjs/Misc/observable";
  8301. import { Nullable } from "babylonjs/types";
  8302. import { Color4 } from "babylonjs/Maths/math.color";
  8303. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8304. import { Effect } from "babylonjs/Materials/effect";
  8305. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8306. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8307. /**
  8308. * Interface to follow in your material defines to integrate easily the
  8309. * Image proccessing functions.
  8310. * @hidden
  8311. */
  8312. export interface IImageProcessingConfigurationDefines {
  8313. IMAGEPROCESSING: boolean;
  8314. VIGNETTE: boolean;
  8315. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8316. VIGNETTEBLENDMODEOPAQUE: boolean;
  8317. TONEMAPPING: boolean;
  8318. TONEMAPPING_ACES: boolean;
  8319. CONTRAST: boolean;
  8320. EXPOSURE: boolean;
  8321. COLORCURVES: boolean;
  8322. COLORGRADING: boolean;
  8323. COLORGRADING3D: boolean;
  8324. SAMPLER3DGREENDEPTH: boolean;
  8325. SAMPLER3DBGRMAP: boolean;
  8326. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8327. }
  8328. /**
  8329. * @hidden
  8330. */
  8331. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8332. IMAGEPROCESSING: boolean;
  8333. VIGNETTE: boolean;
  8334. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8335. VIGNETTEBLENDMODEOPAQUE: boolean;
  8336. TONEMAPPING: boolean;
  8337. TONEMAPPING_ACES: boolean;
  8338. CONTRAST: boolean;
  8339. COLORCURVES: boolean;
  8340. COLORGRADING: boolean;
  8341. COLORGRADING3D: boolean;
  8342. SAMPLER3DGREENDEPTH: boolean;
  8343. SAMPLER3DBGRMAP: boolean;
  8344. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8345. EXPOSURE: boolean;
  8346. constructor();
  8347. }
  8348. /**
  8349. * This groups together the common properties used for image processing either in direct forward pass
  8350. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8351. * or not.
  8352. */
  8353. export class ImageProcessingConfiguration {
  8354. /**
  8355. * Default tone mapping applied in BabylonJS.
  8356. */
  8357. static readonly TONEMAPPING_STANDARD: number;
  8358. /**
  8359. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8360. * to other engines rendering to increase portability.
  8361. */
  8362. static readonly TONEMAPPING_ACES: number;
  8363. /**
  8364. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8365. */
  8366. colorCurves: Nullable<ColorCurves>;
  8367. private _colorCurvesEnabled;
  8368. /**
  8369. * Gets wether the color curves effect is enabled.
  8370. */
  8371. get colorCurvesEnabled(): boolean;
  8372. /**
  8373. * Sets wether the color curves effect is enabled.
  8374. */
  8375. set colorCurvesEnabled(value: boolean);
  8376. private _colorGradingTexture;
  8377. /**
  8378. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8379. */
  8380. get colorGradingTexture(): Nullable<BaseTexture>;
  8381. /**
  8382. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8383. */
  8384. set colorGradingTexture(value: Nullable<BaseTexture>);
  8385. private _colorGradingEnabled;
  8386. /**
  8387. * Gets wether the color grading effect is enabled.
  8388. */
  8389. get colorGradingEnabled(): boolean;
  8390. /**
  8391. * Sets wether the color grading effect is enabled.
  8392. */
  8393. set colorGradingEnabled(value: boolean);
  8394. private _colorGradingWithGreenDepth;
  8395. /**
  8396. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8397. */
  8398. get colorGradingWithGreenDepth(): boolean;
  8399. /**
  8400. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8401. */
  8402. set colorGradingWithGreenDepth(value: boolean);
  8403. private _colorGradingBGR;
  8404. /**
  8405. * Gets wether the color grading texture contains BGR values.
  8406. */
  8407. get colorGradingBGR(): boolean;
  8408. /**
  8409. * Sets wether the color grading texture contains BGR values.
  8410. */
  8411. set colorGradingBGR(value: boolean);
  8412. /** @hidden */
  8413. _exposure: number;
  8414. /**
  8415. * Gets the Exposure used in the effect.
  8416. */
  8417. get exposure(): number;
  8418. /**
  8419. * Sets the Exposure used in the effect.
  8420. */
  8421. set exposure(value: number);
  8422. private _toneMappingEnabled;
  8423. /**
  8424. * Gets wether the tone mapping effect is enabled.
  8425. */
  8426. get toneMappingEnabled(): boolean;
  8427. /**
  8428. * Sets wether the tone mapping effect is enabled.
  8429. */
  8430. set toneMappingEnabled(value: boolean);
  8431. private _toneMappingType;
  8432. /**
  8433. * Gets the type of tone mapping effect.
  8434. */
  8435. get toneMappingType(): number;
  8436. /**
  8437. * Sets the type of tone mapping effect used in BabylonJS.
  8438. */
  8439. set toneMappingType(value: number);
  8440. protected _contrast: number;
  8441. /**
  8442. * Gets the contrast used in the effect.
  8443. */
  8444. get contrast(): number;
  8445. /**
  8446. * Sets the contrast used in the effect.
  8447. */
  8448. set contrast(value: number);
  8449. /**
  8450. * Vignette stretch size.
  8451. */
  8452. vignetteStretch: number;
  8453. /**
  8454. * Vignette centre X Offset.
  8455. */
  8456. vignetteCentreX: number;
  8457. /**
  8458. * Vignette centre Y Offset.
  8459. */
  8460. vignetteCentreY: number;
  8461. /**
  8462. * Vignette weight or intensity of the vignette effect.
  8463. */
  8464. vignetteWeight: number;
  8465. /**
  8466. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8467. * if vignetteEnabled is set to true.
  8468. */
  8469. vignetteColor: Color4;
  8470. /**
  8471. * Camera field of view used by the Vignette effect.
  8472. */
  8473. vignetteCameraFov: number;
  8474. private _vignetteBlendMode;
  8475. /**
  8476. * Gets the vignette blend mode allowing different kind of effect.
  8477. */
  8478. get vignetteBlendMode(): number;
  8479. /**
  8480. * Sets the vignette blend mode allowing different kind of effect.
  8481. */
  8482. set vignetteBlendMode(value: number);
  8483. private _vignetteEnabled;
  8484. /**
  8485. * Gets wether the vignette effect is enabled.
  8486. */
  8487. get vignetteEnabled(): boolean;
  8488. /**
  8489. * Sets wether the vignette effect is enabled.
  8490. */
  8491. set vignetteEnabled(value: boolean);
  8492. private _applyByPostProcess;
  8493. /**
  8494. * Gets wether the image processing is applied through a post process or not.
  8495. */
  8496. get applyByPostProcess(): boolean;
  8497. /**
  8498. * Sets wether the image processing is applied through a post process or not.
  8499. */
  8500. set applyByPostProcess(value: boolean);
  8501. private _isEnabled;
  8502. /**
  8503. * Gets wether the image processing is enabled or not.
  8504. */
  8505. get isEnabled(): boolean;
  8506. /**
  8507. * Sets wether the image processing is enabled or not.
  8508. */
  8509. set isEnabled(value: boolean);
  8510. /**
  8511. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8512. */
  8513. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8514. /**
  8515. * Method called each time the image processing information changes requires to recompile the effect.
  8516. */
  8517. protected _updateParameters(): void;
  8518. /**
  8519. * Gets the current class name.
  8520. * @return "ImageProcessingConfiguration"
  8521. */
  8522. getClassName(): string;
  8523. /**
  8524. * Prepare the list of uniforms associated with the Image Processing effects.
  8525. * @param uniforms The list of uniforms used in the effect
  8526. * @param defines the list of defines currently in use
  8527. */
  8528. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8529. /**
  8530. * Prepare the list of samplers associated with the Image Processing effects.
  8531. * @param samplersList The list of uniforms used in the effect
  8532. * @param defines the list of defines currently in use
  8533. */
  8534. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8535. /**
  8536. * Prepare the list of defines associated to the shader.
  8537. * @param defines the list of defines to complete
  8538. * @param forPostProcess Define if we are currently in post process mode or not
  8539. */
  8540. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8541. /**
  8542. * Returns true if all the image processing information are ready.
  8543. * @returns True if ready, otherwise, false
  8544. */
  8545. isReady(): boolean;
  8546. /**
  8547. * Binds the image processing to the shader.
  8548. * @param effect The effect to bind to
  8549. * @param overrideAspectRatio Override the aspect ratio of the effect
  8550. */
  8551. bind(effect: Effect, overrideAspectRatio?: number): void;
  8552. /**
  8553. * Clones the current image processing instance.
  8554. * @return The cloned image processing
  8555. */
  8556. clone(): ImageProcessingConfiguration;
  8557. /**
  8558. * Serializes the current image processing instance to a json representation.
  8559. * @return a JSON representation
  8560. */
  8561. serialize(): any;
  8562. /**
  8563. * Parses the image processing from a json representation.
  8564. * @param source the JSON source to parse
  8565. * @return The parsed image processing
  8566. */
  8567. static Parse(source: any): ImageProcessingConfiguration;
  8568. private static _VIGNETTEMODE_MULTIPLY;
  8569. private static _VIGNETTEMODE_OPAQUE;
  8570. /**
  8571. * Used to apply the vignette as a mix with the pixel color.
  8572. */
  8573. static get VIGNETTEMODE_MULTIPLY(): number;
  8574. /**
  8575. * Used to apply the vignette as a replacement of the pixel color.
  8576. */
  8577. static get VIGNETTEMODE_OPAQUE(): number;
  8578. }
  8579. }
  8580. declare module "babylonjs/Shaders/postprocess.vertex" {
  8581. /** @hidden */
  8582. export var postprocessVertexShader: {
  8583. name: string;
  8584. shader: string;
  8585. };
  8586. }
  8587. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  8588. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8589. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  8590. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  8591. module "babylonjs/Engines/thinEngine" {
  8592. interface ThinEngine {
  8593. /**
  8594. * Creates a new render target texture
  8595. * @param size defines the size of the texture
  8596. * @param options defines the options used to create the texture
  8597. * @returns a new render target texture stored in an InternalTexture
  8598. */
  8599. createRenderTargetTexture(size: number | {
  8600. width: number;
  8601. height: number;
  8602. layers?: number;
  8603. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8604. /**
  8605. * Creates a depth stencil texture.
  8606. * This is only available in WebGL 2 or with the depth texture extension available.
  8607. * @param size The size of face edge in the texture.
  8608. * @param options The options defining the texture.
  8609. * @returns The texture
  8610. */
  8611. createDepthStencilTexture(size: number | {
  8612. width: number;
  8613. height: number;
  8614. layers?: number;
  8615. }, options: DepthTextureCreationOptions): InternalTexture;
  8616. /** @hidden */
  8617. _createDepthStencilTexture(size: number | {
  8618. width: number;
  8619. height: number;
  8620. layers?: number;
  8621. }, options: DepthTextureCreationOptions): InternalTexture;
  8622. }
  8623. }
  8624. }
  8625. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  8626. /**
  8627. * Defines the kind of connection point for node based material
  8628. */
  8629. export enum NodeMaterialBlockConnectionPointTypes {
  8630. /** Float */
  8631. Float = 1,
  8632. /** Int */
  8633. Int = 2,
  8634. /** Vector2 */
  8635. Vector2 = 4,
  8636. /** Vector3 */
  8637. Vector3 = 8,
  8638. /** Vector4 */
  8639. Vector4 = 16,
  8640. /** Color3 */
  8641. Color3 = 32,
  8642. /** Color4 */
  8643. Color4 = 64,
  8644. /** Matrix */
  8645. Matrix = 128,
  8646. /** Custom object */
  8647. Object = 256,
  8648. /** Detect type based on connection */
  8649. AutoDetect = 1024,
  8650. /** Output type that will be defined by input type */
  8651. BasedOnInput = 2048
  8652. }
  8653. }
  8654. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  8655. /**
  8656. * Enum used to define the target of a block
  8657. */
  8658. export enum NodeMaterialBlockTargets {
  8659. /** Vertex shader */
  8660. Vertex = 1,
  8661. /** Fragment shader */
  8662. Fragment = 2,
  8663. /** Neutral */
  8664. Neutral = 4,
  8665. /** Vertex and Fragment */
  8666. VertexAndFragment = 3
  8667. }
  8668. }
  8669. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  8670. /**
  8671. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  8672. */
  8673. export enum NodeMaterialBlockConnectionPointMode {
  8674. /** Value is an uniform */
  8675. Uniform = 0,
  8676. /** Value is a mesh attribute */
  8677. Attribute = 1,
  8678. /** Value is a varying between vertex and fragment shaders */
  8679. Varying = 2,
  8680. /** Mode is undefined */
  8681. Undefined = 3
  8682. }
  8683. }
  8684. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  8685. /**
  8686. * Enum used to define system values e.g. values automatically provided by the system
  8687. */
  8688. export enum NodeMaterialSystemValues {
  8689. /** World */
  8690. World = 1,
  8691. /** View */
  8692. View = 2,
  8693. /** Projection */
  8694. Projection = 3,
  8695. /** ViewProjection */
  8696. ViewProjection = 4,
  8697. /** WorldView */
  8698. WorldView = 5,
  8699. /** WorldViewProjection */
  8700. WorldViewProjection = 6,
  8701. /** CameraPosition */
  8702. CameraPosition = 7,
  8703. /** Fog Color */
  8704. FogColor = 8,
  8705. /** Delta time */
  8706. DeltaTime = 9
  8707. }
  8708. }
  8709. declare module "babylonjs/Maths/math.axis" {
  8710. import { Vector3 } from "babylonjs/Maths/math.vector";
  8711. /** Defines supported spaces */
  8712. export enum Space {
  8713. /** Local (object) space */
  8714. LOCAL = 0,
  8715. /** World space */
  8716. WORLD = 1,
  8717. /** Bone space */
  8718. BONE = 2
  8719. }
  8720. /** Defines the 3 main axes */
  8721. export class Axis {
  8722. /** X axis */
  8723. static X: Vector3;
  8724. /** Y axis */
  8725. static Y: Vector3;
  8726. /** Z axis */
  8727. static Z: Vector3;
  8728. }
  8729. }
  8730. declare module "babylonjs/Maths/math.frustum" {
  8731. import { Matrix } from "babylonjs/Maths/math.vector";
  8732. import { DeepImmutable } from "babylonjs/types";
  8733. import { Plane } from "babylonjs/Maths/math.plane";
  8734. /**
  8735. * Represents a camera frustum
  8736. */
  8737. export class Frustum {
  8738. /**
  8739. * Gets the planes representing the frustum
  8740. * @param transform matrix to be applied to the returned planes
  8741. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  8742. */
  8743. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  8744. /**
  8745. * Gets the near frustum plane transformed by the transform matrix
  8746. * @param transform transformation matrix to be applied to the resulting frustum plane
  8747. * @param frustumPlane the resuling frustum plane
  8748. */
  8749. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8750. /**
  8751. * Gets the far frustum plane transformed by the transform matrix
  8752. * @param transform transformation matrix to be applied to the resulting frustum plane
  8753. * @param frustumPlane the resuling frustum plane
  8754. */
  8755. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8756. /**
  8757. * Gets the left frustum plane transformed by the transform matrix
  8758. * @param transform transformation matrix to be applied to the resulting frustum plane
  8759. * @param frustumPlane the resuling frustum plane
  8760. */
  8761. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8762. /**
  8763. * Gets the right frustum plane transformed by the transform matrix
  8764. * @param transform transformation matrix to be applied to the resulting frustum plane
  8765. * @param frustumPlane the resuling frustum plane
  8766. */
  8767. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8768. /**
  8769. * Gets the top frustum plane transformed by the transform matrix
  8770. * @param transform transformation matrix to be applied to the resulting frustum plane
  8771. * @param frustumPlane the resuling frustum plane
  8772. */
  8773. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8774. /**
  8775. * Gets the bottom frustum plane transformed by the transform matrix
  8776. * @param transform transformation matrix to be applied to the resulting frustum plane
  8777. * @param frustumPlane the resuling frustum plane
  8778. */
  8779. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8780. /**
  8781. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  8782. * @param transform transformation matrix to be applied to the resulting frustum planes
  8783. * @param frustumPlanes the resuling frustum planes
  8784. */
  8785. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  8786. }
  8787. }
  8788. declare module "babylonjs/Maths/math.size" {
  8789. /**
  8790. * Interface for the size containing width and height
  8791. */
  8792. export interface ISize {
  8793. /**
  8794. * Width
  8795. */
  8796. width: number;
  8797. /**
  8798. * Heighht
  8799. */
  8800. height: number;
  8801. }
  8802. /**
  8803. * Size containing widht and height
  8804. */
  8805. export class Size implements ISize {
  8806. /**
  8807. * Width
  8808. */
  8809. width: number;
  8810. /**
  8811. * Height
  8812. */
  8813. height: number;
  8814. /**
  8815. * Creates a Size object from the given width and height (floats).
  8816. * @param width width of the new size
  8817. * @param height height of the new size
  8818. */
  8819. constructor(width: number, height: number);
  8820. /**
  8821. * Returns a string with the Size width and height
  8822. * @returns a string with the Size width and height
  8823. */
  8824. toString(): string;
  8825. /**
  8826. * "Size"
  8827. * @returns the string "Size"
  8828. */
  8829. getClassName(): string;
  8830. /**
  8831. * Returns the Size hash code.
  8832. * @returns a hash code for a unique width and height
  8833. */
  8834. getHashCode(): number;
  8835. /**
  8836. * Updates the current size from the given one.
  8837. * @param src the given size
  8838. */
  8839. copyFrom(src: Size): void;
  8840. /**
  8841. * Updates in place the current Size from the given floats.
  8842. * @param width width of the new size
  8843. * @param height height of the new size
  8844. * @returns the updated Size.
  8845. */
  8846. copyFromFloats(width: number, height: number): Size;
  8847. /**
  8848. * Updates in place the current Size from the given floats.
  8849. * @param width width to set
  8850. * @param height height to set
  8851. * @returns the updated Size.
  8852. */
  8853. set(width: number, height: number): Size;
  8854. /**
  8855. * Multiplies the width and height by numbers
  8856. * @param w factor to multiple the width by
  8857. * @param h factor to multiple the height by
  8858. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  8859. */
  8860. multiplyByFloats(w: number, h: number): Size;
  8861. /**
  8862. * Clones the size
  8863. * @returns a new Size copied from the given one.
  8864. */
  8865. clone(): Size;
  8866. /**
  8867. * True if the current Size and the given one width and height are strictly equal.
  8868. * @param other the other size to compare against
  8869. * @returns True if the current Size and the given one width and height are strictly equal.
  8870. */
  8871. equals(other: Size): boolean;
  8872. /**
  8873. * The surface of the Size : width * height (float).
  8874. */
  8875. get surface(): number;
  8876. /**
  8877. * Create a new size of zero
  8878. * @returns a new Size set to (0.0, 0.0)
  8879. */
  8880. static Zero(): Size;
  8881. /**
  8882. * Sums the width and height of two sizes
  8883. * @param otherSize size to add to this size
  8884. * @returns a new Size set as the addition result of the current Size and the given one.
  8885. */
  8886. add(otherSize: Size): Size;
  8887. /**
  8888. * Subtracts the width and height of two
  8889. * @param otherSize size to subtract to this size
  8890. * @returns a new Size set as the subtraction result of the given one from the current Size.
  8891. */
  8892. subtract(otherSize: Size): Size;
  8893. /**
  8894. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  8895. * @param start starting size to lerp between
  8896. * @param end end size to lerp between
  8897. * @param amount amount to lerp between the start and end values
  8898. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  8899. */
  8900. static Lerp(start: Size, end: Size, amount: number): Size;
  8901. }
  8902. }
  8903. declare module "babylonjs/Maths/math.vertexFormat" {
  8904. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  8905. /**
  8906. * Contains position and normal vectors for a vertex
  8907. */
  8908. export class PositionNormalVertex {
  8909. /** the position of the vertex (defaut: 0,0,0) */
  8910. position: Vector3;
  8911. /** the normal of the vertex (defaut: 0,1,0) */
  8912. normal: Vector3;
  8913. /**
  8914. * Creates a PositionNormalVertex
  8915. * @param position the position of the vertex (defaut: 0,0,0)
  8916. * @param normal the normal of the vertex (defaut: 0,1,0)
  8917. */
  8918. constructor(
  8919. /** the position of the vertex (defaut: 0,0,0) */
  8920. position?: Vector3,
  8921. /** the normal of the vertex (defaut: 0,1,0) */
  8922. normal?: Vector3);
  8923. /**
  8924. * Clones the PositionNormalVertex
  8925. * @returns the cloned PositionNormalVertex
  8926. */
  8927. clone(): PositionNormalVertex;
  8928. }
  8929. /**
  8930. * Contains position, normal and uv vectors for a vertex
  8931. */
  8932. export class PositionNormalTextureVertex {
  8933. /** the position of the vertex (defaut: 0,0,0) */
  8934. position: Vector3;
  8935. /** the normal of the vertex (defaut: 0,1,0) */
  8936. normal: Vector3;
  8937. /** the uv of the vertex (default: 0,0) */
  8938. uv: Vector2;
  8939. /**
  8940. * Creates a PositionNormalTextureVertex
  8941. * @param position the position of the vertex (defaut: 0,0,0)
  8942. * @param normal the normal of the vertex (defaut: 0,1,0)
  8943. * @param uv the uv of the vertex (default: 0,0)
  8944. */
  8945. constructor(
  8946. /** the position of the vertex (defaut: 0,0,0) */
  8947. position?: Vector3,
  8948. /** the normal of the vertex (defaut: 0,1,0) */
  8949. normal?: Vector3,
  8950. /** the uv of the vertex (default: 0,0) */
  8951. uv?: Vector2);
  8952. /**
  8953. * Clones the PositionNormalTextureVertex
  8954. * @returns the cloned PositionNormalTextureVertex
  8955. */
  8956. clone(): PositionNormalTextureVertex;
  8957. }
  8958. }
  8959. declare module "babylonjs/Maths/math" {
  8960. export * from "babylonjs/Maths/math.axis";
  8961. export * from "babylonjs/Maths/math.color";
  8962. export * from "babylonjs/Maths/math.constants";
  8963. export * from "babylonjs/Maths/math.frustum";
  8964. export * from "babylonjs/Maths/math.path";
  8965. export * from "babylonjs/Maths/math.plane";
  8966. export * from "babylonjs/Maths/math.size";
  8967. export * from "babylonjs/Maths/math.vector";
  8968. export * from "babylonjs/Maths/math.vertexFormat";
  8969. export * from "babylonjs/Maths/math.viewport";
  8970. }
  8971. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  8972. /**
  8973. * Enum defining the type of animations supported by InputBlock
  8974. */
  8975. export enum AnimatedInputBlockTypes {
  8976. /** No animation */
  8977. None = 0,
  8978. /** Time based animation. Will only work for floats */
  8979. Time = 1
  8980. }
  8981. }
  8982. declare module "babylonjs/Lights/shadowLight" {
  8983. import { Camera } from "babylonjs/Cameras/camera";
  8984. import { Scene } from "babylonjs/scene";
  8985. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  8986. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8987. import { Light } from "babylonjs/Lights/light";
  8988. /**
  8989. * Interface describing all the common properties and methods a shadow light needs to implement.
  8990. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8991. * as well as binding the different shadow properties to the effects.
  8992. */
  8993. export interface IShadowLight extends Light {
  8994. /**
  8995. * The light id in the scene (used in scene.findLighById for instance)
  8996. */
  8997. id: string;
  8998. /**
  8999. * The position the shdow will be casted from.
  9000. */
  9001. position: Vector3;
  9002. /**
  9003. * In 2d mode (needCube being false), the direction used to cast the shadow.
  9004. */
  9005. direction: Vector3;
  9006. /**
  9007. * The transformed position. Position of the light in world space taking parenting in account.
  9008. */
  9009. transformedPosition: Vector3;
  9010. /**
  9011. * The transformed direction. Direction of the light in world space taking parenting in account.
  9012. */
  9013. transformedDirection: Vector3;
  9014. /**
  9015. * The friendly name of the light in the scene.
  9016. */
  9017. name: string;
  9018. /**
  9019. * Defines the shadow projection clipping minimum z value.
  9020. */
  9021. shadowMinZ: number;
  9022. /**
  9023. * Defines the shadow projection clipping maximum z value.
  9024. */
  9025. shadowMaxZ: number;
  9026. /**
  9027. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9028. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9029. */
  9030. computeTransformedInformation(): boolean;
  9031. /**
  9032. * Gets the scene the light belongs to.
  9033. * @returns The scene
  9034. */
  9035. getScene(): Scene;
  9036. /**
  9037. * Callback defining a custom Projection Matrix Builder.
  9038. * This can be used to override the default projection matrix computation.
  9039. */
  9040. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9041. /**
  9042. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9043. * @param matrix The materix to updated with the projection information
  9044. * @param viewMatrix The transform matrix of the light
  9045. * @param renderList The list of mesh to render in the map
  9046. * @returns The current light
  9047. */
  9048. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9049. /**
  9050. * Gets the current depth scale used in ESM.
  9051. * @returns The scale
  9052. */
  9053. getDepthScale(): number;
  9054. /**
  9055. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9056. * @returns true if a cube texture needs to be use
  9057. */
  9058. needCube(): boolean;
  9059. /**
  9060. * Detects if the projection matrix requires to be recomputed this frame.
  9061. * @returns true if it requires to be recomputed otherwise, false.
  9062. */
  9063. needProjectionMatrixCompute(): boolean;
  9064. /**
  9065. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9066. */
  9067. forceProjectionMatrixCompute(): void;
  9068. /**
  9069. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9070. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9071. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9072. */
  9073. getShadowDirection(faceIndex?: number): Vector3;
  9074. /**
  9075. * Gets the minZ used for shadow according to both the scene and the light.
  9076. * @param activeCamera The camera we are returning the min for
  9077. * @returns the depth min z
  9078. */
  9079. getDepthMinZ(activeCamera: Camera): number;
  9080. /**
  9081. * Gets the maxZ used for shadow according to both the scene and the light.
  9082. * @param activeCamera The camera we are returning the max for
  9083. * @returns the depth max z
  9084. */
  9085. getDepthMaxZ(activeCamera: Camera): number;
  9086. }
  9087. /**
  9088. * Base implementation IShadowLight
  9089. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9090. */
  9091. export abstract class ShadowLight extends Light implements IShadowLight {
  9092. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9093. protected _position: Vector3;
  9094. protected _setPosition(value: Vector3): void;
  9095. /**
  9096. * Sets the position the shadow will be casted from. Also use as the light position for both
  9097. * point and spot lights.
  9098. */
  9099. get position(): Vector3;
  9100. /**
  9101. * Sets the position the shadow will be casted from. Also use as the light position for both
  9102. * point and spot lights.
  9103. */
  9104. set position(value: Vector3);
  9105. protected _direction: Vector3;
  9106. protected _setDirection(value: Vector3): void;
  9107. /**
  9108. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9109. * Also use as the light direction on spot and directional lights.
  9110. */
  9111. get direction(): Vector3;
  9112. /**
  9113. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9114. * Also use as the light direction on spot and directional lights.
  9115. */
  9116. set direction(value: Vector3);
  9117. protected _shadowMinZ: number;
  9118. /**
  9119. * Gets the shadow projection clipping minimum z value.
  9120. */
  9121. get shadowMinZ(): number;
  9122. /**
  9123. * Sets the shadow projection clipping minimum z value.
  9124. */
  9125. set shadowMinZ(value: number);
  9126. protected _shadowMaxZ: number;
  9127. /**
  9128. * Sets the shadow projection clipping maximum z value.
  9129. */
  9130. get shadowMaxZ(): number;
  9131. /**
  9132. * Gets the shadow projection clipping maximum z value.
  9133. */
  9134. set shadowMaxZ(value: number);
  9135. /**
  9136. * Callback defining a custom Projection Matrix Builder.
  9137. * This can be used to override the default projection matrix computation.
  9138. */
  9139. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9140. /**
  9141. * The transformed position. Position of the light in world space taking parenting in account.
  9142. */
  9143. transformedPosition: Vector3;
  9144. /**
  9145. * The transformed direction. Direction of the light in world space taking parenting in account.
  9146. */
  9147. transformedDirection: Vector3;
  9148. private _needProjectionMatrixCompute;
  9149. /**
  9150. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9151. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9152. */
  9153. computeTransformedInformation(): boolean;
  9154. /**
  9155. * Return the depth scale used for the shadow map.
  9156. * @returns the depth scale.
  9157. */
  9158. getDepthScale(): number;
  9159. /**
  9160. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9161. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9162. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9163. */
  9164. getShadowDirection(faceIndex?: number): Vector3;
  9165. /**
  9166. * Returns the ShadowLight absolute position in the World.
  9167. * @returns the position vector in world space
  9168. */
  9169. getAbsolutePosition(): Vector3;
  9170. /**
  9171. * Sets the ShadowLight direction toward the passed target.
  9172. * @param target The point to target in local space
  9173. * @returns the updated ShadowLight direction
  9174. */
  9175. setDirectionToTarget(target: Vector3): Vector3;
  9176. /**
  9177. * Returns the light rotation in euler definition.
  9178. * @returns the x y z rotation in local space.
  9179. */
  9180. getRotation(): Vector3;
  9181. /**
  9182. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9183. * @returns true if a cube texture needs to be use
  9184. */
  9185. needCube(): boolean;
  9186. /**
  9187. * Detects if the projection matrix requires to be recomputed this frame.
  9188. * @returns true if it requires to be recomputed otherwise, false.
  9189. */
  9190. needProjectionMatrixCompute(): boolean;
  9191. /**
  9192. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9193. */
  9194. forceProjectionMatrixCompute(): void;
  9195. /** @hidden */
  9196. _initCache(): void;
  9197. /** @hidden */
  9198. _isSynchronized(): boolean;
  9199. /**
  9200. * Computes the world matrix of the node
  9201. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9202. * @returns the world matrix
  9203. */
  9204. computeWorldMatrix(force?: boolean): Matrix;
  9205. /**
  9206. * Gets the minZ used for shadow according to both the scene and the light.
  9207. * @param activeCamera The camera we are returning the min for
  9208. * @returns the depth min z
  9209. */
  9210. getDepthMinZ(activeCamera: Camera): number;
  9211. /**
  9212. * Gets the maxZ used for shadow according to both the scene and the light.
  9213. * @param activeCamera The camera we are returning the max for
  9214. * @returns the depth max z
  9215. */
  9216. getDepthMaxZ(activeCamera: Camera): number;
  9217. /**
  9218. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9219. * @param matrix The materix to updated with the projection information
  9220. * @param viewMatrix The transform matrix of the light
  9221. * @param renderList The list of mesh to render in the map
  9222. * @returns The current light
  9223. */
  9224. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9225. }
  9226. }
  9227. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9228. /** @hidden */
  9229. export var packingFunctions: {
  9230. name: string;
  9231. shader: string;
  9232. };
  9233. }
  9234. declare module "babylonjs/Shaders/ShadersInclude/bayerDitherFunctions" {
  9235. /** @hidden */
  9236. export var bayerDitherFunctions: {
  9237. name: string;
  9238. shader: string;
  9239. };
  9240. }
  9241. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragmentDeclaration" {
  9242. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9243. import "babylonjs/Shaders/ShadersInclude/bayerDitherFunctions";
  9244. /** @hidden */
  9245. export var shadowMapFragmentDeclaration: {
  9246. name: string;
  9247. shader: string;
  9248. };
  9249. }
  9250. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  9251. /** @hidden */
  9252. export var clipPlaneFragmentDeclaration: {
  9253. name: string;
  9254. shader: string;
  9255. };
  9256. }
  9257. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  9258. /** @hidden */
  9259. export var clipPlaneFragment: {
  9260. name: string;
  9261. shader: string;
  9262. };
  9263. }
  9264. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragment" {
  9265. /** @hidden */
  9266. export var shadowMapFragment: {
  9267. name: string;
  9268. shader: string;
  9269. };
  9270. }
  9271. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9272. import "babylonjs/Shaders/ShadersInclude/shadowMapFragmentDeclaration";
  9273. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  9274. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  9275. import "babylonjs/Shaders/ShadersInclude/shadowMapFragment";
  9276. /** @hidden */
  9277. export var shadowMapPixelShader: {
  9278. name: string;
  9279. shader: string;
  9280. };
  9281. }
  9282. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9283. /** @hidden */
  9284. export var bonesDeclaration: {
  9285. name: string;
  9286. shader: string;
  9287. };
  9288. }
  9289. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9290. /** @hidden */
  9291. export var morphTargetsVertexGlobalDeclaration: {
  9292. name: string;
  9293. shader: string;
  9294. };
  9295. }
  9296. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9297. /** @hidden */
  9298. export var morphTargetsVertexDeclaration: {
  9299. name: string;
  9300. shader: string;
  9301. };
  9302. }
  9303. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9304. /** @hidden */
  9305. export var instancesDeclaration: {
  9306. name: string;
  9307. shader: string;
  9308. };
  9309. }
  9310. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9311. /** @hidden */
  9312. export var helperFunctions: {
  9313. name: string;
  9314. shader: string;
  9315. };
  9316. }
  9317. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexDeclaration" {
  9318. /** @hidden */
  9319. export var shadowMapVertexDeclaration: {
  9320. name: string;
  9321. shader: string;
  9322. };
  9323. }
  9324. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  9325. /** @hidden */
  9326. export var clipPlaneVertexDeclaration: {
  9327. name: string;
  9328. shader: string;
  9329. };
  9330. }
  9331. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9332. /** @hidden */
  9333. export var morphTargetsVertex: {
  9334. name: string;
  9335. shader: string;
  9336. };
  9337. }
  9338. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9339. /** @hidden */
  9340. export var instancesVertex: {
  9341. name: string;
  9342. shader: string;
  9343. };
  9344. }
  9345. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9346. /** @hidden */
  9347. export var bonesVertex: {
  9348. name: string;
  9349. shader: string;
  9350. };
  9351. }
  9352. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexNormalBias" {
  9353. /** @hidden */
  9354. export var shadowMapVertexNormalBias: {
  9355. name: string;
  9356. shader: string;
  9357. };
  9358. }
  9359. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexMetric" {
  9360. /** @hidden */
  9361. export var shadowMapVertexMetric: {
  9362. name: string;
  9363. shader: string;
  9364. };
  9365. }
  9366. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  9367. /** @hidden */
  9368. export var clipPlaneVertex: {
  9369. name: string;
  9370. shader: string;
  9371. };
  9372. }
  9373. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9374. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9375. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9376. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9377. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9378. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9379. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexDeclaration";
  9380. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  9381. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9382. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9383. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9384. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexNormalBias";
  9385. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexMetric";
  9386. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  9387. /** @hidden */
  9388. export var shadowMapVertexShader: {
  9389. name: string;
  9390. shader: string;
  9391. };
  9392. }
  9393. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9394. /** @hidden */
  9395. export var depthBoxBlurPixelShader: {
  9396. name: string;
  9397. shader: string;
  9398. };
  9399. }
  9400. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragmentSoftTransparentShadow" {
  9401. /** @hidden */
  9402. export var shadowMapFragmentSoftTransparentShadow: {
  9403. name: string;
  9404. shader: string;
  9405. };
  9406. }
  9407. declare module "babylonjs/Materials/effectFallbacks" {
  9408. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  9409. import { Effect } from "babylonjs/Materials/effect";
  9410. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9411. /**
  9412. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9413. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9414. */
  9415. export class EffectFallbacks implements IEffectFallbacks {
  9416. private _defines;
  9417. private _currentRank;
  9418. private _maxRank;
  9419. private _mesh;
  9420. /**
  9421. * Removes the fallback from the bound mesh.
  9422. */
  9423. unBindMesh(): void;
  9424. /**
  9425. * Adds a fallback on the specified property.
  9426. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9427. * @param define The name of the define in the shader
  9428. */
  9429. addFallback(rank: number, define: string): void;
  9430. /**
  9431. * Sets the mesh to use CPU skinning when needing to fallback.
  9432. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9433. * @param mesh The mesh to use the fallbacks.
  9434. */
  9435. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9436. /**
  9437. * Checks to see if more fallbacks are still availible.
  9438. */
  9439. get hasMoreFallbacks(): boolean;
  9440. /**
  9441. * Removes the defines that should be removed when falling back.
  9442. * @param currentDefines defines the current define statements for the shader.
  9443. * @param effect defines the current effect we try to compile
  9444. * @returns The resulting defines with defines of the current rank removed.
  9445. */
  9446. reduce(currentDefines: string, effect: Effect): string;
  9447. }
  9448. }
  9449. declare module "babylonjs/Actions/action" {
  9450. import { Observable } from "babylonjs/Misc/observable";
  9451. import { Condition } from "babylonjs/Actions/condition";
  9452. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  9453. import { ActionManager } from "babylonjs/Actions/actionManager";
  9454. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  9455. /**
  9456. * Interface used to define Action
  9457. */
  9458. export interface IAction {
  9459. /**
  9460. * Trigger for the action
  9461. */
  9462. trigger: number;
  9463. /** Options of the trigger */
  9464. triggerOptions: any;
  9465. /**
  9466. * Gets the trigger parameters
  9467. * @returns the trigger parameters
  9468. */
  9469. getTriggerParameter(): any;
  9470. /**
  9471. * Internal only - executes current action event
  9472. * @hidden
  9473. */
  9474. _executeCurrent(evt?: ActionEvent): void;
  9475. /**
  9476. * Serialize placeholder for child classes
  9477. * @param parent of child
  9478. * @returns the serialized object
  9479. */
  9480. serialize(parent: any): any;
  9481. /**
  9482. * Internal only
  9483. * @hidden
  9484. */
  9485. _prepare(): void;
  9486. /**
  9487. * Internal only - manager for action
  9488. * @hidden
  9489. */
  9490. _actionManager: AbstractActionManager;
  9491. /**
  9492. * Adds action to chain of actions, may be a DoNothingAction
  9493. * @param action defines the next action to execute
  9494. * @returns The action passed in
  9495. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9496. */
  9497. then(action: IAction): IAction;
  9498. }
  9499. /**
  9500. * The action to be carried out following a trigger
  9501. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  9502. */
  9503. export class Action implements IAction {
  9504. /** the trigger, with or without parameters, for the action */
  9505. triggerOptions: any;
  9506. /**
  9507. * Trigger for the action
  9508. */
  9509. trigger: number;
  9510. /**
  9511. * Internal only - manager for action
  9512. * @hidden
  9513. */
  9514. _actionManager: ActionManager;
  9515. private _nextActiveAction;
  9516. private _child;
  9517. private _condition?;
  9518. private _triggerParameter;
  9519. /**
  9520. * An event triggered prior to action being executed.
  9521. */
  9522. onBeforeExecuteObservable: Observable<Action>;
  9523. /**
  9524. * Creates a new Action
  9525. * @param triggerOptions the trigger, with or without parameters, for the action
  9526. * @param condition an optional determinant of action
  9527. */
  9528. constructor(
  9529. /** the trigger, with or without parameters, for the action */
  9530. triggerOptions: any, condition?: Condition);
  9531. /**
  9532. * Internal only
  9533. * @hidden
  9534. */
  9535. _prepare(): void;
  9536. /**
  9537. * Gets the trigger parameters
  9538. * @returns the trigger parameters
  9539. */
  9540. getTriggerParameter(): any;
  9541. /**
  9542. * Internal only - executes current action event
  9543. * @hidden
  9544. */
  9545. _executeCurrent(evt?: ActionEvent): void;
  9546. /**
  9547. * Execute placeholder for child classes
  9548. * @param evt optional action event
  9549. */
  9550. execute(evt?: ActionEvent): void;
  9551. /**
  9552. * Skips to next active action
  9553. */
  9554. skipToNextActiveAction(): void;
  9555. /**
  9556. * Adds action to chain of actions, may be a DoNothingAction
  9557. * @param action defines the next action to execute
  9558. * @returns The action passed in
  9559. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9560. */
  9561. then(action: Action): Action;
  9562. /**
  9563. * Internal only
  9564. * @hidden
  9565. */
  9566. _getProperty(propertyPath: string): string;
  9567. /**
  9568. * Internal only
  9569. * @hidden
  9570. */
  9571. _getEffectiveTarget(target: any, propertyPath: string): any;
  9572. /**
  9573. * Serialize placeholder for child classes
  9574. * @param parent of child
  9575. * @returns the serialized object
  9576. */
  9577. serialize(parent: any): any;
  9578. /**
  9579. * Internal only called by serialize
  9580. * @hidden
  9581. */
  9582. protected _serialize(serializedAction: any, parent?: any): any;
  9583. /**
  9584. * Internal only
  9585. * @hidden
  9586. */
  9587. static _SerializeValueAsString: (value: any) => string;
  9588. /**
  9589. * Internal only
  9590. * @hidden
  9591. */
  9592. static _GetTargetProperty: (target: import("babylonjs/node").Node | import("babylonjs/scene").Scene) => {
  9593. name: string;
  9594. targetType: string;
  9595. value: string;
  9596. };
  9597. }
  9598. }
  9599. declare module "babylonjs/Actions/condition" {
  9600. import { ActionManager } from "babylonjs/Actions/actionManager";
  9601. /**
  9602. * A Condition applied to an Action
  9603. */
  9604. export class Condition {
  9605. /**
  9606. * Internal only - manager for action
  9607. * @hidden
  9608. */
  9609. _actionManager: ActionManager;
  9610. /**
  9611. * Internal only
  9612. * @hidden
  9613. */
  9614. _evaluationId: number;
  9615. /**
  9616. * Internal only
  9617. * @hidden
  9618. */
  9619. _currentResult: boolean;
  9620. /**
  9621. * Creates a new Condition
  9622. * @param actionManager the manager of the action the condition is applied to
  9623. */
  9624. constructor(actionManager: ActionManager);
  9625. /**
  9626. * Check if the current condition is valid
  9627. * @returns a boolean
  9628. */
  9629. isValid(): boolean;
  9630. /**
  9631. * Internal only
  9632. * @hidden
  9633. */
  9634. _getProperty(propertyPath: string): string;
  9635. /**
  9636. * Internal only
  9637. * @hidden
  9638. */
  9639. _getEffectiveTarget(target: any, propertyPath: string): any;
  9640. /**
  9641. * Serialize placeholder for child classes
  9642. * @returns the serialized object
  9643. */
  9644. serialize(): any;
  9645. /**
  9646. * Internal only
  9647. * @hidden
  9648. */
  9649. protected _serialize(serializedCondition: any): any;
  9650. }
  9651. /**
  9652. * Defines specific conditional operators as extensions of Condition
  9653. */
  9654. export class ValueCondition extends Condition {
  9655. /** path to specify the property of the target the conditional operator uses */
  9656. propertyPath: string;
  9657. /** the value compared by the conditional operator against the current value of the property */
  9658. value: any;
  9659. /** the conditional operator, default ValueCondition.IsEqual */
  9660. operator: number;
  9661. /**
  9662. * Internal only
  9663. * @hidden
  9664. */
  9665. private static _IsEqual;
  9666. /**
  9667. * Internal only
  9668. * @hidden
  9669. */
  9670. private static _IsDifferent;
  9671. /**
  9672. * Internal only
  9673. * @hidden
  9674. */
  9675. private static _IsGreater;
  9676. /**
  9677. * Internal only
  9678. * @hidden
  9679. */
  9680. private static _IsLesser;
  9681. /**
  9682. * returns the number for IsEqual
  9683. */
  9684. static get IsEqual(): number;
  9685. /**
  9686. * Returns the number for IsDifferent
  9687. */
  9688. static get IsDifferent(): number;
  9689. /**
  9690. * Returns the number for IsGreater
  9691. */
  9692. static get IsGreater(): number;
  9693. /**
  9694. * Returns the number for IsLesser
  9695. */
  9696. static get IsLesser(): number;
  9697. /**
  9698. * Internal only The action manager for the condition
  9699. * @hidden
  9700. */
  9701. _actionManager: ActionManager;
  9702. /**
  9703. * Internal only
  9704. * @hidden
  9705. */
  9706. private _target;
  9707. /**
  9708. * Internal only
  9709. * @hidden
  9710. */
  9711. private _effectiveTarget;
  9712. /**
  9713. * Internal only
  9714. * @hidden
  9715. */
  9716. private _property;
  9717. /**
  9718. * Creates a new ValueCondition
  9719. * @param actionManager manager for the action the condition applies to
  9720. * @param target for the action
  9721. * @param propertyPath path to specify the property of the target the conditional operator uses
  9722. * @param value the value compared by the conditional operator against the current value of the property
  9723. * @param operator the conditional operator, default ValueCondition.IsEqual
  9724. */
  9725. constructor(actionManager: ActionManager, target: any,
  9726. /** path to specify the property of the target the conditional operator uses */
  9727. propertyPath: string,
  9728. /** the value compared by the conditional operator against the current value of the property */
  9729. value: any,
  9730. /** the conditional operator, default ValueCondition.IsEqual */
  9731. operator?: number);
  9732. /**
  9733. * Compares the given value with the property value for the specified conditional operator
  9734. * @returns the result of the comparison
  9735. */
  9736. isValid(): boolean;
  9737. /**
  9738. * Serialize the ValueCondition into a JSON compatible object
  9739. * @returns serialization object
  9740. */
  9741. serialize(): any;
  9742. /**
  9743. * Gets the name of the conditional operator for the ValueCondition
  9744. * @param operator the conditional operator
  9745. * @returns the name
  9746. */
  9747. static GetOperatorName(operator: number): string;
  9748. }
  9749. /**
  9750. * Defines a predicate condition as an extension of Condition
  9751. */
  9752. export class PredicateCondition extends Condition {
  9753. /** defines the predicate function used to validate the condition */
  9754. predicate: () => boolean;
  9755. /**
  9756. * Internal only - manager for action
  9757. * @hidden
  9758. */
  9759. _actionManager: ActionManager;
  9760. /**
  9761. * Creates a new PredicateCondition
  9762. * @param actionManager manager for the action the condition applies to
  9763. * @param predicate defines the predicate function used to validate the condition
  9764. */
  9765. constructor(actionManager: ActionManager,
  9766. /** defines the predicate function used to validate the condition */
  9767. predicate: () => boolean);
  9768. /**
  9769. * @returns the validity of the predicate condition
  9770. */
  9771. isValid(): boolean;
  9772. }
  9773. /**
  9774. * Defines a state condition as an extension of Condition
  9775. */
  9776. export class StateCondition extends Condition {
  9777. /** Value to compare with target state */
  9778. value: string;
  9779. /**
  9780. * Internal only - manager for action
  9781. * @hidden
  9782. */
  9783. _actionManager: ActionManager;
  9784. /**
  9785. * Internal only
  9786. * @hidden
  9787. */
  9788. private _target;
  9789. /**
  9790. * Creates a new StateCondition
  9791. * @param actionManager manager for the action the condition applies to
  9792. * @param target of the condition
  9793. * @param value to compare with target state
  9794. */
  9795. constructor(actionManager: ActionManager, target: any,
  9796. /** Value to compare with target state */
  9797. value: string);
  9798. /**
  9799. * Gets a boolean indicating if the current condition is met
  9800. * @returns the validity of the state
  9801. */
  9802. isValid(): boolean;
  9803. /**
  9804. * Serialize the StateCondition into a JSON compatible object
  9805. * @returns serialization object
  9806. */
  9807. serialize(): any;
  9808. }
  9809. }
  9810. declare module "babylonjs/Actions/directActions" {
  9811. import { Action } from "babylonjs/Actions/action";
  9812. import { Condition } from "babylonjs/Actions/condition";
  9813. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  9814. /**
  9815. * This defines an action responsible to toggle a boolean once triggered.
  9816. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9817. */
  9818. export class SwitchBooleanAction extends Action {
  9819. /**
  9820. * The path to the boolean property in the target object
  9821. */
  9822. propertyPath: string;
  9823. private _target;
  9824. private _effectiveTarget;
  9825. private _property;
  9826. /**
  9827. * Instantiate the action
  9828. * @param triggerOptions defines the trigger options
  9829. * @param target defines the object containing the boolean
  9830. * @param propertyPath defines the path to the boolean property in the target object
  9831. * @param condition defines the trigger related conditions
  9832. */
  9833. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  9834. /** @hidden */
  9835. _prepare(): void;
  9836. /**
  9837. * Execute the action toggle the boolean value.
  9838. */
  9839. execute(): void;
  9840. /**
  9841. * Serializes the actions and its related information.
  9842. * @param parent defines the object to serialize in
  9843. * @returns the serialized object
  9844. */
  9845. serialize(parent: any): any;
  9846. }
  9847. /**
  9848. * This defines an action responsible to set a the state field of the target
  9849. * to a desired value once triggered.
  9850. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9851. */
  9852. export class SetStateAction extends Action {
  9853. /**
  9854. * The value to store in the state field.
  9855. */
  9856. value: string;
  9857. private _target;
  9858. /**
  9859. * Instantiate the action
  9860. * @param triggerOptions defines the trigger options
  9861. * @param target defines the object containing the state property
  9862. * @param value defines the value to store in the state field
  9863. * @param condition defines the trigger related conditions
  9864. */
  9865. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  9866. /**
  9867. * Execute the action and store the value on the target state property.
  9868. */
  9869. execute(): void;
  9870. /**
  9871. * Serializes the actions and its related information.
  9872. * @param parent defines the object to serialize in
  9873. * @returns the serialized object
  9874. */
  9875. serialize(parent: any): any;
  9876. }
  9877. /**
  9878. * This defines an action responsible to set a property of the target
  9879. * to a desired value once triggered.
  9880. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9881. */
  9882. export class SetValueAction extends Action {
  9883. /**
  9884. * The path of the property to set in the target.
  9885. */
  9886. propertyPath: string;
  9887. /**
  9888. * The value to set in the property
  9889. */
  9890. value: any;
  9891. private _target;
  9892. private _effectiveTarget;
  9893. private _property;
  9894. /**
  9895. * Instantiate the action
  9896. * @param triggerOptions defines the trigger options
  9897. * @param target defines the object containing the property
  9898. * @param propertyPath defines the path of the property to set in the target
  9899. * @param value defines the value to set in the property
  9900. * @param condition defines the trigger related conditions
  9901. */
  9902. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9903. /** @hidden */
  9904. _prepare(): void;
  9905. /**
  9906. * Execute the action and set the targetted property to the desired value.
  9907. */
  9908. execute(): void;
  9909. /**
  9910. * Serializes the actions and its related information.
  9911. * @param parent defines the object to serialize in
  9912. * @returns the serialized object
  9913. */
  9914. serialize(parent: any): any;
  9915. }
  9916. /**
  9917. * This defines an action responsible to increment the target value
  9918. * to a desired value once triggered.
  9919. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9920. */
  9921. export class IncrementValueAction extends Action {
  9922. /**
  9923. * The path of the property to increment in the target.
  9924. */
  9925. propertyPath: string;
  9926. /**
  9927. * The value we should increment the property by.
  9928. */
  9929. value: any;
  9930. private _target;
  9931. private _effectiveTarget;
  9932. private _property;
  9933. /**
  9934. * Instantiate the action
  9935. * @param triggerOptions defines the trigger options
  9936. * @param target defines the object containing the property
  9937. * @param propertyPath defines the path of the property to increment in the target
  9938. * @param value defines the value value we should increment the property by
  9939. * @param condition defines the trigger related conditions
  9940. */
  9941. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9942. /** @hidden */
  9943. _prepare(): void;
  9944. /**
  9945. * Execute the action and increment the target of the value amount.
  9946. */
  9947. execute(): void;
  9948. /**
  9949. * Serializes the actions and its related information.
  9950. * @param parent defines the object to serialize in
  9951. * @returns the serialized object
  9952. */
  9953. serialize(parent: any): any;
  9954. }
  9955. /**
  9956. * This defines an action responsible to start an animation once triggered.
  9957. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9958. */
  9959. export class PlayAnimationAction extends Action {
  9960. /**
  9961. * Where the animation should start (animation frame)
  9962. */
  9963. from: number;
  9964. /**
  9965. * Where the animation should stop (animation frame)
  9966. */
  9967. to: number;
  9968. /**
  9969. * Define if the animation should loop or stop after the first play.
  9970. */
  9971. loop?: boolean;
  9972. private _target;
  9973. /**
  9974. * Instantiate the action
  9975. * @param triggerOptions defines the trigger options
  9976. * @param target defines the target animation or animation name
  9977. * @param from defines from where the animation should start (animation frame)
  9978. * @param end defines where the animation should stop (animation frame)
  9979. * @param loop defines if the animation should loop or stop after the first play
  9980. * @param condition defines the trigger related conditions
  9981. */
  9982. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  9983. /** @hidden */
  9984. _prepare(): void;
  9985. /**
  9986. * Execute the action and play the animation.
  9987. */
  9988. execute(): void;
  9989. /**
  9990. * Serializes the actions and its related information.
  9991. * @param parent defines the object to serialize in
  9992. * @returns the serialized object
  9993. */
  9994. serialize(parent: any): any;
  9995. }
  9996. /**
  9997. * This defines an action responsible to stop an animation once triggered.
  9998. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9999. */
  10000. export class StopAnimationAction extends Action {
  10001. private _target;
  10002. /**
  10003. * Instantiate the action
  10004. * @param triggerOptions defines the trigger options
  10005. * @param target defines the target animation or animation name
  10006. * @param condition defines the trigger related conditions
  10007. */
  10008. constructor(triggerOptions: any, target: any, condition?: Condition);
  10009. /** @hidden */
  10010. _prepare(): void;
  10011. /**
  10012. * Execute the action and stop the animation.
  10013. */
  10014. execute(): void;
  10015. /**
  10016. * Serializes the actions and its related information.
  10017. * @param parent defines the object to serialize in
  10018. * @returns the serialized object
  10019. */
  10020. serialize(parent: any): any;
  10021. }
  10022. /**
  10023. * This defines an action responsible that does nothing once triggered.
  10024. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10025. */
  10026. export class DoNothingAction extends Action {
  10027. /**
  10028. * Instantiate the action
  10029. * @param triggerOptions defines the trigger options
  10030. * @param condition defines the trigger related conditions
  10031. */
  10032. constructor(triggerOptions?: any, condition?: Condition);
  10033. /**
  10034. * Execute the action and do nothing.
  10035. */
  10036. execute(): void;
  10037. /**
  10038. * Serializes the actions and its related information.
  10039. * @param parent defines the object to serialize in
  10040. * @returns the serialized object
  10041. */
  10042. serialize(parent: any): any;
  10043. }
  10044. /**
  10045. * This defines an action responsible to trigger several actions once triggered.
  10046. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10047. */
  10048. export class CombineAction extends Action {
  10049. /**
  10050. * The list of aggregated animations to run.
  10051. */
  10052. children: Action[];
  10053. /**
  10054. * Instantiate the action
  10055. * @param triggerOptions defines the trigger options
  10056. * @param children defines the list of aggregated animations to run
  10057. * @param condition defines the trigger related conditions
  10058. */
  10059. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10060. /** @hidden */
  10061. _prepare(): void;
  10062. /**
  10063. * Execute the action and executes all the aggregated actions.
  10064. */
  10065. execute(evt: ActionEvent): void;
  10066. /**
  10067. * Serializes the actions and its related information.
  10068. * @param parent defines the object to serialize in
  10069. * @returns the serialized object
  10070. */
  10071. serialize(parent: any): any;
  10072. }
  10073. /**
  10074. * This defines an action responsible to run code (external event) once triggered.
  10075. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10076. */
  10077. export class ExecuteCodeAction extends Action {
  10078. /**
  10079. * The callback function to run.
  10080. */
  10081. func: (evt: ActionEvent) => void;
  10082. /**
  10083. * Instantiate the action
  10084. * @param triggerOptions defines the trigger options
  10085. * @param func defines the callback function to run
  10086. * @param condition defines the trigger related conditions
  10087. */
  10088. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10089. /**
  10090. * Execute the action and run the attached code.
  10091. */
  10092. execute(evt: ActionEvent): void;
  10093. }
  10094. /**
  10095. * This defines an action responsible to set the parent property of the target once triggered.
  10096. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10097. */
  10098. export class SetParentAction extends Action {
  10099. private _parent;
  10100. private _target;
  10101. /**
  10102. * Instantiate the action
  10103. * @param triggerOptions defines the trigger options
  10104. * @param target defines the target containing the parent property
  10105. * @param parent defines from where the animation should start (animation frame)
  10106. * @param condition defines the trigger related conditions
  10107. */
  10108. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10109. /** @hidden */
  10110. _prepare(): void;
  10111. /**
  10112. * Execute the action and set the parent property.
  10113. */
  10114. execute(): void;
  10115. /**
  10116. * Serializes the actions and its related information.
  10117. * @param parent defines the object to serialize in
  10118. * @returns the serialized object
  10119. */
  10120. serialize(parent: any): any;
  10121. }
  10122. }
  10123. declare module "babylonjs/Actions/actionManager" {
  10124. import { Nullable } from "babylonjs/types";
  10125. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10126. import { Scene } from "babylonjs/scene";
  10127. import { IAction } from "babylonjs/Actions/action";
  10128. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  10129. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10130. /**
  10131. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10132. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10133. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10134. */
  10135. export class ActionManager extends AbstractActionManager {
  10136. /**
  10137. * Nothing
  10138. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10139. */
  10140. static readonly NothingTrigger: number;
  10141. /**
  10142. * On pick
  10143. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10144. */
  10145. static readonly OnPickTrigger: number;
  10146. /**
  10147. * On left pick
  10148. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10149. */
  10150. static readonly OnLeftPickTrigger: number;
  10151. /**
  10152. * On right pick
  10153. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10154. */
  10155. static readonly OnRightPickTrigger: number;
  10156. /**
  10157. * On center pick
  10158. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10159. */
  10160. static readonly OnCenterPickTrigger: number;
  10161. /**
  10162. * On pick down
  10163. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10164. */
  10165. static readonly OnPickDownTrigger: number;
  10166. /**
  10167. * On double pick
  10168. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10169. */
  10170. static readonly OnDoublePickTrigger: number;
  10171. /**
  10172. * On pick up
  10173. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10174. */
  10175. static readonly OnPickUpTrigger: number;
  10176. /**
  10177. * On pick out.
  10178. * This trigger will only be raised if you also declared a OnPickDown
  10179. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10180. */
  10181. static readonly OnPickOutTrigger: number;
  10182. /**
  10183. * On long press
  10184. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10185. */
  10186. static readonly OnLongPressTrigger: number;
  10187. /**
  10188. * On pointer over
  10189. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10190. */
  10191. static readonly OnPointerOverTrigger: number;
  10192. /**
  10193. * On pointer out
  10194. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10195. */
  10196. static readonly OnPointerOutTrigger: number;
  10197. /**
  10198. * On every frame
  10199. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10200. */
  10201. static readonly OnEveryFrameTrigger: number;
  10202. /**
  10203. * On intersection enter
  10204. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10205. */
  10206. static readonly OnIntersectionEnterTrigger: number;
  10207. /**
  10208. * On intersection exit
  10209. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10210. */
  10211. static readonly OnIntersectionExitTrigger: number;
  10212. /**
  10213. * On key down
  10214. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10215. */
  10216. static readonly OnKeyDownTrigger: number;
  10217. /**
  10218. * On key up
  10219. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10220. */
  10221. static readonly OnKeyUpTrigger: number;
  10222. private _scene;
  10223. /**
  10224. * Creates a new action manager
  10225. * @param scene defines the hosting scene
  10226. */
  10227. constructor(scene: Scene);
  10228. /**
  10229. * Releases all associated resources
  10230. */
  10231. dispose(): void;
  10232. /**
  10233. * Gets hosting scene
  10234. * @returns the hosting scene
  10235. */
  10236. getScene(): Scene;
  10237. /**
  10238. * Does this action manager handles actions of any of the given triggers
  10239. * @param triggers defines the triggers to be tested
  10240. * @return a boolean indicating whether one (or more) of the triggers is handled
  10241. */
  10242. hasSpecificTriggers(triggers: number[]): boolean;
  10243. /**
  10244. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10245. * speed.
  10246. * @param triggerA defines the trigger to be tested
  10247. * @param triggerB defines the trigger to be tested
  10248. * @return a boolean indicating whether one (or more) of the triggers is handled
  10249. */
  10250. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10251. /**
  10252. * Does this action manager handles actions of a given trigger
  10253. * @param trigger defines the trigger to be tested
  10254. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10255. * @return whether the trigger is handled
  10256. */
  10257. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10258. /**
  10259. * Does this action manager has pointer triggers
  10260. */
  10261. get hasPointerTriggers(): boolean;
  10262. /**
  10263. * Does this action manager has pick triggers
  10264. */
  10265. get hasPickTriggers(): boolean;
  10266. /**
  10267. * Registers an action to this action manager
  10268. * @param action defines the action to be registered
  10269. * @return the action amended (prepared) after registration
  10270. */
  10271. registerAction(action: IAction): Nullable<IAction>;
  10272. /**
  10273. * Unregisters an action to this action manager
  10274. * @param action defines the action to be unregistered
  10275. * @return a boolean indicating whether the action has been unregistered
  10276. */
  10277. unregisterAction(action: IAction): Boolean;
  10278. /**
  10279. * Process a specific trigger
  10280. * @param trigger defines the trigger to process
  10281. * @param evt defines the event details to be processed
  10282. */
  10283. processTrigger(trigger: number, evt?: IActionEvent): void;
  10284. /** @hidden */
  10285. _getEffectiveTarget(target: any, propertyPath: string): any;
  10286. /** @hidden */
  10287. _getProperty(propertyPath: string): string;
  10288. /**
  10289. * Serialize this manager to a JSON object
  10290. * @param name defines the property name to store this manager
  10291. * @returns a JSON representation of this manager
  10292. */
  10293. serialize(name: string): any;
  10294. /**
  10295. * Creates a new ActionManager from a JSON data
  10296. * @param parsedActions defines the JSON data to read from
  10297. * @param object defines the hosting mesh
  10298. * @param scene defines the hosting scene
  10299. */
  10300. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10301. /**
  10302. * Get a trigger name by index
  10303. * @param trigger defines the trigger index
  10304. * @returns a trigger name
  10305. */
  10306. static GetTriggerName(trigger: number): string;
  10307. }
  10308. }
  10309. declare module "babylonjs/Sprites/sprite" {
  10310. import { Vector3 } from "babylonjs/Maths/math.vector";
  10311. import { Nullable } from "babylonjs/types";
  10312. import { ActionManager } from "babylonjs/Actions/actionManager";
  10313. import { ISpriteManager, SpriteManager } from "babylonjs/Sprites/spriteManager";
  10314. import { Color4 } from "babylonjs/Maths/math.color";
  10315. import { Observable } from "babylonjs/Misc/observable";
  10316. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  10317. import { Animation } from "babylonjs/Animations/animation";
  10318. /**
  10319. * Class used to represent a sprite
  10320. * @see http://doc.babylonjs.com/babylon101/sprites
  10321. */
  10322. export class Sprite implements IAnimatable {
  10323. /** defines the name */
  10324. name: string;
  10325. /** Gets or sets the current world position */
  10326. position: Vector3;
  10327. /** Gets or sets the main color */
  10328. color: Color4;
  10329. /** Gets or sets the width */
  10330. width: number;
  10331. /** Gets or sets the height */
  10332. height: number;
  10333. /** Gets or sets rotation angle */
  10334. angle: number;
  10335. /** Gets or sets the cell index in the sprite sheet */
  10336. cellIndex: number;
  10337. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  10338. cellRef: string;
  10339. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  10340. invertU: boolean;
  10341. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  10342. invertV: boolean;
  10343. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  10344. disposeWhenFinishedAnimating: boolean;
  10345. /** Gets the list of attached animations */
  10346. animations: Nullable<Array<Animation>>;
  10347. /** Gets or sets a boolean indicating if the sprite can be picked */
  10348. isPickable: boolean;
  10349. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  10350. useAlphaForPicking: boolean;
  10351. /** @hidden */
  10352. _xOffset: number;
  10353. /** @hidden */
  10354. _yOffset: number;
  10355. /** @hidden */
  10356. _xSize: number;
  10357. /** @hidden */
  10358. _ySize: number;
  10359. /**
  10360. * Gets or sets the associated action manager
  10361. */
  10362. actionManager: Nullable<ActionManager>;
  10363. /**
  10364. * An event triggered when the control has been disposed
  10365. */
  10366. onDisposeObservable: Observable<Sprite>;
  10367. private _animationStarted;
  10368. private _loopAnimation;
  10369. private _fromIndex;
  10370. private _toIndex;
  10371. private _delay;
  10372. private _direction;
  10373. private _manager;
  10374. private _time;
  10375. private _onAnimationEnd;
  10376. /**
  10377. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  10378. */
  10379. isVisible: boolean;
  10380. /**
  10381. * Gets or sets the sprite size
  10382. */
  10383. get size(): number;
  10384. set size(value: number);
  10385. /**
  10386. * Returns a boolean indicating if the animation is started
  10387. */
  10388. get animationStarted(): boolean;
  10389. /**
  10390. * Gets or sets the unique id of the sprite
  10391. */
  10392. uniqueId: number;
  10393. /**
  10394. * Gets the manager of this sprite
  10395. */
  10396. get manager(): ISpriteManager;
  10397. /**
  10398. * Creates a new Sprite
  10399. * @param name defines the name
  10400. * @param manager defines the manager
  10401. */
  10402. constructor(
  10403. /** defines the name */
  10404. name: string, manager: ISpriteManager);
  10405. /**
  10406. * Returns the string "Sprite"
  10407. * @returns "Sprite"
  10408. */
  10409. getClassName(): string;
  10410. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  10411. get fromIndex(): number;
  10412. set fromIndex(value: number);
  10413. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  10414. get toIndex(): number;
  10415. set toIndex(value: number);
  10416. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  10417. get loopAnimation(): boolean;
  10418. set loopAnimation(value: boolean);
  10419. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  10420. get delay(): number;
  10421. set delay(value: number);
  10422. /**
  10423. * Starts an animation
  10424. * @param from defines the initial key
  10425. * @param to defines the end key
  10426. * @param loop defines if the animation must loop
  10427. * @param delay defines the start delay (in ms)
  10428. * @param onAnimationEnd defines a callback to call when animation ends
  10429. */
  10430. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  10431. /** Stops current animation (if any) */
  10432. stopAnimation(): void;
  10433. /** @hidden */
  10434. _animate(deltaTime: number): void;
  10435. /** Release associated resources */
  10436. dispose(): void;
  10437. /**
  10438. * Serializes the sprite to a JSON object
  10439. * @returns the JSON object
  10440. */
  10441. serialize(): any;
  10442. /**
  10443. * Parses a JSON object to create a new sprite
  10444. * @param parsedSprite The JSON object to parse
  10445. * @param manager defines the hosting manager
  10446. * @returns the new sprite
  10447. */
  10448. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  10449. }
  10450. }
  10451. declare module "babylonjs/Collisions/pickingInfo" {
  10452. import { Nullable } from "babylonjs/types";
  10453. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  10454. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10455. import { Sprite } from "babylonjs/Sprites/sprite";
  10456. import { Ray } from "babylonjs/Culling/ray";
  10457. /**
  10458. * Information about the result of picking within a scene
  10459. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  10460. */
  10461. export class PickingInfo {
  10462. /** @hidden */
  10463. _pickingUnavailable: boolean;
  10464. /**
  10465. * If the pick collided with an object
  10466. */
  10467. hit: boolean;
  10468. /**
  10469. * Distance away where the pick collided
  10470. */
  10471. distance: number;
  10472. /**
  10473. * The location of pick collision
  10474. */
  10475. pickedPoint: Nullable<Vector3>;
  10476. /**
  10477. * The mesh corresponding the the pick collision
  10478. */
  10479. pickedMesh: Nullable<AbstractMesh>;
  10480. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  10481. bu: number;
  10482. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  10483. bv: number;
  10484. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10485. faceId: number;
  10486. /** Id of the the submesh that was picked */
  10487. subMeshId: number;
  10488. /** If a sprite was picked, this will be the sprite the pick collided with */
  10489. pickedSprite: Nullable<Sprite>;
  10490. /**
  10491. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  10492. */
  10493. originMesh: Nullable<AbstractMesh>;
  10494. /**
  10495. * The ray that was used to perform the picking.
  10496. */
  10497. ray: Nullable<Ray>;
  10498. /**
  10499. * Gets the normal correspodning to the face the pick collided with
  10500. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  10501. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  10502. * @returns The normal correspodning to the face the pick collided with
  10503. */
  10504. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  10505. /**
  10506. * Gets the texture coordinates of where the pick occured
  10507. * @returns the vector containing the coordnates of the texture
  10508. */
  10509. getTextureCoordinates(): Nullable<Vector2>;
  10510. }
  10511. }
  10512. declare module "babylonjs/Culling/ray" {
  10513. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  10514. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  10515. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10516. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10517. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  10518. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  10519. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  10520. import { Plane } from "babylonjs/Maths/math.plane";
  10521. /**
  10522. * Class representing a ray with position and direction
  10523. */
  10524. export class Ray {
  10525. /** origin point */
  10526. origin: Vector3;
  10527. /** direction */
  10528. direction: Vector3;
  10529. /** length of the ray */
  10530. length: number;
  10531. private static readonly TmpVector3;
  10532. private _tmpRay;
  10533. /**
  10534. * Creates a new ray
  10535. * @param origin origin point
  10536. * @param direction direction
  10537. * @param length length of the ray
  10538. */
  10539. constructor(
  10540. /** origin point */
  10541. origin: Vector3,
  10542. /** direction */
  10543. direction: Vector3,
  10544. /** length of the ray */
  10545. length?: number);
  10546. /**
  10547. * Checks if the ray intersects a box
  10548. * This does not account for the ray lenght by design to improve perfs.
  10549. * @param minimum bound of the box
  10550. * @param maximum bound of the box
  10551. * @param intersectionTreshold extra extend to be added to the box in all direction
  10552. * @returns if the box was hit
  10553. */
  10554. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10555. /**
  10556. * Checks if the ray intersects a box
  10557. * This does not account for the ray lenght by design to improve perfs.
  10558. * @param box the bounding box to check
  10559. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10560. * @returns if the box was hit
  10561. */
  10562. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10563. /**
  10564. * If the ray hits a sphere
  10565. * @param sphere the bounding sphere to check
  10566. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10567. * @returns true if it hits the sphere
  10568. */
  10569. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10570. /**
  10571. * If the ray hits a triange
  10572. * @param vertex0 triangle vertex
  10573. * @param vertex1 triangle vertex
  10574. * @param vertex2 triangle vertex
  10575. * @returns intersection information if hit
  10576. */
  10577. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10578. /**
  10579. * Checks if ray intersects a plane
  10580. * @param plane the plane to check
  10581. * @returns the distance away it was hit
  10582. */
  10583. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10584. /**
  10585. * Calculate the intercept of a ray on a given axis
  10586. * @param axis to check 'x' | 'y' | 'z'
  10587. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10588. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10589. */
  10590. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10591. /**
  10592. * Checks if ray intersects a mesh
  10593. * @param mesh the mesh to check
  10594. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10595. * @returns picking info of the intersecton
  10596. */
  10597. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10598. /**
  10599. * Checks if ray intersects a mesh
  10600. * @param meshes the meshes to check
  10601. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10602. * @param results array to store result in
  10603. * @returns Array of picking infos
  10604. */
  10605. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10606. private _comparePickingInfo;
  10607. private static smallnum;
  10608. private static rayl;
  10609. /**
  10610. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10611. * @param sega the first point of the segment to test the intersection against
  10612. * @param segb the second point of the segment to test the intersection against
  10613. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10614. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10615. */
  10616. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10617. /**
  10618. * Update the ray from viewport position
  10619. * @param x position
  10620. * @param y y position
  10621. * @param viewportWidth viewport width
  10622. * @param viewportHeight viewport height
  10623. * @param world world matrix
  10624. * @param view view matrix
  10625. * @param projection projection matrix
  10626. * @returns this ray updated
  10627. */
  10628. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10629. /**
  10630. * Creates a ray with origin and direction of 0,0,0
  10631. * @returns the new ray
  10632. */
  10633. static Zero(): Ray;
  10634. /**
  10635. * Creates a new ray from screen space and viewport
  10636. * @param x position
  10637. * @param y y position
  10638. * @param viewportWidth viewport width
  10639. * @param viewportHeight viewport height
  10640. * @param world world matrix
  10641. * @param view view matrix
  10642. * @param projection projection matrix
  10643. * @returns new ray
  10644. */
  10645. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10646. /**
  10647. * Function will create a new transformed ray starting from origin and ending at the end point. Ray's length will be set, and ray will be
  10648. * transformed to the given world matrix.
  10649. * @param origin The origin point
  10650. * @param end The end point
  10651. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10652. * @returns the new ray
  10653. */
  10654. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  10655. /**
  10656. * Transforms a ray by a matrix
  10657. * @param ray ray to transform
  10658. * @param matrix matrix to apply
  10659. * @returns the resulting new ray
  10660. */
  10661. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10662. /**
  10663. * Transforms a ray by a matrix
  10664. * @param ray ray to transform
  10665. * @param matrix matrix to apply
  10666. * @param result ray to store result in
  10667. */
  10668. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10669. /**
  10670. * Unproject a ray from screen space to object space
  10671. * @param sourceX defines the screen space x coordinate to use
  10672. * @param sourceY defines the screen space y coordinate to use
  10673. * @param viewportWidth defines the current width of the viewport
  10674. * @param viewportHeight defines the current height of the viewport
  10675. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10676. * @param view defines the view matrix to use
  10677. * @param projection defines the projection matrix to use
  10678. */
  10679. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10680. }
  10681. /**
  10682. * Type used to define predicate used to select faces when a mesh intersection is detected
  10683. */
  10684. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10685. module "babylonjs/scene" {
  10686. interface Scene {
  10687. /** @hidden */
  10688. _tempPickingRay: Nullable<Ray>;
  10689. /** @hidden */
  10690. _cachedRayForTransform: Ray;
  10691. /** @hidden */
  10692. _pickWithRayInverseMatrix: Matrix;
  10693. /** @hidden */
  10694. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10695. /** @hidden */
  10696. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  10697. }
  10698. }
  10699. }
  10700. declare module "babylonjs/sceneComponent" {
  10701. import { Scene } from "babylonjs/scene";
  10702. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10703. import { SubMesh } from "babylonjs/Meshes/subMesh";
  10704. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  10705. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  10706. import { Nullable } from "babylonjs/types";
  10707. import { Camera } from "babylonjs/Cameras/camera";
  10708. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  10709. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10710. import { AbstractScene } from "babylonjs/abstractScene";
  10711. import { Mesh } from "babylonjs/Meshes/mesh";
  10712. /**
  10713. * Groups all the scene component constants in one place to ease maintenance.
  10714. * @hidden
  10715. */
  10716. export class SceneComponentConstants {
  10717. static readonly NAME_EFFECTLAYER: string;
  10718. static readonly NAME_LAYER: string;
  10719. static readonly NAME_LENSFLARESYSTEM: string;
  10720. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10721. static readonly NAME_PARTICLESYSTEM: string;
  10722. static readonly NAME_GAMEPAD: string;
  10723. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10724. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10725. static readonly NAME_DEPTHRENDERER: string;
  10726. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10727. static readonly NAME_SPRITE: string;
  10728. static readonly NAME_OUTLINERENDERER: string;
  10729. static readonly NAME_PROCEDURALTEXTURE: string;
  10730. static readonly NAME_SHADOWGENERATOR: string;
  10731. static readonly NAME_OCTREE: string;
  10732. static readonly NAME_PHYSICSENGINE: string;
  10733. static readonly NAME_AUDIO: string;
  10734. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10735. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10736. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10737. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10738. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10739. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10740. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10741. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10742. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10743. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10744. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10745. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10746. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10747. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10748. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10749. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10750. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10751. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10752. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10753. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10754. static readonly STEP_AFTERRENDER_AUDIO: number;
  10755. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10756. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10757. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10758. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10759. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10760. static readonly STEP_POINTERMOVE_SPRITE: number;
  10761. static readonly STEP_POINTERDOWN_SPRITE: number;
  10762. static readonly STEP_POINTERUP_SPRITE: number;
  10763. }
  10764. /**
  10765. * This represents a scene component.
  10766. *
  10767. * This is used to decouple the dependency the scene is having on the different workloads like
  10768. * layers, post processes...
  10769. */
  10770. export interface ISceneComponent {
  10771. /**
  10772. * The name of the component. Each component must have a unique name.
  10773. */
  10774. name: string;
  10775. /**
  10776. * The scene the component belongs to.
  10777. */
  10778. scene: Scene;
  10779. /**
  10780. * Register the component to one instance of a scene.
  10781. */
  10782. register(): void;
  10783. /**
  10784. * Rebuilds the elements related to this component in case of
  10785. * context lost for instance.
  10786. */
  10787. rebuild(): void;
  10788. /**
  10789. * Disposes the component and the associated ressources.
  10790. */
  10791. dispose(): void;
  10792. }
  10793. /**
  10794. * This represents a SERIALIZABLE scene component.
  10795. *
  10796. * This extends Scene Component to add Serialization methods on top.
  10797. */
  10798. export interface ISceneSerializableComponent extends ISceneComponent {
  10799. /**
  10800. * Adds all the elements from the container to the scene
  10801. * @param container the container holding the elements
  10802. */
  10803. addFromContainer(container: AbstractScene): void;
  10804. /**
  10805. * Removes all the elements in the container from the scene
  10806. * @param container contains the elements to remove
  10807. * @param dispose if the removed element should be disposed (default: false)
  10808. */
  10809. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10810. /**
  10811. * Serializes the component data to the specified json object
  10812. * @param serializationObject The object to serialize to
  10813. */
  10814. serialize(serializationObject: any): void;
  10815. }
  10816. /**
  10817. * Strong typing of a Mesh related stage step action
  10818. */
  10819. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  10820. /**
  10821. * Strong typing of a Evaluate Sub Mesh related stage step action
  10822. */
  10823. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  10824. /**
  10825. * Strong typing of a Active Mesh related stage step action
  10826. */
  10827. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  10828. /**
  10829. * Strong typing of a Camera related stage step action
  10830. */
  10831. export type CameraStageAction = (camera: Camera) => void;
  10832. /**
  10833. * Strong typing of a Camera Frame buffer related stage step action
  10834. */
  10835. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  10836. /**
  10837. * Strong typing of a Render Target related stage step action
  10838. */
  10839. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  10840. /**
  10841. * Strong typing of a RenderingGroup related stage step action
  10842. */
  10843. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  10844. /**
  10845. * Strong typing of a Mesh Render related stage step action
  10846. */
  10847. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  10848. /**
  10849. * Strong typing of a simple stage step action
  10850. */
  10851. export type SimpleStageAction = () => void;
  10852. /**
  10853. * Strong typing of a render target action.
  10854. */
  10855. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  10856. /**
  10857. * Strong typing of a pointer move action.
  10858. */
  10859. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  10860. /**
  10861. * Strong typing of a pointer up/down action.
  10862. */
  10863. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  10864. /**
  10865. * Representation of a stage in the scene (Basically a list of ordered steps)
  10866. * @hidden
  10867. */
  10868. export class Stage<T extends Function> extends Array<{
  10869. index: number;
  10870. component: ISceneComponent;
  10871. action: T;
  10872. }> {
  10873. /**
  10874. * Hide ctor from the rest of the world.
  10875. * @param items The items to add.
  10876. */
  10877. private constructor();
  10878. /**
  10879. * Creates a new Stage.
  10880. * @returns A new instance of a Stage
  10881. */
  10882. static Create<T extends Function>(): Stage<T>;
  10883. /**
  10884. * Registers a step in an ordered way in the targeted stage.
  10885. * @param index Defines the position to register the step in
  10886. * @param component Defines the component attached to the step
  10887. * @param action Defines the action to launch during the step
  10888. */
  10889. registerStep(index: number, component: ISceneComponent, action: T): void;
  10890. /**
  10891. * Clears all the steps from the stage.
  10892. */
  10893. clear(): void;
  10894. }
  10895. }
  10896. declare module "babylonjs/Sprites/spriteSceneComponent" {
  10897. import { Nullable } from "babylonjs/types";
  10898. import { Observable } from "babylonjs/Misc/observable";
  10899. import { Scene } from "babylonjs/scene";
  10900. import { Sprite } from "babylonjs/Sprites/sprite";
  10901. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  10902. import { Ray } from "babylonjs/Culling/ray";
  10903. import { Camera } from "babylonjs/Cameras/camera";
  10904. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10905. import { ISceneComponent } from "babylonjs/sceneComponent";
  10906. module "babylonjs/scene" {
  10907. interface Scene {
  10908. /** @hidden */
  10909. _pointerOverSprite: Nullable<Sprite>;
  10910. /** @hidden */
  10911. _pickedDownSprite: Nullable<Sprite>;
  10912. /** @hidden */
  10913. _tempSpritePickingRay: Nullable<Ray>;
  10914. /**
  10915. * All of the sprite managers added to this scene
  10916. * @see http://doc.babylonjs.com/babylon101/sprites
  10917. */
  10918. spriteManagers: Array<ISpriteManager>;
  10919. /**
  10920. * An event triggered when sprites rendering is about to start
  10921. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10922. */
  10923. onBeforeSpritesRenderingObservable: Observable<Scene>;
  10924. /**
  10925. * An event triggered when sprites rendering is done
  10926. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10927. */
  10928. onAfterSpritesRenderingObservable: Observable<Scene>;
  10929. /** @hidden */
  10930. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10931. /** Launch a ray to try to pick a sprite in the scene
  10932. * @param x position on screen
  10933. * @param y position on screen
  10934. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  10935. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10936. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10937. * @returns a PickingInfo
  10938. */
  10939. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10940. /** Use the given ray to pick a sprite in the scene
  10941. * @param ray The ray (in world space) to use to pick meshes
  10942. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  10943. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10944. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10945. * @returns a PickingInfo
  10946. */
  10947. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10948. /** @hidden */
  10949. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10950. /** Launch a ray to try to pick sprites in the scene
  10951. * @param x position on screen
  10952. * @param y position on screen
  10953. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  10954. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10955. * @returns a PickingInfo array
  10956. */
  10957. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10958. /** Use the given ray to pick sprites in the scene
  10959. * @param ray The ray (in world space) to use to pick meshes
  10960. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  10961. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10962. * @returns a PickingInfo array
  10963. */
  10964. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10965. /**
  10966. * Force the sprite under the pointer
  10967. * @param sprite defines the sprite to use
  10968. */
  10969. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  10970. /**
  10971. * Gets the sprite under the pointer
  10972. * @returns a Sprite or null if no sprite is under the pointer
  10973. */
  10974. getPointerOverSprite(): Nullable<Sprite>;
  10975. }
  10976. }
  10977. /**
  10978. * Defines the sprite scene component responsible to manage sprites
  10979. * in a given scene.
  10980. */
  10981. export class SpriteSceneComponent implements ISceneComponent {
  10982. /**
  10983. * The component name helpfull to identify the component in the list of scene components.
  10984. */
  10985. readonly name: string;
  10986. /**
  10987. * The scene the component belongs to.
  10988. */
  10989. scene: Scene;
  10990. /** @hidden */
  10991. private _spritePredicate;
  10992. /**
  10993. * Creates a new instance of the component for the given scene
  10994. * @param scene Defines the scene to register the component in
  10995. */
  10996. constructor(scene: Scene);
  10997. /**
  10998. * Registers the component in a given scene
  10999. */
  11000. register(): void;
  11001. /**
  11002. * Rebuilds the elements related to this component in case of
  11003. * context lost for instance.
  11004. */
  11005. rebuild(): void;
  11006. /**
  11007. * Disposes the component and the associated ressources.
  11008. */
  11009. dispose(): void;
  11010. private _pickSpriteButKeepRay;
  11011. private _pointerMove;
  11012. private _pointerDown;
  11013. private _pointerUp;
  11014. }
  11015. }
  11016. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11017. /** @hidden */
  11018. export var fogFragmentDeclaration: {
  11019. name: string;
  11020. shader: string;
  11021. };
  11022. }
  11023. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11024. /** @hidden */
  11025. export var fogFragment: {
  11026. name: string;
  11027. shader: string;
  11028. };
  11029. }
  11030. declare module "babylonjs/Shaders/sprites.fragment" {
  11031. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11032. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11033. /** @hidden */
  11034. export var spritesPixelShader: {
  11035. name: string;
  11036. shader: string;
  11037. };
  11038. }
  11039. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11040. /** @hidden */
  11041. export var fogVertexDeclaration: {
  11042. name: string;
  11043. shader: string;
  11044. };
  11045. }
  11046. declare module "babylonjs/Shaders/sprites.vertex" {
  11047. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11048. /** @hidden */
  11049. export var spritesVertexShader: {
  11050. name: string;
  11051. shader: string;
  11052. };
  11053. }
  11054. declare module "babylonjs/Sprites/spriteManager" {
  11055. import { IDisposable, Scene } from "babylonjs/scene";
  11056. import { Nullable } from "babylonjs/types";
  11057. import { Observable } from "babylonjs/Misc/observable";
  11058. import { Sprite } from "babylonjs/Sprites/sprite";
  11059. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11060. import { Camera } from "babylonjs/Cameras/camera";
  11061. import { Texture } from "babylonjs/Materials/Textures/texture";
  11062. import "babylonjs/Shaders/sprites.fragment";
  11063. import "babylonjs/Shaders/sprites.vertex";
  11064. import { Ray } from "babylonjs/Culling/ray";
  11065. /**
  11066. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11067. */
  11068. export interface ISpriteManager extends IDisposable {
  11069. /**
  11070. * Gets manager's name
  11071. */
  11072. name: string;
  11073. /**
  11074. * Restricts the camera to viewing objects with the same layerMask.
  11075. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11076. */
  11077. layerMask: number;
  11078. /**
  11079. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11080. */
  11081. isPickable: boolean;
  11082. /**
  11083. * Gets the hosting scene
  11084. */
  11085. scene: Scene;
  11086. /**
  11087. * Specifies the rendering group id for this mesh (0 by default)
  11088. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11089. */
  11090. renderingGroupId: number;
  11091. /**
  11092. * Defines the list of sprites managed by the manager.
  11093. */
  11094. sprites: Array<Sprite>;
  11095. /**
  11096. * Gets or sets the spritesheet texture
  11097. */
  11098. texture: Texture;
  11099. /** Defines the default width of a cell in the spritesheet */
  11100. cellWidth: number;
  11101. /** Defines the default height of a cell in the spritesheet */
  11102. cellHeight: number;
  11103. /**
  11104. * Tests the intersection of a sprite with a specific ray.
  11105. * @param ray The ray we are sending to test the collision
  11106. * @param camera The camera space we are sending rays in
  11107. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11108. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11109. * @returns picking info or null.
  11110. */
  11111. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11112. /**
  11113. * Intersects the sprites with a ray
  11114. * @param ray defines the ray to intersect with
  11115. * @param camera defines the current active camera
  11116. * @param predicate defines a predicate used to select candidate sprites
  11117. * @returns null if no hit or a PickingInfo array
  11118. */
  11119. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11120. /**
  11121. * Renders the list of sprites on screen.
  11122. */
  11123. render(): void;
  11124. }
  11125. /**
  11126. * Class used to manage multiple sprites on the same spritesheet
  11127. * @see http://doc.babylonjs.com/babylon101/sprites
  11128. */
  11129. export class SpriteManager implements ISpriteManager {
  11130. /** defines the manager's name */
  11131. name: string;
  11132. /** Define the Url to load snippets */
  11133. static SnippetUrl: string;
  11134. /** Snippet ID if the manager was created from the snippet server */
  11135. snippetId: string;
  11136. /** Gets the list of sprites */
  11137. sprites: Sprite[];
  11138. /** Gets or sets the rendering group id (0 by default) */
  11139. renderingGroupId: number;
  11140. /** Gets or sets camera layer mask */
  11141. layerMask: number;
  11142. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11143. fogEnabled: boolean;
  11144. /** Gets or sets a boolean indicating if the sprites are pickable */
  11145. isPickable: boolean;
  11146. /** Defines the default width of a cell in the spritesheet */
  11147. cellWidth: number;
  11148. /** Defines the default height of a cell in the spritesheet */
  11149. cellHeight: number;
  11150. /** Associative array from JSON sprite data file */
  11151. private _cellData;
  11152. /** Array of sprite names from JSON sprite data file */
  11153. private _spriteMap;
  11154. /** True when packed cell data from JSON file is ready*/
  11155. private _packedAndReady;
  11156. private _textureContent;
  11157. /**
  11158. * An event triggered when the manager is disposed.
  11159. */
  11160. onDisposeObservable: Observable<SpriteManager>;
  11161. private _onDisposeObserver;
  11162. /**
  11163. * Callback called when the manager is disposed
  11164. */
  11165. set onDispose(callback: () => void);
  11166. private _capacity;
  11167. private _fromPacked;
  11168. private _spriteTexture;
  11169. private _epsilon;
  11170. private _scene;
  11171. private _vertexData;
  11172. private _buffer;
  11173. private _vertexBuffers;
  11174. private _indexBuffer;
  11175. private _effectBase;
  11176. private _effectFog;
  11177. /**
  11178. * Gets or sets the unique id of the sprite
  11179. */
  11180. uniqueId: number;
  11181. /**
  11182. * Gets the array of sprites
  11183. */
  11184. get children(): Sprite[];
  11185. /**
  11186. * Gets the hosting scene
  11187. */
  11188. get scene(): Scene;
  11189. /**
  11190. * Gets the capacity of the manager
  11191. */
  11192. get capacity(): number;
  11193. /**
  11194. * Gets or sets the spritesheet texture
  11195. */
  11196. get texture(): Texture;
  11197. set texture(value: Texture);
  11198. private _blendMode;
  11199. /**
  11200. * Blend mode use to render the particle, it can be any of
  11201. * the static Constants.ALPHA_x properties provided in this class.
  11202. * Default value is Constants.ALPHA_COMBINE
  11203. */
  11204. get blendMode(): number;
  11205. set blendMode(blendMode: number);
  11206. /** Disables writing to the depth buffer when rendering the sprites.
  11207. * It can be handy to disable depth writing when using textures without alpha channel
  11208. * and setting some specific blend modes.
  11209. */
  11210. disableDepthWrite: boolean;
  11211. /**
  11212. * Creates a new sprite manager
  11213. * @param name defines the manager's name
  11214. * @param imgUrl defines the sprite sheet url
  11215. * @param capacity defines the maximum allowed number of sprites
  11216. * @param cellSize defines the size of a sprite cell
  11217. * @param scene defines the hosting scene
  11218. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11219. * @param samplingMode defines the smapling mode to use with spritesheet
  11220. * @param fromPacked set to false; do not alter
  11221. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11222. */
  11223. constructor(
  11224. /** defines the manager's name */
  11225. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  11226. /**
  11227. * Returns the string "SpriteManager"
  11228. * @returns "SpriteManager"
  11229. */
  11230. getClassName(): string;
  11231. private _makePacked;
  11232. private _appendSpriteVertex;
  11233. private _checkTextureAlpha;
  11234. /**
  11235. * Intersects the sprites with a ray
  11236. * @param ray defines the ray to intersect with
  11237. * @param camera defines the current active camera
  11238. * @param predicate defines a predicate used to select candidate sprites
  11239. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11240. * @returns null if no hit or a PickingInfo
  11241. */
  11242. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11243. /**
  11244. * Intersects the sprites with a ray
  11245. * @param ray defines the ray to intersect with
  11246. * @param camera defines the current active camera
  11247. * @param predicate defines a predicate used to select candidate sprites
  11248. * @returns null if no hit or a PickingInfo array
  11249. */
  11250. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11251. /**
  11252. * Render all child sprites
  11253. */
  11254. render(): void;
  11255. /**
  11256. * Release associated resources
  11257. */
  11258. dispose(): void;
  11259. /**
  11260. * Serializes the sprite manager to a JSON object
  11261. * @param serializeTexture defines if the texture must be serialized as well
  11262. * @returns the JSON object
  11263. */
  11264. serialize(serializeTexture?: boolean): any;
  11265. /**
  11266. * Parses a JSON object to create a new sprite manager.
  11267. * @param parsedManager The JSON object to parse
  11268. * @param scene The scene to create the sprite managerin
  11269. * @param rootUrl The root url to use to load external dependencies like texture
  11270. * @returns the new sprite manager
  11271. */
  11272. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  11273. /**
  11274. * Creates a sprite manager from a snippet saved by the sprite editor
  11275. * @param snippetId defines the snippet to load
  11276. * @param scene defines the hosting scene
  11277. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11278. * @returns a promise that will resolve to the new sprite manager
  11279. */
  11280. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11281. }
  11282. }
  11283. declare module "babylonjs/Misc/gradients" {
  11284. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  11285. /** Interface used by value gradients (color, factor, ...) */
  11286. export interface IValueGradient {
  11287. /**
  11288. * Gets or sets the gradient value (between 0 and 1)
  11289. */
  11290. gradient: number;
  11291. }
  11292. /** Class used to store color4 gradient */
  11293. export class ColorGradient implements IValueGradient {
  11294. /**
  11295. * Gets or sets the gradient value (between 0 and 1)
  11296. */
  11297. gradient: number;
  11298. /**
  11299. * Gets or sets first associated color
  11300. */
  11301. color1: Color4;
  11302. /**
  11303. * Gets or sets second associated color
  11304. */
  11305. color2?: Color4 | undefined;
  11306. /**
  11307. * Creates a new color4 gradient
  11308. * @param gradient gets or sets the gradient value (between 0 and 1)
  11309. * @param color1 gets or sets first associated color
  11310. * @param color2 gets or sets first second color
  11311. */
  11312. constructor(
  11313. /**
  11314. * Gets or sets the gradient value (between 0 and 1)
  11315. */
  11316. gradient: number,
  11317. /**
  11318. * Gets or sets first associated color
  11319. */
  11320. color1: Color4,
  11321. /**
  11322. * Gets or sets second associated color
  11323. */
  11324. color2?: Color4 | undefined);
  11325. /**
  11326. * Will get a color picked randomly between color1 and color2.
  11327. * If color2 is undefined then color1 will be used
  11328. * @param result defines the target Color4 to store the result in
  11329. */
  11330. getColorToRef(result: Color4): void;
  11331. }
  11332. /** Class used to store color 3 gradient */
  11333. export class Color3Gradient implements IValueGradient {
  11334. /**
  11335. * Gets or sets the gradient value (between 0 and 1)
  11336. */
  11337. gradient: number;
  11338. /**
  11339. * Gets or sets the associated color
  11340. */
  11341. color: Color3;
  11342. /**
  11343. * Creates a new color3 gradient
  11344. * @param gradient gets or sets the gradient value (between 0 and 1)
  11345. * @param color gets or sets associated color
  11346. */
  11347. constructor(
  11348. /**
  11349. * Gets or sets the gradient value (between 0 and 1)
  11350. */
  11351. gradient: number,
  11352. /**
  11353. * Gets or sets the associated color
  11354. */
  11355. color: Color3);
  11356. }
  11357. /** Class used to store factor gradient */
  11358. export class FactorGradient implements IValueGradient {
  11359. /**
  11360. * Gets or sets the gradient value (between 0 and 1)
  11361. */
  11362. gradient: number;
  11363. /**
  11364. * Gets or sets first associated factor
  11365. */
  11366. factor1: number;
  11367. /**
  11368. * Gets or sets second associated factor
  11369. */
  11370. factor2?: number | undefined;
  11371. /**
  11372. * Creates a new factor gradient
  11373. * @param gradient gets or sets the gradient value (between 0 and 1)
  11374. * @param factor1 gets or sets first associated factor
  11375. * @param factor2 gets or sets second associated factor
  11376. */
  11377. constructor(
  11378. /**
  11379. * Gets or sets the gradient value (between 0 and 1)
  11380. */
  11381. gradient: number,
  11382. /**
  11383. * Gets or sets first associated factor
  11384. */
  11385. factor1: number,
  11386. /**
  11387. * Gets or sets second associated factor
  11388. */
  11389. factor2?: number | undefined);
  11390. /**
  11391. * Will get a number picked randomly between factor1 and factor2.
  11392. * If factor2 is undefined then factor1 will be used
  11393. * @returns the picked number
  11394. */
  11395. getFactor(): number;
  11396. }
  11397. /**
  11398. * Helper used to simplify some generic gradient tasks
  11399. */
  11400. export class GradientHelper {
  11401. /**
  11402. * Gets the current gradient from an array of IValueGradient
  11403. * @param ratio defines the current ratio to get
  11404. * @param gradients defines the array of IValueGradient
  11405. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  11406. */
  11407. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  11408. }
  11409. }
  11410. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  11411. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  11412. import { Nullable } from "babylonjs/types";
  11413. module "babylonjs/Engines/thinEngine" {
  11414. interface ThinEngine {
  11415. /**
  11416. * Creates a dynamic texture
  11417. * @param width defines the width of the texture
  11418. * @param height defines the height of the texture
  11419. * @param generateMipMaps defines if the engine should generate the mip levels
  11420. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  11421. * @returns the dynamic texture inside an InternalTexture
  11422. */
  11423. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  11424. /**
  11425. * Update the content of a dynamic texture
  11426. * @param texture defines the texture to update
  11427. * @param canvas defines the canvas containing the source
  11428. * @param invertY defines if data must be stored with Y axis inverted
  11429. * @param premulAlpha defines if alpha is stored as premultiplied
  11430. * @param format defines the format of the data
  11431. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  11432. */
  11433. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  11434. }
  11435. }
  11436. }
  11437. declare module "babylonjs/Misc/canvasGenerator" {
  11438. /**
  11439. * Helper class used to generate a canvas to manipulate images
  11440. */
  11441. export class CanvasGenerator {
  11442. /**
  11443. * Create a new canvas (or offscreen canvas depending on the context)
  11444. * @param width defines the expected width
  11445. * @param height defines the expected height
  11446. * @return a new canvas or offscreen canvas
  11447. */
  11448. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  11449. }
  11450. }
  11451. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  11452. import { Scene } from "babylonjs/scene";
  11453. import { Texture } from "babylonjs/Materials/Textures/texture";
  11454. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  11455. /**
  11456. * A class extending Texture allowing drawing on a texture
  11457. * @see http://doc.babylonjs.com/how_to/dynamictexture
  11458. */
  11459. export class DynamicTexture extends Texture {
  11460. private _generateMipMaps;
  11461. private _canvas;
  11462. private _context;
  11463. /**
  11464. * Creates a DynamicTexture
  11465. * @param name defines the name of the texture
  11466. * @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
  11467. * @param scene defines the scene where you want the texture
  11468. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  11469. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  11470. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  11471. */
  11472. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  11473. /**
  11474. * Get the current class name of the texture useful for serialization or dynamic coding.
  11475. * @returns "DynamicTexture"
  11476. */
  11477. getClassName(): string;
  11478. /**
  11479. * Gets the current state of canRescale
  11480. */
  11481. get canRescale(): boolean;
  11482. private _recreate;
  11483. /**
  11484. * Scales the texture
  11485. * @param ratio the scale factor to apply to both width and height
  11486. */
  11487. scale(ratio: number): void;
  11488. /**
  11489. * Resizes the texture
  11490. * @param width the new width
  11491. * @param height the new height
  11492. */
  11493. scaleTo(width: number, height: number): void;
  11494. /**
  11495. * Gets the context of the canvas used by the texture
  11496. * @returns the canvas context of the dynamic texture
  11497. */
  11498. getContext(): CanvasRenderingContext2D;
  11499. /**
  11500. * Clears the texture
  11501. */
  11502. clear(): void;
  11503. /**
  11504. * Updates the texture
  11505. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  11506. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  11507. */
  11508. update(invertY?: boolean, premulAlpha?: boolean): void;
  11509. /**
  11510. * Draws text onto the texture
  11511. * @param text defines the text to be drawn
  11512. * @param x defines the placement of the text from the left
  11513. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  11514. * @param font defines the font to be used with font-style, font-size, font-name
  11515. * @param color defines the color used for the text
  11516. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  11517. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  11518. * @param update defines whether texture is immediately update (default is true)
  11519. */
  11520. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  11521. /**
  11522. * Clones the texture
  11523. * @returns the clone of the texture.
  11524. */
  11525. clone(): DynamicTexture;
  11526. /**
  11527. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  11528. * @returns a serialized dynamic texture object
  11529. */
  11530. serialize(): any;
  11531. /** @hidden */
  11532. _rebuild(): void;
  11533. }
  11534. }
  11535. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  11536. import { Nullable } from "babylonjs/types";
  11537. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  11538. import { Scene } from "babylonjs/scene";
  11539. module "babylonjs/Engines/thinEngine" {
  11540. interface ThinEngine {
  11541. /**
  11542. * Creates a raw texture
  11543. * @param data defines the data to store in the texture
  11544. * @param width defines the width of the texture
  11545. * @param height defines the height of the texture
  11546. * @param format defines the format of the data
  11547. * @param generateMipMaps defines if the engine should generate the mip levels
  11548. * @param invertY defines if data must be stored with Y axis inverted
  11549. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  11550. * @param compression defines the compression used (null by default)
  11551. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11552. * @returns the raw texture inside an InternalTexture
  11553. */
  11554. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  11555. /**
  11556. * Update a raw texture
  11557. * @param texture defines the texture to update
  11558. * @param data defines the data to store in the texture
  11559. * @param format defines the format of the data
  11560. * @param invertY defines if data must be stored with Y axis inverted
  11561. */
  11562. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11563. /**
  11564. * Update a raw texture
  11565. * @param texture defines the texture to update
  11566. * @param data defines the data to store in the texture
  11567. * @param format defines the format of the data
  11568. * @param invertY defines if data must be stored with Y axis inverted
  11569. * @param compression defines the compression used (null by default)
  11570. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11571. */
  11572. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  11573. /**
  11574. * Creates a new raw cube texture
  11575. * @param data defines the array of data to use to create each face
  11576. * @param size defines the size of the textures
  11577. * @param format defines the format of the data
  11578. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11579. * @param generateMipMaps defines if the engine should generate the mip levels
  11580. * @param invertY defines if data must be stored with Y axis inverted
  11581. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11582. * @param compression defines the compression used (null by default)
  11583. * @returns the cube texture as an InternalTexture
  11584. */
  11585. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  11586. /**
  11587. * Update a raw cube texture
  11588. * @param texture defines the texture to udpdate
  11589. * @param data defines the data to store
  11590. * @param format defines the data format
  11591. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11592. * @param invertY defines if data must be stored with Y axis inverted
  11593. */
  11594. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  11595. /**
  11596. * Update a raw cube texture
  11597. * @param texture defines the texture to udpdate
  11598. * @param data defines the data to store
  11599. * @param format defines the data format
  11600. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11601. * @param invertY defines if data must be stored with Y axis inverted
  11602. * @param compression defines the compression used (null by default)
  11603. */
  11604. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  11605. /**
  11606. * Update a raw cube texture
  11607. * @param texture defines the texture to udpdate
  11608. * @param data defines the data to store
  11609. * @param format defines the data format
  11610. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11611. * @param invertY defines if data must be stored with Y axis inverted
  11612. * @param compression defines the compression used (null by default)
  11613. * @param level defines which level of the texture to update
  11614. */
  11615. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  11616. /**
  11617. * Creates a new raw cube texture from a specified url
  11618. * @param url defines the url where the data is located
  11619. * @param scene defines the current scene
  11620. * @param size defines the size of the textures
  11621. * @param format defines the format of the data
  11622. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11623. * @param noMipmap defines if the engine should avoid generating the mip levels
  11624. * @param callback defines a callback used to extract texture data from loaded data
  11625. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11626. * @param onLoad defines a callback called when texture is loaded
  11627. * @param onError defines a callback called if there is an error
  11628. * @returns the cube texture as an InternalTexture
  11629. */
  11630. 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;
  11631. /**
  11632. * Creates a new raw cube texture from a specified url
  11633. * @param url defines the url where the data is located
  11634. * @param scene defines the current scene
  11635. * @param size defines the size of the textures
  11636. * @param format defines the format of the data
  11637. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11638. * @param noMipmap defines if the engine should avoid generating the mip levels
  11639. * @param callback defines a callback used to extract texture data from loaded data
  11640. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11641. * @param onLoad defines a callback called when texture is loaded
  11642. * @param onError defines a callback called if there is an error
  11643. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11644. * @param invertY defines if data must be stored with Y axis inverted
  11645. * @returns the cube texture as an InternalTexture
  11646. */
  11647. 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;
  11648. /**
  11649. * Creates a new raw 3D texture
  11650. * @param data defines the data used to create the texture
  11651. * @param width defines the width of the texture
  11652. * @param height defines the height of the texture
  11653. * @param depth defines the depth of the texture
  11654. * @param format defines the format of the texture
  11655. * @param generateMipMaps defines if the engine must generate mip levels
  11656. * @param invertY defines if data must be stored with Y axis inverted
  11657. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11658. * @param compression defines the compressed used (can be null)
  11659. * @param textureType defines the compressed used (can be null)
  11660. * @returns a new raw 3D texture (stored in an InternalTexture)
  11661. */
  11662. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11663. /**
  11664. * Update a raw 3D texture
  11665. * @param texture defines the texture to update
  11666. * @param data defines the data to store
  11667. * @param format defines the data format
  11668. * @param invertY defines if data must be stored with Y axis inverted
  11669. */
  11670. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11671. /**
  11672. * Update a raw 3D texture
  11673. * @param texture defines the texture to update
  11674. * @param data defines the data to store
  11675. * @param format defines the data format
  11676. * @param invertY defines if data must be stored with Y axis inverted
  11677. * @param compression defines the used compression (can be null)
  11678. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11679. */
  11680. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11681. /**
  11682. * Creates a new raw 2D array texture
  11683. * @param data defines the data used to create the texture
  11684. * @param width defines the width of the texture
  11685. * @param height defines the height of the texture
  11686. * @param depth defines the number of layers of the texture
  11687. * @param format defines the format of the texture
  11688. * @param generateMipMaps defines if the engine must generate mip levels
  11689. * @param invertY defines if data must be stored with Y axis inverted
  11690. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11691. * @param compression defines the compressed used (can be null)
  11692. * @param textureType defines the compressed used (can be null)
  11693. * @returns a new raw 2D array texture (stored in an InternalTexture)
  11694. */
  11695. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11696. /**
  11697. * Update a raw 2D array texture
  11698. * @param texture defines the texture to update
  11699. * @param data defines the data to store
  11700. * @param format defines the data format
  11701. * @param invertY defines if data must be stored with Y axis inverted
  11702. */
  11703. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11704. /**
  11705. * Update a raw 2D array texture
  11706. * @param texture defines the texture to update
  11707. * @param data defines the data to store
  11708. * @param format defines the data format
  11709. * @param invertY defines if data must be stored with Y axis inverted
  11710. * @param compression defines the used compression (can be null)
  11711. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11712. */
  11713. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11714. }
  11715. }
  11716. }
  11717. declare module "babylonjs/Materials/Textures/rawTexture" {
  11718. import { Scene } from "babylonjs/scene";
  11719. import { Texture } from "babylonjs/Materials/Textures/texture";
  11720. import "babylonjs/Engines/Extensions/engine.rawTexture";
  11721. /**
  11722. * Raw texture can help creating a texture directly from an array of data.
  11723. * This can be super useful if you either get the data from an uncompressed source or
  11724. * if you wish to create your texture pixel by pixel.
  11725. */
  11726. export class RawTexture extends Texture {
  11727. /**
  11728. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11729. */
  11730. format: number;
  11731. /**
  11732. * Instantiates a new RawTexture.
  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. * @param data define the array of data to use to create the texture
  11737. * @param width define the width of the texture
  11738. * @param height define the height of the texture
  11739. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11740. * @param scene define the scene the texture belongs to
  11741. * @param generateMipMaps define whether mip maps should be generated or not
  11742. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11743. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11744. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11745. */
  11746. constructor(data: ArrayBufferView, width: number, height: number,
  11747. /**
  11748. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11749. */
  11750. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  11751. /**
  11752. * Updates the texture underlying data.
  11753. * @param data Define the new data of the texture
  11754. */
  11755. update(data: ArrayBufferView): void;
  11756. /**
  11757. * Creates a luminance texture from some data.
  11758. * @param data Define the texture data
  11759. * @param width Define the width of the texture
  11760. * @param height Define the height of the texture
  11761. * @param scene Define the scene the texture belongs to
  11762. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11763. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11764. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11765. * @returns the luminance texture
  11766. */
  11767. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11768. /**
  11769. * Creates a luminance alpha texture from some data.
  11770. * @param data Define the texture data
  11771. * @param width Define the width of the texture
  11772. * @param height Define the height of the texture
  11773. * @param scene Define the scene the texture belongs to
  11774. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11775. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11776. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11777. * @returns the luminance alpha texture
  11778. */
  11779. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11780. /**
  11781. * Creates an alpha texture from some data.
  11782. * @param data Define the texture data
  11783. * @param width Define the width of the texture
  11784. * @param height Define the height of the texture
  11785. * @param scene Define the scene the texture belongs to
  11786. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11787. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11788. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11789. * @returns the alpha texture
  11790. */
  11791. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11792. /**
  11793. * Creates a RGB texture from some data.
  11794. * @param data Define the texture data
  11795. * @param width Define the width of the texture
  11796. * @param height Define the height of the texture
  11797. * @param scene Define the scene the texture belongs to
  11798. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11799. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11800. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11801. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11802. * @returns the RGB alpha texture
  11803. */
  11804. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11805. /**
  11806. * Creates a RGBA texture from some data.
  11807. * @param data Define the texture data
  11808. * @param width Define the width of the texture
  11809. * @param height Define the height of the texture
  11810. * @param scene Define the scene the texture belongs to
  11811. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11812. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11813. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11814. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11815. * @returns the RGBA texture
  11816. */
  11817. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11818. /**
  11819. * Creates a R texture from some data.
  11820. * @param data Define the texture data
  11821. * @param width Define the width of the texture
  11822. * @param height Define the height of the texture
  11823. * @param scene Define the scene the texture belongs to
  11824. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11825. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11826. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11827. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11828. * @returns the R texture
  11829. */
  11830. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11831. }
  11832. }
  11833. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  11834. import { Scene } from "babylonjs/scene";
  11835. import { ISceneComponent } from "babylonjs/sceneComponent";
  11836. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  11837. module "babylonjs/abstractScene" {
  11838. interface AbstractScene {
  11839. /**
  11840. * The list of procedural textures added to the scene
  11841. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11842. */
  11843. proceduralTextures: Array<ProceduralTexture>;
  11844. }
  11845. }
  11846. /**
  11847. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  11848. * in a given scene.
  11849. */
  11850. export class ProceduralTextureSceneComponent implements ISceneComponent {
  11851. /**
  11852. * The component name helpfull to identify the component in the list of scene components.
  11853. */
  11854. readonly name: string;
  11855. /**
  11856. * The scene the component belongs to.
  11857. */
  11858. scene: Scene;
  11859. /**
  11860. * Creates a new instance of the component for the given scene
  11861. * @param scene Defines the scene to register the component in
  11862. */
  11863. constructor(scene: Scene);
  11864. /**
  11865. * Registers the component in a given scene
  11866. */
  11867. register(): void;
  11868. /**
  11869. * Rebuilds the elements related to this component in case of
  11870. * context lost for instance.
  11871. */
  11872. rebuild(): void;
  11873. /**
  11874. * Disposes the component and the associated ressources.
  11875. */
  11876. dispose(): void;
  11877. private _beforeClear;
  11878. }
  11879. }
  11880. declare module "babylonjs/Engines/Extensions/engine.renderTargetCube" {
  11881. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  11882. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  11883. module "babylonjs/Engines/thinEngine" {
  11884. interface ThinEngine {
  11885. /**
  11886. * Creates a new render target cube texture
  11887. * @param size defines the size of the texture
  11888. * @param options defines the options used to create the texture
  11889. * @returns a new render target cube texture stored in an InternalTexture
  11890. */
  11891. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  11892. }
  11893. }
  11894. }
  11895. declare module "babylonjs/Shaders/procedural.vertex" {
  11896. /** @hidden */
  11897. export var proceduralVertexShader: {
  11898. name: string;
  11899. shader: string;
  11900. };
  11901. }
  11902. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  11903. import { Observable } from "babylonjs/Misc/observable";
  11904. import { Nullable } from "babylonjs/types";
  11905. import { Scene } from "babylonjs/scene";
  11906. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  11907. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  11908. import { Effect } from "babylonjs/Materials/effect";
  11909. import { Texture } from "babylonjs/Materials/Textures/texture";
  11910. import "babylonjs/Engines/Extensions/engine.renderTarget";
  11911. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  11912. import "babylonjs/Shaders/procedural.vertex";
  11913. /**
  11914. * 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.
  11915. * This is the base class of any Procedural texture and contains most of the shareable code.
  11916. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11917. */
  11918. export class ProceduralTexture extends Texture {
  11919. isCube: boolean;
  11920. /**
  11921. * Define if the texture is enabled or not (disabled texture will not render)
  11922. */
  11923. isEnabled: boolean;
  11924. /**
  11925. * Define if the texture must be cleared before rendering (default is true)
  11926. */
  11927. autoClear: boolean;
  11928. /**
  11929. * Callback called when the texture is generated
  11930. */
  11931. onGenerated: () => void;
  11932. /**
  11933. * Event raised when the texture is generated
  11934. */
  11935. onGeneratedObservable: Observable<ProceduralTexture>;
  11936. /** @hidden */
  11937. _generateMipMaps: boolean;
  11938. /** @hidden **/
  11939. _effect: Effect;
  11940. /** @hidden */
  11941. _textures: {
  11942. [key: string]: Texture;
  11943. };
  11944. /** @hidden */
  11945. protected _fallbackTexture: Nullable<Texture>;
  11946. private _size;
  11947. private _currentRefreshId;
  11948. private _frameId;
  11949. private _refreshRate;
  11950. private _vertexBuffers;
  11951. private _indexBuffer;
  11952. private _uniforms;
  11953. private _samplers;
  11954. private _fragment;
  11955. private _floats;
  11956. private _ints;
  11957. private _floatsArrays;
  11958. private _colors3;
  11959. private _colors4;
  11960. private _vectors2;
  11961. private _vectors3;
  11962. private _matrices;
  11963. private _fallbackTextureUsed;
  11964. private _fullEngine;
  11965. private _cachedDefines;
  11966. private _contentUpdateId;
  11967. private _contentData;
  11968. /**
  11969. * Instantiates a new procedural texture.
  11970. * 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.
  11971. * This is the base class of any Procedural texture and contains most of the shareable code.
  11972. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11973. * @param name Define the name of the texture
  11974. * @param size Define the size of the texture to create
  11975. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  11976. * @param scene Define the scene the texture belongs to
  11977. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  11978. * @param generateMipMaps Define if the texture should creates mip maps or not
  11979. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  11980. */
  11981. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  11982. /**
  11983. * The effect that is created when initializing the post process.
  11984. * @returns The created effect corresponding the the postprocess.
  11985. */
  11986. getEffect(): Effect;
  11987. /**
  11988. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  11989. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  11990. */
  11991. getContent(): Nullable<ArrayBufferView>;
  11992. private _createIndexBuffer;
  11993. /** @hidden */
  11994. _rebuild(): void;
  11995. /**
  11996. * Resets the texture in order to recreate its associated resources.
  11997. * This can be called in case of context loss
  11998. */
  11999. reset(): void;
  12000. protected _getDefines(): string;
  12001. /**
  12002. * Is the texture ready to be used ? (rendered at least once)
  12003. * @returns true if ready, otherwise, false.
  12004. */
  12005. isReady(): boolean;
  12006. /**
  12007. * Resets the refresh counter of the texture and start bak from scratch.
  12008. * Could be useful to regenerate the texture if it is setup to render only once.
  12009. */
  12010. resetRefreshCounter(): void;
  12011. /**
  12012. * Set the fragment shader to use in order to render the texture.
  12013. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  12014. */
  12015. setFragment(fragment: any): void;
  12016. /**
  12017. * Define the refresh rate of the texture or the rendering frequency.
  12018. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  12019. */
  12020. get refreshRate(): number;
  12021. set refreshRate(value: number);
  12022. /** @hidden */
  12023. _shouldRender(): boolean;
  12024. /**
  12025. * Get the size the texture is rendering at.
  12026. * @returns the size (texture is always squared)
  12027. */
  12028. getRenderSize(): number;
  12029. /**
  12030. * Resize the texture to new value.
  12031. * @param size Define the new size the texture should have
  12032. * @param generateMipMaps Define whether the new texture should create mip maps
  12033. */
  12034. resize(size: number, generateMipMaps: boolean): void;
  12035. private _checkUniform;
  12036. /**
  12037. * Set a texture in the shader program used to render.
  12038. * @param name Define the name of the uniform samplers as defined in the shader
  12039. * @param texture Define the texture to bind to this sampler
  12040. * @return the texture itself allowing "fluent" like uniform updates
  12041. */
  12042. setTexture(name: string, texture: Texture): ProceduralTexture;
  12043. /**
  12044. * Set a float in the shader.
  12045. * @param name Define the name of the uniform as defined in the shader
  12046. * @param value Define the value to give to the uniform
  12047. * @return the texture itself allowing "fluent" like uniform updates
  12048. */
  12049. setFloat(name: string, value: number): ProceduralTexture;
  12050. /**
  12051. * Set a int in the shader.
  12052. * @param name Define the name of the uniform as defined in the shader
  12053. * @param value Define the value to give to the uniform
  12054. * @return the texture itself allowing "fluent" like uniform updates
  12055. */
  12056. setInt(name: string, value: number): ProceduralTexture;
  12057. /**
  12058. * Set an array of floats in the shader.
  12059. * @param name Define the name of the uniform as defined in the shader
  12060. * @param value Define the value to give to the uniform
  12061. * @return the texture itself allowing "fluent" like uniform updates
  12062. */
  12063. setFloats(name: string, value: number[]): ProceduralTexture;
  12064. /**
  12065. * Set a vec3 in the shader from a Color3.
  12066. * @param name Define the name of the uniform as defined in the shader
  12067. * @param value Define the value to give to the uniform
  12068. * @return the texture itself allowing "fluent" like uniform updates
  12069. */
  12070. setColor3(name: string, value: Color3): ProceduralTexture;
  12071. /**
  12072. * Set a vec4 in the shader from a Color4.
  12073. * @param name Define the name of the uniform as defined in the shader
  12074. * @param value Define the value to give to the uniform
  12075. * @return the texture itself allowing "fluent" like uniform updates
  12076. */
  12077. setColor4(name: string, value: Color4): ProceduralTexture;
  12078. /**
  12079. * Set a vec2 in the shader from a Vector2.
  12080. * @param name Define the name of the uniform as defined in the shader
  12081. * @param value Define the value to give to the uniform
  12082. * @return the texture itself allowing "fluent" like uniform updates
  12083. */
  12084. setVector2(name: string, value: Vector2): ProceduralTexture;
  12085. /**
  12086. * Set a vec3 in the shader from a Vector3.
  12087. * @param name Define the name of the uniform as defined in the shader
  12088. * @param value Define the value to give to the uniform
  12089. * @return the texture itself allowing "fluent" like uniform updates
  12090. */
  12091. setVector3(name: string, value: Vector3): ProceduralTexture;
  12092. /**
  12093. * Set a mat4 in the shader from a MAtrix.
  12094. * @param name Define the name of the uniform as defined in the shader
  12095. * @param value Define the value to give to the uniform
  12096. * @return the texture itself allowing "fluent" like uniform updates
  12097. */
  12098. setMatrix(name: string, value: Matrix): ProceduralTexture;
  12099. /**
  12100. * Render the texture to its associated render target.
  12101. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  12102. */
  12103. render(useCameraPostProcess?: boolean): void;
  12104. /**
  12105. * Clone the texture.
  12106. * @returns the cloned texture
  12107. */
  12108. clone(): ProceduralTexture;
  12109. /**
  12110. * Dispose the texture and release its asoociated resources.
  12111. */
  12112. dispose(): void;
  12113. }
  12114. }
  12115. declare module "babylonjs/Particles/baseParticleSystem" {
  12116. import { Nullable } from "babylonjs/types";
  12117. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  12118. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12119. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  12120. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  12121. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  12122. import { Scene } from "babylonjs/scene";
  12123. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  12124. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  12125. import { Texture } from "babylonjs/Materials/Textures/texture";
  12126. import { Color4 } from "babylonjs/Maths/math.color";
  12127. import { Animation } from "babylonjs/Animations/animation";
  12128. /**
  12129. * This represents the base class for particle system in Babylon.
  12130. * 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.
  12131. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12132. * @example https://doc.babylonjs.com/babylon101/particles
  12133. */
  12134. export class BaseParticleSystem {
  12135. /**
  12136. * Source color is added to the destination color without alpha affecting the result
  12137. */
  12138. static BLENDMODE_ONEONE: number;
  12139. /**
  12140. * Blend current color and particle color using particle’s alpha
  12141. */
  12142. static BLENDMODE_STANDARD: number;
  12143. /**
  12144. * Add current color and particle color multiplied by particle’s alpha
  12145. */
  12146. static BLENDMODE_ADD: number;
  12147. /**
  12148. * Multiply current color with particle color
  12149. */
  12150. static BLENDMODE_MULTIPLY: number;
  12151. /**
  12152. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  12153. */
  12154. static BLENDMODE_MULTIPLYADD: number;
  12155. /**
  12156. * List of animations used by the particle system.
  12157. */
  12158. animations: Animation[];
  12159. /**
  12160. * Gets or sets the unique id of the particle system
  12161. */
  12162. uniqueId: number;
  12163. /**
  12164. * The id of the Particle system.
  12165. */
  12166. id: string;
  12167. /**
  12168. * The friendly name of the Particle system.
  12169. */
  12170. name: string;
  12171. /**
  12172. * Snippet ID if the particle system was created from the snippet server
  12173. */
  12174. snippetId: string;
  12175. /**
  12176. * The rendering group used by the Particle system to chose when to render.
  12177. */
  12178. renderingGroupId: number;
  12179. /**
  12180. * The emitter represents the Mesh or position we are attaching the particle system to.
  12181. */
  12182. emitter: Nullable<AbstractMesh | Vector3>;
  12183. /**
  12184. * The maximum number of particles to emit per frame
  12185. */
  12186. emitRate: number;
  12187. /**
  12188. * If you want to launch only a few particles at once, that can be done, as well.
  12189. */
  12190. manualEmitCount: number;
  12191. /**
  12192. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  12193. */
  12194. updateSpeed: number;
  12195. /**
  12196. * The amount of time the particle system is running (depends of the overall update speed).
  12197. */
  12198. targetStopDuration: number;
  12199. /**
  12200. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  12201. */
  12202. disposeOnStop: boolean;
  12203. /**
  12204. * Minimum power of emitting particles.
  12205. */
  12206. minEmitPower: number;
  12207. /**
  12208. * Maximum power of emitting particles.
  12209. */
  12210. maxEmitPower: number;
  12211. /**
  12212. * Minimum life time of emitting particles.
  12213. */
  12214. minLifeTime: number;
  12215. /**
  12216. * Maximum life time of emitting particles.
  12217. */
  12218. maxLifeTime: number;
  12219. /**
  12220. * Minimum Size of emitting particles.
  12221. */
  12222. minSize: number;
  12223. /**
  12224. * Maximum Size of emitting particles.
  12225. */
  12226. maxSize: number;
  12227. /**
  12228. * Minimum scale of emitting particles on X axis.
  12229. */
  12230. minScaleX: number;
  12231. /**
  12232. * Maximum scale of emitting particles on X axis.
  12233. */
  12234. maxScaleX: number;
  12235. /**
  12236. * Minimum scale of emitting particles on Y axis.
  12237. */
  12238. minScaleY: number;
  12239. /**
  12240. * Maximum scale of emitting particles on Y axis.
  12241. */
  12242. maxScaleY: number;
  12243. /**
  12244. * Gets or sets the minimal initial rotation in radians.
  12245. */
  12246. minInitialRotation: number;
  12247. /**
  12248. * Gets or sets the maximal initial rotation in radians.
  12249. */
  12250. maxInitialRotation: number;
  12251. /**
  12252. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  12253. */
  12254. minAngularSpeed: number;
  12255. /**
  12256. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  12257. */
  12258. maxAngularSpeed: number;
  12259. /**
  12260. * The texture used to render each particle. (this can be a spritesheet)
  12261. */
  12262. particleTexture: Nullable<Texture>;
  12263. /**
  12264. * The layer mask we are rendering the particles through.
  12265. */
  12266. layerMask: number;
  12267. /**
  12268. * This can help using your own shader to render the particle system.
  12269. * The according effect will be created
  12270. */
  12271. customShader: any;
  12272. /**
  12273. * By default particle system starts as soon as they are created. This prevents the
  12274. * automatic start to happen and let you decide when to start emitting particles.
  12275. */
  12276. preventAutoStart: boolean;
  12277. private _noiseTexture;
  12278. /**
  12279. * Gets or sets a texture used to add random noise to particle positions
  12280. */
  12281. get noiseTexture(): Nullable<ProceduralTexture>;
  12282. set noiseTexture(value: Nullable<ProceduralTexture>);
  12283. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  12284. noiseStrength: Vector3;
  12285. /**
  12286. * Callback triggered when the particle animation is ending.
  12287. */
  12288. onAnimationEnd: Nullable<() => void>;
  12289. /**
  12290. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  12291. */
  12292. blendMode: number;
  12293. /**
  12294. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  12295. * to override the particles.
  12296. */
  12297. forceDepthWrite: boolean;
  12298. /** 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 */
  12299. preWarmCycles: number;
  12300. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  12301. preWarmStepOffset: number;
  12302. /**
  12303. * 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)
  12304. */
  12305. spriteCellChangeSpeed: number;
  12306. /**
  12307. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  12308. */
  12309. startSpriteCellID: number;
  12310. /**
  12311. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  12312. */
  12313. endSpriteCellID: number;
  12314. /**
  12315. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  12316. */
  12317. spriteCellWidth: number;
  12318. /**
  12319. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  12320. */
  12321. spriteCellHeight: number;
  12322. /**
  12323. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  12324. */
  12325. spriteRandomStartCell: boolean;
  12326. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  12327. translationPivot: Vector2;
  12328. /** @hidden */
  12329. protected _isAnimationSheetEnabled: boolean;
  12330. /**
  12331. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  12332. */
  12333. beginAnimationOnStart: boolean;
  12334. /**
  12335. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  12336. */
  12337. beginAnimationFrom: number;
  12338. /**
  12339. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  12340. */
  12341. beginAnimationTo: number;
  12342. /**
  12343. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  12344. */
  12345. beginAnimationLoop: boolean;
  12346. /**
  12347. * Gets or sets a world offset applied to all particles
  12348. */
  12349. worldOffset: Vector3;
  12350. /**
  12351. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  12352. */
  12353. get isAnimationSheetEnabled(): boolean;
  12354. set isAnimationSheetEnabled(value: boolean);
  12355. /**
  12356. * Get hosting scene
  12357. * @returns the scene
  12358. */
  12359. getScene(): Scene;
  12360. /**
  12361. * You can use gravity if you want to give an orientation to your particles.
  12362. */
  12363. gravity: Vector3;
  12364. protected _colorGradients: Nullable<Array<ColorGradient>>;
  12365. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  12366. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  12367. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  12368. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  12369. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  12370. protected _dragGradients: Nullable<Array<FactorGradient>>;
  12371. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  12372. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  12373. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  12374. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  12375. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  12376. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  12377. /**
  12378. * Defines the delay in milliseconds before starting the system (0 by default)
  12379. */
  12380. startDelay: number;
  12381. /**
  12382. * Gets the current list of drag gradients.
  12383. * You must use addDragGradient and removeDragGradient to udpate this list
  12384. * @returns the list of drag gradients
  12385. */
  12386. getDragGradients(): Nullable<Array<FactorGradient>>;
  12387. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  12388. limitVelocityDamping: number;
  12389. /**
  12390. * Gets the current list of limit velocity gradients.
  12391. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  12392. * @returns the list of limit velocity gradients
  12393. */
  12394. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  12395. /**
  12396. * Gets the current list of color gradients.
  12397. * You must use addColorGradient and removeColorGradient to udpate this list
  12398. * @returns the list of color gradients
  12399. */
  12400. getColorGradients(): Nullable<Array<ColorGradient>>;
  12401. /**
  12402. * Gets the current list of size gradients.
  12403. * You must use addSizeGradient and removeSizeGradient to udpate this list
  12404. * @returns the list of size gradients
  12405. */
  12406. getSizeGradients(): Nullable<Array<FactorGradient>>;
  12407. /**
  12408. * Gets the current list of color remap gradients.
  12409. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  12410. * @returns the list of color remap gradients
  12411. */
  12412. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  12413. /**
  12414. * Gets the current list of alpha remap gradients.
  12415. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  12416. * @returns the list of alpha remap gradients
  12417. */
  12418. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  12419. /**
  12420. * Gets the current list of life time gradients.
  12421. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  12422. * @returns the list of life time gradients
  12423. */
  12424. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  12425. /**
  12426. * Gets the current list of angular speed gradients.
  12427. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  12428. * @returns the list of angular speed gradients
  12429. */
  12430. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  12431. /**
  12432. * Gets the current list of velocity gradients.
  12433. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  12434. * @returns the list of velocity gradients
  12435. */
  12436. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  12437. /**
  12438. * Gets the current list of start size gradients.
  12439. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  12440. * @returns the list of start size gradients
  12441. */
  12442. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  12443. /**
  12444. * Gets the current list of emit rate gradients.
  12445. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  12446. * @returns the list of emit rate gradients
  12447. */
  12448. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  12449. /**
  12450. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12451. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12452. */
  12453. get direction1(): Vector3;
  12454. set direction1(value: Vector3);
  12455. /**
  12456. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12457. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12458. */
  12459. get direction2(): Vector3;
  12460. set direction2(value: Vector3);
  12461. /**
  12462. * 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.
  12463. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12464. */
  12465. get minEmitBox(): Vector3;
  12466. set minEmitBox(value: Vector3);
  12467. /**
  12468. * 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.
  12469. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12470. */
  12471. get maxEmitBox(): Vector3;
  12472. set maxEmitBox(value: Vector3);
  12473. /**
  12474. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12475. */
  12476. color1: Color4;
  12477. /**
  12478. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12479. */
  12480. color2: Color4;
  12481. /**
  12482. * Color the particle will have at the end of its lifetime
  12483. */
  12484. colorDead: Color4;
  12485. /**
  12486. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  12487. */
  12488. textureMask: Color4;
  12489. /**
  12490. * The particle emitter type defines the emitter used by the particle system.
  12491. * It can be for example box, sphere, or cone...
  12492. */
  12493. particleEmitterType: IParticleEmitterType;
  12494. /** @hidden */
  12495. _isSubEmitter: boolean;
  12496. /**
  12497. * Gets or sets the billboard mode to use when isBillboardBased = true.
  12498. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  12499. */
  12500. billboardMode: number;
  12501. protected _isBillboardBased: boolean;
  12502. /**
  12503. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  12504. */
  12505. get isBillboardBased(): boolean;
  12506. set isBillboardBased(value: boolean);
  12507. /**
  12508. * The scene the particle system belongs to.
  12509. */
  12510. protected _scene: Scene;
  12511. /**
  12512. * Local cache of defines for image processing.
  12513. */
  12514. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  12515. /**
  12516. * Default configuration related to image processing available in the standard Material.
  12517. */
  12518. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  12519. /**
  12520. * Gets the image processing configuration used either in this material.
  12521. */
  12522. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  12523. /**
  12524. * Sets the Default image processing configuration used either in the this material.
  12525. *
  12526. * If sets to null, the scene one is in use.
  12527. */
  12528. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  12529. /**
  12530. * Attaches a new image processing configuration to the Standard Material.
  12531. * @param configuration
  12532. */
  12533. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  12534. /** @hidden */
  12535. protected _reset(): void;
  12536. /** @hidden */
  12537. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  12538. /**
  12539. * Instantiates a particle system.
  12540. * 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.
  12541. * @param name The name of the particle system
  12542. */
  12543. constructor(name: string);
  12544. /**
  12545. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  12546. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12547. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12548. * @returns the emitter
  12549. */
  12550. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  12551. /**
  12552. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  12553. * @param radius The radius of the hemisphere to emit from
  12554. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12555. * @returns the emitter
  12556. */
  12557. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  12558. /**
  12559. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  12560. * @param radius The radius of the sphere to emit from
  12561. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12562. * @returns the emitter
  12563. */
  12564. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  12565. /**
  12566. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  12567. * @param radius The radius of the sphere to emit from
  12568. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  12569. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  12570. * @returns the emitter
  12571. */
  12572. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  12573. /**
  12574. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  12575. * @param radius The radius of the emission cylinder
  12576. * @param height The height of the emission cylinder
  12577. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  12578. * @param directionRandomizer How much to randomize the particle direction [0-1]
  12579. * @returns the emitter
  12580. */
  12581. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  12582. /**
  12583. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  12584. * @param radius The radius of the cylinder to emit from
  12585. * @param height The height of the emission cylinder
  12586. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12587. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  12588. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  12589. * @returns the emitter
  12590. */
  12591. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  12592. /**
  12593. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  12594. * @param radius The radius of the cone to emit from
  12595. * @param angle The base angle of the cone
  12596. * @returns the emitter
  12597. */
  12598. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  12599. /**
  12600. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  12601. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12602. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12603. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12604. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12605. * @returns the emitter
  12606. */
  12607. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  12608. }
  12609. }
  12610. declare module "babylonjs/Particles/subEmitter" {
  12611. import { Scene } from "babylonjs/scene";
  12612. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  12613. /**
  12614. * Type of sub emitter
  12615. */
  12616. export enum SubEmitterType {
  12617. /**
  12618. * Attached to the particle over it's lifetime
  12619. */
  12620. ATTACHED = 0,
  12621. /**
  12622. * Created when the particle dies
  12623. */
  12624. END = 1
  12625. }
  12626. /**
  12627. * Sub emitter class used to emit particles from an existing particle
  12628. */
  12629. export class SubEmitter {
  12630. /**
  12631. * the particle system to be used by the sub emitter
  12632. */
  12633. particleSystem: ParticleSystem;
  12634. /**
  12635. * Type of the submitter (Default: END)
  12636. */
  12637. type: SubEmitterType;
  12638. /**
  12639. * 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)
  12640. * Note: This only is supported when using an emitter of type Mesh
  12641. */
  12642. inheritDirection: boolean;
  12643. /**
  12644. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  12645. */
  12646. inheritedVelocityAmount: number;
  12647. /**
  12648. * Creates a sub emitter
  12649. * @param particleSystem the particle system to be used by the sub emitter
  12650. */
  12651. constructor(
  12652. /**
  12653. * the particle system to be used by the sub emitter
  12654. */
  12655. particleSystem: ParticleSystem);
  12656. /**
  12657. * Clones the sub emitter
  12658. * @returns the cloned sub emitter
  12659. */
  12660. clone(): SubEmitter;
  12661. /**
  12662. * Serialize current object to a JSON object
  12663. * @returns the serialized object
  12664. */
  12665. serialize(): any;
  12666. /** @hidden */
  12667. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  12668. /**
  12669. * Creates a new SubEmitter from a serialized JSON version
  12670. * @param serializationObject defines the JSON object to read from
  12671. * @param scene defines the hosting scene
  12672. * @param rootUrl defines the rootUrl for data loading
  12673. * @returns a new SubEmitter
  12674. */
  12675. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  12676. /** Release associated resources */
  12677. dispose(): void;
  12678. }
  12679. }
  12680. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  12681. /** @hidden */
  12682. export var imageProcessingDeclaration: {
  12683. name: string;
  12684. shader: string;
  12685. };
  12686. }
  12687. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  12688. /** @hidden */
  12689. export var imageProcessingFunctions: {
  12690. name: string;
  12691. shader: string;
  12692. };
  12693. }
  12694. declare module "babylonjs/Shaders/particles.fragment" {
  12695. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  12696. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  12697. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  12698. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  12699. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  12700. /** @hidden */
  12701. export var particlesPixelShader: {
  12702. name: string;
  12703. shader: string;
  12704. };
  12705. }
  12706. declare module "babylonjs/Shaders/particles.vertex" {
  12707. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  12708. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  12709. /** @hidden */
  12710. export var particlesVertexShader: {
  12711. name: string;
  12712. shader: string;
  12713. };
  12714. }
  12715. declare module "babylonjs/Particles/particleSystem" {
  12716. import { Nullable } from "babylonjs/types";
  12717. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  12718. import { Observable } from "babylonjs/Misc/observable";
  12719. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12720. import { Effect } from "babylonjs/Materials/effect";
  12721. import { Scene, IDisposable } from "babylonjs/scene";
  12722. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  12723. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  12724. import { Particle } from "babylonjs/Particles/particle";
  12725. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  12726. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  12727. import "babylonjs/Shaders/particles.fragment";
  12728. import "babylonjs/Shaders/particles.vertex";
  12729. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  12730. /**
  12731. * This represents a particle system in Babylon.
  12732. * 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.
  12733. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12734. * @example https://doc.babylonjs.com/babylon101/particles
  12735. */
  12736. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  12737. /**
  12738. * Billboard mode will only apply to Y axis
  12739. */
  12740. static readonly BILLBOARDMODE_Y: number;
  12741. /**
  12742. * Billboard mode will apply to all axes
  12743. */
  12744. static readonly BILLBOARDMODE_ALL: number;
  12745. /**
  12746. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  12747. */
  12748. static readonly BILLBOARDMODE_STRETCHED: number;
  12749. /**
  12750. * This function can be defined to provide custom update for active particles.
  12751. * This function will be called instead of regular update (age, position, color, etc.).
  12752. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  12753. */
  12754. updateFunction: (particles: Particle[]) => void;
  12755. private _emitterWorldMatrix;
  12756. /**
  12757. * This function can be defined to specify initial direction for every new particle.
  12758. * It by default use the emitterType defined function
  12759. */
  12760. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12761. /**
  12762. * This function can be defined to specify initial position for every new particle.
  12763. * It by default use the emitterType defined function
  12764. */
  12765. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12766. /**
  12767. * @hidden
  12768. */
  12769. _inheritedVelocityOffset: Vector3;
  12770. /**
  12771. * An event triggered when the system is disposed
  12772. */
  12773. onDisposeObservable: Observable<IParticleSystem>;
  12774. private _onDisposeObserver;
  12775. /**
  12776. * Sets a callback that will be triggered when the system is disposed
  12777. */
  12778. set onDispose(callback: () => void);
  12779. private _particles;
  12780. private _epsilon;
  12781. private _capacity;
  12782. private _stockParticles;
  12783. private _newPartsExcess;
  12784. private _vertexData;
  12785. private _vertexBuffer;
  12786. private _vertexBuffers;
  12787. private _spriteBuffer;
  12788. private _indexBuffer;
  12789. private _effect;
  12790. private _customEffect;
  12791. private _cachedDefines;
  12792. private _scaledColorStep;
  12793. private _colorDiff;
  12794. private _scaledDirection;
  12795. private _scaledGravity;
  12796. private _currentRenderId;
  12797. private _alive;
  12798. private _useInstancing;
  12799. private _started;
  12800. private _stopped;
  12801. private _actualFrame;
  12802. private _scaledUpdateSpeed;
  12803. private _vertexBufferSize;
  12804. /** @hidden */
  12805. _currentEmitRateGradient: Nullable<FactorGradient>;
  12806. /** @hidden */
  12807. _currentEmitRate1: number;
  12808. /** @hidden */
  12809. _currentEmitRate2: number;
  12810. /** @hidden */
  12811. _currentStartSizeGradient: Nullable<FactorGradient>;
  12812. /** @hidden */
  12813. _currentStartSize1: number;
  12814. /** @hidden */
  12815. _currentStartSize2: number;
  12816. private readonly _rawTextureWidth;
  12817. private _rampGradientsTexture;
  12818. private _useRampGradients;
  12819. /** Gets or sets a boolean indicating that ramp gradients must be used
  12820. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  12821. */
  12822. get useRampGradients(): boolean;
  12823. set useRampGradients(value: boolean);
  12824. /**
  12825. * 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.
  12826. * 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: [])
  12827. */
  12828. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  12829. private _subEmitters;
  12830. /**
  12831. * @hidden
  12832. * If the particle systems emitter should be disposed when the particle system is disposed
  12833. */
  12834. _disposeEmitterOnDispose: boolean;
  12835. /**
  12836. * The current active Sub-systems, this property is used by the root particle system only.
  12837. */
  12838. activeSubSystems: Array<ParticleSystem>;
  12839. /**
  12840. * Specifies if the particles are updated in emitter local space or world space
  12841. */
  12842. isLocal: boolean;
  12843. private _rootParticleSystem;
  12844. /**
  12845. * Gets the current list of active particles
  12846. */
  12847. get particles(): Particle[];
  12848. /**
  12849. * Gets the number of particles active at the same time.
  12850. * @returns The number of active particles.
  12851. */
  12852. getActiveCount(): number;
  12853. /**
  12854. * Returns the string "ParticleSystem"
  12855. * @returns a string containing the class name
  12856. */
  12857. getClassName(): string;
  12858. /**
  12859. * Gets a boolean indicating that the system is stopping
  12860. * @returns true if the system is currently stopping
  12861. */
  12862. isStopping(): boolean;
  12863. /**
  12864. * Gets the custom effect used to render the particles
  12865. * @param blendMode Blend mode for which the effect should be retrieved
  12866. * @returns The effect
  12867. */
  12868. getCustomEffect(blendMode?: number): Nullable<Effect>;
  12869. /**
  12870. * Sets the custom effect used to render the particles
  12871. * @param effect The effect to set
  12872. * @param blendMode Blend mode for which the effect should be set
  12873. */
  12874. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  12875. /** @hidden */
  12876. private _onBeforeDrawParticlesObservable;
  12877. /**
  12878. * Observable that will be called just before the particles are drawn
  12879. */
  12880. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  12881. /**
  12882. * Gets the name of the particle vertex shader
  12883. */
  12884. get vertexShaderName(): string;
  12885. /**
  12886. * Instantiates a particle system.
  12887. * 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.
  12888. * @param name The name of the particle system
  12889. * @param capacity The max number of particles alive at the same time
  12890. * @param scene The scene the particle system belongs to
  12891. * @param customEffect a custom effect used to change the way particles are rendered by default
  12892. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  12893. * @param epsilon Offset used to render the particles
  12894. */
  12895. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  12896. private _addFactorGradient;
  12897. private _removeFactorGradient;
  12898. /**
  12899. * Adds a new life time gradient
  12900. * @param gradient defines the gradient to use (between 0 and 1)
  12901. * @param factor defines the life time factor to affect to the specified gradient
  12902. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12903. * @returns the current particle system
  12904. */
  12905. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12906. /**
  12907. * Remove a specific life time gradient
  12908. * @param gradient defines the gradient to remove
  12909. * @returns the current particle system
  12910. */
  12911. removeLifeTimeGradient(gradient: number): IParticleSystem;
  12912. /**
  12913. * Adds a new size gradient
  12914. * @param gradient defines the gradient to use (between 0 and 1)
  12915. * @param factor defines the size factor to affect to the specified gradient
  12916. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12917. * @returns the current particle system
  12918. */
  12919. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12920. /**
  12921. * Remove a specific size gradient
  12922. * @param gradient defines the gradient to remove
  12923. * @returns the current particle system
  12924. */
  12925. removeSizeGradient(gradient: number): IParticleSystem;
  12926. /**
  12927. * Adds a new color remap gradient
  12928. * @param gradient defines the gradient to use (between 0 and 1)
  12929. * @param min defines the color remap minimal range
  12930. * @param max defines the color remap maximal range
  12931. * @returns the current particle system
  12932. */
  12933. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12934. /**
  12935. * Remove a specific color remap gradient
  12936. * @param gradient defines the gradient to remove
  12937. * @returns the current particle system
  12938. */
  12939. removeColorRemapGradient(gradient: number): IParticleSystem;
  12940. /**
  12941. * Adds a new alpha remap gradient
  12942. * @param gradient defines the gradient to use (between 0 and 1)
  12943. * @param min defines the alpha remap minimal range
  12944. * @param max defines the alpha remap maximal range
  12945. * @returns the current particle system
  12946. */
  12947. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12948. /**
  12949. * Remove a specific alpha remap gradient
  12950. * @param gradient defines the gradient to remove
  12951. * @returns the current particle system
  12952. */
  12953. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  12954. /**
  12955. * Adds a new angular speed gradient
  12956. * @param gradient defines the gradient to use (between 0 and 1)
  12957. * @param factor defines the angular speed to affect to the specified gradient
  12958. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12959. * @returns the current particle system
  12960. */
  12961. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12962. /**
  12963. * Remove a specific angular speed gradient
  12964. * @param gradient defines the gradient to remove
  12965. * @returns the current particle system
  12966. */
  12967. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  12968. /**
  12969. * Adds a new velocity gradient
  12970. * @param gradient defines the gradient to use (between 0 and 1)
  12971. * @param factor defines the velocity to affect to the specified gradient
  12972. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12973. * @returns the current particle system
  12974. */
  12975. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12976. /**
  12977. * Remove a specific velocity gradient
  12978. * @param gradient defines the gradient to remove
  12979. * @returns the current particle system
  12980. */
  12981. removeVelocityGradient(gradient: number): IParticleSystem;
  12982. /**
  12983. * Adds a new limit velocity gradient
  12984. * @param gradient defines the gradient to use (between 0 and 1)
  12985. * @param factor defines the limit velocity value to affect to the specified gradient
  12986. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12987. * @returns the current particle system
  12988. */
  12989. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12990. /**
  12991. * Remove a specific limit velocity gradient
  12992. * @param gradient defines the gradient to remove
  12993. * @returns the current particle system
  12994. */
  12995. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  12996. /**
  12997. * Adds a new drag gradient
  12998. * @param gradient defines the gradient to use (between 0 and 1)
  12999. * @param factor defines the drag value to affect to the specified gradient
  13000. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13001. * @returns the current particle system
  13002. */
  13003. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13004. /**
  13005. * Remove a specific drag gradient
  13006. * @param gradient defines the gradient to remove
  13007. * @returns the current particle system
  13008. */
  13009. removeDragGradient(gradient: number): IParticleSystem;
  13010. /**
  13011. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  13012. * @param gradient defines the gradient to use (between 0 and 1)
  13013. * @param factor defines the emit rate value to affect to the specified gradient
  13014. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13015. * @returns the current particle system
  13016. */
  13017. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13018. /**
  13019. * Remove a specific emit rate gradient
  13020. * @param gradient defines the gradient to remove
  13021. * @returns the current particle system
  13022. */
  13023. removeEmitRateGradient(gradient: number): IParticleSystem;
  13024. /**
  13025. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  13026. * @param gradient defines the gradient to use (between 0 and 1)
  13027. * @param factor defines the start size value to affect to the specified gradient
  13028. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13029. * @returns the current particle system
  13030. */
  13031. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13032. /**
  13033. * Remove a specific start size gradient
  13034. * @param gradient defines the gradient to remove
  13035. * @returns the current particle system
  13036. */
  13037. removeStartSizeGradient(gradient: number): IParticleSystem;
  13038. private _createRampGradientTexture;
  13039. /**
  13040. * Gets the current list of ramp gradients.
  13041. * You must use addRampGradient and removeRampGradient to udpate this list
  13042. * @returns the list of ramp gradients
  13043. */
  13044. getRampGradients(): Nullable<Array<Color3Gradient>>;
  13045. /** Force the system to rebuild all gradients that need to be resync */
  13046. forceRefreshGradients(): void;
  13047. private _syncRampGradientTexture;
  13048. /**
  13049. * Adds a new ramp gradient used to remap particle colors
  13050. * @param gradient defines the gradient to use (between 0 and 1)
  13051. * @param color defines the color to affect to the specified gradient
  13052. * @returns the current particle system
  13053. */
  13054. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  13055. /**
  13056. * Remove a specific ramp gradient
  13057. * @param gradient defines the gradient to remove
  13058. * @returns the current particle system
  13059. */
  13060. removeRampGradient(gradient: number): ParticleSystem;
  13061. /**
  13062. * Adds a new color gradient
  13063. * @param gradient defines the gradient to use (between 0 and 1)
  13064. * @param color1 defines the color to affect to the specified gradient
  13065. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  13066. * @returns this particle system
  13067. */
  13068. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  13069. /**
  13070. * Remove a specific color gradient
  13071. * @param gradient defines the gradient to remove
  13072. * @returns this particle system
  13073. */
  13074. removeColorGradient(gradient: number): IParticleSystem;
  13075. private _fetchR;
  13076. protected _reset(): void;
  13077. private _resetEffect;
  13078. private _createVertexBuffers;
  13079. private _createIndexBuffer;
  13080. /**
  13081. * Gets the maximum number of particles active at the same time.
  13082. * @returns The max number of active particles.
  13083. */
  13084. getCapacity(): number;
  13085. /**
  13086. * Gets whether there are still active particles in the system.
  13087. * @returns True if it is alive, otherwise false.
  13088. */
  13089. isAlive(): boolean;
  13090. /**
  13091. * Gets if the system has been started. (Note: this will still be true after stop is called)
  13092. * @returns True if it has been started, otherwise false.
  13093. */
  13094. isStarted(): boolean;
  13095. private _prepareSubEmitterInternalArray;
  13096. /**
  13097. * Starts the particle system and begins to emit
  13098. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  13099. */
  13100. start(delay?: number): void;
  13101. /**
  13102. * Stops the particle system.
  13103. * @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.
  13104. */
  13105. stop(stopSubEmitters?: boolean): void;
  13106. /**
  13107. * Remove all active particles
  13108. */
  13109. reset(): void;
  13110. /**
  13111. * @hidden (for internal use only)
  13112. */
  13113. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  13114. /**
  13115. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  13116. * Its lifetime will start back at 0.
  13117. */
  13118. recycleParticle: (particle: Particle) => void;
  13119. private _stopSubEmitters;
  13120. private _createParticle;
  13121. private _removeFromRoot;
  13122. private _emitFromParticle;
  13123. private _update;
  13124. /** @hidden */
  13125. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  13126. /** @hidden */
  13127. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  13128. /**
  13129. * Fill the defines array according to the current settings of the particle system
  13130. * @param defines Array to be updated
  13131. * @param blendMode blend mode to take into account when updating the array
  13132. */
  13133. fillDefines(defines: Array<string>, blendMode: number): void;
  13134. /**
  13135. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  13136. * @param uniforms Uniforms array to fill
  13137. * @param attributes Attributes array to fill
  13138. * @param samplers Samplers array to fill
  13139. */
  13140. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  13141. /** @hidden */
  13142. private _getEffect;
  13143. /**
  13144. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  13145. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  13146. */
  13147. animate(preWarmOnly?: boolean): void;
  13148. private _appendParticleVertices;
  13149. /**
  13150. * Rebuilds the particle system.
  13151. */
  13152. rebuild(): void;
  13153. /**
  13154. * Is this system ready to be used/rendered
  13155. * @return true if the system is ready
  13156. */
  13157. isReady(): boolean;
  13158. private _render;
  13159. /**
  13160. * Renders the particle system in its current state.
  13161. * @returns the current number of particles
  13162. */
  13163. render(): number;
  13164. /**
  13165. * Disposes the particle system and free the associated resources
  13166. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13167. */
  13168. dispose(disposeTexture?: boolean): void;
  13169. /**
  13170. * Clones the particle system.
  13171. * @param name The name of the cloned object
  13172. * @param newEmitter The new emitter to use
  13173. * @returns the cloned particle system
  13174. */
  13175. clone(name: string, newEmitter: any): ParticleSystem;
  13176. /**
  13177. * Serializes the particle system to a JSON object
  13178. * @param serializeTexture defines if the texture must be serialized as well
  13179. * @returns the JSON object
  13180. */
  13181. serialize(serializeTexture?: boolean): any;
  13182. /** @hidden */
  13183. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  13184. /** @hidden */
  13185. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  13186. /**
  13187. * Parses a JSON object to create a particle system.
  13188. * @param parsedParticleSystem The JSON object to parse
  13189. * @param scene The scene to create the particle system in
  13190. * @param rootUrl The root url to use to load external dependencies like texture
  13191. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  13192. * @returns the Parsed particle system
  13193. */
  13194. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  13195. }
  13196. }
  13197. declare module "babylonjs/Particles/particle" {
  13198. import { Nullable } from "babylonjs/types";
  13199. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  13200. import { Color4 } from "babylonjs/Maths/math.color";
  13201. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  13202. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  13203. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  13204. /**
  13205. * A particle represents one of the element emitted by a particle system.
  13206. * This is mainly define by its coordinates, direction, velocity and age.
  13207. */
  13208. export class Particle {
  13209. /**
  13210. * The particle system the particle belongs to.
  13211. */
  13212. particleSystem: ParticleSystem;
  13213. private static _Count;
  13214. /**
  13215. * Unique ID of the particle
  13216. */
  13217. id: number;
  13218. /**
  13219. * The world position of the particle in the scene.
  13220. */
  13221. position: Vector3;
  13222. /**
  13223. * The world direction of the particle in the scene.
  13224. */
  13225. direction: Vector3;
  13226. /**
  13227. * The color of the particle.
  13228. */
  13229. color: Color4;
  13230. /**
  13231. * The color change of the particle per step.
  13232. */
  13233. colorStep: Color4;
  13234. /**
  13235. * Defines how long will the life of the particle be.
  13236. */
  13237. lifeTime: number;
  13238. /**
  13239. * The current age of the particle.
  13240. */
  13241. age: number;
  13242. /**
  13243. * The current size of the particle.
  13244. */
  13245. size: number;
  13246. /**
  13247. * The current scale of the particle.
  13248. */
  13249. scale: Vector2;
  13250. /**
  13251. * The current angle of the particle.
  13252. */
  13253. angle: number;
  13254. /**
  13255. * Defines how fast is the angle changing.
  13256. */
  13257. angularSpeed: number;
  13258. /**
  13259. * Defines the cell index used by the particle to be rendered from a sprite.
  13260. */
  13261. cellIndex: number;
  13262. /**
  13263. * The information required to support color remapping
  13264. */
  13265. remapData: Vector4;
  13266. /** @hidden */
  13267. _randomCellOffset?: number;
  13268. /** @hidden */
  13269. _initialDirection: Nullable<Vector3>;
  13270. /** @hidden */
  13271. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  13272. /** @hidden */
  13273. _initialStartSpriteCellID: number;
  13274. /** @hidden */
  13275. _initialEndSpriteCellID: number;
  13276. /** @hidden */
  13277. _currentColorGradient: Nullable<ColorGradient>;
  13278. /** @hidden */
  13279. _currentColor1: Color4;
  13280. /** @hidden */
  13281. _currentColor2: Color4;
  13282. /** @hidden */
  13283. _currentSizeGradient: Nullable<FactorGradient>;
  13284. /** @hidden */
  13285. _currentSize1: number;
  13286. /** @hidden */
  13287. _currentSize2: number;
  13288. /** @hidden */
  13289. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  13290. /** @hidden */
  13291. _currentAngularSpeed1: number;
  13292. /** @hidden */
  13293. _currentAngularSpeed2: number;
  13294. /** @hidden */
  13295. _currentVelocityGradient: Nullable<FactorGradient>;
  13296. /** @hidden */
  13297. _currentVelocity1: number;
  13298. /** @hidden */
  13299. _currentVelocity2: number;
  13300. /** @hidden */
  13301. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  13302. /** @hidden */
  13303. _currentLimitVelocity1: number;
  13304. /** @hidden */
  13305. _currentLimitVelocity2: number;
  13306. /** @hidden */
  13307. _currentDragGradient: Nullable<FactorGradient>;
  13308. /** @hidden */
  13309. _currentDrag1: number;
  13310. /** @hidden */
  13311. _currentDrag2: number;
  13312. /** @hidden */
  13313. _randomNoiseCoordinates1: Vector3;
  13314. /** @hidden */
  13315. _randomNoiseCoordinates2: Vector3;
  13316. /** @hidden */
  13317. _localPosition?: Vector3;
  13318. /**
  13319. * Creates a new instance Particle
  13320. * @param particleSystem the particle system the particle belongs to
  13321. */
  13322. constructor(
  13323. /**
  13324. * The particle system the particle belongs to.
  13325. */
  13326. particleSystem: ParticleSystem);
  13327. private updateCellInfoFromSystem;
  13328. /**
  13329. * Defines how the sprite cell index is updated for the particle
  13330. */
  13331. updateCellIndex(): void;
  13332. /** @hidden */
  13333. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  13334. /** @hidden */
  13335. _inheritParticleInfoToSubEmitters(): void;
  13336. /** @hidden */
  13337. _reset(): void;
  13338. /**
  13339. * Copy the properties of particle to another one.
  13340. * @param other the particle to copy the information to.
  13341. */
  13342. copyTo(other: Particle): void;
  13343. }
  13344. }
  13345. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  13346. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13347. import { Effect } from "babylonjs/Materials/effect";
  13348. import { Particle } from "babylonjs/Particles/particle";
  13349. import { Scene } from "babylonjs/scene";
  13350. /**
  13351. * Particle emitter represents a volume emitting particles.
  13352. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  13353. */
  13354. export interface IParticleEmitterType {
  13355. /**
  13356. * Called by the particle System when the direction is computed for the created particle.
  13357. * @param worldMatrix is the world matrix of the particle system
  13358. * @param directionToUpdate is the direction vector to update with the result
  13359. * @param particle is the particle we are computed the direction for
  13360. * @param isLocal defines if the direction should be set in local space
  13361. */
  13362. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13363. /**
  13364. * Called by the particle System when the position is computed for the created particle.
  13365. * @param worldMatrix is the world matrix of the particle system
  13366. * @param positionToUpdate is the position vector to update with the result
  13367. * @param particle is the particle we are computed the position for
  13368. * @param isLocal defines if the position should be set in local space
  13369. */
  13370. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13371. /**
  13372. * Clones the current emitter and returns a copy of it
  13373. * @returns the new emitter
  13374. */
  13375. clone(): IParticleEmitterType;
  13376. /**
  13377. * Called by the GPUParticleSystem to setup the update shader
  13378. * @param effect defines the update shader
  13379. */
  13380. applyToShader(effect: Effect): void;
  13381. /**
  13382. * Returns a string to use to update the GPU particles update shader
  13383. * @returns the effect defines string
  13384. */
  13385. getEffectDefines(): string;
  13386. /**
  13387. * Returns a string representing the class name
  13388. * @returns a string containing the class name
  13389. */
  13390. getClassName(): string;
  13391. /**
  13392. * Serializes the particle system to a JSON object.
  13393. * @returns the JSON object
  13394. */
  13395. serialize(): any;
  13396. /**
  13397. * Parse properties from a JSON object
  13398. * @param serializationObject defines the JSON object
  13399. * @param scene defines the hosting scene
  13400. */
  13401. parse(serializationObject: any, scene: Scene): void;
  13402. }
  13403. }
  13404. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  13405. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13406. import { Effect } from "babylonjs/Materials/effect";
  13407. import { Particle } from "babylonjs/Particles/particle";
  13408. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13409. /**
  13410. * Particle emitter emitting particles from the inside of a box.
  13411. * It emits the particles randomly between 2 given directions.
  13412. */
  13413. export class BoxParticleEmitter implements IParticleEmitterType {
  13414. /**
  13415. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13416. */
  13417. direction1: Vector3;
  13418. /**
  13419. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13420. */
  13421. direction2: Vector3;
  13422. /**
  13423. * 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.
  13424. */
  13425. minEmitBox: Vector3;
  13426. /**
  13427. * 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.
  13428. */
  13429. maxEmitBox: Vector3;
  13430. /**
  13431. * Creates a new instance BoxParticleEmitter
  13432. */
  13433. constructor();
  13434. /**
  13435. * Called by the particle System when the direction is computed for the created particle.
  13436. * @param worldMatrix is the world matrix of the particle system
  13437. * @param directionToUpdate is the direction vector to update with the result
  13438. * @param particle is the particle we are computed the direction for
  13439. * @param isLocal defines if the direction should be set in local space
  13440. */
  13441. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13442. /**
  13443. * Called by the particle System when the position is computed for the created particle.
  13444. * @param worldMatrix is the world matrix of the particle system
  13445. * @param positionToUpdate is the position vector to update with the result
  13446. * @param particle is the particle we are computed the position for
  13447. * @param isLocal defines if the position should be set in local space
  13448. */
  13449. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13450. /**
  13451. * Clones the current emitter and returns a copy of it
  13452. * @returns the new emitter
  13453. */
  13454. clone(): BoxParticleEmitter;
  13455. /**
  13456. * Called by the GPUParticleSystem to setup the update shader
  13457. * @param effect defines the update shader
  13458. */
  13459. applyToShader(effect: Effect): void;
  13460. /**
  13461. * Returns a string to use to update the GPU particles update shader
  13462. * @returns a string containng the defines string
  13463. */
  13464. getEffectDefines(): string;
  13465. /**
  13466. * Returns the string "BoxParticleEmitter"
  13467. * @returns a string containing the class name
  13468. */
  13469. getClassName(): string;
  13470. /**
  13471. * Serializes the particle system to a JSON object.
  13472. * @returns the JSON object
  13473. */
  13474. serialize(): any;
  13475. /**
  13476. * Parse properties from a JSON object
  13477. * @param serializationObject defines the JSON object
  13478. */
  13479. parse(serializationObject: any): void;
  13480. }
  13481. }
  13482. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  13483. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13484. import { Effect } from "babylonjs/Materials/effect";
  13485. import { Particle } from "babylonjs/Particles/particle";
  13486. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13487. /**
  13488. * Particle emitter emitting particles from the inside of a cone.
  13489. * It emits the particles alongside the cone volume from the base to the particle.
  13490. * The emission direction might be randomized.
  13491. */
  13492. export class ConeParticleEmitter implements IParticleEmitterType {
  13493. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13494. directionRandomizer: number;
  13495. private _radius;
  13496. private _angle;
  13497. private _height;
  13498. /**
  13499. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  13500. */
  13501. radiusRange: number;
  13502. /**
  13503. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  13504. */
  13505. heightRange: number;
  13506. /**
  13507. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  13508. */
  13509. emitFromSpawnPointOnly: boolean;
  13510. /**
  13511. * Gets or sets the radius of the emission cone
  13512. */
  13513. get radius(): number;
  13514. set radius(value: number);
  13515. /**
  13516. * Gets or sets the angle of the emission cone
  13517. */
  13518. get angle(): number;
  13519. set angle(value: number);
  13520. private _buildHeight;
  13521. /**
  13522. * Creates a new instance ConeParticleEmitter
  13523. * @param radius the radius of the emission cone (1 by default)
  13524. * @param angle the cone base angle (PI by default)
  13525. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  13526. */
  13527. constructor(radius?: number, angle?: number,
  13528. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13529. directionRandomizer?: number);
  13530. /**
  13531. * Called by the particle System when the direction is computed for the created particle.
  13532. * @param worldMatrix is the world matrix of the particle system
  13533. * @param directionToUpdate is the direction vector to update with the result
  13534. * @param particle is the particle we are computed the direction for
  13535. * @param isLocal defines if the direction should be set in local space
  13536. */
  13537. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13538. /**
  13539. * Called by the particle System when the position is computed for the created particle.
  13540. * @param worldMatrix is the world matrix of the particle system
  13541. * @param positionToUpdate is the position vector to update with the result
  13542. * @param particle is the particle we are computed the position for
  13543. * @param isLocal defines if the position should be set in local space
  13544. */
  13545. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13546. /**
  13547. * Clones the current emitter and returns a copy of it
  13548. * @returns the new emitter
  13549. */
  13550. clone(): ConeParticleEmitter;
  13551. /**
  13552. * Called by the GPUParticleSystem to setup the update shader
  13553. * @param effect defines the update shader
  13554. */
  13555. applyToShader(effect: Effect): void;
  13556. /**
  13557. * Returns a string to use to update the GPU particles update shader
  13558. * @returns a string containng the defines string
  13559. */
  13560. getEffectDefines(): string;
  13561. /**
  13562. * Returns the string "ConeParticleEmitter"
  13563. * @returns a string containing the class name
  13564. */
  13565. getClassName(): string;
  13566. /**
  13567. * Serializes the particle system to a JSON object.
  13568. * @returns the JSON object
  13569. */
  13570. serialize(): any;
  13571. /**
  13572. * Parse properties from a JSON object
  13573. * @param serializationObject defines the JSON object
  13574. */
  13575. parse(serializationObject: any): void;
  13576. }
  13577. }
  13578. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  13579. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13580. import { Effect } from "babylonjs/Materials/effect";
  13581. import { Particle } from "babylonjs/Particles/particle";
  13582. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13583. /**
  13584. * Particle emitter emitting particles from the inside of a cylinder.
  13585. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  13586. */
  13587. export class CylinderParticleEmitter implements IParticleEmitterType {
  13588. /**
  13589. * The radius of the emission cylinder.
  13590. */
  13591. radius: number;
  13592. /**
  13593. * The height of the emission cylinder.
  13594. */
  13595. height: number;
  13596. /**
  13597. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13598. */
  13599. radiusRange: number;
  13600. /**
  13601. * How much to randomize the particle direction [0-1].
  13602. */
  13603. directionRandomizer: number;
  13604. /**
  13605. * Creates a new instance CylinderParticleEmitter
  13606. * @param radius the radius of the emission cylinder (1 by default)
  13607. * @param height the height of the emission cylinder (1 by default)
  13608. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13609. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13610. */
  13611. constructor(
  13612. /**
  13613. * The radius of the emission cylinder.
  13614. */
  13615. radius?: number,
  13616. /**
  13617. * The height of the emission cylinder.
  13618. */
  13619. height?: number,
  13620. /**
  13621. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13622. */
  13623. radiusRange?: number,
  13624. /**
  13625. * How much to randomize the particle direction [0-1].
  13626. */
  13627. directionRandomizer?: number);
  13628. /**
  13629. * Called by the particle System when the direction is computed for the created particle.
  13630. * @param worldMatrix is the world matrix of the particle system
  13631. * @param directionToUpdate is the direction vector to update with the result
  13632. * @param particle is the particle we are computed the direction for
  13633. * @param isLocal defines if the direction should be set in local space
  13634. */
  13635. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13636. /**
  13637. * Called by the particle System when the position is computed for the created particle.
  13638. * @param worldMatrix is the world matrix of the particle system
  13639. * @param positionToUpdate is the position vector to update with the result
  13640. * @param particle is the particle we are computed the position for
  13641. * @param isLocal defines if the position should be set in local space
  13642. */
  13643. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13644. /**
  13645. * Clones the current emitter and returns a copy of it
  13646. * @returns the new emitter
  13647. */
  13648. clone(): CylinderParticleEmitter;
  13649. /**
  13650. * Called by the GPUParticleSystem to setup the update shader
  13651. * @param effect defines the update shader
  13652. */
  13653. applyToShader(effect: Effect): void;
  13654. /**
  13655. * Returns a string to use to update the GPU particles update shader
  13656. * @returns a string containng the defines string
  13657. */
  13658. getEffectDefines(): string;
  13659. /**
  13660. * Returns the string "CylinderParticleEmitter"
  13661. * @returns a string containing the class name
  13662. */
  13663. getClassName(): string;
  13664. /**
  13665. * Serializes the particle system to a JSON object.
  13666. * @returns the JSON object
  13667. */
  13668. serialize(): any;
  13669. /**
  13670. * Parse properties from a JSON object
  13671. * @param serializationObject defines the JSON object
  13672. */
  13673. parse(serializationObject: any): void;
  13674. }
  13675. /**
  13676. * Particle emitter emitting particles from the inside of a cylinder.
  13677. * It emits the particles randomly between two vectors.
  13678. */
  13679. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  13680. /**
  13681. * The min limit of the emission direction.
  13682. */
  13683. direction1: Vector3;
  13684. /**
  13685. * The max limit of the emission direction.
  13686. */
  13687. direction2: Vector3;
  13688. /**
  13689. * Creates a new instance CylinderDirectedParticleEmitter
  13690. * @param radius the radius of the emission cylinder (1 by default)
  13691. * @param height the height of the emission cylinder (1 by default)
  13692. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13693. * @param direction1 the min limit of the emission direction (up vector by default)
  13694. * @param direction2 the max limit of the emission direction (up vector by default)
  13695. */
  13696. constructor(radius?: number, height?: number, radiusRange?: number,
  13697. /**
  13698. * The min limit of the emission direction.
  13699. */
  13700. direction1?: Vector3,
  13701. /**
  13702. * The max limit of the emission direction.
  13703. */
  13704. direction2?: Vector3);
  13705. /**
  13706. * Called by the particle System when the direction is computed for the created particle.
  13707. * @param worldMatrix is the world matrix of the particle system
  13708. * @param directionToUpdate is the direction vector to update with the result
  13709. * @param particle is the particle we are computed the direction for
  13710. */
  13711. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13712. /**
  13713. * Clones the current emitter and returns a copy of it
  13714. * @returns the new emitter
  13715. */
  13716. clone(): CylinderDirectedParticleEmitter;
  13717. /**
  13718. * Called by the GPUParticleSystem to setup the update shader
  13719. * @param effect defines the update shader
  13720. */
  13721. applyToShader(effect: Effect): void;
  13722. /**
  13723. * Returns a string to use to update the GPU particles update shader
  13724. * @returns a string containng the defines string
  13725. */
  13726. getEffectDefines(): string;
  13727. /**
  13728. * Returns the string "CylinderDirectedParticleEmitter"
  13729. * @returns a string containing the class name
  13730. */
  13731. getClassName(): string;
  13732. /**
  13733. * Serializes the particle system to a JSON object.
  13734. * @returns the JSON object
  13735. */
  13736. serialize(): any;
  13737. /**
  13738. * Parse properties from a JSON object
  13739. * @param serializationObject defines the JSON object
  13740. */
  13741. parse(serializationObject: any): void;
  13742. }
  13743. }
  13744. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  13745. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13746. import { Effect } from "babylonjs/Materials/effect";
  13747. import { Particle } from "babylonjs/Particles/particle";
  13748. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13749. /**
  13750. * Particle emitter emitting particles from the inside of a hemisphere.
  13751. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  13752. */
  13753. export class HemisphericParticleEmitter implements IParticleEmitterType {
  13754. /**
  13755. * The radius of the emission hemisphere.
  13756. */
  13757. radius: number;
  13758. /**
  13759. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13760. */
  13761. radiusRange: number;
  13762. /**
  13763. * How much to randomize the particle direction [0-1].
  13764. */
  13765. directionRandomizer: number;
  13766. /**
  13767. * Creates a new instance HemisphericParticleEmitter
  13768. * @param radius the radius of the emission hemisphere (1 by default)
  13769. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13770. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13771. */
  13772. constructor(
  13773. /**
  13774. * The radius of the emission hemisphere.
  13775. */
  13776. radius?: number,
  13777. /**
  13778. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13779. */
  13780. radiusRange?: number,
  13781. /**
  13782. * How much to randomize the particle direction [0-1].
  13783. */
  13784. directionRandomizer?: number);
  13785. /**
  13786. * Called by the particle System when the direction is computed for the created particle.
  13787. * @param worldMatrix is the world matrix of the particle system
  13788. * @param directionToUpdate is the direction vector to update with the result
  13789. * @param particle is the particle we are computed the direction for
  13790. * @param isLocal defines if the direction should be set in local space
  13791. */
  13792. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13793. /**
  13794. * Called by the particle System when the position is computed for the created particle.
  13795. * @param worldMatrix is the world matrix of the particle system
  13796. * @param positionToUpdate is the position vector to update with the result
  13797. * @param particle is the particle we are computed the position for
  13798. * @param isLocal defines if the position should be set in local space
  13799. */
  13800. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13801. /**
  13802. * Clones the current emitter and returns a copy of it
  13803. * @returns the new emitter
  13804. */
  13805. clone(): HemisphericParticleEmitter;
  13806. /**
  13807. * Called by the GPUParticleSystem to setup the update shader
  13808. * @param effect defines the update shader
  13809. */
  13810. applyToShader(effect: Effect): void;
  13811. /**
  13812. * Returns a string to use to update the GPU particles update shader
  13813. * @returns a string containng the defines string
  13814. */
  13815. getEffectDefines(): string;
  13816. /**
  13817. * Returns the string "HemisphericParticleEmitter"
  13818. * @returns a string containing the class name
  13819. */
  13820. getClassName(): string;
  13821. /**
  13822. * Serializes the particle system to a JSON object.
  13823. * @returns the JSON object
  13824. */
  13825. serialize(): any;
  13826. /**
  13827. * Parse properties from a JSON object
  13828. * @param serializationObject defines the JSON object
  13829. */
  13830. parse(serializationObject: any): void;
  13831. }
  13832. }
  13833. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  13834. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13835. import { Effect } from "babylonjs/Materials/effect";
  13836. import { Particle } from "babylonjs/Particles/particle";
  13837. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13838. /**
  13839. * Particle emitter emitting particles from a point.
  13840. * It emits the particles randomly between 2 given directions.
  13841. */
  13842. export class PointParticleEmitter implements IParticleEmitterType {
  13843. /**
  13844. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13845. */
  13846. direction1: Vector3;
  13847. /**
  13848. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13849. */
  13850. direction2: Vector3;
  13851. /**
  13852. * Creates a new instance PointParticleEmitter
  13853. */
  13854. constructor();
  13855. /**
  13856. * Called by the particle System when the direction is computed for the created particle.
  13857. * @param worldMatrix is the world matrix of the particle system
  13858. * @param directionToUpdate is the direction vector to update with the result
  13859. * @param particle is the particle we are computed the direction for
  13860. * @param isLocal defines if the direction should be set in local space
  13861. */
  13862. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13863. /**
  13864. * Called by the particle System when the position is computed for the created particle.
  13865. * @param worldMatrix is the world matrix of the particle system
  13866. * @param positionToUpdate is the position vector to update with the result
  13867. * @param particle is the particle we are computed the position for
  13868. * @param isLocal defines if the position should be set in local space
  13869. */
  13870. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13871. /**
  13872. * Clones the current emitter and returns a copy of it
  13873. * @returns the new emitter
  13874. */
  13875. clone(): PointParticleEmitter;
  13876. /**
  13877. * Called by the GPUParticleSystem to setup the update shader
  13878. * @param effect defines the update shader
  13879. */
  13880. applyToShader(effect: Effect): void;
  13881. /**
  13882. * Returns a string to use to update the GPU particles update shader
  13883. * @returns a string containng the defines string
  13884. */
  13885. getEffectDefines(): string;
  13886. /**
  13887. * Returns the string "PointParticleEmitter"
  13888. * @returns a string containing the class name
  13889. */
  13890. getClassName(): string;
  13891. /**
  13892. * Serializes the particle system to a JSON object.
  13893. * @returns the JSON object
  13894. */
  13895. serialize(): any;
  13896. /**
  13897. * Parse properties from a JSON object
  13898. * @param serializationObject defines the JSON object
  13899. */
  13900. parse(serializationObject: any): void;
  13901. }
  13902. }
  13903. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  13904. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13905. import { Effect } from "babylonjs/Materials/effect";
  13906. import { Particle } from "babylonjs/Particles/particle";
  13907. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13908. /**
  13909. * Particle emitter emitting particles from the inside of a sphere.
  13910. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  13911. */
  13912. export class SphereParticleEmitter implements IParticleEmitterType {
  13913. /**
  13914. * The radius of the emission sphere.
  13915. */
  13916. radius: number;
  13917. /**
  13918. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13919. */
  13920. radiusRange: number;
  13921. /**
  13922. * How much to randomize the particle direction [0-1].
  13923. */
  13924. directionRandomizer: number;
  13925. /**
  13926. * Creates a new instance SphereParticleEmitter
  13927. * @param radius the radius of the emission sphere (1 by default)
  13928. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13929. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13930. */
  13931. constructor(
  13932. /**
  13933. * The radius of the emission sphere.
  13934. */
  13935. radius?: number,
  13936. /**
  13937. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13938. */
  13939. radiusRange?: number,
  13940. /**
  13941. * How much to randomize the particle direction [0-1].
  13942. */
  13943. directionRandomizer?: number);
  13944. /**
  13945. * Called by the particle System when the direction is computed for the created particle.
  13946. * @param worldMatrix is the world matrix of the particle system
  13947. * @param directionToUpdate is the direction vector to update with the result
  13948. * @param particle is the particle we are computed the direction for
  13949. * @param isLocal defines if the direction should be set in local space
  13950. */
  13951. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13952. /**
  13953. * Called by the particle System when the position is computed for the created particle.
  13954. * @param worldMatrix is the world matrix of the particle system
  13955. * @param positionToUpdate is the position vector to update with the result
  13956. * @param particle is the particle we are computed the position for
  13957. * @param isLocal defines if the position should be set in local space
  13958. */
  13959. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13960. /**
  13961. * Clones the current emitter and returns a copy of it
  13962. * @returns the new emitter
  13963. */
  13964. clone(): SphereParticleEmitter;
  13965. /**
  13966. * Called by the GPUParticleSystem to setup the update shader
  13967. * @param effect defines the update shader
  13968. */
  13969. applyToShader(effect: Effect): void;
  13970. /**
  13971. * Returns a string to use to update the GPU particles update shader
  13972. * @returns a string containng the defines string
  13973. */
  13974. getEffectDefines(): string;
  13975. /**
  13976. * Returns the string "SphereParticleEmitter"
  13977. * @returns a string containing the class name
  13978. */
  13979. getClassName(): string;
  13980. /**
  13981. * Serializes the particle system to a JSON object.
  13982. * @returns the JSON object
  13983. */
  13984. serialize(): any;
  13985. /**
  13986. * Parse properties from a JSON object
  13987. * @param serializationObject defines the JSON object
  13988. */
  13989. parse(serializationObject: any): void;
  13990. }
  13991. /**
  13992. * Particle emitter emitting particles from the inside of a sphere.
  13993. * It emits the particles randomly between two vectors.
  13994. */
  13995. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  13996. /**
  13997. * The min limit of the emission direction.
  13998. */
  13999. direction1: Vector3;
  14000. /**
  14001. * The max limit of the emission direction.
  14002. */
  14003. direction2: Vector3;
  14004. /**
  14005. * Creates a new instance SphereDirectedParticleEmitter
  14006. * @param radius the radius of the emission sphere (1 by default)
  14007. * @param direction1 the min limit of the emission direction (up vector by default)
  14008. * @param direction2 the max limit of the emission direction (up vector by default)
  14009. */
  14010. constructor(radius?: number,
  14011. /**
  14012. * The min limit of the emission direction.
  14013. */
  14014. direction1?: Vector3,
  14015. /**
  14016. * The max limit of the emission direction.
  14017. */
  14018. direction2?: Vector3);
  14019. /**
  14020. * Called by the particle System when the direction is computed for the created particle.
  14021. * @param worldMatrix is the world matrix of the particle system
  14022. * @param directionToUpdate is the direction vector to update with the result
  14023. * @param particle is the particle we are computed the direction for
  14024. */
  14025. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  14026. /**
  14027. * Clones the current emitter and returns a copy of it
  14028. * @returns the new emitter
  14029. */
  14030. clone(): SphereDirectedParticleEmitter;
  14031. /**
  14032. * Called by the GPUParticleSystem to setup the update shader
  14033. * @param effect defines the update shader
  14034. */
  14035. applyToShader(effect: Effect): void;
  14036. /**
  14037. * Returns a string to use to update the GPU particles update shader
  14038. * @returns a string containng the defines string
  14039. */
  14040. getEffectDefines(): string;
  14041. /**
  14042. * Returns the string "SphereDirectedParticleEmitter"
  14043. * @returns a string containing the class name
  14044. */
  14045. getClassName(): string;
  14046. /**
  14047. * Serializes the particle system to a JSON object.
  14048. * @returns the JSON object
  14049. */
  14050. serialize(): any;
  14051. /**
  14052. * Parse properties from a JSON object
  14053. * @param serializationObject defines the JSON object
  14054. */
  14055. parse(serializationObject: any): void;
  14056. }
  14057. }
  14058. declare module "babylonjs/Particles/EmitterTypes/customParticleEmitter" {
  14059. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14060. import { Effect } from "babylonjs/Materials/effect";
  14061. import { Particle } from "babylonjs/Particles/particle";
  14062. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14063. import { Nullable } from "babylonjs/types";
  14064. /**
  14065. * Particle emitter emitting particles from a custom list of positions.
  14066. */
  14067. export class CustomParticleEmitter implements IParticleEmitterType {
  14068. /**
  14069. * Gets or sets the position generator that will create the inital position of each particle.
  14070. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  14071. */
  14072. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  14073. /**
  14074. * Gets or sets the destination generator that will create the final destination of each particle.
  14075. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  14076. */
  14077. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  14078. /**
  14079. * Creates a new instance CustomParticleEmitter
  14080. */
  14081. constructor();
  14082. /**
  14083. * Called by the particle System when the direction is computed for the created particle.
  14084. * @param worldMatrix is the world matrix of the particle system
  14085. * @param directionToUpdate is the direction vector to update with the result
  14086. * @param particle is the particle we are computed the direction for
  14087. * @param isLocal defines if the direction should be set in local space
  14088. */
  14089. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14090. /**
  14091. * Called by the particle System when the position is computed for the created particle.
  14092. * @param worldMatrix is the world matrix of the particle system
  14093. * @param positionToUpdate is the position vector to update with the result
  14094. * @param particle is the particle we are computed the position for
  14095. * @param isLocal defines if the position should be set in local space
  14096. */
  14097. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14098. /**
  14099. * Clones the current emitter and returns a copy of it
  14100. * @returns the new emitter
  14101. */
  14102. clone(): CustomParticleEmitter;
  14103. /**
  14104. * Called by the GPUParticleSystem to setup the update shader
  14105. * @param effect defines the update shader
  14106. */
  14107. applyToShader(effect: Effect): void;
  14108. /**
  14109. * Returns a string to use to update the GPU particles update shader
  14110. * @returns a string containng the defines string
  14111. */
  14112. getEffectDefines(): string;
  14113. /**
  14114. * Returns the string "PointParticleEmitter"
  14115. * @returns a string containing the class name
  14116. */
  14117. getClassName(): string;
  14118. /**
  14119. * Serializes the particle system to a JSON object.
  14120. * @returns the JSON object
  14121. */
  14122. serialize(): any;
  14123. /**
  14124. * Parse properties from a JSON object
  14125. * @param serializationObject defines the JSON object
  14126. */
  14127. parse(serializationObject: any): void;
  14128. }
  14129. }
  14130. declare module "babylonjs/Particles/EmitterTypes/meshParticleEmitter" {
  14131. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14132. import { Effect } from "babylonjs/Materials/effect";
  14133. import { Particle } from "babylonjs/Particles/particle";
  14134. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14135. import { Nullable } from "babylonjs/types";
  14136. import { Scene } from "babylonjs/scene";
  14137. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14138. /**
  14139. * Particle emitter emitting particles from the inside of a box.
  14140. * It emits the particles randomly between 2 given directions.
  14141. */
  14142. export class MeshParticleEmitter implements IParticleEmitterType {
  14143. private _indices;
  14144. private _positions;
  14145. private _normals;
  14146. private _storedNormal;
  14147. private _mesh;
  14148. /**
  14149. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14150. */
  14151. direction1: Vector3;
  14152. /**
  14153. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14154. */
  14155. direction2: Vector3;
  14156. /**
  14157. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  14158. */
  14159. useMeshNormalsForDirection: boolean;
  14160. /** Defines the mesh to use as source */
  14161. get mesh(): Nullable<AbstractMesh>;
  14162. set mesh(value: Nullable<AbstractMesh>);
  14163. /**
  14164. * Creates a new instance MeshParticleEmitter
  14165. * @param mesh defines the mesh to use as source
  14166. */
  14167. constructor(mesh?: Nullable<AbstractMesh>);
  14168. /**
  14169. * Called by the particle System when the direction is computed for the created particle.
  14170. * @param worldMatrix is the world matrix of the particle system
  14171. * @param directionToUpdate is the direction vector to update with the result
  14172. * @param particle is the particle we are computed the direction for
  14173. * @param isLocal defines if the direction should be set in local space
  14174. */
  14175. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14176. /**
  14177. * Called by the particle System when the position is computed for the created particle.
  14178. * @param worldMatrix is the world matrix of the particle system
  14179. * @param positionToUpdate is the position vector to update with the result
  14180. * @param particle is the particle we are computed the position for
  14181. * @param isLocal defines if the position should be set in local space
  14182. */
  14183. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14184. /**
  14185. * Clones the current emitter and returns a copy of it
  14186. * @returns the new emitter
  14187. */
  14188. clone(): MeshParticleEmitter;
  14189. /**
  14190. * Called by the GPUParticleSystem to setup the update shader
  14191. * @param effect defines the update shader
  14192. */
  14193. applyToShader(effect: Effect): void;
  14194. /**
  14195. * Returns a string to use to update the GPU particles update shader
  14196. * @returns a string containng the defines string
  14197. */
  14198. getEffectDefines(): string;
  14199. /**
  14200. * Returns the string "BoxParticleEmitter"
  14201. * @returns a string containing the class name
  14202. */
  14203. getClassName(): string;
  14204. /**
  14205. * Serializes the particle system to a JSON object.
  14206. * @returns the JSON object
  14207. */
  14208. serialize(): any;
  14209. /**
  14210. * Parse properties from a JSON object
  14211. * @param serializationObject defines the JSON object
  14212. * @param scene defines the hosting scene
  14213. */
  14214. parse(serializationObject: any, scene: Scene): void;
  14215. }
  14216. }
  14217. declare module "babylonjs/Particles/EmitterTypes/index" {
  14218. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  14219. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  14220. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  14221. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  14222. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14223. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  14224. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  14225. export * from "babylonjs/Particles/EmitterTypes/customParticleEmitter";
  14226. export * from "babylonjs/Particles/EmitterTypes/meshParticleEmitter";
  14227. }
  14228. declare module "babylonjs/Particles/IParticleSystem" {
  14229. import { Nullable } from "babylonjs/types";
  14230. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  14231. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  14232. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14233. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  14234. import { Texture } from "babylonjs/Materials/Textures/texture";
  14235. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  14236. import { Scene } from "babylonjs/scene";
  14237. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  14238. import { Effect } from "babylonjs/Materials/effect";
  14239. import { Observable } from "babylonjs/Misc/observable";
  14240. import { Animation } from "babylonjs/Animations/animation";
  14241. /**
  14242. * Interface representing a particle system in Babylon.js.
  14243. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  14244. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  14245. */
  14246. export interface IParticleSystem {
  14247. /**
  14248. * List of animations used by the particle system.
  14249. */
  14250. animations: Animation[];
  14251. /**
  14252. * The id of the Particle system.
  14253. */
  14254. id: string;
  14255. /**
  14256. * The name of the Particle system.
  14257. */
  14258. name: string;
  14259. /**
  14260. * The emitter represents the Mesh or position we are attaching the particle system to.
  14261. */
  14262. emitter: Nullable<AbstractMesh | Vector3>;
  14263. /**
  14264. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14265. */
  14266. isBillboardBased: boolean;
  14267. /**
  14268. * The rendering group used by the Particle system to chose when to render.
  14269. */
  14270. renderingGroupId: number;
  14271. /**
  14272. * The layer mask we are rendering the particles through.
  14273. */
  14274. layerMask: number;
  14275. /**
  14276. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14277. */
  14278. updateSpeed: number;
  14279. /**
  14280. * The amount of time the particle system is running (depends of the overall update speed).
  14281. */
  14282. targetStopDuration: number;
  14283. /**
  14284. * The texture used to render each particle. (this can be a spritesheet)
  14285. */
  14286. particleTexture: Nullable<Texture>;
  14287. /**
  14288. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  14289. */
  14290. blendMode: number;
  14291. /**
  14292. * Minimum life time of emitting particles.
  14293. */
  14294. minLifeTime: number;
  14295. /**
  14296. * Maximum life time of emitting particles.
  14297. */
  14298. maxLifeTime: number;
  14299. /**
  14300. * Minimum Size of emitting particles.
  14301. */
  14302. minSize: number;
  14303. /**
  14304. * Maximum Size of emitting particles.
  14305. */
  14306. maxSize: number;
  14307. /**
  14308. * Minimum scale of emitting particles on X axis.
  14309. */
  14310. minScaleX: number;
  14311. /**
  14312. * Maximum scale of emitting particles on X axis.
  14313. */
  14314. maxScaleX: number;
  14315. /**
  14316. * Minimum scale of emitting particles on Y axis.
  14317. */
  14318. minScaleY: number;
  14319. /**
  14320. * Maximum scale of emitting particles on Y axis.
  14321. */
  14322. maxScaleY: number;
  14323. /**
  14324. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14325. */
  14326. color1: Color4;
  14327. /**
  14328. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14329. */
  14330. color2: Color4;
  14331. /**
  14332. * Color the particle will have at the end of its lifetime.
  14333. */
  14334. colorDead: Color4;
  14335. /**
  14336. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  14337. */
  14338. emitRate: number;
  14339. /**
  14340. * You can use gravity if you want to give an orientation to your particles.
  14341. */
  14342. gravity: Vector3;
  14343. /**
  14344. * Minimum power of emitting particles.
  14345. */
  14346. minEmitPower: number;
  14347. /**
  14348. * Maximum power of emitting particles.
  14349. */
  14350. maxEmitPower: number;
  14351. /**
  14352. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14353. */
  14354. minAngularSpeed: number;
  14355. /**
  14356. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14357. */
  14358. maxAngularSpeed: number;
  14359. /**
  14360. * Gets or sets the minimal initial rotation in radians.
  14361. */
  14362. minInitialRotation: number;
  14363. /**
  14364. * Gets or sets the maximal initial rotation in radians.
  14365. */
  14366. maxInitialRotation: number;
  14367. /**
  14368. * The particle emitter type defines the emitter used by the particle system.
  14369. * It can be for example box, sphere, or cone...
  14370. */
  14371. particleEmitterType: Nullable<IParticleEmitterType>;
  14372. /**
  14373. * Defines the delay in milliseconds before starting the system (0 by default)
  14374. */
  14375. startDelay: number;
  14376. /**
  14377. * 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
  14378. */
  14379. preWarmCycles: number;
  14380. /**
  14381. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  14382. */
  14383. preWarmStepOffset: number;
  14384. /**
  14385. * 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)
  14386. */
  14387. spriteCellChangeSpeed: number;
  14388. /**
  14389. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14390. */
  14391. startSpriteCellID: number;
  14392. /**
  14393. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14394. */
  14395. endSpriteCellID: number;
  14396. /**
  14397. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14398. */
  14399. spriteCellWidth: number;
  14400. /**
  14401. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14402. */
  14403. spriteCellHeight: number;
  14404. /**
  14405. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14406. */
  14407. spriteRandomStartCell: boolean;
  14408. /**
  14409. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  14410. */
  14411. isAnimationSheetEnabled: boolean;
  14412. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14413. translationPivot: Vector2;
  14414. /**
  14415. * Gets or sets a texture used to add random noise to particle positions
  14416. */
  14417. noiseTexture: Nullable<BaseTexture>;
  14418. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14419. noiseStrength: Vector3;
  14420. /**
  14421. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14422. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14423. */
  14424. billboardMode: number;
  14425. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14426. limitVelocityDamping: number;
  14427. /**
  14428. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14429. */
  14430. beginAnimationOnStart: boolean;
  14431. /**
  14432. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14433. */
  14434. beginAnimationFrom: number;
  14435. /**
  14436. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14437. */
  14438. beginAnimationTo: number;
  14439. /**
  14440. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14441. */
  14442. beginAnimationLoop: boolean;
  14443. /**
  14444. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14445. */
  14446. disposeOnStop: boolean;
  14447. /**
  14448. * Specifies if the particles are updated in emitter local space or world space
  14449. */
  14450. isLocal: boolean;
  14451. /** Snippet ID if the particle system was created from the snippet server */
  14452. snippetId: string;
  14453. /**
  14454. * Gets the maximum number of particles active at the same time.
  14455. * @returns The max number of active particles.
  14456. */
  14457. getCapacity(): number;
  14458. /**
  14459. * Gets the number of particles active at the same time.
  14460. * @returns The number of active particles.
  14461. */
  14462. getActiveCount(): number;
  14463. /**
  14464. * Gets if the system has been started. (Note: this will still be true after stop is called)
  14465. * @returns True if it has been started, otherwise false.
  14466. */
  14467. isStarted(): boolean;
  14468. /**
  14469. * Animates the particle system for this frame.
  14470. */
  14471. animate(): void;
  14472. /**
  14473. * Renders the particle system in its current state.
  14474. * @returns the current number of particles
  14475. */
  14476. render(): number;
  14477. /**
  14478. * Dispose the particle system and frees its associated resources.
  14479. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  14480. */
  14481. dispose(disposeTexture?: boolean): void;
  14482. /**
  14483. * An event triggered when the system is disposed
  14484. */
  14485. onDisposeObservable: Observable<IParticleSystem>;
  14486. /**
  14487. * Clones the particle system.
  14488. * @param name The name of the cloned object
  14489. * @param newEmitter The new emitter to use
  14490. * @returns the cloned particle system
  14491. */
  14492. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  14493. /**
  14494. * Serializes the particle system to a JSON object
  14495. * @param serializeTexture defines if the texture must be serialized as well
  14496. * @returns the JSON object
  14497. */
  14498. serialize(serializeTexture: boolean): any;
  14499. /**
  14500. * Rebuild the particle system
  14501. */
  14502. rebuild(): void;
  14503. /** Force the system to rebuild all gradients that need to be resync */
  14504. forceRefreshGradients(): void;
  14505. /**
  14506. * Starts the particle system and begins to emit
  14507. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  14508. */
  14509. start(delay?: number): void;
  14510. /**
  14511. * Stops the particle system.
  14512. */
  14513. stop(): void;
  14514. /**
  14515. * Remove all active particles
  14516. */
  14517. reset(): void;
  14518. /**
  14519. * Gets a boolean indicating that the system is stopping
  14520. * @returns true if the system is currently stopping
  14521. */
  14522. isStopping(): boolean;
  14523. /**
  14524. * Is this system ready to be used/rendered
  14525. * @return true if the system is ready
  14526. */
  14527. isReady(): boolean;
  14528. /**
  14529. * Returns the string "ParticleSystem"
  14530. * @returns a string containing the class name
  14531. */
  14532. getClassName(): string;
  14533. /**
  14534. * Gets the custom effect used to render the particles
  14535. * @param blendMode Blend mode for which the effect should be retrieved
  14536. * @returns The effect
  14537. */
  14538. getCustomEffect(blendMode: number): Nullable<Effect>;
  14539. /**
  14540. * Sets the custom effect used to render the particles
  14541. * @param effect The effect to set
  14542. * @param blendMode Blend mode for which the effect should be set
  14543. */
  14544. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  14545. /**
  14546. * Fill the defines array according to the current settings of the particle system
  14547. * @param defines Array to be updated
  14548. * @param blendMode blend mode to take into account when updating the array
  14549. */
  14550. fillDefines(defines: Array<string>, blendMode: number): void;
  14551. /**
  14552. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  14553. * @param uniforms Uniforms array to fill
  14554. * @param attributes Attributes array to fill
  14555. * @param samplers Samplers array to fill
  14556. */
  14557. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  14558. /**
  14559. * Observable that will be called just before the particles are drawn
  14560. */
  14561. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  14562. /**
  14563. * Gets the name of the particle vertex shader
  14564. */
  14565. vertexShaderName: string;
  14566. /**
  14567. * Adds a new color gradient
  14568. * @param gradient defines the gradient to use (between 0 and 1)
  14569. * @param color1 defines the color to affect to the specified gradient
  14570. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14571. * @returns the current particle system
  14572. */
  14573. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14574. /**
  14575. * Remove a specific color gradient
  14576. * @param gradient defines the gradient to remove
  14577. * @returns the current particle system
  14578. */
  14579. removeColorGradient(gradient: number): IParticleSystem;
  14580. /**
  14581. * Adds a new size gradient
  14582. * @param gradient defines the gradient to use (between 0 and 1)
  14583. * @param factor defines the size factor to affect to the specified gradient
  14584. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14585. * @returns the current particle system
  14586. */
  14587. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14588. /**
  14589. * Remove a specific size gradient
  14590. * @param gradient defines the gradient to remove
  14591. * @returns the current particle system
  14592. */
  14593. removeSizeGradient(gradient: number): IParticleSystem;
  14594. /**
  14595. * Gets the current list of color gradients.
  14596. * You must use addColorGradient and removeColorGradient to udpate this list
  14597. * @returns the list of color gradients
  14598. */
  14599. getColorGradients(): Nullable<Array<ColorGradient>>;
  14600. /**
  14601. * Gets the current list of size gradients.
  14602. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14603. * @returns the list of size gradients
  14604. */
  14605. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14606. /**
  14607. * Gets the current list of angular speed gradients.
  14608. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14609. * @returns the list of angular speed gradients
  14610. */
  14611. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14612. /**
  14613. * Adds a new angular speed gradient
  14614. * @param gradient defines the gradient to use (between 0 and 1)
  14615. * @param factor defines the angular speed to affect to the specified gradient
  14616. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14617. * @returns the current particle system
  14618. */
  14619. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14620. /**
  14621. * Remove a specific angular speed gradient
  14622. * @param gradient defines the gradient to remove
  14623. * @returns the current particle system
  14624. */
  14625. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14626. /**
  14627. * Gets the current list of velocity gradients.
  14628. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14629. * @returns the list of velocity gradients
  14630. */
  14631. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14632. /**
  14633. * Adds a new velocity gradient
  14634. * @param gradient defines the gradient to use (between 0 and 1)
  14635. * @param factor defines the velocity to affect to the specified gradient
  14636. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14637. * @returns the current particle system
  14638. */
  14639. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14640. /**
  14641. * Remove a specific velocity gradient
  14642. * @param gradient defines the gradient to remove
  14643. * @returns the current particle system
  14644. */
  14645. removeVelocityGradient(gradient: number): IParticleSystem;
  14646. /**
  14647. * Gets the current list of limit velocity gradients.
  14648. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14649. * @returns the list of limit velocity gradients
  14650. */
  14651. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14652. /**
  14653. * Adds a new limit velocity gradient
  14654. * @param gradient defines the gradient to use (between 0 and 1)
  14655. * @param factor defines the limit velocity to affect to the specified gradient
  14656. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14657. * @returns the current particle system
  14658. */
  14659. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14660. /**
  14661. * Remove a specific limit velocity gradient
  14662. * @param gradient defines the gradient to remove
  14663. * @returns the current particle system
  14664. */
  14665. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14666. /**
  14667. * Adds a new drag gradient
  14668. * @param gradient defines the gradient to use (between 0 and 1)
  14669. * @param factor defines the drag to affect to the specified gradient
  14670. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14671. * @returns the current particle system
  14672. */
  14673. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14674. /**
  14675. * Remove a specific drag gradient
  14676. * @param gradient defines the gradient to remove
  14677. * @returns the current particle system
  14678. */
  14679. removeDragGradient(gradient: number): IParticleSystem;
  14680. /**
  14681. * Gets the current list of drag gradients.
  14682. * You must use addDragGradient and removeDragGradient to udpate this list
  14683. * @returns the list of drag gradients
  14684. */
  14685. getDragGradients(): Nullable<Array<FactorGradient>>;
  14686. /**
  14687. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14688. * @param gradient defines the gradient to use (between 0 and 1)
  14689. * @param factor defines the emit rate to affect to the specified gradient
  14690. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14691. * @returns the current particle system
  14692. */
  14693. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14694. /**
  14695. * Remove a specific emit rate gradient
  14696. * @param gradient defines the gradient to remove
  14697. * @returns the current particle system
  14698. */
  14699. removeEmitRateGradient(gradient: number): IParticleSystem;
  14700. /**
  14701. * Gets the current list of emit rate gradients.
  14702. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14703. * @returns the list of emit rate gradients
  14704. */
  14705. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14706. /**
  14707. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14708. * @param gradient defines the gradient to use (between 0 and 1)
  14709. * @param factor defines the start size to affect to the specified gradient
  14710. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14711. * @returns the current particle system
  14712. */
  14713. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14714. /**
  14715. * Remove a specific start size gradient
  14716. * @param gradient defines the gradient to remove
  14717. * @returns the current particle system
  14718. */
  14719. removeStartSizeGradient(gradient: number): IParticleSystem;
  14720. /**
  14721. * Gets the current list of start size gradients.
  14722. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14723. * @returns the list of start size gradients
  14724. */
  14725. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14726. /**
  14727. * Adds a new life time gradient
  14728. * @param gradient defines the gradient to use (between 0 and 1)
  14729. * @param factor defines the life time factor to affect to the specified gradient
  14730. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14731. * @returns the current particle system
  14732. */
  14733. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14734. /**
  14735. * Remove a specific life time gradient
  14736. * @param gradient defines the gradient to remove
  14737. * @returns the current particle system
  14738. */
  14739. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14740. /**
  14741. * Gets the current list of life time gradients.
  14742. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14743. * @returns the list of life time gradients
  14744. */
  14745. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14746. /**
  14747. * Gets the current list of color gradients.
  14748. * You must use addColorGradient and removeColorGradient to udpate this list
  14749. * @returns the list of color gradients
  14750. */
  14751. getColorGradients(): Nullable<Array<ColorGradient>>;
  14752. /**
  14753. * Adds a new ramp gradient used to remap particle colors
  14754. * @param gradient defines the gradient to use (between 0 and 1)
  14755. * @param color defines the color to affect to the specified gradient
  14756. * @returns the current particle system
  14757. */
  14758. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  14759. /**
  14760. * Gets the current list of ramp gradients.
  14761. * You must use addRampGradient and removeRampGradient to udpate this list
  14762. * @returns the list of ramp gradients
  14763. */
  14764. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14765. /** Gets or sets a boolean indicating that ramp gradients must be used
  14766. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14767. */
  14768. useRampGradients: boolean;
  14769. /**
  14770. * Adds a new color remap gradient
  14771. * @param gradient defines the gradient to use (between 0 and 1)
  14772. * @param min defines the color remap minimal range
  14773. * @param max defines the color remap maximal range
  14774. * @returns the current particle system
  14775. */
  14776. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14777. /**
  14778. * Gets the current list of color remap gradients.
  14779. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14780. * @returns the list of color remap gradients
  14781. */
  14782. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14783. /**
  14784. * Adds a new alpha remap gradient
  14785. * @param gradient defines the gradient to use (between 0 and 1)
  14786. * @param min defines the alpha remap minimal range
  14787. * @param max defines the alpha remap maximal range
  14788. * @returns the current particle system
  14789. */
  14790. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14791. /**
  14792. * Gets the current list of alpha remap gradients.
  14793. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14794. * @returns the list of alpha remap gradients
  14795. */
  14796. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14797. /**
  14798. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14799. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14800. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14801. * @returns the emitter
  14802. */
  14803. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14804. /**
  14805. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14806. * @param radius The radius of the hemisphere to emit from
  14807. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14808. * @returns the emitter
  14809. */
  14810. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  14811. /**
  14812. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14813. * @param radius The radius of the sphere to emit from
  14814. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14815. * @returns the emitter
  14816. */
  14817. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  14818. /**
  14819. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14820. * @param radius The radius of the sphere to emit from
  14821. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14822. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14823. * @returns the emitter
  14824. */
  14825. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14826. /**
  14827. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14828. * @param radius The radius of the emission cylinder
  14829. * @param height The height of the emission cylinder
  14830. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14831. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14832. * @returns the emitter
  14833. */
  14834. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  14835. /**
  14836. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14837. * @param radius The radius of the cylinder to emit from
  14838. * @param height The height of the emission cylinder
  14839. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14840. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14841. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14842. * @returns the emitter
  14843. */
  14844. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14845. /**
  14846. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14847. * @param radius The radius of the cone to emit from
  14848. * @param angle The base angle of the cone
  14849. * @returns the emitter
  14850. */
  14851. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  14852. /**
  14853. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14854. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14855. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14856. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14857. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14858. * @returns the emitter
  14859. */
  14860. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14861. /**
  14862. * Get hosting scene
  14863. * @returns the scene
  14864. */
  14865. getScene(): Scene;
  14866. }
  14867. }
  14868. declare module "babylonjs/Meshes/transformNode" {
  14869. import { DeepImmutable } from "babylonjs/types";
  14870. import { Observable } from "babylonjs/Misc/observable";
  14871. import { Nullable } from "babylonjs/types";
  14872. import { Camera } from "babylonjs/Cameras/camera";
  14873. import { Scene } from "babylonjs/scene";
  14874. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14875. import { Node } from "babylonjs/node";
  14876. import { Bone } from "babylonjs/Bones/bone";
  14877. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14878. import { Space } from "babylonjs/Maths/math.axis";
  14879. /**
  14880. * 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.
  14881. * @see https://doc.babylonjs.com/how_to/transformnode
  14882. */
  14883. export class TransformNode extends Node {
  14884. /**
  14885. * Object will not rotate to face the camera
  14886. */
  14887. static BILLBOARDMODE_NONE: number;
  14888. /**
  14889. * Object will rotate to face the camera but only on the x axis
  14890. */
  14891. static BILLBOARDMODE_X: number;
  14892. /**
  14893. * Object will rotate to face the camera but only on the y axis
  14894. */
  14895. static BILLBOARDMODE_Y: number;
  14896. /**
  14897. * Object will rotate to face the camera but only on the z axis
  14898. */
  14899. static BILLBOARDMODE_Z: number;
  14900. /**
  14901. * Object will rotate to face the camera
  14902. */
  14903. static BILLBOARDMODE_ALL: number;
  14904. /**
  14905. * Object will rotate to face the camera's position instead of orientation
  14906. */
  14907. static BILLBOARDMODE_USE_POSITION: number;
  14908. private _forward;
  14909. private _forwardInverted;
  14910. private _up;
  14911. private _right;
  14912. private _rightInverted;
  14913. private _position;
  14914. private _rotation;
  14915. private _rotationQuaternion;
  14916. protected _scaling: Vector3;
  14917. protected _isDirty: boolean;
  14918. private _transformToBoneReferal;
  14919. private _isAbsoluteSynced;
  14920. private _billboardMode;
  14921. /**
  14922. * Gets or sets the billboard mode. Default is 0.
  14923. *
  14924. * | Value | Type | Description |
  14925. * | --- | --- | --- |
  14926. * | 0 | BILLBOARDMODE_NONE | |
  14927. * | 1 | BILLBOARDMODE_X | |
  14928. * | 2 | BILLBOARDMODE_Y | |
  14929. * | 4 | BILLBOARDMODE_Z | |
  14930. * | 7 | BILLBOARDMODE_ALL | |
  14931. *
  14932. */
  14933. get billboardMode(): number;
  14934. set billboardMode(value: number);
  14935. private _preserveParentRotationForBillboard;
  14936. /**
  14937. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14938. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14939. */
  14940. get preserveParentRotationForBillboard(): boolean;
  14941. set preserveParentRotationForBillboard(value: boolean);
  14942. /**
  14943. * 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
  14944. */
  14945. scalingDeterminant: number;
  14946. private _infiniteDistance;
  14947. /**
  14948. * Gets or sets the distance of the object to max, often used by skybox
  14949. */
  14950. get infiniteDistance(): boolean;
  14951. set infiniteDistance(value: boolean);
  14952. /**
  14953. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14954. * By default the system will update normals to compensate
  14955. */
  14956. ignoreNonUniformScaling: boolean;
  14957. /**
  14958. * 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
  14959. */
  14960. reIntegrateRotationIntoRotationQuaternion: boolean;
  14961. /** @hidden */
  14962. _poseMatrix: Nullable<Matrix>;
  14963. /** @hidden */
  14964. _localMatrix: Matrix;
  14965. private _usePivotMatrix;
  14966. private _absolutePosition;
  14967. private _absoluteScaling;
  14968. private _absoluteRotationQuaternion;
  14969. private _pivotMatrix;
  14970. private _pivotMatrixInverse;
  14971. protected _postMultiplyPivotMatrix: boolean;
  14972. protected _isWorldMatrixFrozen: boolean;
  14973. /** @hidden */
  14974. _indexInSceneTransformNodesArray: number;
  14975. /**
  14976. * An event triggered after the world matrix is updated
  14977. */
  14978. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14979. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14980. /**
  14981. * Gets a string identifying the name of the class
  14982. * @returns "TransformNode" string
  14983. */
  14984. getClassName(): string;
  14985. /**
  14986. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14987. */
  14988. get position(): Vector3;
  14989. set position(newPosition: Vector3);
  14990. /**
  14991. * 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)).
  14992. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14993. */
  14994. get rotation(): Vector3;
  14995. set rotation(newRotation: Vector3);
  14996. /**
  14997. * 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)).
  14998. */
  14999. get scaling(): Vector3;
  15000. set scaling(newScaling: Vector3);
  15001. /**
  15002. * 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).
  15003. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  15004. */
  15005. get rotationQuaternion(): Nullable<Quaternion>;
  15006. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  15007. /**
  15008. * The forward direction of that transform in world space.
  15009. */
  15010. get forward(): Vector3;
  15011. /**
  15012. * The up direction of that transform in world space.
  15013. */
  15014. get up(): Vector3;
  15015. /**
  15016. * The right direction of that transform in world space.
  15017. */
  15018. get right(): Vector3;
  15019. /**
  15020. * Copies the parameter passed Matrix into the mesh Pose matrix.
  15021. * @param matrix the matrix to copy the pose from
  15022. * @returns this TransformNode.
  15023. */
  15024. updatePoseMatrix(matrix: Matrix): TransformNode;
  15025. /**
  15026. * Returns the mesh Pose matrix.
  15027. * @returns the pose matrix
  15028. */
  15029. getPoseMatrix(): Matrix;
  15030. /** @hidden */
  15031. _isSynchronized(): boolean;
  15032. /** @hidden */
  15033. _initCache(): void;
  15034. /**
  15035. * Flag the transform node as dirty (Forcing it to update everything)
  15036. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  15037. * @returns this transform node
  15038. */
  15039. markAsDirty(property: string): TransformNode;
  15040. /**
  15041. * Returns the current mesh absolute position.
  15042. * Returns a Vector3.
  15043. */
  15044. get absolutePosition(): Vector3;
  15045. /**
  15046. * Returns the current mesh absolute scaling.
  15047. * Returns a Vector3.
  15048. */
  15049. get absoluteScaling(): Vector3;
  15050. /**
  15051. * Returns the current mesh absolute rotation.
  15052. * Returns a Quaternion.
  15053. */
  15054. get absoluteRotationQuaternion(): Quaternion;
  15055. /**
  15056. * Sets a new matrix to apply before all other transformation
  15057. * @param matrix defines the transform matrix
  15058. * @returns the current TransformNode
  15059. */
  15060. setPreTransformMatrix(matrix: Matrix): TransformNode;
  15061. /**
  15062. * Sets a new pivot matrix to the current node
  15063. * @param matrix defines the new pivot matrix to use
  15064. * @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
  15065. * @returns the current TransformNode
  15066. */
  15067. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  15068. /**
  15069. * Returns the mesh pivot matrix.
  15070. * Default : Identity.
  15071. * @returns the matrix
  15072. */
  15073. getPivotMatrix(): Matrix;
  15074. /**
  15075. * Instantiate (when possible) or clone that node with its hierarchy
  15076. * @param newParent defines the new parent to use for the instance (or clone)
  15077. * @param options defines options to configure how copy is done
  15078. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  15079. * @returns an instance (or a clone) of the current node with its hiearchy
  15080. */
  15081. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  15082. doNotInstantiate: boolean;
  15083. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  15084. /**
  15085. * Prevents the World matrix to be computed any longer
  15086. * @param newWorldMatrix defines an optional matrix to use as world matrix
  15087. * @returns the TransformNode.
  15088. */
  15089. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  15090. /**
  15091. * Allows back the World matrix computation.
  15092. * @returns the TransformNode.
  15093. */
  15094. unfreezeWorldMatrix(): this;
  15095. /**
  15096. * True if the World matrix has been frozen.
  15097. */
  15098. get isWorldMatrixFrozen(): boolean;
  15099. /**
  15100. * Retuns the mesh absolute position in the World.
  15101. * @returns a Vector3.
  15102. */
  15103. getAbsolutePosition(): Vector3;
  15104. /**
  15105. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  15106. * @param absolutePosition the absolute position to set
  15107. * @returns the TransformNode.
  15108. */
  15109. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  15110. /**
  15111. * Sets the mesh position in its local space.
  15112. * @param vector3 the position to set in localspace
  15113. * @returns the TransformNode.
  15114. */
  15115. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  15116. /**
  15117. * Returns the mesh position in the local space from the current World matrix values.
  15118. * @returns a new Vector3.
  15119. */
  15120. getPositionExpressedInLocalSpace(): Vector3;
  15121. /**
  15122. * Translates the mesh along the passed Vector3 in its local space.
  15123. * @param vector3 the distance to translate in localspace
  15124. * @returns the TransformNode.
  15125. */
  15126. locallyTranslate(vector3: Vector3): TransformNode;
  15127. private static _lookAtVectorCache;
  15128. /**
  15129. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  15130. * @param targetPoint the position (must be in same space as current mesh) to look at
  15131. * @param yawCor optional yaw (y-axis) correction in radians
  15132. * @param pitchCor optional pitch (x-axis) correction in radians
  15133. * @param rollCor optional roll (z-axis) correction in radians
  15134. * @param space the choosen space of the target
  15135. * @returns the TransformNode.
  15136. */
  15137. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  15138. /**
  15139. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  15140. * This Vector3 is expressed in the World space.
  15141. * @param localAxis axis to rotate
  15142. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  15143. */
  15144. getDirection(localAxis: Vector3): Vector3;
  15145. /**
  15146. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  15147. * localAxis is expressed in the mesh local space.
  15148. * result is computed in the Wordl space from the mesh World matrix.
  15149. * @param localAxis axis to rotate
  15150. * @param result the resulting transformnode
  15151. * @returns this TransformNode.
  15152. */
  15153. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  15154. /**
  15155. * Sets this transform node rotation to the given local axis.
  15156. * @param localAxis the axis in local space
  15157. * @param yawCor optional yaw (y-axis) correction in radians
  15158. * @param pitchCor optional pitch (x-axis) correction in radians
  15159. * @param rollCor optional roll (z-axis) correction in radians
  15160. * @returns this TransformNode
  15161. */
  15162. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  15163. /**
  15164. * Sets a new pivot point to the current node
  15165. * @param point defines the new pivot point to use
  15166. * @param space defines if the point is in world or local space (local by default)
  15167. * @returns the current TransformNode
  15168. */
  15169. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  15170. /**
  15171. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  15172. * @returns the pivot point
  15173. */
  15174. getPivotPoint(): Vector3;
  15175. /**
  15176. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  15177. * @param result the vector3 to store the result
  15178. * @returns this TransformNode.
  15179. */
  15180. getPivotPointToRef(result: Vector3): TransformNode;
  15181. /**
  15182. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  15183. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  15184. */
  15185. getAbsolutePivotPoint(): Vector3;
  15186. /**
  15187. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  15188. * @param result vector3 to store the result
  15189. * @returns this TransformNode.
  15190. */
  15191. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  15192. /**
  15193. * Defines the passed node as the parent of the current node.
  15194. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  15195. * @see https://doc.babylonjs.com/how_to/parenting
  15196. * @param node the node ot set as the parent
  15197. * @returns this TransformNode.
  15198. */
  15199. setParent(node: Nullable<Node>): TransformNode;
  15200. private _nonUniformScaling;
  15201. /**
  15202. * True if the scaling property of this object is non uniform eg. (1,2,1)
  15203. */
  15204. get nonUniformScaling(): boolean;
  15205. /** @hidden */
  15206. _updateNonUniformScalingState(value: boolean): boolean;
  15207. /**
  15208. * Attach the current TransformNode to another TransformNode associated with a bone
  15209. * @param bone Bone affecting the TransformNode
  15210. * @param affectedTransformNode TransformNode associated with the bone
  15211. * @returns this object
  15212. */
  15213. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  15214. /**
  15215. * Detach the transform node if its associated with a bone
  15216. * @returns this object
  15217. */
  15218. detachFromBone(): TransformNode;
  15219. private static _rotationAxisCache;
  15220. /**
  15221. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  15222. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  15223. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  15224. * The passed axis is also normalized.
  15225. * @param axis the axis to rotate around
  15226. * @param amount the amount to rotate in radians
  15227. * @param space Space to rotate in (Default: local)
  15228. * @returns the TransformNode.
  15229. */
  15230. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  15231. /**
  15232. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  15233. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  15234. * The passed axis is also normalized. .
  15235. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  15236. * @param point the point to rotate around
  15237. * @param axis the axis to rotate around
  15238. * @param amount the amount to rotate in radians
  15239. * @returns the TransformNode
  15240. */
  15241. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  15242. /**
  15243. * Translates the mesh along the axis vector for the passed distance in the given space.
  15244. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  15245. * @param axis the axis to translate in
  15246. * @param distance the distance to translate
  15247. * @param space Space to rotate in (Default: local)
  15248. * @returns the TransformNode.
  15249. */
  15250. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  15251. /**
  15252. * Adds a rotation step to the mesh current rotation.
  15253. * x, y, z are Euler angles expressed in radians.
  15254. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  15255. * This means this rotation is made in the mesh local space only.
  15256. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  15257. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  15258. * ```javascript
  15259. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  15260. * ```
  15261. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  15262. * 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.
  15263. * @param x Rotation to add
  15264. * @param y Rotation to add
  15265. * @param z Rotation to add
  15266. * @returns the TransformNode.
  15267. */
  15268. addRotation(x: number, y: number, z: number): TransformNode;
  15269. /**
  15270. * @hidden
  15271. */
  15272. protected _getEffectiveParent(): Nullable<Node>;
  15273. /**
  15274. * Computes the world matrix of the node
  15275. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15276. * @returns the world matrix
  15277. */
  15278. computeWorldMatrix(force?: boolean): Matrix;
  15279. /**
  15280. * Resets this nodeTransform's local matrix to Matrix.Identity().
  15281. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  15282. */
  15283. resetLocalMatrix(independentOfChildren?: boolean): void;
  15284. protected _afterComputeWorldMatrix(): void;
  15285. /**
  15286. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  15287. * @param func callback function to add
  15288. *
  15289. * @returns the TransformNode.
  15290. */
  15291. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15292. /**
  15293. * Removes a registered callback function.
  15294. * @param func callback function to remove
  15295. * @returns the TransformNode.
  15296. */
  15297. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15298. /**
  15299. * Gets the position of the current mesh in camera space
  15300. * @param camera defines the camera to use
  15301. * @returns a position
  15302. */
  15303. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  15304. /**
  15305. * Returns the distance from the mesh to the active camera
  15306. * @param camera defines the camera to use
  15307. * @returns the distance
  15308. */
  15309. getDistanceToCamera(camera?: Nullable<Camera>): number;
  15310. /**
  15311. * Clone the current transform node
  15312. * @param name Name of the new clone
  15313. * @param newParent New parent for the clone
  15314. * @param doNotCloneChildren Do not clone children hierarchy
  15315. * @returns the new transform node
  15316. */
  15317. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  15318. /**
  15319. * Serializes the objects information.
  15320. * @param currentSerializationObject defines the object to serialize in
  15321. * @returns the serialized object
  15322. */
  15323. serialize(currentSerializationObject?: any): any;
  15324. /**
  15325. * Returns a new TransformNode object parsed from the source provided.
  15326. * @param parsedTransformNode is the source.
  15327. * @param scene the scne the object belongs to
  15328. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  15329. * @returns a new TransformNode object parsed from the source provided.
  15330. */
  15331. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  15332. /**
  15333. * Get all child-transformNodes of this node
  15334. * @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
  15335. * @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
  15336. * @returns an array of TransformNode
  15337. */
  15338. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  15339. /**
  15340. * Releases resources associated with this transform node.
  15341. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  15342. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  15343. */
  15344. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15345. /**
  15346. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  15347. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  15348. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  15349. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  15350. * @returns the current mesh
  15351. */
  15352. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  15353. private _syncAbsoluteScalingAndRotation;
  15354. }
  15355. }
  15356. declare module "babylonjs/Animations/animationPropertiesOverride" {
  15357. /**
  15358. * Class used to override all child animations of a given target
  15359. */
  15360. export class AnimationPropertiesOverride {
  15361. /**
  15362. * Gets or sets a value indicating if animation blending must be used
  15363. */
  15364. enableBlending: boolean;
  15365. /**
  15366. * Gets or sets the blending speed to use when enableBlending is true
  15367. */
  15368. blendingSpeed: number;
  15369. /**
  15370. * Gets or sets the default loop mode to use
  15371. */
  15372. loopMode: number;
  15373. }
  15374. }
  15375. declare module "babylonjs/Bones/bone" {
  15376. import { Skeleton } from "babylonjs/Bones/skeleton";
  15377. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  15378. import { Nullable } from "babylonjs/types";
  15379. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15380. import { TransformNode } from "babylonjs/Meshes/transformNode";
  15381. import { Node } from "babylonjs/node";
  15382. import { Space } from "babylonjs/Maths/math.axis";
  15383. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  15384. /**
  15385. * Class used to store bone information
  15386. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15387. */
  15388. export class Bone extends Node {
  15389. /**
  15390. * defines the bone name
  15391. */
  15392. name: string;
  15393. private static _tmpVecs;
  15394. private static _tmpQuat;
  15395. private static _tmpMats;
  15396. /**
  15397. * Gets the list of child bones
  15398. */
  15399. children: Bone[];
  15400. /** Gets the animations associated with this bone */
  15401. animations: import("babylonjs/Animations/animation").Animation[];
  15402. /**
  15403. * Gets or sets bone length
  15404. */
  15405. length: number;
  15406. /**
  15407. * @hidden Internal only
  15408. * Set this value to map this bone to a different index in the transform matrices
  15409. * Set this value to -1 to exclude the bone from the transform matrices
  15410. */
  15411. _index: Nullable<number>;
  15412. private _skeleton;
  15413. private _localMatrix;
  15414. private _restPose;
  15415. private _baseMatrix;
  15416. private _absoluteTransform;
  15417. private _invertedAbsoluteTransform;
  15418. private _parent;
  15419. private _scalingDeterminant;
  15420. private _worldTransform;
  15421. private _localScaling;
  15422. private _localRotation;
  15423. private _localPosition;
  15424. private _needToDecompose;
  15425. private _needToCompose;
  15426. /** @hidden */
  15427. _linkedTransformNode: Nullable<TransformNode>;
  15428. /** @hidden */
  15429. _waitingTransformNodeId: Nullable<string>;
  15430. /** @hidden */
  15431. get _matrix(): Matrix;
  15432. /** @hidden */
  15433. set _matrix(value: Matrix);
  15434. /**
  15435. * Create a new bone
  15436. * @param name defines the bone name
  15437. * @param skeleton defines the parent skeleton
  15438. * @param parentBone defines the parent (can be null if the bone is the root)
  15439. * @param localMatrix defines the local matrix
  15440. * @param restPose defines the rest pose matrix
  15441. * @param baseMatrix defines the base matrix
  15442. * @param index defines index of the bone in the hiearchy
  15443. */
  15444. constructor(
  15445. /**
  15446. * defines the bone name
  15447. */
  15448. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  15449. /**
  15450. * Gets the current object class name.
  15451. * @return the class name
  15452. */
  15453. getClassName(): string;
  15454. /**
  15455. * Gets the parent skeleton
  15456. * @returns a skeleton
  15457. */
  15458. getSkeleton(): Skeleton;
  15459. /**
  15460. * Gets parent bone
  15461. * @returns a bone or null if the bone is the root of the bone hierarchy
  15462. */
  15463. getParent(): Nullable<Bone>;
  15464. /**
  15465. * Returns an array containing the root bones
  15466. * @returns an array containing the root bones
  15467. */
  15468. getChildren(): Array<Bone>;
  15469. /**
  15470. * Gets the node index in matrix array generated for rendering
  15471. * @returns the node index
  15472. */
  15473. getIndex(): number;
  15474. /**
  15475. * Sets the parent bone
  15476. * @param parent defines the parent (can be null if the bone is the root)
  15477. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15478. */
  15479. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  15480. /**
  15481. * Gets the local matrix
  15482. * @returns a matrix
  15483. */
  15484. getLocalMatrix(): Matrix;
  15485. /**
  15486. * Gets the base matrix (initial matrix which remains unchanged)
  15487. * @returns a matrix
  15488. */
  15489. getBaseMatrix(): Matrix;
  15490. /**
  15491. * Gets the rest pose matrix
  15492. * @returns a matrix
  15493. */
  15494. getRestPose(): Matrix;
  15495. /**
  15496. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  15497. */
  15498. getWorldMatrix(): Matrix;
  15499. /**
  15500. * Sets the local matrix to rest pose matrix
  15501. */
  15502. returnToRest(): void;
  15503. /**
  15504. * Gets the inverse of the absolute transform matrix.
  15505. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  15506. * @returns a matrix
  15507. */
  15508. getInvertedAbsoluteTransform(): Matrix;
  15509. /**
  15510. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  15511. * @returns a matrix
  15512. */
  15513. getAbsoluteTransform(): Matrix;
  15514. /**
  15515. * Links with the given transform node.
  15516. * The local matrix of this bone is copied from the transform node every frame.
  15517. * @param transformNode defines the transform node to link to
  15518. */
  15519. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  15520. /**
  15521. * Gets the node used to drive the bone's transformation
  15522. * @returns a transform node or null
  15523. */
  15524. getTransformNode(): Nullable<TransformNode>;
  15525. /** Gets or sets current position (in local space) */
  15526. get position(): Vector3;
  15527. set position(newPosition: Vector3);
  15528. /** Gets or sets current rotation (in local space) */
  15529. get rotation(): Vector3;
  15530. set rotation(newRotation: Vector3);
  15531. /** Gets or sets current rotation quaternion (in local space) */
  15532. get rotationQuaternion(): Quaternion;
  15533. set rotationQuaternion(newRotation: Quaternion);
  15534. /** Gets or sets current scaling (in local space) */
  15535. get scaling(): Vector3;
  15536. set scaling(newScaling: Vector3);
  15537. /**
  15538. * Gets the animation properties override
  15539. */
  15540. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15541. private _decompose;
  15542. private _compose;
  15543. /**
  15544. * Update the base and local matrices
  15545. * @param matrix defines the new base or local matrix
  15546. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15547. * @param updateLocalMatrix defines if the local matrix should be updated
  15548. */
  15549. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  15550. /** @hidden */
  15551. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  15552. /**
  15553. * Flag the bone as dirty (Forcing it to update everything)
  15554. */
  15555. markAsDirty(): void;
  15556. /** @hidden */
  15557. _markAsDirtyAndCompose(): void;
  15558. private _markAsDirtyAndDecompose;
  15559. /**
  15560. * Translate the bone in local or world space
  15561. * @param vec The amount to translate the bone
  15562. * @param space The space that the translation is in
  15563. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15564. */
  15565. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15566. /**
  15567. * Set the postion of the bone in local or world space
  15568. * @param position The position to set the bone
  15569. * @param space The space that the position is in
  15570. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15571. */
  15572. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15573. /**
  15574. * Set the absolute position of the bone (world space)
  15575. * @param position The position to set the bone
  15576. * @param mesh The mesh that this bone is attached to
  15577. */
  15578. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  15579. /**
  15580. * Scale the bone on the x, y and z axes (in local space)
  15581. * @param x The amount to scale the bone on the x axis
  15582. * @param y The amount to scale the bone on the y axis
  15583. * @param z The amount to scale the bone on the z axis
  15584. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  15585. */
  15586. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  15587. /**
  15588. * Set the bone scaling in local space
  15589. * @param scale defines the scaling vector
  15590. */
  15591. setScale(scale: Vector3): void;
  15592. /**
  15593. * Gets the current scaling in local space
  15594. * @returns the current scaling vector
  15595. */
  15596. getScale(): Vector3;
  15597. /**
  15598. * Gets the current scaling in local space and stores it in a target vector
  15599. * @param result defines the target vector
  15600. */
  15601. getScaleToRef(result: Vector3): void;
  15602. /**
  15603. * Set the yaw, pitch, and roll of the bone in local or world space
  15604. * @param yaw The rotation of the bone on the y axis
  15605. * @param pitch The rotation of the bone on the x axis
  15606. * @param roll The rotation of the bone on the z axis
  15607. * @param space The space that the axes of rotation are in
  15608. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15609. */
  15610. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  15611. /**
  15612. * Add a rotation to the bone on an axis in local or world space
  15613. * @param axis The axis to rotate the bone on
  15614. * @param amount The amount to rotate the bone
  15615. * @param space The space that the axis is in
  15616. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15617. */
  15618. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  15619. /**
  15620. * Set the rotation of the bone to a particular axis angle in local or world space
  15621. * @param axis The axis to rotate the bone on
  15622. * @param angle The angle that the bone should be rotated to
  15623. * @param space The space that the axis is in
  15624. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15625. */
  15626. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  15627. /**
  15628. * Set the euler rotation of the bone in local of world space
  15629. * @param rotation The euler rotation that the bone should be set to
  15630. * @param space The space that the rotation is in
  15631. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15632. */
  15633. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15634. /**
  15635. * Set the quaternion rotation of the bone in local of world space
  15636. * @param quat The quaternion rotation that the bone should be set to
  15637. * @param space The space that the rotation is in
  15638. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15639. */
  15640. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  15641. /**
  15642. * Set the rotation matrix of the bone in local of world space
  15643. * @param rotMat The rotation matrix 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. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  15648. private _rotateWithMatrix;
  15649. private _getNegativeRotationToRef;
  15650. /**
  15651. * Get the position of the bone in local or world space
  15652. * @param space The space that the returned position is in
  15653. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15654. * @returns The position of the bone
  15655. */
  15656. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15657. /**
  15658. * Copy the position of the bone to a vector3 in local or world space
  15659. * @param space The space that the returned position is in
  15660. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15661. * @param result The vector3 to copy the position to
  15662. */
  15663. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  15664. /**
  15665. * Get the absolute position of the bone (world space)
  15666. * @param mesh The mesh that this bone is attached to
  15667. * @returns The absolute position of the bone
  15668. */
  15669. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  15670. /**
  15671. * Copy the absolute position of the bone (world space) to the result param
  15672. * @param mesh The mesh that this bone is attached to
  15673. * @param result The vector3 to copy the absolute position to
  15674. */
  15675. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  15676. /**
  15677. * Compute the absolute transforms of this bone and its children
  15678. */
  15679. computeAbsoluteTransforms(): void;
  15680. /**
  15681. * Get the world direction from an axis that is in the local space of the bone
  15682. * @param localAxis The local direction that is used to compute the world direction
  15683. * @param mesh The mesh that this bone is attached to
  15684. * @returns The world direction
  15685. */
  15686. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15687. /**
  15688. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  15689. * @param localAxis The local direction that is used to compute the world direction
  15690. * @param mesh The mesh that this bone is attached to
  15691. * @param result The vector3 that the world direction will be copied to
  15692. */
  15693. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15694. /**
  15695. * Get the euler rotation of the bone in local or world space
  15696. * @param space The space that the rotation should be in
  15697. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15698. * @returns The euler rotation
  15699. */
  15700. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15701. /**
  15702. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  15703. * @param space The space that the rotation should be in
  15704. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15705. * @param result The vector3 that the rotation should be copied to
  15706. */
  15707. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15708. /**
  15709. * Get the quaternion rotation of the bone in either 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 quaternion rotation
  15713. */
  15714. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  15715. /**
  15716. * Copy the quaternion rotation of the bone to a quaternion. 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 quaternion that the rotation should be copied to
  15720. */
  15721. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  15722. /**
  15723. * Get the rotation matrix of the bone in 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 rotation matrix
  15727. */
  15728. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  15729. /**
  15730. * Copy the rotation matrix of the bone to a matrix. 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. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  15736. /**
  15737. * Get the world position of a point that is in the local space of the bone
  15738. * @param position The local position
  15739. * @param mesh The mesh that this bone is attached to
  15740. * @returns The world position
  15741. */
  15742. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15743. /**
  15744. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  15745. * @param position The local position
  15746. * @param mesh The mesh that this bone is attached to
  15747. * @param result The vector3 that the world position should be copied to
  15748. */
  15749. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15750. /**
  15751. * Get the local position of a point that is in world space
  15752. * @param position The world position
  15753. * @param mesh The mesh that this bone is attached to
  15754. * @returns The local position
  15755. */
  15756. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15757. /**
  15758. * Get the local position of a point that is in world space and copy it to the result param
  15759. * @param position The world position
  15760. * @param mesh The mesh that this bone is attached to
  15761. * @param result The vector3 that the local position should be copied to
  15762. */
  15763. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15764. }
  15765. }
  15766. declare module "babylonjs/Animations/runtimeAnimation" {
  15767. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  15768. import { Animatable } from "babylonjs/Animations/animatable";
  15769. import { Scene } from "babylonjs/scene";
  15770. /**
  15771. * Defines a runtime animation
  15772. */
  15773. export class RuntimeAnimation {
  15774. private _events;
  15775. /**
  15776. * The current frame of the runtime animation
  15777. */
  15778. private _currentFrame;
  15779. /**
  15780. * The animation used by the runtime animation
  15781. */
  15782. private _animation;
  15783. /**
  15784. * The target of the runtime animation
  15785. */
  15786. private _target;
  15787. /**
  15788. * The initiating animatable
  15789. */
  15790. private _host;
  15791. /**
  15792. * The original value of the runtime animation
  15793. */
  15794. private _originalValue;
  15795. /**
  15796. * The original blend value of the runtime animation
  15797. */
  15798. private _originalBlendValue;
  15799. /**
  15800. * The offsets cache of the runtime animation
  15801. */
  15802. private _offsetsCache;
  15803. /**
  15804. * The high limits cache of the runtime animation
  15805. */
  15806. private _highLimitsCache;
  15807. /**
  15808. * Specifies if the runtime animation has been stopped
  15809. */
  15810. private _stopped;
  15811. /**
  15812. * The blending factor of the runtime animation
  15813. */
  15814. private _blendingFactor;
  15815. /**
  15816. * The BabylonJS scene
  15817. */
  15818. private _scene;
  15819. /**
  15820. * The current value of the runtime animation
  15821. */
  15822. private _currentValue;
  15823. /** @hidden */
  15824. _animationState: _IAnimationState;
  15825. /**
  15826. * The active target of the runtime animation
  15827. */
  15828. private _activeTargets;
  15829. private _currentActiveTarget;
  15830. private _directTarget;
  15831. /**
  15832. * The target path of the runtime animation
  15833. */
  15834. private _targetPath;
  15835. /**
  15836. * The weight of the runtime animation
  15837. */
  15838. private _weight;
  15839. /**
  15840. * The ratio offset of the runtime animation
  15841. */
  15842. private _ratioOffset;
  15843. /**
  15844. * The previous delay of the runtime animation
  15845. */
  15846. private _previousDelay;
  15847. /**
  15848. * The previous ratio of the runtime animation
  15849. */
  15850. private _previousRatio;
  15851. private _enableBlending;
  15852. private _keys;
  15853. private _minFrame;
  15854. private _maxFrame;
  15855. private _minValue;
  15856. private _maxValue;
  15857. private _targetIsArray;
  15858. /**
  15859. * Gets the current frame of the runtime animation
  15860. */
  15861. get currentFrame(): number;
  15862. /**
  15863. * Gets the weight of the runtime animation
  15864. */
  15865. get weight(): number;
  15866. /**
  15867. * Gets the current value of the runtime animation
  15868. */
  15869. get currentValue(): any;
  15870. /**
  15871. * Gets the target path of the runtime animation
  15872. */
  15873. get targetPath(): string;
  15874. /**
  15875. * Gets the actual target of the runtime animation
  15876. */
  15877. get target(): any;
  15878. /**
  15879. * Gets the additive state of the runtime animation
  15880. */
  15881. get isAdditive(): boolean;
  15882. /** @hidden */
  15883. _onLoop: () => void;
  15884. /**
  15885. * Create a new RuntimeAnimation object
  15886. * @param target defines the target of the animation
  15887. * @param animation defines the source animation object
  15888. * @param scene defines the hosting scene
  15889. * @param host defines the initiating Animatable
  15890. */
  15891. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  15892. private _preparePath;
  15893. /**
  15894. * Gets the animation from the runtime animation
  15895. */
  15896. get animation(): Animation;
  15897. /**
  15898. * Resets the runtime animation to the beginning
  15899. * @param restoreOriginal defines whether to restore the target property to the original value
  15900. */
  15901. reset(restoreOriginal?: boolean): void;
  15902. /**
  15903. * Specifies if the runtime animation is stopped
  15904. * @returns Boolean specifying if the runtime animation is stopped
  15905. */
  15906. isStopped(): boolean;
  15907. /**
  15908. * Disposes of the runtime animation
  15909. */
  15910. dispose(): void;
  15911. /**
  15912. * Apply the interpolated value to the target
  15913. * @param currentValue defines the value computed by the animation
  15914. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  15915. */
  15916. setValue(currentValue: any, weight: number): void;
  15917. private _getOriginalValues;
  15918. private _setValue;
  15919. /**
  15920. * Gets the loop pmode of the runtime animation
  15921. * @returns Loop Mode
  15922. */
  15923. private _getCorrectLoopMode;
  15924. /**
  15925. * Move the current animation to a given frame
  15926. * @param frame defines the frame to move to
  15927. */
  15928. goToFrame(frame: number): void;
  15929. /**
  15930. * @hidden Internal use only
  15931. */
  15932. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  15933. /**
  15934. * Execute the current animation
  15935. * @param delay defines the delay to add to the current frame
  15936. * @param from defines the lower bound of the animation range
  15937. * @param to defines the upper bound of the animation range
  15938. * @param loop defines if the current animation must loop
  15939. * @param speedRatio defines the current speed ratio
  15940. * @param weight defines the weight of the animation (default is -1 so no weight)
  15941. * @param onLoop optional callback called when animation loops
  15942. * @returns a boolean indicating if the animation is running
  15943. */
  15944. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  15945. }
  15946. }
  15947. declare module "babylonjs/Animations/animatable" {
  15948. import { Animation } from "babylonjs/Animations/animation";
  15949. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  15950. import { Nullable } from "babylonjs/types";
  15951. import { Observable } from "babylonjs/Misc/observable";
  15952. import { Scene } from "babylonjs/scene";
  15953. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  15954. import { Node } from "babylonjs/node";
  15955. /**
  15956. * Class used to store an actual running animation
  15957. */
  15958. export class Animatable {
  15959. /** defines the target object */
  15960. target: any;
  15961. /** defines the starting frame number (default is 0) */
  15962. fromFrame: number;
  15963. /** defines the ending frame number (default is 100) */
  15964. toFrame: number;
  15965. /** defines if the animation must loop (default is false) */
  15966. loopAnimation: boolean;
  15967. /** defines a callback to call when animation ends if it is not looping */
  15968. onAnimationEnd?: (() => void) | null | undefined;
  15969. /** defines a callback to call when animation loops */
  15970. onAnimationLoop?: (() => void) | null | undefined;
  15971. /** defines whether the animation should be evaluated additively */
  15972. isAdditive: boolean;
  15973. private _localDelayOffset;
  15974. private _pausedDelay;
  15975. private _runtimeAnimations;
  15976. private _paused;
  15977. private _scene;
  15978. private _speedRatio;
  15979. private _weight;
  15980. private _syncRoot;
  15981. /**
  15982. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  15983. * This will only apply for non looping animation (default is true)
  15984. */
  15985. disposeOnEnd: boolean;
  15986. /**
  15987. * Gets a boolean indicating if the animation has started
  15988. */
  15989. animationStarted: boolean;
  15990. /**
  15991. * Observer raised when the animation ends
  15992. */
  15993. onAnimationEndObservable: Observable<Animatable>;
  15994. /**
  15995. * Observer raised when the animation loops
  15996. */
  15997. onAnimationLoopObservable: Observable<Animatable>;
  15998. /**
  15999. * Gets the root Animatable used to synchronize and normalize animations
  16000. */
  16001. get syncRoot(): Nullable<Animatable>;
  16002. /**
  16003. * Gets the current frame of the first RuntimeAnimation
  16004. * Used to synchronize Animatables
  16005. */
  16006. get masterFrame(): number;
  16007. /**
  16008. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  16009. */
  16010. get weight(): number;
  16011. set weight(value: number);
  16012. /**
  16013. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  16014. */
  16015. get speedRatio(): number;
  16016. set speedRatio(value: number);
  16017. /**
  16018. * Creates a new Animatable
  16019. * @param scene defines the hosting scene
  16020. * @param target defines the target object
  16021. * @param fromFrame defines the starting frame number (default is 0)
  16022. * @param toFrame defines the ending frame number (default is 100)
  16023. * @param loopAnimation defines if the animation must loop (default is false)
  16024. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  16025. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  16026. * @param animations defines a group of animation to add to the new Animatable
  16027. * @param onAnimationLoop defines a callback to call when animation loops
  16028. * @param isAdditive defines whether the animation should be evaluated additively
  16029. */
  16030. constructor(scene: Scene,
  16031. /** defines the target object */
  16032. target: any,
  16033. /** defines the starting frame number (default is 0) */
  16034. fromFrame?: number,
  16035. /** defines the ending frame number (default is 100) */
  16036. toFrame?: number,
  16037. /** defines if the animation must loop (default is false) */
  16038. loopAnimation?: boolean, speedRatio?: number,
  16039. /** defines a callback to call when animation ends if it is not looping */
  16040. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  16041. /** defines a callback to call when animation loops */
  16042. onAnimationLoop?: (() => void) | null | undefined,
  16043. /** defines whether the animation should be evaluated additively */
  16044. isAdditive?: boolean);
  16045. /**
  16046. * Synchronize and normalize current Animatable with a source Animatable
  16047. * This is useful when using animation weights and when animations are not of the same length
  16048. * @param root defines the root Animatable to synchronize with
  16049. * @returns the current Animatable
  16050. */
  16051. syncWith(root: Animatable): Animatable;
  16052. /**
  16053. * Gets the list of runtime animations
  16054. * @returns an array of RuntimeAnimation
  16055. */
  16056. getAnimations(): RuntimeAnimation[];
  16057. /**
  16058. * Adds more animations to the current animatable
  16059. * @param target defines the target of the animations
  16060. * @param animations defines the new animations to add
  16061. */
  16062. appendAnimations(target: any, animations: Animation[]): void;
  16063. /**
  16064. * Gets the source animation for a specific property
  16065. * @param property defines the propertyu to look for
  16066. * @returns null or the source animation for the given property
  16067. */
  16068. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  16069. /**
  16070. * Gets the runtime animation for a specific property
  16071. * @param property defines the propertyu to look for
  16072. * @returns null or the runtime animation for the given property
  16073. */
  16074. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  16075. /**
  16076. * Resets the animatable to its original state
  16077. */
  16078. reset(): void;
  16079. /**
  16080. * Allows the animatable to blend with current running animations
  16081. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  16082. * @param blendingSpeed defines the blending speed to use
  16083. */
  16084. enableBlending(blendingSpeed: number): void;
  16085. /**
  16086. * Disable animation blending
  16087. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  16088. */
  16089. disableBlending(): void;
  16090. /**
  16091. * Jump directly to a given frame
  16092. * @param frame defines the frame to jump to
  16093. */
  16094. goToFrame(frame: number): void;
  16095. /**
  16096. * Pause the animation
  16097. */
  16098. pause(): void;
  16099. /**
  16100. * Restart the animation
  16101. */
  16102. restart(): void;
  16103. private _raiseOnAnimationEnd;
  16104. /**
  16105. * Stop and delete the current animation
  16106. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  16107. * @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)
  16108. */
  16109. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  16110. /**
  16111. * Wait asynchronously for the animation to end
  16112. * @returns a promise which will be fullfilled when the animation ends
  16113. */
  16114. waitAsync(): Promise<Animatable>;
  16115. /** @hidden */
  16116. _animate(delay: number): boolean;
  16117. }
  16118. module "babylonjs/scene" {
  16119. interface Scene {
  16120. /** @hidden */
  16121. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  16122. /** @hidden */
  16123. _processLateAnimationBindingsForMatrices(holder: {
  16124. totalWeight: number;
  16125. totalAdditiveWeight: number;
  16126. animations: RuntimeAnimation[];
  16127. additiveAnimations: RuntimeAnimation[];
  16128. originalValue: Matrix;
  16129. }): any;
  16130. /** @hidden */
  16131. _processLateAnimationBindingsForQuaternions(holder: {
  16132. totalWeight: number;
  16133. totalAdditiveWeight: number;
  16134. animations: RuntimeAnimation[];
  16135. additiveAnimations: RuntimeAnimation[];
  16136. originalValue: Quaternion;
  16137. }, refQuaternion: Quaternion): Quaternion;
  16138. /** @hidden */
  16139. _processLateAnimationBindings(): void;
  16140. /**
  16141. * Will start the animation sequence of a given target
  16142. * @param target defines the target
  16143. * @param from defines from which frame should animation start
  16144. * @param to defines until which frame should animation run.
  16145. * @param weight defines the weight to apply to the animation (1.0 by default)
  16146. * @param loop defines if the animation loops
  16147. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16148. * @param onAnimationEnd defines the function to be executed when the animation ends
  16149. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16150. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  16151. * @param onAnimationLoop defines the callback to call when an animation loops
  16152. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16153. * @returns the animatable object created for this animation
  16154. */
  16155. 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;
  16156. /**
  16157. * Will start the animation sequence of a given target
  16158. * @param target defines the target
  16159. * @param from defines from which frame should animation start
  16160. * @param to defines until which frame should animation run.
  16161. * @param loop defines if the animation loops
  16162. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16163. * @param onAnimationEnd defines the function to be executed when the animation ends
  16164. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16165. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  16166. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  16167. * @param onAnimationLoop defines the callback to call when an animation loops
  16168. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16169. * @returns the animatable object created for this animation
  16170. */
  16171. 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;
  16172. /**
  16173. * Will start the animation sequence of a given target and its hierarchy
  16174. * @param target defines the target
  16175. * @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.
  16176. * @param from defines from which frame should animation start
  16177. * @param to defines until which frame should animation run.
  16178. * @param loop defines if the animation loops
  16179. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16180. * @param onAnimationEnd defines the function to be executed when the animation ends
  16181. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16182. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  16183. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  16184. * @param onAnimationLoop defines the callback to call when an animation loops
  16185. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16186. * @returns the list of created animatables
  16187. */
  16188. 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[];
  16189. /**
  16190. * Begin a new animation on a given node
  16191. * @param target defines the target where the animation will take place
  16192. * @param animations defines the list of animations to start
  16193. * @param from defines the initial value
  16194. * @param to defines the final value
  16195. * @param loop defines if you want animation to loop (off by default)
  16196. * @param speedRatio defines the speed ratio to apply to all animations
  16197. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  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. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  16203. /**
  16204. * Begin a new animation on a given node and its hierarchy
  16205. * @param target defines the root node where the animation will take place
  16206. * @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.
  16207. * @param animations defines the list of animations to start
  16208. * @param from defines the initial value
  16209. * @param to defines the final value
  16210. * @param loop defines if you want animation to loop (off by default)
  16211. * @param speedRatio defines the speed ratio to apply to all animations
  16212. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  16213. * @param onAnimationLoop defines the callback to call when an animation loops
  16214. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16215. * @returns the list of animatables created for all nodes
  16216. */
  16217. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  16218. /**
  16219. * Gets the animatable associated with a specific target
  16220. * @param target defines the target of the animatable
  16221. * @returns the required animatable if found
  16222. */
  16223. getAnimatableByTarget(target: any): Nullable<Animatable>;
  16224. /**
  16225. * Gets all animatables associated with a given target
  16226. * @param target defines the target to look animatables for
  16227. * @returns an array of Animatables
  16228. */
  16229. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  16230. /**
  16231. * Stops and removes all animations that have been applied to the scene
  16232. */
  16233. stopAllAnimations(): void;
  16234. /**
  16235. * Gets the current delta time used by animation engine
  16236. */
  16237. deltaTime: number;
  16238. }
  16239. }
  16240. module "babylonjs/Bones/bone" {
  16241. interface Bone {
  16242. /**
  16243. * Copy an animation range from another bone
  16244. * @param source defines the source bone
  16245. * @param rangeName defines the range name to copy
  16246. * @param frameOffset defines the frame offset
  16247. * @param rescaleAsRequired defines if rescaling must be applied if required
  16248. * @param skelDimensionsRatio defines the scaling ratio
  16249. * @returns true if operation was successful
  16250. */
  16251. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  16252. }
  16253. }
  16254. }
  16255. declare module "babylonjs/Bones/skeleton" {
  16256. import { Bone } from "babylonjs/Bones/bone";
  16257. import { Observable } from "babylonjs/Misc/observable";
  16258. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16259. import { Scene } from "babylonjs/scene";
  16260. import { Nullable } from "babylonjs/types";
  16261. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16262. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  16263. import { Animatable } from "babylonjs/Animations/animatable";
  16264. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  16265. import { Animation } from "babylonjs/Animations/animation";
  16266. import { AnimationRange } from "babylonjs/Animations/animationRange";
  16267. import { IInspectable } from "babylonjs/Misc/iInspectable";
  16268. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  16269. /**
  16270. * Class used to handle skinning animations
  16271. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  16272. */
  16273. export class Skeleton implements IAnimatable {
  16274. /** defines the skeleton name */
  16275. name: string;
  16276. /** defines the skeleton Id */
  16277. id: string;
  16278. /**
  16279. * Defines the list of child bones
  16280. */
  16281. bones: Bone[];
  16282. /**
  16283. * Defines an estimate of the dimension of the skeleton at rest
  16284. */
  16285. dimensionsAtRest: Vector3;
  16286. /**
  16287. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  16288. */
  16289. needInitialSkinMatrix: boolean;
  16290. /**
  16291. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  16292. */
  16293. overrideMesh: Nullable<AbstractMesh>;
  16294. /**
  16295. * Gets the list of animations attached to this skeleton
  16296. */
  16297. animations: Array<Animation>;
  16298. private _scene;
  16299. private _isDirty;
  16300. private _transformMatrices;
  16301. private _transformMatrixTexture;
  16302. private _meshesWithPoseMatrix;
  16303. private _animatables;
  16304. private _identity;
  16305. private _synchronizedWithMesh;
  16306. private _ranges;
  16307. private _lastAbsoluteTransformsUpdateId;
  16308. private _canUseTextureForBones;
  16309. private _uniqueId;
  16310. /** @hidden */
  16311. _numBonesWithLinkedTransformNode: number;
  16312. /** @hidden */
  16313. _hasWaitingData: Nullable<boolean>;
  16314. /**
  16315. * Specifies if the skeleton should be serialized
  16316. */
  16317. doNotSerialize: boolean;
  16318. private _useTextureToStoreBoneMatrices;
  16319. /**
  16320. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  16321. * Please note that this option is not available if the hardware does not support it
  16322. */
  16323. get useTextureToStoreBoneMatrices(): boolean;
  16324. set useTextureToStoreBoneMatrices(value: boolean);
  16325. private _animationPropertiesOverride;
  16326. /**
  16327. * Gets or sets the animation properties override
  16328. */
  16329. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  16330. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  16331. /**
  16332. * List of inspectable custom properties (used by the Inspector)
  16333. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16334. */
  16335. inspectableCustomProperties: IInspectable[];
  16336. /**
  16337. * An observable triggered before computing the skeleton's matrices
  16338. */
  16339. onBeforeComputeObservable: Observable<Skeleton>;
  16340. /**
  16341. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  16342. */
  16343. get isUsingTextureForMatrices(): boolean;
  16344. /**
  16345. * Gets the unique ID of this skeleton
  16346. */
  16347. get uniqueId(): number;
  16348. /**
  16349. * Creates a new skeleton
  16350. * @param name defines the skeleton name
  16351. * @param id defines the skeleton Id
  16352. * @param scene defines the hosting scene
  16353. */
  16354. constructor(
  16355. /** defines the skeleton name */
  16356. name: string,
  16357. /** defines the skeleton Id */
  16358. id: string, scene: Scene);
  16359. /**
  16360. * Gets the current object class name.
  16361. * @return the class name
  16362. */
  16363. getClassName(): string;
  16364. /**
  16365. * Returns an array containing the root bones
  16366. * @returns an array containing the root bones
  16367. */
  16368. getChildren(): Array<Bone>;
  16369. /**
  16370. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  16371. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16372. * @returns a Float32Array containing matrices data
  16373. */
  16374. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  16375. /**
  16376. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  16377. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16378. * @returns a raw texture containing the data
  16379. */
  16380. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  16381. /**
  16382. * Gets the current hosting scene
  16383. * @returns a scene object
  16384. */
  16385. getScene(): Scene;
  16386. /**
  16387. * Gets a string representing the current skeleton data
  16388. * @param fullDetails defines a boolean indicating if we want a verbose version
  16389. * @returns a string representing the current skeleton data
  16390. */
  16391. toString(fullDetails?: boolean): string;
  16392. /**
  16393. * Get bone's index searching by name
  16394. * @param name defines bone's name to search for
  16395. * @return the indice of the bone. Returns -1 if not found
  16396. */
  16397. getBoneIndexByName(name: string): number;
  16398. /**
  16399. * Creater a new animation range
  16400. * @param name defines the name of the range
  16401. * @param from defines the start key
  16402. * @param to defines the end key
  16403. */
  16404. createAnimationRange(name: string, from: number, to: number): void;
  16405. /**
  16406. * Delete a specific animation range
  16407. * @param name defines the name of the range
  16408. * @param deleteFrames defines if frames must be removed as well
  16409. */
  16410. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  16411. /**
  16412. * Gets a specific animation range
  16413. * @param name defines the name of the range to look for
  16414. * @returns the requested animation range or null if not found
  16415. */
  16416. getAnimationRange(name: string): Nullable<AnimationRange>;
  16417. /**
  16418. * Gets the list of all animation ranges defined on this skeleton
  16419. * @returns an array
  16420. */
  16421. getAnimationRanges(): Nullable<AnimationRange>[];
  16422. /**
  16423. * Copy animation range from a source skeleton.
  16424. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  16425. * @param source defines the source skeleton
  16426. * @param name defines the name of the range to copy
  16427. * @param rescaleAsRequired defines if rescaling must be applied if required
  16428. * @returns true if operation was successful
  16429. */
  16430. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  16431. /**
  16432. * Forces the skeleton to go to rest pose
  16433. */
  16434. returnToRest(): void;
  16435. private _getHighestAnimationFrame;
  16436. /**
  16437. * Begin a specific animation range
  16438. * @param name defines the name of the range to start
  16439. * @param loop defines if looping must be turned on (false by default)
  16440. * @param speedRatio defines the speed ratio to apply (1 by default)
  16441. * @param onAnimationEnd defines a callback which will be called when animation will end
  16442. * @returns a new animatable
  16443. */
  16444. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  16445. /**
  16446. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  16447. * @param skeleton defines the Skeleton containing the animation range to convert
  16448. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  16449. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  16450. * @returns the original skeleton
  16451. */
  16452. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  16453. /** @hidden */
  16454. _markAsDirty(): void;
  16455. /** @hidden */
  16456. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16457. /** @hidden */
  16458. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16459. private _computeTransformMatrices;
  16460. /**
  16461. * Build all resources required to render a skeleton
  16462. */
  16463. prepare(): void;
  16464. /**
  16465. * Gets the list of animatables currently running for this skeleton
  16466. * @returns an array of animatables
  16467. */
  16468. getAnimatables(): IAnimatable[];
  16469. /**
  16470. * Clone the current skeleton
  16471. * @param name defines the name of the new skeleton
  16472. * @param id defines the id of the new skeleton
  16473. * @returns the new skeleton
  16474. */
  16475. clone(name: string, id?: string): Skeleton;
  16476. /**
  16477. * Enable animation blending for this skeleton
  16478. * @param blendingSpeed defines the blending speed to apply
  16479. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  16480. */
  16481. enableBlending(blendingSpeed?: number): void;
  16482. /**
  16483. * Releases all resources associated with the current skeleton
  16484. */
  16485. dispose(): void;
  16486. /**
  16487. * Serialize the skeleton in a JSON object
  16488. * @returns a JSON object
  16489. */
  16490. serialize(): any;
  16491. /**
  16492. * Creates a new skeleton from serialized data
  16493. * @param parsedSkeleton defines the serialized data
  16494. * @param scene defines the hosting scene
  16495. * @returns a new skeleton
  16496. */
  16497. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  16498. /**
  16499. * Compute all node absolute transforms
  16500. * @param forceUpdate defines if computation must be done even if cache is up to date
  16501. */
  16502. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  16503. /**
  16504. * Gets the root pose matrix
  16505. * @returns a matrix
  16506. */
  16507. getPoseMatrix(): Nullable<Matrix>;
  16508. /**
  16509. * Sorts bones per internal index
  16510. */
  16511. sortBones(): void;
  16512. private _sortBones;
  16513. }
  16514. }
  16515. declare module "babylonjs/Meshes/instancedMesh" {
  16516. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  16517. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16518. import { Camera } from "babylonjs/Cameras/camera";
  16519. import { Node } from "babylonjs/node";
  16520. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16521. import { Mesh } from "babylonjs/Meshes/mesh";
  16522. import { Material } from "babylonjs/Materials/material";
  16523. import { Skeleton } from "babylonjs/Bones/skeleton";
  16524. import { Light } from "babylonjs/Lights/light";
  16525. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  16526. /**
  16527. * Creates an instance based on a source mesh.
  16528. */
  16529. export class InstancedMesh extends AbstractMesh {
  16530. private _sourceMesh;
  16531. private _currentLOD;
  16532. /** @hidden */
  16533. _indexInSourceMeshInstanceArray: number;
  16534. constructor(name: string, source: Mesh);
  16535. /**
  16536. * Returns the string "InstancedMesh".
  16537. */
  16538. getClassName(): string;
  16539. /** Gets the list of lights affecting that mesh */
  16540. get lightSources(): Light[];
  16541. _resyncLightSources(): void;
  16542. _resyncLightSource(light: Light): void;
  16543. _removeLightSource(light: Light, dispose: boolean): void;
  16544. /**
  16545. * If the source mesh receives shadows
  16546. */
  16547. get receiveShadows(): boolean;
  16548. /**
  16549. * The material of the source mesh
  16550. */
  16551. get material(): Nullable<Material>;
  16552. /**
  16553. * Visibility of the source mesh
  16554. */
  16555. get visibility(): number;
  16556. /**
  16557. * Skeleton of the source mesh
  16558. */
  16559. get skeleton(): Nullable<Skeleton>;
  16560. /**
  16561. * Rendering ground id of the source mesh
  16562. */
  16563. get renderingGroupId(): number;
  16564. set renderingGroupId(value: number);
  16565. /**
  16566. * Returns the total number of vertices (integer).
  16567. */
  16568. getTotalVertices(): number;
  16569. /**
  16570. * Returns a positive integer : the total number of indices in this mesh geometry.
  16571. * @returns the numner of indices or zero if the mesh has no geometry.
  16572. */
  16573. getTotalIndices(): number;
  16574. /**
  16575. * The source mesh of the instance
  16576. */
  16577. get sourceMesh(): Mesh;
  16578. /**
  16579. * Creates a new InstancedMesh object from the mesh model.
  16580. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  16581. * @param name defines the name of the new instance
  16582. * @returns a new InstancedMesh
  16583. */
  16584. createInstance(name: string): InstancedMesh;
  16585. /**
  16586. * Is this node ready to be used/rendered
  16587. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16588. * @return {boolean} is it ready
  16589. */
  16590. isReady(completeCheck?: boolean): boolean;
  16591. /**
  16592. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16593. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16594. * @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.
  16595. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16596. */
  16597. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16598. /**
  16599. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16600. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16601. * The `data` are either a numeric array either a Float32Array.
  16602. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16603. * 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).
  16604. * Note that a new underlying VertexBuffer object is created each call.
  16605. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16606. *
  16607. * Possible `kind` values :
  16608. * - VertexBuffer.PositionKind
  16609. * - VertexBuffer.UVKind
  16610. * - VertexBuffer.UV2Kind
  16611. * - VertexBuffer.UV3Kind
  16612. * - VertexBuffer.UV4Kind
  16613. * - VertexBuffer.UV5Kind
  16614. * - VertexBuffer.UV6Kind
  16615. * - VertexBuffer.ColorKind
  16616. * - VertexBuffer.MatricesIndicesKind
  16617. * - VertexBuffer.MatricesIndicesExtraKind
  16618. * - VertexBuffer.MatricesWeightsKind
  16619. * - VertexBuffer.MatricesWeightsExtraKind
  16620. *
  16621. * Returns the Mesh.
  16622. */
  16623. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  16624. /**
  16625. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16626. * If the mesh has no geometry, it is simply returned as it is.
  16627. * The `data` are either a numeric array either a Float32Array.
  16628. * No new underlying VertexBuffer object is created.
  16629. * 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.
  16630. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16631. *
  16632. * Possible `kind` values :
  16633. * - VertexBuffer.PositionKind
  16634. * - VertexBuffer.UVKind
  16635. * - VertexBuffer.UV2Kind
  16636. * - VertexBuffer.UV3Kind
  16637. * - VertexBuffer.UV4Kind
  16638. * - VertexBuffer.UV5Kind
  16639. * - VertexBuffer.UV6Kind
  16640. * - VertexBuffer.ColorKind
  16641. * - VertexBuffer.MatricesIndicesKind
  16642. * - VertexBuffer.MatricesIndicesExtraKind
  16643. * - VertexBuffer.MatricesWeightsKind
  16644. * - VertexBuffer.MatricesWeightsExtraKind
  16645. *
  16646. * Returns the Mesh.
  16647. */
  16648. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16649. /**
  16650. * Sets the mesh indices.
  16651. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16652. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16653. * This method creates a new index buffer each call.
  16654. * Returns the Mesh.
  16655. */
  16656. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16657. /**
  16658. * Boolean : True if the mesh owns the requested kind of data.
  16659. */
  16660. isVerticesDataPresent(kind: string): boolean;
  16661. /**
  16662. * Returns an array of indices (IndicesArray).
  16663. */
  16664. getIndices(): Nullable<IndicesArray>;
  16665. get _positions(): Nullable<Vector3[]>;
  16666. /**
  16667. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16668. * This means the mesh underlying bounding box and sphere are recomputed.
  16669. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16670. * @returns the current mesh
  16671. */
  16672. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16673. /** @hidden */
  16674. _preActivate(): InstancedMesh;
  16675. /** @hidden */
  16676. _activate(renderId: number, intermediateRendering: boolean): boolean;
  16677. /** @hidden */
  16678. _postActivate(): void;
  16679. getWorldMatrix(): Matrix;
  16680. get isAnInstance(): boolean;
  16681. /**
  16682. * Returns the current associated LOD AbstractMesh.
  16683. */
  16684. getLOD(camera: Camera): AbstractMesh;
  16685. /** @hidden */
  16686. _preActivateForIntermediateRendering(renderId: number): Mesh;
  16687. /** @hidden */
  16688. _syncSubMeshes(): InstancedMesh;
  16689. /** @hidden */
  16690. _generatePointsArray(): boolean;
  16691. /**
  16692. * Creates a new InstancedMesh from the current mesh.
  16693. * - name (string) : the cloned mesh name
  16694. * - newParent (optional Node) : the optional Node to parent the clone to.
  16695. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16696. *
  16697. * Returns the clone.
  16698. */
  16699. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  16700. /**
  16701. * Disposes the InstancedMesh.
  16702. * Returns nothing.
  16703. */
  16704. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16705. }
  16706. module "babylonjs/Meshes/mesh" {
  16707. interface Mesh {
  16708. /**
  16709. * Register a custom buffer that will be instanced
  16710. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16711. * @param kind defines the buffer kind
  16712. * @param stride defines the stride in floats
  16713. */
  16714. registerInstancedBuffer(kind: string, stride: number): void;
  16715. /** @hidden */
  16716. _userInstancedBuffersStorage: {
  16717. data: {
  16718. [key: string]: Float32Array;
  16719. };
  16720. sizes: {
  16721. [key: string]: number;
  16722. };
  16723. vertexBuffers: {
  16724. [key: string]: Nullable<VertexBuffer>;
  16725. };
  16726. strides: {
  16727. [key: string]: number;
  16728. };
  16729. };
  16730. }
  16731. }
  16732. module "babylonjs/Meshes/abstractMesh" {
  16733. interface AbstractMesh {
  16734. /**
  16735. * Object used to store instanced buffers defined by user
  16736. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16737. */
  16738. instancedBuffers: {
  16739. [key: string]: any;
  16740. };
  16741. }
  16742. }
  16743. }
  16744. declare module "babylonjs/Materials/shaderMaterial" {
  16745. import { Nullable } from "babylonjs/types";
  16746. import { Scene } from "babylonjs/scene";
  16747. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  16748. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16749. import { Mesh } from "babylonjs/Meshes/mesh";
  16750. import { SubMesh, BaseSubMesh } from "babylonjs/Meshes/subMesh";
  16751. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16752. import { Effect } from "babylonjs/Materials/effect";
  16753. import { Material } from "babylonjs/Materials/material";
  16754. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  16755. /**
  16756. * Defines the options associated with the creation of a shader material.
  16757. */
  16758. export interface IShaderMaterialOptions {
  16759. /**
  16760. * Does the material work in alpha blend mode
  16761. */
  16762. needAlphaBlending: boolean;
  16763. /**
  16764. * Does the material work in alpha test mode
  16765. */
  16766. needAlphaTesting: boolean;
  16767. /**
  16768. * The list of attribute names used in the shader
  16769. */
  16770. attributes: string[];
  16771. /**
  16772. * The list of unifrom names used in the shader
  16773. */
  16774. uniforms: string[];
  16775. /**
  16776. * The list of UBO names used in the shader
  16777. */
  16778. uniformBuffers: string[];
  16779. /**
  16780. * The list of sampler names used in the shader
  16781. */
  16782. samplers: string[];
  16783. /**
  16784. * The list of defines used in the shader
  16785. */
  16786. defines: string[];
  16787. }
  16788. /**
  16789. * 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.
  16790. *
  16791. * This returned material effects how the mesh will look based on the code in the shaders.
  16792. *
  16793. * @see http://doc.babylonjs.com/how_to/shader_material
  16794. */
  16795. export class ShaderMaterial extends Material {
  16796. private _shaderPath;
  16797. private _options;
  16798. private _textures;
  16799. private _textureArrays;
  16800. private _floats;
  16801. private _ints;
  16802. private _floatsArrays;
  16803. private _colors3;
  16804. private _colors3Arrays;
  16805. private _colors4;
  16806. private _colors4Arrays;
  16807. private _vectors2;
  16808. private _vectors3;
  16809. private _vectors4;
  16810. private _matrices;
  16811. private _matrixArrays;
  16812. private _matrices3x3;
  16813. private _matrices2x2;
  16814. private _vectors2Arrays;
  16815. private _vectors3Arrays;
  16816. private _vectors4Arrays;
  16817. private _cachedWorldViewMatrix;
  16818. private _cachedWorldViewProjectionMatrix;
  16819. private _renderId;
  16820. private _multiview;
  16821. private _cachedDefines;
  16822. /**
  16823. * Instantiate a new shader material.
  16824. * 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.
  16825. * This returned material effects how the mesh will look based on the code in the shaders.
  16826. * @see http://doc.babylonjs.com/how_to/shader_material
  16827. * @param name Define the name of the material in the scene
  16828. * @param scene Define the scene the material belongs to
  16829. * @param shaderPath Defines the route to the shader code in one of three ways:
  16830. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  16831. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  16832. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  16833. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16834. * @param options Define the options used to create the shader
  16835. */
  16836. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16837. /**
  16838. * Gets the shader path used to define the shader code
  16839. * It can be modified to trigger a new compilation
  16840. */
  16841. get shaderPath(): any;
  16842. /**
  16843. * Sets the shader path used to define the shader code
  16844. * It can be modified to trigger a new compilation
  16845. */
  16846. set shaderPath(shaderPath: any);
  16847. /**
  16848. * Gets the options used to compile the shader.
  16849. * They can be modified to trigger a new compilation
  16850. */
  16851. get options(): IShaderMaterialOptions;
  16852. /**
  16853. * Gets the current class name of the material e.g. "ShaderMaterial"
  16854. * Mainly use in serialization.
  16855. * @returns the class name
  16856. */
  16857. getClassName(): string;
  16858. /**
  16859. * Specifies if the material will require alpha blending
  16860. * @returns a boolean specifying if alpha blending is needed
  16861. */
  16862. needAlphaBlending(): boolean;
  16863. /**
  16864. * Specifies if this material should be rendered in alpha test mode
  16865. * @returns a boolean specifying if an alpha test is needed.
  16866. */
  16867. needAlphaTesting(): boolean;
  16868. private _checkUniform;
  16869. /**
  16870. * Set a texture in the shader.
  16871. * @param name Define the name of the uniform samplers as defined in the shader
  16872. * @param texture Define the texture to bind to this sampler
  16873. * @return the material itself allowing "fluent" like uniform updates
  16874. */
  16875. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  16876. /**
  16877. * Set a texture array in the shader.
  16878. * @param name Define the name of the uniform sampler array as defined in the shader
  16879. * @param textures Define the list of textures to bind to this sampler
  16880. * @return the material itself allowing "fluent" like uniform updates
  16881. */
  16882. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  16883. /**
  16884. * Set a float in the shader.
  16885. * @param name Define the name of the uniform as defined in the shader
  16886. * @param value Define the value to give to the uniform
  16887. * @return the material itself allowing "fluent" like uniform updates
  16888. */
  16889. setFloat(name: string, value: number): ShaderMaterial;
  16890. /**
  16891. * Set a int in the shader.
  16892. * @param name Define the name of the uniform as defined in the shader
  16893. * @param value Define the value to give to the uniform
  16894. * @return the material itself allowing "fluent" like uniform updates
  16895. */
  16896. setInt(name: string, value: number): ShaderMaterial;
  16897. /**
  16898. * Set an array of floats in the shader.
  16899. * @param name Define the name of the uniform as defined in the shader
  16900. * @param value Define the value to give to the uniform
  16901. * @return the material itself allowing "fluent" like uniform updates
  16902. */
  16903. setFloats(name: string, value: number[]): ShaderMaterial;
  16904. /**
  16905. * Set a vec3 in the shader from a Color3.
  16906. * @param name Define the name of the uniform as defined in the shader
  16907. * @param value Define the value to give to the uniform
  16908. * @return the material itself allowing "fluent" like uniform updates
  16909. */
  16910. setColor3(name: string, value: Color3): ShaderMaterial;
  16911. /**
  16912. * Set a vec3 array in the shader from a Color3 array.
  16913. * @param name Define the name of the uniform as defined in the shader
  16914. * @param value Define the value to give to the uniform
  16915. * @return the material itself allowing "fluent" like uniform updates
  16916. */
  16917. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  16918. /**
  16919. * Set a vec4 in the shader from a Color4.
  16920. * @param name Define the name of the uniform as defined in the shader
  16921. * @param value Define the value to give to the uniform
  16922. * @return the material itself allowing "fluent" like uniform updates
  16923. */
  16924. setColor4(name: string, value: Color4): ShaderMaterial;
  16925. /**
  16926. * Set a vec4 array in the shader from a Color4 array.
  16927. * @param name Define the name of the uniform as defined in the shader
  16928. * @param value Define the value to give to the uniform
  16929. * @return the material itself allowing "fluent" like uniform updates
  16930. */
  16931. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  16932. /**
  16933. * Set a vec2 in the shader from a Vector2.
  16934. * @param name Define the name of the uniform as defined in the shader
  16935. * @param value Define the value to give to the uniform
  16936. * @return the material itself allowing "fluent" like uniform updates
  16937. */
  16938. setVector2(name: string, value: Vector2): ShaderMaterial;
  16939. /**
  16940. * Set a vec3 in the shader from a Vector3.
  16941. * @param name Define the name of the uniform as defined in the shader
  16942. * @param value Define the value to give to the uniform
  16943. * @return the material itself allowing "fluent" like uniform updates
  16944. */
  16945. setVector3(name: string, value: Vector3): ShaderMaterial;
  16946. /**
  16947. * Set a vec4 in the shader from a Vector4.
  16948. * @param name Define the name of the uniform as defined in the shader
  16949. * @param value Define the value to give to the uniform
  16950. * @return the material itself allowing "fluent" like uniform updates
  16951. */
  16952. setVector4(name: string, value: Vector4): ShaderMaterial;
  16953. /**
  16954. * Set a mat4 in the shader from a Matrix.
  16955. * @param name Define the name of the uniform as defined in the shader
  16956. * @param value Define the value to give to the uniform
  16957. * @return the material itself allowing "fluent" like uniform updates
  16958. */
  16959. setMatrix(name: string, value: Matrix): ShaderMaterial;
  16960. /**
  16961. * Set a float32Array in the shader from a matrix array.
  16962. * @param name Define the name of the uniform as defined in the shader
  16963. * @param value Define the value to give to the uniform
  16964. * @return the material itself allowing "fluent" like uniform updates
  16965. */
  16966. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  16967. /**
  16968. * Set a mat3 in the shader from a Float32Array.
  16969. * @param name Define the name of the uniform as defined in the shader
  16970. * @param value Define the value to give to the uniform
  16971. * @return the material itself allowing "fluent" like uniform updates
  16972. */
  16973. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  16974. /**
  16975. * Set a mat2 in the shader from a Float32Array.
  16976. * @param name Define the name of the uniform as defined in the shader
  16977. * @param value Define the value to give to the uniform
  16978. * @return the material itself allowing "fluent" like uniform updates
  16979. */
  16980. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  16981. /**
  16982. * Set a vec2 array in the shader from a number array.
  16983. * @param name Define the name of the uniform as defined in the shader
  16984. * @param value Define the value to give to the uniform
  16985. * @return the material itself allowing "fluent" like uniform updates
  16986. */
  16987. setArray2(name: string, value: number[]): ShaderMaterial;
  16988. /**
  16989. * Set a vec3 array in the shader from a number array.
  16990. * @param name Define the name of the uniform as defined in the shader
  16991. * @param value Define the value to give to the uniform
  16992. * @return the material itself allowing "fluent" like uniform updates
  16993. */
  16994. setArray3(name: string, value: number[]): ShaderMaterial;
  16995. /**
  16996. * Set a vec4 array in the shader from a number array.
  16997. * @param name Define the name of the uniform as defined in the shader
  16998. * @param value Define the value to give to the uniform
  16999. * @return the material itself allowing "fluent" like uniform updates
  17000. */
  17001. setArray4(name: string, value: number[]): ShaderMaterial;
  17002. private _checkCache;
  17003. /**
  17004. * Specifies that the submesh is ready to be used
  17005. * @param mesh defines the mesh to check
  17006. * @param subMesh defines which submesh to check
  17007. * @param useInstances specifies that instances should be used
  17008. * @returns a boolean indicating that the submesh is ready or not
  17009. */
  17010. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  17011. /**
  17012. * Checks if the material is ready to render the requested mesh
  17013. * @param mesh Define the mesh to render
  17014. * @param useInstances Define whether or not the material is used with instances
  17015. * @returns true if ready, otherwise false
  17016. */
  17017. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  17018. /**
  17019. * Binds the world matrix to the material
  17020. * @param world defines the world transformation matrix
  17021. * @param effectOverride - If provided, use this effect instead of internal effect
  17022. */
  17023. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  17024. /**
  17025. * Binds the submesh to this material by preparing the effect and shader to draw
  17026. * @param world defines the world transformation matrix
  17027. * @param mesh defines the mesh containing the submesh
  17028. * @param subMesh defines the submesh to bind the material to
  17029. */
  17030. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  17031. /**
  17032. * Binds the material to the mesh
  17033. * @param world defines the world transformation matrix
  17034. * @param mesh defines the mesh to bind the material to
  17035. * @param effectOverride - If provided, use this effect instead of internal effect
  17036. */
  17037. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  17038. protected _afterBind(mesh?: Mesh): void;
  17039. /**
  17040. * Gets the active textures from the material
  17041. * @returns an array of textures
  17042. */
  17043. getActiveTextures(): BaseTexture[];
  17044. /**
  17045. * Specifies if the material uses a texture
  17046. * @param texture defines the texture to check against the material
  17047. * @returns a boolean specifying if the material uses the texture
  17048. */
  17049. hasTexture(texture: BaseTexture): boolean;
  17050. /**
  17051. * Makes a duplicate of the material, and gives it a new name
  17052. * @param name defines the new name for the duplicated material
  17053. * @returns the cloned material
  17054. */
  17055. clone(name: string): ShaderMaterial;
  17056. /**
  17057. * Disposes the material
  17058. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  17059. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  17060. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  17061. */
  17062. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  17063. /**
  17064. * Serializes this material in a JSON representation
  17065. * @returns the serialized material object
  17066. */
  17067. serialize(): any;
  17068. /**
  17069. * Creates a shader material from parsed shader material data
  17070. * @param source defines the JSON represnetation of the material
  17071. * @param scene defines the hosting scene
  17072. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17073. * @returns a new material
  17074. */
  17075. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  17076. }
  17077. }
  17078. declare module "babylonjs/Shaders/color.fragment" {
  17079. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17080. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17081. /** @hidden */
  17082. export var colorPixelShader: {
  17083. name: string;
  17084. shader: string;
  17085. };
  17086. }
  17087. declare module "babylonjs/Shaders/color.vertex" {
  17088. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  17089. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17090. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  17091. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17092. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  17093. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17094. /** @hidden */
  17095. export var colorVertexShader: {
  17096. name: string;
  17097. shader: string;
  17098. };
  17099. }
  17100. declare module "babylonjs/Meshes/linesMesh" {
  17101. import { Nullable } from "babylonjs/types";
  17102. import { Scene } from "babylonjs/scene";
  17103. import { Color3 } from "babylonjs/Maths/math.color";
  17104. import { Node } from "babylonjs/node";
  17105. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17106. import { Mesh } from "babylonjs/Meshes/mesh";
  17107. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  17108. import { Effect } from "babylonjs/Materials/effect";
  17109. import { Material } from "babylonjs/Materials/material";
  17110. import "babylonjs/Shaders/color.fragment";
  17111. import "babylonjs/Shaders/color.vertex";
  17112. /**
  17113. * Line mesh
  17114. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  17115. */
  17116. export class LinesMesh extends Mesh {
  17117. /**
  17118. * If vertex color should be applied to the mesh
  17119. */
  17120. readonly useVertexColor?: boolean | undefined;
  17121. /**
  17122. * If vertex alpha should be applied to the mesh
  17123. */
  17124. readonly useVertexAlpha?: boolean | undefined;
  17125. /**
  17126. * Color of the line (Default: White)
  17127. */
  17128. color: Color3;
  17129. /**
  17130. * Alpha of the line (Default: 1)
  17131. */
  17132. alpha: number;
  17133. /**
  17134. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17135. * This margin is expressed in world space coordinates, so its value may vary.
  17136. * Default value is 0.1
  17137. */
  17138. intersectionThreshold: number;
  17139. private _colorShader;
  17140. private color4;
  17141. /**
  17142. * Creates a new LinesMesh
  17143. * @param name defines the name
  17144. * @param scene defines the hosting scene
  17145. * @param parent defines the parent mesh if any
  17146. * @param source defines the optional source LinesMesh used to clone data from
  17147. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  17148. * When false, achieved by calling a clone(), also passing False.
  17149. * This will make creation of children, recursive.
  17150. * @param useVertexColor defines if this LinesMesh supports vertex color
  17151. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  17152. */
  17153. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  17154. /**
  17155. * If vertex color should be applied to the mesh
  17156. */
  17157. useVertexColor?: boolean | undefined,
  17158. /**
  17159. * If vertex alpha should be applied to the mesh
  17160. */
  17161. useVertexAlpha?: boolean | undefined);
  17162. private _addClipPlaneDefine;
  17163. private _removeClipPlaneDefine;
  17164. isReady(): boolean;
  17165. /**
  17166. * Returns the string "LineMesh"
  17167. */
  17168. getClassName(): string;
  17169. /**
  17170. * @hidden
  17171. */
  17172. get material(): Material;
  17173. /**
  17174. * @hidden
  17175. */
  17176. set material(value: Material);
  17177. /**
  17178. * @hidden
  17179. */
  17180. get checkCollisions(): boolean;
  17181. /** @hidden */
  17182. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  17183. /** @hidden */
  17184. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  17185. /**
  17186. * Disposes of the line mesh
  17187. * @param doNotRecurse If children should be disposed
  17188. */
  17189. dispose(doNotRecurse?: boolean): void;
  17190. /**
  17191. * Returns a new LineMesh object cloned from the current one.
  17192. */
  17193. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  17194. /**
  17195. * Creates a new InstancedLinesMesh object from the mesh model.
  17196. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  17197. * @param name defines the name of the new instance
  17198. * @returns a new InstancedLinesMesh
  17199. */
  17200. createInstance(name: string): InstancedLinesMesh;
  17201. }
  17202. /**
  17203. * Creates an instance based on a source LinesMesh
  17204. */
  17205. export class InstancedLinesMesh extends InstancedMesh {
  17206. /**
  17207. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17208. * This margin is expressed in world space coordinates, so its value may vary.
  17209. * Initilized with the intersectionThreshold value of the source LinesMesh
  17210. */
  17211. intersectionThreshold: number;
  17212. constructor(name: string, source: LinesMesh);
  17213. /**
  17214. * Returns the string "InstancedLinesMesh".
  17215. */
  17216. getClassName(): string;
  17217. }
  17218. }
  17219. declare module "babylonjs/Shaders/line.fragment" {
  17220. /** @hidden */
  17221. export var linePixelShader: {
  17222. name: string;
  17223. shader: string;
  17224. };
  17225. }
  17226. declare module "babylonjs/Shaders/line.vertex" {
  17227. /** @hidden */
  17228. export var lineVertexShader: {
  17229. name: string;
  17230. shader: string;
  17231. };
  17232. }
  17233. declare module "babylonjs/Rendering/edgesRenderer" {
  17234. import { Nullable } from "babylonjs/types";
  17235. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  17236. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17237. import { Vector3 } from "babylonjs/Maths/math.vector";
  17238. import { IDisposable } from "babylonjs/scene";
  17239. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  17240. import "babylonjs/Shaders/line.fragment";
  17241. import "babylonjs/Shaders/line.vertex";
  17242. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  17243. module "babylonjs/Meshes/abstractMesh" {
  17244. interface AbstractMesh {
  17245. /**
  17246. * Gets the edgesRenderer associated with the mesh
  17247. */
  17248. edgesRenderer: Nullable<EdgesRenderer>;
  17249. }
  17250. }
  17251. module "babylonjs/Meshes/linesMesh" {
  17252. interface LinesMesh {
  17253. /**
  17254. * Enables the edge rendering mode on the mesh.
  17255. * This mode makes the mesh edges visible
  17256. * @param epsilon defines the maximal distance between two angles to detect a face
  17257. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17258. * @returns the currentAbstractMesh
  17259. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17260. */
  17261. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17262. }
  17263. }
  17264. module "babylonjs/Meshes/linesMesh" {
  17265. interface InstancedLinesMesh {
  17266. /**
  17267. * Enables the edge rendering mode on the mesh.
  17268. * This mode makes the mesh edges visible
  17269. * @param epsilon defines the maximal distance between two angles to detect a face
  17270. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17271. * @returns the current InstancedLinesMesh
  17272. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17273. */
  17274. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17275. }
  17276. }
  17277. /**
  17278. * Defines the minimum contract an Edges renderer should follow.
  17279. */
  17280. export interface IEdgesRenderer extends IDisposable {
  17281. /**
  17282. * Gets or sets a boolean indicating if the edgesRenderer is active
  17283. */
  17284. isEnabled: boolean;
  17285. /**
  17286. * Renders the edges of the attached mesh,
  17287. */
  17288. render(): void;
  17289. /**
  17290. * Checks wether or not the edges renderer is ready to render.
  17291. * @return true if ready, otherwise false.
  17292. */
  17293. isReady(): boolean;
  17294. }
  17295. /**
  17296. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17297. */
  17298. export class EdgesRenderer implements IEdgesRenderer {
  17299. /**
  17300. * Define the size of the edges with an orthographic camera
  17301. */
  17302. edgesWidthScalerForOrthographic: number;
  17303. /**
  17304. * Define the size of the edges with a perspective camera
  17305. */
  17306. edgesWidthScalerForPerspective: number;
  17307. protected _source: AbstractMesh;
  17308. protected _linesPositions: number[];
  17309. protected _linesNormals: number[];
  17310. protected _linesIndices: number[];
  17311. protected _epsilon: number;
  17312. protected _indicesCount: number;
  17313. protected _lineShader: ShaderMaterial;
  17314. protected _ib: DataBuffer;
  17315. protected _buffers: {
  17316. [key: string]: Nullable<VertexBuffer>;
  17317. };
  17318. protected _checkVerticesInsteadOfIndices: boolean;
  17319. private _meshRebuildObserver;
  17320. private _meshDisposeObserver;
  17321. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17322. isEnabled: boolean;
  17323. /**
  17324. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17325. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17326. * @param source Mesh used to create edges
  17327. * @param epsilon sum of angles in adjacency to check for edge
  17328. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  17329. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17330. */
  17331. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  17332. protected _prepareRessources(): void;
  17333. /** @hidden */
  17334. _rebuild(): void;
  17335. /**
  17336. * Releases the required resources for the edges renderer
  17337. */
  17338. dispose(): void;
  17339. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17340. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17341. /**
  17342. * Checks if the pair of p0 and p1 is en edge
  17343. * @param faceIndex
  17344. * @param edge
  17345. * @param faceNormals
  17346. * @param p0
  17347. * @param p1
  17348. * @private
  17349. */
  17350. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17351. /**
  17352. * push line into the position, normal and index buffer
  17353. * @protected
  17354. */
  17355. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17356. /**
  17357. * Generates lines edges from adjacencjes
  17358. * @private
  17359. */
  17360. _generateEdgesLines(): void;
  17361. /**
  17362. * Checks wether or not the edges renderer is ready to render.
  17363. * @return true if ready, otherwise false.
  17364. */
  17365. isReady(): boolean;
  17366. /**
  17367. * Renders the edges of the attached mesh,
  17368. */
  17369. render(): void;
  17370. }
  17371. /**
  17372. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17373. */
  17374. export class LineEdgesRenderer extends EdgesRenderer {
  17375. /**
  17376. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17377. * @param source LineMesh used to generate edges
  17378. * @param epsilon not important (specified angle for edge detection)
  17379. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17380. */
  17381. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17382. /**
  17383. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17384. */
  17385. _generateEdgesLines(): void;
  17386. }
  17387. }
  17388. declare module "babylonjs/Rendering/renderingGroup" {
  17389. import { SmartArray } from "babylonjs/Misc/smartArray";
  17390. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17391. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17392. import { Nullable } from "babylonjs/types";
  17393. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17394. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  17395. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17396. import { Material } from "babylonjs/Materials/material";
  17397. import { Scene } from "babylonjs/scene";
  17398. /**
  17399. * This represents the object necessary to create a rendering group.
  17400. * This is exclusively used and created by the rendering manager.
  17401. * To modify the behavior, you use the available helpers in your scene or meshes.
  17402. * @hidden
  17403. */
  17404. export class RenderingGroup {
  17405. index: number;
  17406. private static _zeroVector;
  17407. private _scene;
  17408. private _opaqueSubMeshes;
  17409. private _transparentSubMeshes;
  17410. private _alphaTestSubMeshes;
  17411. private _depthOnlySubMeshes;
  17412. private _particleSystems;
  17413. private _spriteManagers;
  17414. private _opaqueSortCompareFn;
  17415. private _alphaTestSortCompareFn;
  17416. private _transparentSortCompareFn;
  17417. private _renderOpaque;
  17418. private _renderAlphaTest;
  17419. private _renderTransparent;
  17420. /** @hidden */
  17421. _edgesRenderers: SmartArray<IEdgesRenderer>;
  17422. onBeforeTransparentRendering: () => void;
  17423. /**
  17424. * Set the opaque sort comparison function.
  17425. * If null the sub meshes will be render in the order they were created
  17426. */
  17427. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17428. /**
  17429. * Set the alpha test sort comparison function.
  17430. * If null the sub meshes will be render in the order they were created
  17431. */
  17432. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17433. /**
  17434. * Set the transparent sort comparison function.
  17435. * If null the sub meshes will be render in the order they were created
  17436. */
  17437. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17438. /**
  17439. * Creates a new rendering group.
  17440. * @param index The rendering group index
  17441. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17442. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17443. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17444. */
  17445. 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>);
  17446. /**
  17447. * Render all the sub meshes contained in the group.
  17448. * @param customRenderFunction Used to override the default render behaviour of the group.
  17449. * @returns true if rendered some submeshes.
  17450. */
  17451. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17452. /**
  17453. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17454. * @param subMeshes The submeshes to render
  17455. */
  17456. private renderOpaqueSorted;
  17457. /**
  17458. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17459. * @param subMeshes The submeshes to render
  17460. */
  17461. private renderAlphaTestSorted;
  17462. /**
  17463. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17464. * @param subMeshes The submeshes to render
  17465. */
  17466. private renderTransparentSorted;
  17467. /**
  17468. * Renders the submeshes in a specified order.
  17469. * @param subMeshes The submeshes to sort before render
  17470. * @param sortCompareFn The comparison function use to sort
  17471. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17472. * @param transparent Specifies to activate blending if true
  17473. */
  17474. private static renderSorted;
  17475. /**
  17476. * Renders the submeshes in the order they were dispatched (no sort applied).
  17477. * @param subMeshes The submeshes to render
  17478. */
  17479. private static renderUnsorted;
  17480. /**
  17481. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17482. * are rendered back to front if in the same alpha index.
  17483. *
  17484. * @param a The first submesh
  17485. * @param b The second submesh
  17486. * @returns The result of the comparison
  17487. */
  17488. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17489. /**
  17490. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17491. * are rendered back to front.
  17492. *
  17493. * @param a The first submesh
  17494. * @param b The second submesh
  17495. * @returns The result of the comparison
  17496. */
  17497. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17498. /**
  17499. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17500. * are rendered front to back (prevent overdraw).
  17501. *
  17502. * @param a The first submesh
  17503. * @param b The second submesh
  17504. * @returns The result of the comparison
  17505. */
  17506. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17507. /**
  17508. * Resets the different lists of submeshes to prepare a new frame.
  17509. */
  17510. prepare(): void;
  17511. dispose(): void;
  17512. /**
  17513. * Inserts the submesh in its correct queue depending on its material.
  17514. * @param subMesh The submesh to dispatch
  17515. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17516. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17517. */
  17518. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17519. dispatchSprites(spriteManager: ISpriteManager): void;
  17520. dispatchParticles(particleSystem: IParticleSystem): void;
  17521. private _renderParticles;
  17522. private _renderSprites;
  17523. }
  17524. }
  17525. declare module "babylonjs/Rendering/renderingManager" {
  17526. import { Nullable } from "babylonjs/types";
  17527. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17528. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17529. import { SmartArray } from "babylonjs/Misc/smartArray";
  17530. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17531. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17532. import { Material } from "babylonjs/Materials/material";
  17533. import { Scene } from "babylonjs/scene";
  17534. import { Camera } from "babylonjs/Cameras/camera";
  17535. /**
  17536. * Interface describing the different options available in the rendering manager
  17537. * regarding Auto Clear between groups.
  17538. */
  17539. export interface IRenderingManagerAutoClearSetup {
  17540. /**
  17541. * Defines whether or not autoclear is enable.
  17542. */
  17543. autoClear: boolean;
  17544. /**
  17545. * Defines whether or not to autoclear the depth buffer.
  17546. */
  17547. depth: boolean;
  17548. /**
  17549. * Defines whether or not to autoclear the stencil buffer.
  17550. */
  17551. stencil: boolean;
  17552. }
  17553. /**
  17554. * This class is used by the onRenderingGroupObservable
  17555. */
  17556. export class RenderingGroupInfo {
  17557. /**
  17558. * The Scene that being rendered
  17559. */
  17560. scene: Scene;
  17561. /**
  17562. * The camera currently used for the rendering pass
  17563. */
  17564. camera: Nullable<Camera>;
  17565. /**
  17566. * The ID of the renderingGroup being processed
  17567. */
  17568. renderingGroupId: number;
  17569. }
  17570. /**
  17571. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17572. * It is enable to manage the different groups as well as the different necessary sort functions.
  17573. * This should not be used directly aside of the few static configurations
  17574. */
  17575. export class RenderingManager {
  17576. /**
  17577. * The max id used for rendering groups (not included)
  17578. */
  17579. static MAX_RENDERINGGROUPS: number;
  17580. /**
  17581. * The min id used for rendering groups (included)
  17582. */
  17583. static MIN_RENDERINGGROUPS: number;
  17584. /**
  17585. * Used to globally prevent autoclearing scenes.
  17586. */
  17587. static AUTOCLEAR: boolean;
  17588. /**
  17589. * @hidden
  17590. */
  17591. _useSceneAutoClearSetup: boolean;
  17592. private _scene;
  17593. private _renderingGroups;
  17594. private _depthStencilBufferAlreadyCleaned;
  17595. private _autoClearDepthStencil;
  17596. private _customOpaqueSortCompareFn;
  17597. private _customAlphaTestSortCompareFn;
  17598. private _customTransparentSortCompareFn;
  17599. private _renderingGroupInfo;
  17600. /**
  17601. * Instantiates a new rendering group for a particular scene
  17602. * @param scene Defines the scene the groups belongs to
  17603. */
  17604. constructor(scene: Scene);
  17605. private _clearDepthStencilBuffer;
  17606. /**
  17607. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17608. * @hidden
  17609. */
  17610. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17611. /**
  17612. * Resets the different information of the group to prepare a new frame
  17613. * @hidden
  17614. */
  17615. reset(): void;
  17616. /**
  17617. * Dispose and release the group and its associated resources.
  17618. * @hidden
  17619. */
  17620. dispose(): void;
  17621. /**
  17622. * Clear the info related to rendering groups preventing retention points during dispose.
  17623. */
  17624. freeRenderingGroups(): void;
  17625. private _prepareRenderingGroup;
  17626. /**
  17627. * Add a sprite manager to the rendering manager in order to render it this frame.
  17628. * @param spriteManager Define the sprite manager to render
  17629. */
  17630. dispatchSprites(spriteManager: ISpriteManager): void;
  17631. /**
  17632. * Add a particle system to the rendering manager in order to render it this frame.
  17633. * @param particleSystem Define the particle system to render
  17634. */
  17635. dispatchParticles(particleSystem: IParticleSystem): void;
  17636. /**
  17637. * Add a submesh to the manager in order to render it this frame
  17638. * @param subMesh The submesh to dispatch
  17639. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17640. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17641. */
  17642. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17643. /**
  17644. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17645. * This allowed control for front to back rendering or reversly depending of the special needs.
  17646. *
  17647. * @param renderingGroupId The rendering group id corresponding to its index
  17648. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17649. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17650. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17651. */
  17652. 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;
  17653. /**
  17654. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17655. *
  17656. * @param renderingGroupId The rendering group id corresponding to its index
  17657. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17658. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17659. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17660. */
  17661. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17662. /**
  17663. * Gets the current auto clear configuration for one rendering group of the rendering
  17664. * manager.
  17665. * @param index the rendering group index to get the information for
  17666. * @returns The auto clear setup for the requested rendering group
  17667. */
  17668. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17669. }
  17670. }
  17671. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  17672. import { SmartArray } from "babylonjs/Misc/smartArray";
  17673. import { Nullable } from "babylonjs/types";
  17674. import { Scene } from "babylonjs/scene";
  17675. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  17676. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17677. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17678. import { Mesh } from "babylonjs/Meshes/mesh";
  17679. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  17680. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  17681. import { Effect } from "babylonjs/Materials/effect";
  17682. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  17683. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  17684. import "babylonjs/Shaders/shadowMap.fragment";
  17685. import "babylonjs/Shaders/shadowMap.vertex";
  17686. import "babylonjs/Shaders/depthBoxBlur.fragment";
  17687. import "babylonjs/Shaders/ShadersInclude/shadowMapFragmentSoftTransparentShadow";
  17688. import { Observable } from "babylonjs/Misc/observable";
  17689. /**
  17690. * Defines the options associated with the creation of a custom shader for a shadow generator.
  17691. */
  17692. export interface ICustomShaderOptions {
  17693. /**
  17694. * Gets or sets the custom shader name to use
  17695. */
  17696. shaderName: string;
  17697. /**
  17698. * The list of attribute names used in the shader
  17699. */
  17700. attributes?: string[];
  17701. /**
  17702. * The list of unifrom names used in the shader
  17703. */
  17704. uniforms?: string[];
  17705. /**
  17706. * The list of sampler names used in the shader
  17707. */
  17708. samplers?: string[];
  17709. /**
  17710. * The list of defines used in the shader
  17711. */
  17712. defines?: string[];
  17713. }
  17714. /**
  17715. * Interface to implement to create a shadow generator compatible with BJS.
  17716. */
  17717. export interface IShadowGenerator {
  17718. /**
  17719. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17720. * @returns The render target texture if present otherwise, null
  17721. */
  17722. getShadowMap(): Nullable<RenderTargetTexture>;
  17723. /**
  17724. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17725. * @param subMesh The submesh we want to render in the shadow map
  17726. * @param useInstances Defines wether will draw in the map using instances
  17727. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  17728. * @returns true if ready otherwise, false
  17729. */
  17730. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  17731. /**
  17732. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17733. * @param defines Defines of the material we want to update
  17734. * @param lightIndex Index of the light in the enabled light list of the material
  17735. */
  17736. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  17737. /**
  17738. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17739. * defined in the generator but impacting the effect).
  17740. * It implies the unifroms available on the materials are the standard BJS ones.
  17741. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17742. * @param effect The effect we are binfing the information for
  17743. */
  17744. bindShadowLight(lightIndex: string, effect: Effect): void;
  17745. /**
  17746. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17747. * (eq to shadow prjection matrix * light transform matrix)
  17748. * @returns The transform matrix used to create the shadow map
  17749. */
  17750. getTransformMatrix(): Matrix;
  17751. /**
  17752. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17753. * Cube and 2D textures for instance.
  17754. */
  17755. recreateShadowMap(): void;
  17756. /**
  17757. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17758. * @param onCompiled Callback triggered at the and of the effects compilation
  17759. * @param options Sets of optional options forcing the compilation with different modes
  17760. */
  17761. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17762. useInstances: boolean;
  17763. }>): void;
  17764. /**
  17765. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17766. * @param options Sets of optional options forcing the compilation with different modes
  17767. * @returns A promise that resolves when the compilation completes
  17768. */
  17769. forceCompilationAsync(options?: Partial<{
  17770. useInstances: boolean;
  17771. }>): Promise<void>;
  17772. /**
  17773. * Serializes the shadow generator setup to a json object.
  17774. * @returns The serialized JSON object
  17775. */
  17776. serialize(): any;
  17777. /**
  17778. * Disposes the Shadow map and related Textures and effects.
  17779. */
  17780. dispose(): void;
  17781. }
  17782. /**
  17783. * Default implementation IShadowGenerator.
  17784. * This is the main object responsible of generating shadows in the framework.
  17785. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  17786. */
  17787. export class ShadowGenerator implements IShadowGenerator {
  17788. /**
  17789. * Name of the shadow generator class
  17790. */
  17791. static CLASSNAME: string;
  17792. /**
  17793. * Shadow generator mode None: no filtering applied.
  17794. */
  17795. static readonly FILTER_NONE: number;
  17796. /**
  17797. * Shadow generator mode ESM: Exponential Shadow Mapping.
  17798. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17799. */
  17800. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  17801. /**
  17802. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  17803. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  17804. */
  17805. static readonly FILTER_POISSONSAMPLING: number;
  17806. /**
  17807. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  17808. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17809. */
  17810. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  17811. /**
  17812. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  17813. * edge artifacts on steep falloff.
  17814. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17815. */
  17816. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  17817. /**
  17818. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  17819. * edge artifacts on steep falloff.
  17820. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17821. */
  17822. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  17823. /**
  17824. * Shadow generator mode PCF: Percentage Closer Filtering
  17825. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17826. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  17827. */
  17828. static readonly FILTER_PCF: number;
  17829. /**
  17830. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  17831. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17832. * Contact Hardening
  17833. */
  17834. static readonly FILTER_PCSS: number;
  17835. /**
  17836. * Reserved for PCF and PCSS
  17837. * Highest Quality.
  17838. *
  17839. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  17840. *
  17841. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  17842. */
  17843. static readonly QUALITY_HIGH: number;
  17844. /**
  17845. * Reserved for PCF and PCSS
  17846. * Good tradeoff for quality/perf cross devices
  17847. *
  17848. * Execute PCF on a 3*3 kernel.
  17849. *
  17850. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  17851. */
  17852. static readonly QUALITY_MEDIUM: number;
  17853. /**
  17854. * Reserved for PCF and PCSS
  17855. * The lowest quality but the fastest.
  17856. *
  17857. * Execute PCF on a 1*1 kernel.
  17858. *
  17859. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  17860. */
  17861. static readonly QUALITY_LOW: number;
  17862. /** Gets or sets the custom shader name to use */
  17863. customShaderOptions: ICustomShaderOptions;
  17864. /**
  17865. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  17866. */
  17867. onBeforeShadowMapRenderObservable: Observable<Effect>;
  17868. /**
  17869. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  17870. */
  17871. onAfterShadowMapRenderObservable: Observable<Effect>;
  17872. /**
  17873. * Observable triggered before a mesh is rendered in the shadow map.
  17874. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  17875. */
  17876. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  17877. /**
  17878. * Observable triggered after a mesh is rendered in the shadow map.
  17879. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  17880. */
  17881. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  17882. protected _bias: number;
  17883. /**
  17884. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  17885. */
  17886. get bias(): number;
  17887. /**
  17888. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  17889. */
  17890. set bias(bias: number);
  17891. protected _normalBias: number;
  17892. /**
  17893. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17894. */
  17895. get normalBias(): number;
  17896. /**
  17897. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17898. */
  17899. set normalBias(normalBias: number);
  17900. protected _blurBoxOffset: number;
  17901. /**
  17902. * Gets the blur box offset: offset applied during the blur pass.
  17903. * Only useful if useKernelBlur = false
  17904. */
  17905. get blurBoxOffset(): number;
  17906. /**
  17907. * Sets the blur box offset: offset applied during the blur pass.
  17908. * Only useful if useKernelBlur = false
  17909. */
  17910. set blurBoxOffset(value: number);
  17911. protected _blurScale: number;
  17912. /**
  17913. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  17914. * 2 means half of the size.
  17915. */
  17916. get blurScale(): number;
  17917. /**
  17918. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  17919. * 2 means half of the size.
  17920. */
  17921. set blurScale(value: number);
  17922. protected _blurKernel: number;
  17923. /**
  17924. * Gets the blur kernel: kernel size of the blur pass.
  17925. * Only useful if useKernelBlur = true
  17926. */
  17927. get blurKernel(): number;
  17928. /**
  17929. * Sets the blur kernel: kernel size of the blur pass.
  17930. * Only useful if useKernelBlur = true
  17931. */
  17932. set blurKernel(value: number);
  17933. protected _useKernelBlur: boolean;
  17934. /**
  17935. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  17936. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17937. */
  17938. get useKernelBlur(): boolean;
  17939. /**
  17940. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  17941. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17942. */
  17943. set useKernelBlur(value: boolean);
  17944. protected _depthScale: number;
  17945. /**
  17946. * Gets the depth scale used in ESM mode.
  17947. */
  17948. get depthScale(): number;
  17949. /**
  17950. * Sets the depth scale used in ESM mode.
  17951. * This can override the scale stored on the light.
  17952. */
  17953. set depthScale(value: number);
  17954. protected _validateFilter(filter: number): number;
  17955. protected _filter: number;
  17956. /**
  17957. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  17958. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17959. */
  17960. get filter(): number;
  17961. /**
  17962. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  17963. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17964. */
  17965. set filter(value: number);
  17966. /**
  17967. * Gets if the current filter is set to Poisson Sampling.
  17968. */
  17969. get usePoissonSampling(): boolean;
  17970. /**
  17971. * Sets the current filter to Poisson Sampling.
  17972. */
  17973. set usePoissonSampling(value: boolean);
  17974. /**
  17975. * Gets if the current filter is set to ESM.
  17976. */
  17977. get useExponentialShadowMap(): boolean;
  17978. /**
  17979. * Sets the current filter is to ESM.
  17980. */
  17981. set useExponentialShadowMap(value: boolean);
  17982. /**
  17983. * Gets if the current filter is set to filtered ESM.
  17984. */
  17985. get useBlurExponentialShadowMap(): boolean;
  17986. /**
  17987. * Gets if the current filter is set to filtered ESM.
  17988. */
  17989. set useBlurExponentialShadowMap(value: boolean);
  17990. /**
  17991. * Gets if the current filter is set to "close ESM" (using the inverse of the
  17992. * exponential to prevent steep falloff artifacts).
  17993. */
  17994. get useCloseExponentialShadowMap(): boolean;
  17995. /**
  17996. * Sets the current filter to "close ESM" (using the inverse of the
  17997. * exponential to prevent steep falloff artifacts).
  17998. */
  17999. set useCloseExponentialShadowMap(value: boolean);
  18000. /**
  18001. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  18002. * exponential to prevent steep falloff artifacts).
  18003. */
  18004. get useBlurCloseExponentialShadowMap(): boolean;
  18005. /**
  18006. * Sets the current filter to filtered "close ESM" (using the inverse of the
  18007. * exponential to prevent steep falloff artifacts).
  18008. */
  18009. set useBlurCloseExponentialShadowMap(value: boolean);
  18010. /**
  18011. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  18012. */
  18013. get usePercentageCloserFiltering(): boolean;
  18014. /**
  18015. * Sets the current filter to "PCF" (percentage closer filtering).
  18016. */
  18017. set usePercentageCloserFiltering(value: boolean);
  18018. protected _filteringQuality: number;
  18019. /**
  18020. * Gets the PCF or PCSS Quality.
  18021. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  18022. */
  18023. get filteringQuality(): number;
  18024. /**
  18025. * Sets the PCF or PCSS Quality.
  18026. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  18027. */
  18028. set filteringQuality(filteringQuality: number);
  18029. /**
  18030. * Gets if the current filter is set to "PCSS" (contact hardening).
  18031. */
  18032. get useContactHardeningShadow(): boolean;
  18033. /**
  18034. * Sets the current filter to "PCSS" (contact hardening).
  18035. */
  18036. set useContactHardeningShadow(value: boolean);
  18037. protected _contactHardeningLightSizeUVRatio: number;
  18038. /**
  18039. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  18040. * Using a ratio helps keeping shape stability independently of the map size.
  18041. *
  18042. * It does not account for the light projection as it was having too much
  18043. * instability during the light setup or during light position changes.
  18044. *
  18045. * Only valid if useContactHardeningShadow is true.
  18046. */
  18047. get contactHardeningLightSizeUVRatio(): number;
  18048. /**
  18049. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  18050. * Using a ratio helps keeping shape stability independently of the map size.
  18051. *
  18052. * It does not account for the light projection as it was having too much
  18053. * instability during the light setup or during light position changes.
  18054. *
  18055. * Only valid if useContactHardeningShadow is true.
  18056. */
  18057. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  18058. protected _darkness: number;
  18059. /** Gets or sets the actual darkness of a shadow */
  18060. get darkness(): number;
  18061. set darkness(value: number);
  18062. /**
  18063. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  18064. * 0 means strongest and 1 would means no shadow.
  18065. * @returns the darkness.
  18066. */
  18067. getDarkness(): number;
  18068. /**
  18069. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  18070. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  18071. * @returns the shadow generator allowing fluent coding.
  18072. */
  18073. setDarkness(darkness: number): ShadowGenerator;
  18074. protected _transparencyShadow: boolean;
  18075. /** Gets or sets the ability to have transparent shadow */
  18076. get transparencyShadow(): boolean;
  18077. set transparencyShadow(value: boolean);
  18078. /**
  18079. * Sets the ability to have transparent shadow (boolean).
  18080. * @param transparent True if transparent else False
  18081. * @returns the shadow generator allowing fluent coding
  18082. */
  18083. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  18084. /**
  18085. * Enables or disables shadows with varying strength based on the transparency
  18086. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  18087. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  18088. * mesh.visibility * alphaTexture.a
  18089. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  18090. */
  18091. enableSoftTransparentShadow: boolean;
  18092. protected _shadowMap: Nullable<RenderTargetTexture>;
  18093. protected _shadowMap2: Nullable<RenderTargetTexture>;
  18094. /**
  18095. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  18096. * @returns The render target texture if present otherwise, null
  18097. */
  18098. getShadowMap(): Nullable<RenderTargetTexture>;
  18099. /**
  18100. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  18101. * @returns The render target texture if the shadow map is present otherwise, null
  18102. */
  18103. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  18104. /**
  18105. * Gets the class name of that object
  18106. * @returns "ShadowGenerator"
  18107. */
  18108. getClassName(): string;
  18109. /**
  18110. * Helper function to add a mesh and its descendants to the list of shadow casters.
  18111. * @param mesh Mesh to add
  18112. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  18113. * @returns the Shadow Generator itself
  18114. */
  18115. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  18116. /**
  18117. * Helper function to remove a mesh and its descendants from the list of shadow casters
  18118. * @param mesh Mesh to remove
  18119. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  18120. * @returns the Shadow Generator itself
  18121. */
  18122. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  18123. /**
  18124. * Controls the extent to which the shadows fade out at the edge of the frustum
  18125. */
  18126. frustumEdgeFalloff: number;
  18127. protected _light: IShadowLight;
  18128. /**
  18129. * Returns the associated light object.
  18130. * @returns the light generating the shadow
  18131. */
  18132. getLight(): IShadowLight;
  18133. /**
  18134. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  18135. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  18136. * It might on the other hand introduce peter panning.
  18137. */
  18138. forceBackFacesOnly: boolean;
  18139. protected _scene: Scene;
  18140. protected _lightDirection: Vector3;
  18141. protected _effect: Effect;
  18142. protected _viewMatrix: Matrix;
  18143. protected _projectionMatrix: Matrix;
  18144. protected _transformMatrix: Matrix;
  18145. protected _cachedPosition: Vector3;
  18146. protected _cachedDirection: Vector3;
  18147. protected _cachedDefines: string;
  18148. protected _currentRenderID: number;
  18149. protected _boxBlurPostprocess: Nullable<PostProcess>;
  18150. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  18151. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  18152. protected _blurPostProcesses: PostProcess[];
  18153. protected _mapSize: number;
  18154. protected _currentFaceIndex: number;
  18155. protected _currentFaceIndexCache: number;
  18156. protected _textureType: number;
  18157. protected _defaultTextureMatrix: Matrix;
  18158. protected _storedUniqueId: Nullable<number>;
  18159. /** @hidden */
  18160. static _SceneComponentInitialization: (scene: Scene) => void;
  18161. /**
  18162. * Creates a ShadowGenerator object.
  18163. * A ShadowGenerator is the required tool to use the shadows.
  18164. * Each light casting shadows needs to use its own ShadowGenerator.
  18165. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  18166. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  18167. * @param light The light object generating the shadows.
  18168. * @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.
  18169. */
  18170. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  18171. protected _initializeGenerator(): void;
  18172. protected _createTargetRenderTexture(): void;
  18173. protected _initializeShadowMap(): void;
  18174. protected _initializeBlurRTTAndPostProcesses(): void;
  18175. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  18176. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  18177. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  18178. protected _applyFilterValues(): void;
  18179. /**
  18180. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18181. * @param onCompiled Callback triggered at the and of the effects compilation
  18182. * @param options Sets of optional options forcing the compilation with different modes
  18183. */
  18184. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  18185. useInstances: boolean;
  18186. }>): void;
  18187. /**
  18188. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18189. * @param options Sets of optional options forcing the compilation with different modes
  18190. * @returns A promise that resolves when the compilation completes
  18191. */
  18192. forceCompilationAsync(options?: Partial<{
  18193. useInstances: boolean;
  18194. }>): Promise<void>;
  18195. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  18196. private _prepareShadowDefines;
  18197. /**
  18198. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  18199. * @param subMesh The submesh we want to render in the shadow map
  18200. * @param useInstances Defines wether will draw in the map using instances
  18201. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  18202. * @returns true if ready otherwise, false
  18203. */
  18204. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  18205. /**
  18206. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  18207. * @param defines Defines of the material we want to update
  18208. * @param lightIndex Index of the light in the enabled light list of the material
  18209. */
  18210. prepareDefines(defines: any, lightIndex: number): void;
  18211. /**
  18212. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  18213. * defined in the generator but impacting the effect).
  18214. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  18215. * @param effect The effect we are binfing the information for
  18216. */
  18217. bindShadowLight(lightIndex: string, effect: Effect): void;
  18218. /**
  18219. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  18220. * (eq to shadow prjection matrix * light transform matrix)
  18221. * @returns The transform matrix used to create the shadow map
  18222. */
  18223. getTransformMatrix(): Matrix;
  18224. /**
  18225. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  18226. * Cube and 2D textures for instance.
  18227. */
  18228. recreateShadowMap(): void;
  18229. protected _disposeBlurPostProcesses(): void;
  18230. protected _disposeRTTandPostProcesses(): void;
  18231. /**
  18232. * Disposes the ShadowGenerator.
  18233. * Returns nothing.
  18234. */
  18235. dispose(): void;
  18236. /**
  18237. * Serializes the shadow generator setup to a json object.
  18238. * @returns The serialized JSON object
  18239. */
  18240. serialize(): any;
  18241. /**
  18242. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  18243. * @param parsedShadowGenerator The JSON object to parse
  18244. * @param scene The scene to create the shadow map for
  18245. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  18246. * @returns The parsed shadow generator
  18247. */
  18248. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  18249. }
  18250. }
  18251. declare module "babylonjs/Lights/light" {
  18252. import { Nullable } from "babylonjs/types";
  18253. import { Scene } from "babylonjs/scene";
  18254. import { Vector3 } from "babylonjs/Maths/math.vector";
  18255. import { Color3 } from "babylonjs/Maths/math.color";
  18256. import { Node } from "babylonjs/node";
  18257. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18258. import { Effect } from "babylonjs/Materials/effect";
  18259. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  18260. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  18261. /**
  18262. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  18263. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  18264. * 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.
  18265. */
  18266. export abstract class Light extends Node {
  18267. /**
  18268. * Falloff Default: light is falling off following the material specification:
  18269. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  18270. */
  18271. static readonly FALLOFF_DEFAULT: number;
  18272. /**
  18273. * Falloff Physical: light is falling off following the inverse squared distance law.
  18274. */
  18275. static readonly FALLOFF_PHYSICAL: number;
  18276. /**
  18277. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  18278. * to enhance interoperability with other engines.
  18279. */
  18280. static readonly FALLOFF_GLTF: number;
  18281. /**
  18282. * Falloff Standard: light is falling off like in the standard material
  18283. * to enhance interoperability with other materials.
  18284. */
  18285. static readonly FALLOFF_STANDARD: number;
  18286. /**
  18287. * If every light affecting the material is in this lightmapMode,
  18288. * material.lightmapTexture adds or multiplies
  18289. * (depends on material.useLightmapAsShadowmap)
  18290. * after every other light calculations.
  18291. */
  18292. static readonly LIGHTMAP_DEFAULT: number;
  18293. /**
  18294. * material.lightmapTexture as only diffuse lighting from this light
  18295. * adds only specular lighting from this light
  18296. * adds dynamic shadows
  18297. */
  18298. static readonly LIGHTMAP_SPECULAR: number;
  18299. /**
  18300. * material.lightmapTexture as only lighting
  18301. * no light calculation from this light
  18302. * only adds dynamic shadows from this light
  18303. */
  18304. static readonly LIGHTMAP_SHADOWSONLY: number;
  18305. /**
  18306. * Each light type uses the default quantity according to its type:
  18307. * point/spot lights use luminous intensity
  18308. * directional lights use illuminance
  18309. */
  18310. static readonly INTENSITYMODE_AUTOMATIC: number;
  18311. /**
  18312. * lumen (lm)
  18313. */
  18314. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  18315. /**
  18316. * candela (lm/sr)
  18317. */
  18318. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  18319. /**
  18320. * lux (lm/m^2)
  18321. */
  18322. static readonly INTENSITYMODE_ILLUMINANCE: number;
  18323. /**
  18324. * nit (cd/m^2)
  18325. */
  18326. static readonly INTENSITYMODE_LUMINANCE: number;
  18327. /**
  18328. * Light type const id of the point light.
  18329. */
  18330. static readonly LIGHTTYPEID_POINTLIGHT: number;
  18331. /**
  18332. * Light type const id of the directional light.
  18333. */
  18334. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  18335. /**
  18336. * Light type const id of the spot light.
  18337. */
  18338. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  18339. /**
  18340. * Light type const id of the hemispheric light.
  18341. */
  18342. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  18343. /**
  18344. * Diffuse gives the basic color to an object.
  18345. */
  18346. diffuse: Color3;
  18347. /**
  18348. * Specular produces a highlight color on an object.
  18349. * Note: This is note affecting PBR materials.
  18350. */
  18351. specular: Color3;
  18352. /**
  18353. * Defines the falloff type for this light. This lets overrriding how punctual light are
  18354. * falling off base on range or angle.
  18355. * This can be set to any values in Light.FALLOFF_x.
  18356. *
  18357. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  18358. * other types of materials.
  18359. */
  18360. falloffType: number;
  18361. /**
  18362. * Strength of the light.
  18363. * Note: By default it is define in the framework own unit.
  18364. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  18365. */
  18366. intensity: number;
  18367. private _range;
  18368. protected _inverseSquaredRange: number;
  18369. /**
  18370. * Defines how far from the source the light is impacting in scene units.
  18371. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18372. */
  18373. get range(): number;
  18374. /**
  18375. * Defines how far from the source the light is impacting in scene units.
  18376. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18377. */
  18378. set range(value: number);
  18379. /**
  18380. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  18381. * of light.
  18382. */
  18383. private _photometricScale;
  18384. private _intensityMode;
  18385. /**
  18386. * Gets the photometric scale used to interpret the intensity.
  18387. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18388. */
  18389. get intensityMode(): number;
  18390. /**
  18391. * Sets the photometric scale used to interpret the intensity.
  18392. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18393. */
  18394. set intensityMode(value: number);
  18395. private _radius;
  18396. /**
  18397. * Gets the light radius used by PBR Materials to simulate soft area lights.
  18398. */
  18399. get radius(): number;
  18400. /**
  18401. * sets the light radius used by PBR Materials to simulate soft area lights.
  18402. */
  18403. set radius(value: number);
  18404. private _renderPriority;
  18405. /**
  18406. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  18407. * exceeding the number allowed of the materials.
  18408. */
  18409. renderPriority: number;
  18410. private _shadowEnabled;
  18411. /**
  18412. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18413. * the current shadow generator.
  18414. */
  18415. get shadowEnabled(): boolean;
  18416. /**
  18417. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18418. * the current shadow generator.
  18419. */
  18420. set shadowEnabled(value: boolean);
  18421. private _includedOnlyMeshes;
  18422. /**
  18423. * Gets the only meshes impacted by this light.
  18424. */
  18425. get includedOnlyMeshes(): AbstractMesh[];
  18426. /**
  18427. * Sets the only meshes impacted by this light.
  18428. */
  18429. set includedOnlyMeshes(value: AbstractMesh[]);
  18430. private _excludedMeshes;
  18431. /**
  18432. * Gets the meshes not impacted by this light.
  18433. */
  18434. get excludedMeshes(): AbstractMesh[];
  18435. /**
  18436. * Sets the meshes not impacted by this light.
  18437. */
  18438. set excludedMeshes(value: AbstractMesh[]);
  18439. private _excludeWithLayerMask;
  18440. /**
  18441. * Gets the layer id use to find what meshes are not impacted by the light.
  18442. * Inactive if 0
  18443. */
  18444. get excludeWithLayerMask(): number;
  18445. /**
  18446. * Sets the layer id use to find what meshes are not impacted by the light.
  18447. * Inactive if 0
  18448. */
  18449. set excludeWithLayerMask(value: number);
  18450. private _includeOnlyWithLayerMask;
  18451. /**
  18452. * Gets the layer id use to find what meshes are impacted by the light.
  18453. * Inactive if 0
  18454. */
  18455. get includeOnlyWithLayerMask(): number;
  18456. /**
  18457. * Sets the layer id use to find what meshes are impacted by the light.
  18458. * Inactive if 0
  18459. */
  18460. set includeOnlyWithLayerMask(value: number);
  18461. private _lightmapMode;
  18462. /**
  18463. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18464. */
  18465. get lightmapMode(): number;
  18466. /**
  18467. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18468. */
  18469. set lightmapMode(value: number);
  18470. /**
  18471. * Shadow generator associted to the light.
  18472. * @hidden Internal use only.
  18473. */
  18474. _shadowGenerator: Nullable<IShadowGenerator>;
  18475. /**
  18476. * @hidden Internal use only.
  18477. */
  18478. _excludedMeshesIds: string[];
  18479. /**
  18480. * @hidden Internal use only.
  18481. */
  18482. _includedOnlyMeshesIds: string[];
  18483. /**
  18484. * The current light unifom buffer.
  18485. * @hidden Internal use only.
  18486. */
  18487. _uniformBuffer: UniformBuffer;
  18488. /** @hidden */
  18489. _renderId: number;
  18490. /**
  18491. * Creates a Light object in the scene.
  18492. * Documentation : https://doc.babylonjs.com/babylon101/lights
  18493. * @param name The firendly name of the light
  18494. * @param scene The scene the light belongs too
  18495. */
  18496. constructor(name: string, scene: Scene);
  18497. protected abstract _buildUniformLayout(): void;
  18498. /**
  18499. * Sets the passed Effect "effect" with the Light information.
  18500. * @param effect The effect to update
  18501. * @param lightIndex The index of the light in the effect to update
  18502. * @returns The light
  18503. */
  18504. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  18505. /**
  18506. * Sets the passed Effect "effect" with the Light textures.
  18507. * @param effect The effect to update
  18508. * @param lightIndex The index of the light in the effect to update
  18509. * @returns The light
  18510. */
  18511. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  18512. /**
  18513. * Binds the lights information from the scene to the effect for the given mesh.
  18514. * @param lightIndex Light index
  18515. * @param scene The scene where the light belongs to
  18516. * @param effect The effect we are binding the data to
  18517. * @param useSpecular Defines if specular is supported
  18518. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  18519. */
  18520. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  18521. /**
  18522. * Sets the passed Effect "effect" with the Light information.
  18523. * @param effect The effect to update
  18524. * @param lightDataUniformName The uniform used to store light data (position or direction)
  18525. * @returns The light
  18526. */
  18527. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  18528. /**
  18529. * Returns the string "Light".
  18530. * @returns the class name
  18531. */
  18532. getClassName(): string;
  18533. /** @hidden */
  18534. readonly _isLight: boolean;
  18535. /**
  18536. * Converts the light information to a readable string for debug purpose.
  18537. * @param fullDetails Supports for multiple levels of logging within scene loading
  18538. * @returns the human readable light info
  18539. */
  18540. toString(fullDetails?: boolean): string;
  18541. /** @hidden */
  18542. protected _syncParentEnabledState(): void;
  18543. /**
  18544. * Set the enabled state of this node.
  18545. * @param value - the new enabled state
  18546. */
  18547. setEnabled(value: boolean): void;
  18548. /**
  18549. * Returns the Light associated shadow generator if any.
  18550. * @return the associated shadow generator.
  18551. */
  18552. getShadowGenerator(): Nullable<IShadowGenerator>;
  18553. /**
  18554. * Returns a Vector3, the absolute light position in the World.
  18555. * @returns the world space position of the light
  18556. */
  18557. getAbsolutePosition(): Vector3;
  18558. /**
  18559. * Specifies if the light will affect the passed mesh.
  18560. * @param mesh The mesh to test against the light
  18561. * @return true the mesh is affected otherwise, false.
  18562. */
  18563. canAffectMesh(mesh: AbstractMesh): boolean;
  18564. /**
  18565. * Sort function to order lights for rendering.
  18566. * @param a First Light object to compare to second.
  18567. * @param b Second Light object to compare first.
  18568. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  18569. */
  18570. static CompareLightsPriority(a: Light, b: Light): number;
  18571. /**
  18572. * Releases resources associated with this node.
  18573. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  18574. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  18575. */
  18576. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18577. /**
  18578. * Returns the light type ID (integer).
  18579. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  18580. */
  18581. getTypeID(): number;
  18582. /**
  18583. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  18584. * @returns the scaled intensity in intensity mode unit
  18585. */
  18586. getScaledIntensity(): number;
  18587. /**
  18588. * Returns a new Light object, named "name", from the current one.
  18589. * @param name The name of the cloned light
  18590. * @param newParent The parent of this light, if it has one
  18591. * @returns the new created light
  18592. */
  18593. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  18594. /**
  18595. * Serializes the current light into a Serialization object.
  18596. * @returns the serialized object.
  18597. */
  18598. serialize(): any;
  18599. /**
  18600. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  18601. * This new light is named "name" and added to the passed scene.
  18602. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  18603. * @param name The friendly name of the light
  18604. * @param scene The scene the new light will belong to
  18605. * @returns the constructor function
  18606. */
  18607. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  18608. /**
  18609. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  18610. * @param parsedLight The JSON representation of the light
  18611. * @param scene The scene to create the parsed light in
  18612. * @returns the created light after parsing
  18613. */
  18614. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  18615. private _hookArrayForExcluded;
  18616. private _hookArrayForIncludedOnly;
  18617. private _resyncMeshes;
  18618. /**
  18619. * Forces the meshes to update their light related information in their rendering used effects
  18620. * @hidden Internal Use Only
  18621. */
  18622. _markMeshesAsLightDirty(): void;
  18623. /**
  18624. * Recomputes the cached photometric scale if needed.
  18625. */
  18626. private _computePhotometricScale;
  18627. /**
  18628. * Returns the Photometric Scale according to the light type and intensity mode.
  18629. */
  18630. private _getPhotometricScale;
  18631. /**
  18632. * Reorder the light in the scene according to their defined priority.
  18633. * @hidden Internal Use Only
  18634. */
  18635. _reorderLightsInScene(): void;
  18636. /**
  18637. * Prepares the list of defines specific to the light type.
  18638. * @param defines the list of defines
  18639. * @param lightIndex defines the index of the light for the effect
  18640. */
  18641. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  18642. }
  18643. }
  18644. declare module "babylonjs/Cameras/targetCamera" {
  18645. import { Nullable } from "babylonjs/types";
  18646. import { Camera } from "babylonjs/Cameras/camera";
  18647. import { Scene } from "babylonjs/scene";
  18648. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  18649. /**
  18650. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  18651. * This is the base of the follow, arc rotate cameras and Free camera
  18652. * @see http://doc.babylonjs.com/features/cameras
  18653. */
  18654. export class TargetCamera extends Camera {
  18655. private static _RigCamTransformMatrix;
  18656. private static _TargetTransformMatrix;
  18657. private static _TargetFocalPoint;
  18658. /**
  18659. * Define the current direction the camera is moving to
  18660. */
  18661. cameraDirection: Vector3;
  18662. /**
  18663. * Define the current rotation the camera is rotating to
  18664. */
  18665. cameraRotation: Vector2;
  18666. /**
  18667. * When set, the up vector of the camera will be updated by the rotation of the camera
  18668. */
  18669. updateUpVectorFromRotation: boolean;
  18670. private _tmpQuaternion;
  18671. /**
  18672. * Define the current rotation of the camera
  18673. */
  18674. rotation: Vector3;
  18675. /**
  18676. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  18677. */
  18678. rotationQuaternion: Quaternion;
  18679. /**
  18680. * Define the current speed of the camera
  18681. */
  18682. speed: number;
  18683. /**
  18684. * Add constraint to the camera to prevent it to move freely in all directions and
  18685. * around all axis.
  18686. */
  18687. noRotationConstraint: boolean;
  18688. /**
  18689. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  18690. * panning
  18691. */
  18692. invertRotation: boolean;
  18693. /**
  18694. * Speed multiplier for inverse camera panning
  18695. */
  18696. inverseRotationSpeed: number;
  18697. /**
  18698. * Define the current target of the camera as an object or a position.
  18699. */
  18700. lockedTarget: any;
  18701. /** @hidden */
  18702. _currentTarget: Vector3;
  18703. /** @hidden */
  18704. _initialFocalDistance: number;
  18705. /** @hidden */
  18706. _viewMatrix: Matrix;
  18707. /** @hidden */
  18708. _camMatrix: Matrix;
  18709. /** @hidden */
  18710. _cameraTransformMatrix: Matrix;
  18711. /** @hidden */
  18712. _cameraRotationMatrix: Matrix;
  18713. /** @hidden */
  18714. _referencePoint: Vector3;
  18715. /** @hidden */
  18716. _transformedReferencePoint: Vector3;
  18717. protected _globalCurrentTarget: Vector3;
  18718. protected _globalCurrentUpVector: Vector3;
  18719. /** @hidden */
  18720. _reset: () => void;
  18721. private _defaultUp;
  18722. /**
  18723. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  18724. * This is the base of the follow, arc rotate cameras and Free camera
  18725. * @see http://doc.babylonjs.com/features/cameras
  18726. * @param name Defines the name of the camera in the scene
  18727. * @param position Defines the start position of the camera in the scene
  18728. * @param scene Defines the scene the camera belongs to
  18729. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18730. */
  18731. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18732. /**
  18733. * Gets the position in front of the camera at a given distance.
  18734. * @param distance The distance from the camera we want the position to be
  18735. * @returns the position
  18736. */
  18737. getFrontPosition(distance: number): Vector3;
  18738. /** @hidden */
  18739. _getLockedTargetPosition(): Nullable<Vector3>;
  18740. private _storedPosition;
  18741. private _storedRotation;
  18742. private _storedRotationQuaternion;
  18743. /**
  18744. * Store current camera state of the camera (fov, position, rotation, etc..)
  18745. * @returns the camera
  18746. */
  18747. storeState(): Camera;
  18748. /**
  18749. * Restored camera state. You must call storeState() first
  18750. * @returns whether it was successful or not
  18751. * @hidden
  18752. */
  18753. _restoreStateValues(): boolean;
  18754. /** @hidden */
  18755. _initCache(): void;
  18756. /** @hidden */
  18757. _updateCache(ignoreParentClass?: boolean): void;
  18758. /** @hidden */
  18759. _isSynchronizedViewMatrix(): boolean;
  18760. /** @hidden */
  18761. _computeLocalCameraSpeed(): number;
  18762. /**
  18763. * Defines the target the camera should look at.
  18764. * @param target Defines the new target as a Vector or a mesh
  18765. */
  18766. setTarget(target: Vector3): void;
  18767. /**
  18768. * Return the current target position of the camera. This value is expressed in local space.
  18769. * @returns the target position
  18770. */
  18771. getTarget(): Vector3;
  18772. /** @hidden */
  18773. _decideIfNeedsToMove(): boolean;
  18774. /** @hidden */
  18775. _updatePosition(): void;
  18776. /** @hidden */
  18777. _checkInputs(): void;
  18778. protected _updateCameraRotationMatrix(): void;
  18779. /**
  18780. * 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)
  18781. * @returns the current camera
  18782. */
  18783. private _rotateUpVectorWithCameraRotationMatrix;
  18784. private _cachedRotationZ;
  18785. private _cachedQuaternionRotationZ;
  18786. /** @hidden */
  18787. _getViewMatrix(): Matrix;
  18788. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  18789. /**
  18790. * @hidden
  18791. */
  18792. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  18793. /**
  18794. * @hidden
  18795. */
  18796. _updateRigCameras(): void;
  18797. private _getRigCamPositionAndTarget;
  18798. /**
  18799. * Gets the current object class name.
  18800. * @return the class name
  18801. */
  18802. getClassName(): string;
  18803. }
  18804. }
  18805. declare module "babylonjs/Events/keyboardEvents" {
  18806. /**
  18807. * Gather the list of keyboard event types as constants.
  18808. */
  18809. export class KeyboardEventTypes {
  18810. /**
  18811. * The keydown event is fired when a key becomes active (pressed).
  18812. */
  18813. static readonly KEYDOWN: number;
  18814. /**
  18815. * The keyup event is fired when a key has been released.
  18816. */
  18817. static readonly KEYUP: number;
  18818. }
  18819. /**
  18820. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18821. */
  18822. export class KeyboardInfo {
  18823. /**
  18824. * Defines the type of event (KeyboardEventTypes)
  18825. */
  18826. type: number;
  18827. /**
  18828. * Defines the related dom event
  18829. */
  18830. event: KeyboardEvent;
  18831. /**
  18832. * Instantiates a new keyboard info.
  18833. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18834. * @param type Defines the type of event (KeyboardEventTypes)
  18835. * @param event Defines the related dom event
  18836. */
  18837. constructor(
  18838. /**
  18839. * Defines the type of event (KeyboardEventTypes)
  18840. */
  18841. type: number,
  18842. /**
  18843. * Defines the related dom event
  18844. */
  18845. event: KeyboardEvent);
  18846. }
  18847. /**
  18848. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18849. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  18850. */
  18851. export class KeyboardInfoPre extends KeyboardInfo {
  18852. /**
  18853. * Defines the type of event (KeyboardEventTypes)
  18854. */
  18855. type: number;
  18856. /**
  18857. * Defines the related dom event
  18858. */
  18859. event: KeyboardEvent;
  18860. /**
  18861. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  18862. */
  18863. skipOnPointerObservable: boolean;
  18864. /**
  18865. * Instantiates a new keyboard pre info.
  18866. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18867. * @param type Defines the type of event (KeyboardEventTypes)
  18868. * @param event Defines the related dom event
  18869. */
  18870. constructor(
  18871. /**
  18872. * Defines the type of event (KeyboardEventTypes)
  18873. */
  18874. type: number,
  18875. /**
  18876. * Defines the related dom event
  18877. */
  18878. event: KeyboardEvent);
  18879. }
  18880. }
  18881. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  18882. import { Nullable } from "babylonjs/types";
  18883. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  18884. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  18885. /**
  18886. * Manage the keyboard inputs to control the movement of a free camera.
  18887. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18888. */
  18889. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  18890. /**
  18891. * Defines the camera the input is attached to.
  18892. */
  18893. camera: FreeCamera;
  18894. /**
  18895. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18896. */
  18897. keysUp: number[];
  18898. /**
  18899. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  18900. */
  18901. keysUpward: number[];
  18902. /**
  18903. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18904. */
  18905. keysDown: number[];
  18906. /**
  18907. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  18908. */
  18909. keysDownward: number[];
  18910. /**
  18911. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18912. */
  18913. keysLeft: number[];
  18914. /**
  18915. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18916. */
  18917. keysRight: number[];
  18918. private _keys;
  18919. private _onCanvasBlurObserver;
  18920. private _onKeyboardObserver;
  18921. private _engine;
  18922. private _scene;
  18923. /**
  18924. * Attach the input controls to a specific dom element to get the input from.
  18925. * @param element Defines the element the controls should be listened from
  18926. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18927. */
  18928. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18929. /**
  18930. * Detach the current controls from the specified dom element.
  18931. * @param element Defines the element to stop listening the inputs from
  18932. */
  18933. detachControl(element: Nullable<HTMLElement>): void;
  18934. /**
  18935. * Update the current camera state depending on the inputs that have been used this frame.
  18936. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18937. */
  18938. checkInputs(): void;
  18939. /**
  18940. * Gets the class name of the current intput.
  18941. * @returns the class name
  18942. */
  18943. getClassName(): string;
  18944. /** @hidden */
  18945. _onLostFocus(): void;
  18946. /**
  18947. * Get the friendly name associated with the input class.
  18948. * @returns the input friendly name
  18949. */
  18950. getSimpleName(): string;
  18951. }
  18952. }
  18953. declare module "babylonjs/Events/pointerEvents" {
  18954. import { Nullable } from "babylonjs/types";
  18955. import { Vector2 } from "babylonjs/Maths/math.vector";
  18956. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  18957. import { Ray } from "babylonjs/Culling/ray";
  18958. /**
  18959. * Gather the list of pointer event types as constants.
  18960. */
  18961. export class PointerEventTypes {
  18962. /**
  18963. * 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.
  18964. */
  18965. static readonly POINTERDOWN: number;
  18966. /**
  18967. * The pointerup event is fired when a pointer is no longer active.
  18968. */
  18969. static readonly POINTERUP: number;
  18970. /**
  18971. * The pointermove event is fired when a pointer changes coordinates.
  18972. */
  18973. static readonly POINTERMOVE: number;
  18974. /**
  18975. * The pointerwheel event is fired when a mouse wheel has been rotated.
  18976. */
  18977. static readonly POINTERWHEEL: number;
  18978. /**
  18979. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  18980. */
  18981. static readonly POINTERPICK: number;
  18982. /**
  18983. * The pointertap event is fired when a the object has been touched and released without drag.
  18984. */
  18985. static readonly POINTERTAP: number;
  18986. /**
  18987. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  18988. */
  18989. static readonly POINTERDOUBLETAP: number;
  18990. }
  18991. /**
  18992. * Base class of pointer info types.
  18993. */
  18994. export class PointerInfoBase {
  18995. /**
  18996. * Defines the type of event (PointerEventTypes)
  18997. */
  18998. type: number;
  18999. /**
  19000. * Defines the related dom event
  19001. */
  19002. event: PointerEvent | MouseWheelEvent;
  19003. /**
  19004. * Instantiates the base class of pointers info.
  19005. * @param type Defines the type of event (PointerEventTypes)
  19006. * @param event Defines the related dom event
  19007. */
  19008. constructor(
  19009. /**
  19010. * Defines the type of event (PointerEventTypes)
  19011. */
  19012. type: number,
  19013. /**
  19014. * Defines the related dom event
  19015. */
  19016. event: PointerEvent | MouseWheelEvent);
  19017. }
  19018. /**
  19019. * This class is used to store pointer related info for the onPrePointerObservable event.
  19020. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  19021. */
  19022. export class PointerInfoPre extends PointerInfoBase {
  19023. /**
  19024. * Ray from a pointer if availible (eg. 6dof controller)
  19025. */
  19026. ray: Nullable<Ray>;
  19027. /**
  19028. * Defines the local position of the pointer on the canvas.
  19029. */
  19030. localPosition: Vector2;
  19031. /**
  19032. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  19033. */
  19034. skipOnPointerObservable: boolean;
  19035. /**
  19036. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  19037. * @param type Defines the type of event (PointerEventTypes)
  19038. * @param event Defines the related dom event
  19039. * @param localX Defines the local x coordinates of the pointer when the event occured
  19040. * @param localY Defines the local y coordinates of the pointer when the event occured
  19041. */
  19042. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  19043. }
  19044. /**
  19045. * This type contains all the data related to a pointer event in Babylon.js.
  19046. * 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.
  19047. */
  19048. export class PointerInfo extends PointerInfoBase {
  19049. /**
  19050. * Defines the picking info associated to the info (if any)\
  19051. */
  19052. pickInfo: Nullable<PickingInfo>;
  19053. /**
  19054. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  19055. * @param type Defines the type of event (PointerEventTypes)
  19056. * @param event Defines the related dom event
  19057. * @param pickInfo Defines the picking info associated to the info (if any)\
  19058. */
  19059. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  19060. /**
  19061. * Defines the picking info associated to the info (if any)\
  19062. */
  19063. pickInfo: Nullable<PickingInfo>);
  19064. }
  19065. /**
  19066. * Data relating to a touch event on the screen.
  19067. */
  19068. export interface PointerTouch {
  19069. /**
  19070. * X coordinate of touch.
  19071. */
  19072. x: number;
  19073. /**
  19074. * Y coordinate of touch.
  19075. */
  19076. y: number;
  19077. /**
  19078. * Id of touch. Unique for each finger.
  19079. */
  19080. pointerId: number;
  19081. /**
  19082. * Event type passed from DOM.
  19083. */
  19084. type: any;
  19085. }
  19086. }
  19087. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  19088. import { Observable } from "babylonjs/Misc/observable";
  19089. import { Nullable } from "babylonjs/types";
  19090. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19091. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19092. /**
  19093. * Manage the mouse inputs to control the movement of a free camera.
  19094. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  19095. */
  19096. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  19097. /**
  19098. * Define if touch is enabled in the mouse input
  19099. */
  19100. touchEnabled: boolean;
  19101. /**
  19102. * Defines the camera the input is attached to.
  19103. */
  19104. camera: FreeCamera;
  19105. /**
  19106. * Defines the buttons associated with the input to handle camera move.
  19107. */
  19108. buttons: number[];
  19109. /**
  19110. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  19111. */
  19112. angularSensibility: number;
  19113. private _pointerInput;
  19114. private _onMouseMove;
  19115. private _observer;
  19116. private previousPosition;
  19117. /**
  19118. * Observable for when a pointer move event occurs containing the move offset
  19119. */
  19120. onPointerMovedObservable: Observable<{
  19121. offsetX: number;
  19122. offsetY: number;
  19123. }>;
  19124. /**
  19125. * @hidden
  19126. * If the camera should be rotated automatically based on pointer movement
  19127. */
  19128. _allowCameraRotation: boolean;
  19129. /**
  19130. * Manage the mouse inputs to control the movement of a free camera.
  19131. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  19132. * @param touchEnabled Defines if touch is enabled or not
  19133. */
  19134. constructor(
  19135. /**
  19136. * Define if touch is enabled in the mouse input
  19137. */
  19138. touchEnabled?: boolean);
  19139. /**
  19140. * Attach the input controls to a specific dom element to get the input from.
  19141. * @param element Defines the element the controls should be listened from
  19142. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19143. */
  19144. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19145. /**
  19146. * Called on JS contextmenu event.
  19147. * Override this method to provide functionality.
  19148. */
  19149. protected onContextMenu(evt: PointerEvent): void;
  19150. /**
  19151. * Detach the current controls from the specified dom element.
  19152. * @param element Defines the element to stop listening the inputs from
  19153. */
  19154. detachControl(element: Nullable<HTMLElement>): void;
  19155. /**
  19156. * Gets the class name of the current intput.
  19157. * @returns the class name
  19158. */
  19159. getClassName(): string;
  19160. /**
  19161. * Get the friendly name associated with the input class.
  19162. * @returns the input friendly name
  19163. */
  19164. getSimpleName(): string;
  19165. }
  19166. }
  19167. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  19168. import { Nullable } from "babylonjs/types";
  19169. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19170. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19171. /**
  19172. * Manage the touch inputs to control the movement of a free camera.
  19173. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  19174. */
  19175. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  19176. /**
  19177. * Defines the camera the input is attached to.
  19178. */
  19179. camera: FreeCamera;
  19180. /**
  19181. * Defines the touch sensibility for rotation.
  19182. * The higher the faster.
  19183. */
  19184. touchAngularSensibility: number;
  19185. /**
  19186. * Defines the touch sensibility for move.
  19187. * The higher the faster.
  19188. */
  19189. touchMoveSensibility: number;
  19190. private _offsetX;
  19191. private _offsetY;
  19192. private _pointerPressed;
  19193. private _pointerInput;
  19194. private _observer;
  19195. private _onLostFocus;
  19196. /**
  19197. * Attach the input controls to a specific dom element to get the input from.
  19198. * @param element Defines the element the controls should be listened from
  19199. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19200. */
  19201. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19202. /**
  19203. * Detach the current controls from the specified dom element.
  19204. * @param element Defines the element to stop listening the inputs from
  19205. */
  19206. detachControl(element: Nullable<HTMLElement>): void;
  19207. /**
  19208. * Update the current camera state depending on the inputs that have been used this frame.
  19209. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  19210. */
  19211. checkInputs(): void;
  19212. /**
  19213. * Gets the class name of the current intput.
  19214. * @returns the class name
  19215. */
  19216. getClassName(): string;
  19217. /**
  19218. * Get the friendly name associated with the input class.
  19219. * @returns the input friendly name
  19220. */
  19221. getSimpleName(): string;
  19222. }
  19223. }
  19224. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  19225. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19226. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  19227. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  19228. import { Nullable } from "babylonjs/types";
  19229. /**
  19230. * Default Inputs manager for the FreeCamera.
  19231. * It groups all the default supported inputs for ease of use.
  19232. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  19233. */
  19234. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  19235. /**
  19236. * @hidden
  19237. */
  19238. _mouseInput: Nullable<FreeCameraMouseInput>;
  19239. /**
  19240. * Instantiates a new FreeCameraInputsManager.
  19241. * @param camera Defines the camera the inputs belong to
  19242. */
  19243. constructor(camera: FreeCamera);
  19244. /**
  19245. * Add keyboard input support to the input manager.
  19246. * @returns the current input manager
  19247. */
  19248. addKeyboard(): FreeCameraInputsManager;
  19249. /**
  19250. * Add mouse input support to the input manager.
  19251. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  19252. * @returns the current input manager
  19253. */
  19254. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  19255. /**
  19256. * Removes the mouse input support from the manager
  19257. * @returns the current input manager
  19258. */
  19259. removeMouse(): FreeCameraInputsManager;
  19260. /**
  19261. * Add touch input support to the input manager.
  19262. * @returns the current input manager
  19263. */
  19264. addTouch(): FreeCameraInputsManager;
  19265. /**
  19266. * Remove all attached input methods from a camera
  19267. */
  19268. clear(): void;
  19269. }
  19270. }
  19271. declare module "babylonjs/Cameras/freeCamera" {
  19272. import { Vector3 } from "babylonjs/Maths/math.vector";
  19273. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19274. import { Scene } from "babylonjs/scene";
  19275. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  19276. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  19277. /**
  19278. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19279. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  19280. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  19281. */
  19282. export class FreeCamera extends TargetCamera {
  19283. /**
  19284. * Define the collision ellipsoid of the camera.
  19285. * This is helpful to simulate a camera body like the player body around the camera
  19286. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  19287. */
  19288. ellipsoid: Vector3;
  19289. /**
  19290. * Define an offset for the position of the ellipsoid around the camera.
  19291. * This can be helpful to determine the center of the body near the gravity center of the body
  19292. * instead of its head.
  19293. */
  19294. ellipsoidOffset: Vector3;
  19295. /**
  19296. * Enable or disable collisions of the camera with the rest of the scene objects.
  19297. */
  19298. checkCollisions: boolean;
  19299. /**
  19300. * Enable or disable gravity on the camera.
  19301. */
  19302. applyGravity: boolean;
  19303. /**
  19304. * Define the input manager associated to the camera.
  19305. */
  19306. inputs: FreeCameraInputsManager;
  19307. /**
  19308. * Gets the input sensibility for a mouse input. (default is 2000.0)
  19309. * Higher values reduce sensitivity.
  19310. */
  19311. get angularSensibility(): number;
  19312. /**
  19313. * Sets the input sensibility for a mouse input. (default is 2000.0)
  19314. * Higher values reduce sensitivity.
  19315. */
  19316. set angularSensibility(value: number);
  19317. /**
  19318. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  19319. */
  19320. get keysUp(): number[];
  19321. set keysUp(value: number[]);
  19322. /**
  19323. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  19324. */
  19325. get keysUpward(): number[];
  19326. set keysUpward(value: number[]);
  19327. /**
  19328. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  19329. */
  19330. get keysDown(): number[];
  19331. set keysDown(value: number[]);
  19332. /**
  19333. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  19334. */
  19335. get keysDownward(): number[];
  19336. set keysDownward(value: number[]);
  19337. /**
  19338. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  19339. */
  19340. get keysLeft(): number[];
  19341. set keysLeft(value: number[]);
  19342. /**
  19343. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  19344. */
  19345. get keysRight(): number[];
  19346. set keysRight(value: number[]);
  19347. /**
  19348. * Event raised when the camera collide with a mesh in the scene.
  19349. */
  19350. onCollide: (collidedMesh: AbstractMesh) => void;
  19351. private _collider;
  19352. private _needMoveForGravity;
  19353. private _oldPosition;
  19354. private _diffPosition;
  19355. private _newPosition;
  19356. /** @hidden */
  19357. _localDirection: Vector3;
  19358. /** @hidden */
  19359. _transformedDirection: Vector3;
  19360. /**
  19361. * Instantiates a Free Camera.
  19362. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19363. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  19364. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  19365. * @param name Define the name of the camera in the scene
  19366. * @param position Define the start position of the camera in the scene
  19367. * @param scene Define the scene the camera belongs to
  19368. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  19369. */
  19370. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  19371. /**
  19372. * Attached controls to the current camera.
  19373. * @param element Defines the element the controls should be listened from
  19374. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19375. */
  19376. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19377. /**
  19378. * Detach the current controls from the camera.
  19379. * The camera will stop reacting to inputs.
  19380. * @param element Defines the element to stop listening the inputs from
  19381. */
  19382. detachControl(element: HTMLElement): void;
  19383. private _collisionMask;
  19384. /**
  19385. * Define a collision mask to limit the list of object the camera can collide with
  19386. */
  19387. get collisionMask(): number;
  19388. set collisionMask(mask: number);
  19389. /** @hidden */
  19390. _collideWithWorld(displacement: Vector3): void;
  19391. private _onCollisionPositionChange;
  19392. /** @hidden */
  19393. _checkInputs(): void;
  19394. /** @hidden */
  19395. _decideIfNeedsToMove(): boolean;
  19396. /** @hidden */
  19397. _updatePosition(): void;
  19398. /**
  19399. * Destroy the camera and release the current resources hold by it.
  19400. */
  19401. dispose(): void;
  19402. /**
  19403. * Gets the current object class name.
  19404. * @return the class name
  19405. */
  19406. getClassName(): string;
  19407. }
  19408. }
  19409. declare module "babylonjs/Gamepads/gamepad" {
  19410. import { Observable } from "babylonjs/Misc/observable";
  19411. /**
  19412. * Represents a gamepad control stick position
  19413. */
  19414. export class StickValues {
  19415. /**
  19416. * The x component of the control stick
  19417. */
  19418. x: number;
  19419. /**
  19420. * The y component of the control stick
  19421. */
  19422. y: number;
  19423. /**
  19424. * Initializes the gamepad x and y control stick values
  19425. * @param x The x component of the gamepad control stick value
  19426. * @param y The y component of the gamepad control stick value
  19427. */
  19428. constructor(
  19429. /**
  19430. * The x component of the control stick
  19431. */
  19432. x: number,
  19433. /**
  19434. * The y component of the control stick
  19435. */
  19436. y: number);
  19437. }
  19438. /**
  19439. * An interface which manages callbacks for gamepad button changes
  19440. */
  19441. export interface GamepadButtonChanges {
  19442. /**
  19443. * Called when a gamepad has been changed
  19444. */
  19445. changed: boolean;
  19446. /**
  19447. * Called when a gamepad press event has been triggered
  19448. */
  19449. pressChanged: boolean;
  19450. /**
  19451. * Called when a touch event has been triggered
  19452. */
  19453. touchChanged: boolean;
  19454. /**
  19455. * Called when a value has changed
  19456. */
  19457. valueChanged: boolean;
  19458. }
  19459. /**
  19460. * Represents a gamepad
  19461. */
  19462. export class Gamepad {
  19463. /**
  19464. * The id of the gamepad
  19465. */
  19466. id: string;
  19467. /**
  19468. * The index of the gamepad
  19469. */
  19470. index: number;
  19471. /**
  19472. * The browser gamepad
  19473. */
  19474. browserGamepad: any;
  19475. /**
  19476. * Specifies what type of gamepad this represents
  19477. */
  19478. type: number;
  19479. private _leftStick;
  19480. private _rightStick;
  19481. /** @hidden */
  19482. _isConnected: boolean;
  19483. private _leftStickAxisX;
  19484. private _leftStickAxisY;
  19485. private _rightStickAxisX;
  19486. private _rightStickAxisY;
  19487. /**
  19488. * Triggered when the left control stick has been changed
  19489. */
  19490. private _onleftstickchanged;
  19491. /**
  19492. * Triggered when the right control stick has been changed
  19493. */
  19494. private _onrightstickchanged;
  19495. /**
  19496. * Represents a gamepad controller
  19497. */
  19498. static GAMEPAD: number;
  19499. /**
  19500. * Represents a generic controller
  19501. */
  19502. static GENERIC: number;
  19503. /**
  19504. * Represents an XBox controller
  19505. */
  19506. static XBOX: number;
  19507. /**
  19508. * Represents a pose-enabled controller
  19509. */
  19510. static POSE_ENABLED: number;
  19511. /**
  19512. * Represents an Dual Shock controller
  19513. */
  19514. static DUALSHOCK: number;
  19515. /**
  19516. * Specifies whether the left control stick should be Y-inverted
  19517. */
  19518. protected _invertLeftStickY: boolean;
  19519. /**
  19520. * Specifies if the gamepad has been connected
  19521. */
  19522. get isConnected(): boolean;
  19523. /**
  19524. * Initializes the gamepad
  19525. * @param id The id of the gamepad
  19526. * @param index The index of the gamepad
  19527. * @param browserGamepad The browser gamepad
  19528. * @param leftStickX The x component of the left joystick
  19529. * @param leftStickY The y component of the left joystick
  19530. * @param rightStickX The x component of the right joystick
  19531. * @param rightStickY The y component of the right joystick
  19532. */
  19533. constructor(
  19534. /**
  19535. * The id of the gamepad
  19536. */
  19537. id: string,
  19538. /**
  19539. * The index of the gamepad
  19540. */
  19541. index: number,
  19542. /**
  19543. * The browser gamepad
  19544. */
  19545. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  19546. /**
  19547. * Callback triggered when the left joystick has changed
  19548. * @param callback
  19549. */
  19550. onleftstickchanged(callback: (values: StickValues) => void): void;
  19551. /**
  19552. * Callback triggered when the right joystick has changed
  19553. * @param callback
  19554. */
  19555. onrightstickchanged(callback: (values: StickValues) => void): void;
  19556. /**
  19557. * Gets the left joystick
  19558. */
  19559. get leftStick(): StickValues;
  19560. /**
  19561. * Sets the left joystick values
  19562. */
  19563. set leftStick(newValues: StickValues);
  19564. /**
  19565. * Gets the right joystick
  19566. */
  19567. get rightStick(): StickValues;
  19568. /**
  19569. * Sets the right joystick value
  19570. */
  19571. set rightStick(newValues: StickValues);
  19572. /**
  19573. * Updates the gamepad joystick positions
  19574. */
  19575. update(): void;
  19576. /**
  19577. * Disposes the gamepad
  19578. */
  19579. dispose(): void;
  19580. }
  19581. /**
  19582. * Represents a generic gamepad
  19583. */
  19584. export class GenericPad extends Gamepad {
  19585. private _buttons;
  19586. private _onbuttondown;
  19587. private _onbuttonup;
  19588. /**
  19589. * Observable triggered when a button has been pressed
  19590. */
  19591. onButtonDownObservable: Observable<number>;
  19592. /**
  19593. * Observable triggered when a button has been released
  19594. */
  19595. onButtonUpObservable: Observable<number>;
  19596. /**
  19597. * Callback triggered when a button has been pressed
  19598. * @param callback Called when a button has been pressed
  19599. */
  19600. onbuttondown(callback: (buttonPressed: number) => void): void;
  19601. /**
  19602. * Callback triggered when a button has been released
  19603. * @param callback Called when a button has been released
  19604. */
  19605. onbuttonup(callback: (buttonReleased: number) => void): void;
  19606. /**
  19607. * Initializes the generic gamepad
  19608. * @param id The id of the generic gamepad
  19609. * @param index The index of the generic gamepad
  19610. * @param browserGamepad The browser gamepad
  19611. */
  19612. constructor(id: string, index: number, browserGamepad: any);
  19613. private _setButtonValue;
  19614. /**
  19615. * Updates the generic gamepad
  19616. */
  19617. update(): void;
  19618. /**
  19619. * Disposes the generic gamepad
  19620. */
  19621. dispose(): void;
  19622. }
  19623. }
  19624. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  19625. import { Observable } from "babylonjs/Misc/observable";
  19626. import { Nullable } from "babylonjs/types";
  19627. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  19628. import { TransformNode } from "babylonjs/Meshes/transformNode";
  19629. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19630. import { Ray } from "babylonjs/Culling/ray";
  19631. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  19632. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  19633. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  19634. /**
  19635. * Defines the types of pose enabled controllers that are supported
  19636. */
  19637. export enum PoseEnabledControllerType {
  19638. /**
  19639. * HTC Vive
  19640. */
  19641. VIVE = 0,
  19642. /**
  19643. * Oculus Rift
  19644. */
  19645. OCULUS = 1,
  19646. /**
  19647. * Windows mixed reality
  19648. */
  19649. WINDOWS = 2,
  19650. /**
  19651. * Samsung gear VR
  19652. */
  19653. GEAR_VR = 3,
  19654. /**
  19655. * Google Daydream
  19656. */
  19657. DAYDREAM = 4,
  19658. /**
  19659. * Generic
  19660. */
  19661. GENERIC = 5
  19662. }
  19663. /**
  19664. * Defines the MutableGamepadButton interface for the state of a gamepad button
  19665. */
  19666. export interface MutableGamepadButton {
  19667. /**
  19668. * Value of the button/trigger
  19669. */
  19670. value: number;
  19671. /**
  19672. * If the button/trigger is currently touched
  19673. */
  19674. touched: boolean;
  19675. /**
  19676. * If the button/trigger is currently pressed
  19677. */
  19678. pressed: boolean;
  19679. }
  19680. /**
  19681. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  19682. * @hidden
  19683. */
  19684. export interface ExtendedGamepadButton extends GamepadButton {
  19685. /**
  19686. * If the button/trigger is currently pressed
  19687. */
  19688. readonly pressed: boolean;
  19689. /**
  19690. * If the button/trigger is currently touched
  19691. */
  19692. readonly touched: boolean;
  19693. /**
  19694. * Value of the button/trigger
  19695. */
  19696. readonly value: number;
  19697. }
  19698. /** @hidden */
  19699. export interface _GamePadFactory {
  19700. /**
  19701. * Returns whether or not the current gamepad can be created for this type of controller.
  19702. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19703. * @returns true if it can be created, otherwise false
  19704. */
  19705. canCreate(gamepadInfo: any): boolean;
  19706. /**
  19707. * Creates a new instance of the Gamepad.
  19708. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19709. * @returns the new gamepad instance
  19710. */
  19711. create(gamepadInfo: any): Gamepad;
  19712. }
  19713. /**
  19714. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19715. */
  19716. export class PoseEnabledControllerHelper {
  19717. /** @hidden */
  19718. static _ControllerFactories: _GamePadFactory[];
  19719. /** @hidden */
  19720. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  19721. /**
  19722. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19723. * @param vrGamepad the gamepad to initialized
  19724. * @returns a vr controller of the type the gamepad identified as
  19725. */
  19726. static InitiateController(vrGamepad: any): Gamepad;
  19727. }
  19728. /**
  19729. * Defines the PoseEnabledController object that contains state of a vr capable controller
  19730. */
  19731. export class PoseEnabledController extends Gamepad implements PoseControlled {
  19732. /**
  19733. * If the controller is used in a webXR session
  19734. */
  19735. isXR: boolean;
  19736. private _deviceRoomPosition;
  19737. private _deviceRoomRotationQuaternion;
  19738. /**
  19739. * The device position in babylon space
  19740. */
  19741. devicePosition: Vector3;
  19742. /**
  19743. * The device rotation in babylon space
  19744. */
  19745. deviceRotationQuaternion: Quaternion;
  19746. /**
  19747. * The scale factor of the device in babylon space
  19748. */
  19749. deviceScaleFactor: number;
  19750. /**
  19751. * (Likely devicePosition should be used instead) The device position in its room space
  19752. */
  19753. position: Vector3;
  19754. /**
  19755. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  19756. */
  19757. rotationQuaternion: Quaternion;
  19758. /**
  19759. * The type of controller (Eg. Windows mixed reality)
  19760. */
  19761. controllerType: PoseEnabledControllerType;
  19762. protected _calculatedPosition: Vector3;
  19763. private _calculatedRotation;
  19764. /**
  19765. * The raw pose from the device
  19766. */
  19767. rawPose: DevicePose;
  19768. private _trackPosition;
  19769. private _maxRotationDistFromHeadset;
  19770. private _draggedRoomRotation;
  19771. /**
  19772. * @hidden
  19773. */
  19774. _disableTrackPosition(fixedPosition: Vector3): void;
  19775. /**
  19776. * Internal, the mesh attached to the controller
  19777. * @hidden
  19778. */
  19779. _mesh: Nullable<AbstractMesh>;
  19780. private _poseControlledCamera;
  19781. private _leftHandSystemQuaternion;
  19782. /**
  19783. * Internal, matrix used to convert room space to babylon space
  19784. * @hidden
  19785. */
  19786. _deviceToWorld: Matrix;
  19787. /**
  19788. * Node to be used when casting a ray from the controller
  19789. * @hidden
  19790. */
  19791. _pointingPoseNode: Nullable<TransformNode>;
  19792. /**
  19793. * Name of the child mesh that can be used to cast a ray from the controller
  19794. */
  19795. static readonly POINTING_POSE: string;
  19796. /**
  19797. * Creates a new PoseEnabledController from a gamepad
  19798. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  19799. */
  19800. constructor(browserGamepad: any);
  19801. private _workingMatrix;
  19802. /**
  19803. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  19804. */
  19805. update(): void;
  19806. /**
  19807. * Updates only the pose device and mesh without doing any button event checking
  19808. */
  19809. protected _updatePoseAndMesh(): void;
  19810. /**
  19811. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  19812. * @param poseData raw pose fromthe device
  19813. */
  19814. updateFromDevice(poseData: DevicePose): void;
  19815. /**
  19816. * @hidden
  19817. */
  19818. _meshAttachedObservable: Observable<AbstractMesh>;
  19819. /**
  19820. * Attaches a mesh to the controller
  19821. * @param mesh the mesh to be attached
  19822. */
  19823. attachToMesh(mesh: AbstractMesh): void;
  19824. /**
  19825. * Attaches the controllers mesh to a camera
  19826. * @param camera the camera the mesh should be attached to
  19827. */
  19828. attachToPoseControlledCamera(camera: TargetCamera): void;
  19829. /**
  19830. * Disposes of the controller
  19831. */
  19832. dispose(): void;
  19833. /**
  19834. * The mesh that is attached to the controller
  19835. */
  19836. get mesh(): Nullable<AbstractMesh>;
  19837. /**
  19838. * Gets the ray of the controller in the direction the controller is pointing
  19839. * @param length the length the resulting ray should be
  19840. * @returns a ray in the direction the controller is pointing
  19841. */
  19842. getForwardRay(length?: number): Ray;
  19843. }
  19844. }
  19845. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  19846. import { Observable } from "babylonjs/Misc/observable";
  19847. import { Scene } from "babylonjs/scene";
  19848. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19849. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  19850. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  19851. import { Nullable } from "babylonjs/types";
  19852. /**
  19853. * Defines the WebVRController object that represents controllers tracked in 3D space
  19854. */
  19855. export abstract class WebVRController extends PoseEnabledController {
  19856. /**
  19857. * Internal, the default controller model for the controller
  19858. */
  19859. protected _defaultModel: Nullable<AbstractMesh>;
  19860. /**
  19861. * Fired when the trigger state has changed
  19862. */
  19863. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  19864. /**
  19865. * Fired when the main button state has changed
  19866. */
  19867. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19868. /**
  19869. * Fired when the secondary button state has changed
  19870. */
  19871. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19872. /**
  19873. * Fired when the pad state has changed
  19874. */
  19875. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  19876. /**
  19877. * Fired when controllers stick values have changed
  19878. */
  19879. onPadValuesChangedObservable: Observable<StickValues>;
  19880. /**
  19881. * Array of button availible on the controller
  19882. */
  19883. protected _buttons: Array<MutableGamepadButton>;
  19884. private _onButtonStateChange;
  19885. /**
  19886. * Fired when a controller button's state has changed
  19887. * @param callback the callback containing the button that was modified
  19888. */
  19889. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  19890. /**
  19891. * X and Y axis corresponding to the controllers joystick
  19892. */
  19893. pad: StickValues;
  19894. /**
  19895. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  19896. */
  19897. hand: string;
  19898. /**
  19899. * The default controller model for the controller
  19900. */
  19901. get defaultModel(): Nullable<AbstractMesh>;
  19902. /**
  19903. * Creates a new WebVRController from a gamepad
  19904. * @param vrGamepad the gamepad that the WebVRController should be created from
  19905. */
  19906. constructor(vrGamepad: any);
  19907. /**
  19908. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  19909. */
  19910. update(): void;
  19911. /**
  19912. * Function to be called when a button is modified
  19913. */
  19914. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  19915. /**
  19916. * Loads a mesh and attaches it to the controller
  19917. * @param scene the scene the mesh should be added to
  19918. * @param meshLoaded callback for when the mesh has been loaded
  19919. */
  19920. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  19921. private _setButtonValue;
  19922. private _changes;
  19923. private _checkChanges;
  19924. /**
  19925. * Disposes of th webVRCOntroller
  19926. */
  19927. dispose(): void;
  19928. }
  19929. }
  19930. declare module "babylonjs/Lights/hemisphericLight" {
  19931. import { Nullable } from "babylonjs/types";
  19932. import { Scene } from "babylonjs/scene";
  19933. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  19934. import { Color3 } from "babylonjs/Maths/math.color";
  19935. import { Effect } from "babylonjs/Materials/effect";
  19936. import { Light } from "babylonjs/Lights/light";
  19937. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  19938. /**
  19939. * The HemisphericLight simulates the ambient environment light,
  19940. * so the passed direction is the light reflection direction, not the incoming direction.
  19941. */
  19942. export class HemisphericLight extends Light {
  19943. /**
  19944. * The groundColor is the light in the opposite direction to the one specified during creation.
  19945. * 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.
  19946. */
  19947. groundColor: Color3;
  19948. /**
  19949. * The light reflection direction, not the incoming direction.
  19950. */
  19951. direction: Vector3;
  19952. /**
  19953. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  19954. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  19955. * The HemisphericLight can't cast shadows.
  19956. * Documentation : https://doc.babylonjs.com/babylon101/lights
  19957. * @param name The friendly name of the light
  19958. * @param direction The direction of the light reflection
  19959. * @param scene The scene the light belongs to
  19960. */
  19961. constructor(name: string, direction: Vector3, scene: Scene);
  19962. protected _buildUniformLayout(): void;
  19963. /**
  19964. * Returns the string "HemisphericLight".
  19965. * @return The class name
  19966. */
  19967. getClassName(): string;
  19968. /**
  19969. * Sets the HemisphericLight direction towards the passed target (Vector3).
  19970. * Returns the updated direction.
  19971. * @param target The target the direction should point to
  19972. * @return The computed direction
  19973. */
  19974. setDirectionToTarget(target: Vector3): Vector3;
  19975. /**
  19976. * Returns the shadow generator associated to the light.
  19977. * @returns Always null for hemispheric lights because it does not support shadows.
  19978. */
  19979. getShadowGenerator(): Nullable<IShadowGenerator>;
  19980. /**
  19981. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  19982. * @param effect The effect to update
  19983. * @param lightIndex The index of the light in the effect to update
  19984. * @returns The hemispheric light
  19985. */
  19986. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  19987. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  19988. /**
  19989. * Computes the world matrix of the node
  19990. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  19991. * @param useWasUpdatedFlag defines a reserved property
  19992. * @returns the world matrix
  19993. */
  19994. computeWorldMatrix(): Matrix;
  19995. /**
  19996. * Returns the integer 3.
  19997. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  19998. */
  19999. getTypeID(): number;
  20000. /**
  20001. * Prepares the list of defines specific to the light type.
  20002. * @param defines the list of defines
  20003. * @param lightIndex defines the index of the light for the effect
  20004. */
  20005. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  20006. }
  20007. }
  20008. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  20009. /** @hidden */
  20010. export var vrMultiviewToSingleviewPixelShader: {
  20011. name: string;
  20012. shader: string;
  20013. };
  20014. }
  20015. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  20016. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20017. import { Scene } from "babylonjs/scene";
  20018. /**
  20019. * Renders to multiple views with a single draw call
  20020. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  20021. */
  20022. export class MultiviewRenderTarget extends RenderTargetTexture {
  20023. /**
  20024. * Creates a multiview render target
  20025. * @param scene scene used with the render target
  20026. * @param size the size of the render target (used for each view)
  20027. */
  20028. constructor(scene: Scene, size?: number | {
  20029. width: number;
  20030. height: number;
  20031. } | {
  20032. ratio: number;
  20033. });
  20034. /**
  20035. * @hidden
  20036. * @param faceIndex the face index, if its a cube texture
  20037. */
  20038. _bindFrameBuffer(faceIndex?: number): void;
  20039. /**
  20040. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20041. * @returns the view count
  20042. */
  20043. getViewCount(): number;
  20044. }
  20045. }
  20046. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  20047. import { Camera } from "babylonjs/Cameras/camera";
  20048. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20049. import { Nullable } from "babylonjs/types";
  20050. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20051. import { Matrix } from "babylonjs/Maths/math.vector";
  20052. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20053. module "babylonjs/Engines/engine" {
  20054. interface Engine {
  20055. /**
  20056. * Creates a new multiview render target
  20057. * @param width defines the width of the texture
  20058. * @param height defines the height of the texture
  20059. * @returns the created multiview texture
  20060. */
  20061. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  20062. /**
  20063. * Binds a multiview framebuffer to be drawn to
  20064. * @param multiviewTexture texture to bind
  20065. */
  20066. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  20067. }
  20068. }
  20069. module "babylonjs/Cameras/camera" {
  20070. interface Camera {
  20071. /**
  20072. * @hidden
  20073. * 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)
  20074. */
  20075. _useMultiviewToSingleView: boolean;
  20076. /**
  20077. * @hidden
  20078. * 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)
  20079. */
  20080. _multiviewTexture: Nullable<RenderTargetTexture>;
  20081. /**
  20082. * @hidden
  20083. * ensures the multiview texture of the camera exists and has the specified width/height
  20084. * @param width height to set on the multiview texture
  20085. * @param height width to set on the multiview texture
  20086. */
  20087. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  20088. }
  20089. }
  20090. module "babylonjs/scene" {
  20091. interface Scene {
  20092. /** @hidden */
  20093. _transformMatrixR: Matrix;
  20094. /** @hidden */
  20095. _multiviewSceneUbo: Nullable<UniformBuffer>;
  20096. /** @hidden */
  20097. _createMultiviewUbo(): void;
  20098. /** @hidden */
  20099. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  20100. /** @hidden */
  20101. _renderMultiviewToSingleView(camera: Camera): void;
  20102. }
  20103. }
  20104. }
  20105. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  20106. import { Camera } from "babylonjs/Cameras/camera";
  20107. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20108. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  20109. import "babylonjs/Engines/Extensions/engine.multiview";
  20110. /**
  20111. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  20112. * This will not be used for webXR as it supports displaying texture arrays directly
  20113. */
  20114. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  20115. /**
  20116. * Initializes a VRMultiviewToSingleview
  20117. * @param name name of the post process
  20118. * @param camera camera to be applied to
  20119. * @param scaleFactor scaling factor to the size of the output texture
  20120. */
  20121. constructor(name: string, camera: Camera, scaleFactor: number);
  20122. }
  20123. }
  20124. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  20125. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  20126. import { Nullable } from "babylonjs/types";
  20127. import { Size } from "babylonjs/Maths/math.size";
  20128. import { Observable } from "babylonjs/Misc/observable";
  20129. import { WebVROptions } from "babylonjs/Cameras/VR/webVRCamera";
  20130. /**
  20131. * Interface used to define additional presentation attributes
  20132. */
  20133. export interface IVRPresentationAttributes {
  20134. /**
  20135. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  20136. */
  20137. highRefreshRate: boolean;
  20138. /**
  20139. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  20140. */
  20141. foveationLevel: number;
  20142. }
  20143. module "babylonjs/Engines/engine" {
  20144. interface Engine {
  20145. /** @hidden */
  20146. _vrDisplay: any;
  20147. /** @hidden */
  20148. _vrSupported: boolean;
  20149. /** @hidden */
  20150. _oldSize: Size;
  20151. /** @hidden */
  20152. _oldHardwareScaleFactor: number;
  20153. /** @hidden */
  20154. _vrExclusivePointerMode: boolean;
  20155. /** @hidden */
  20156. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  20157. /** @hidden */
  20158. _onVRDisplayPointerRestricted: () => void;
  20159. /** @hidden */
  20160. _onVRDisplayPointerUnrestricted: () => void;
  20161. /** @hidden */
  20162. _onVrDisplayConnect: Nullable<(display: any) => void>;
  20163. /** @hidden */
  20164. _onVrDisplayDisconnect: Nullable<() => void>;
  20165. /** @hidden */
  20166. _onVrDisplayPresentChange: Nullable<() => void>;
  20167. /**
  20168. * Observable signaled when VR display mode changes
  20169. */
  20170. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  20171. /**
  20172. * Observable signaled when VR request present is complete
  20173. */
  20174. onVRRequestPresentComplete: Observable<boolean>;
  20175. /**
  20176. * Observable signaled when VR request present starts
  20177. */
  20178. onVRRequestPresentStart: Observable<Engine>;
  20179. /**
  20180. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  20181. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  20182. */
  20183. isInVRExclusivePointerMode: boolean;
  20184. /**
  20185. * Gets a boolean indicating if a webVR device was detected
  20186. * @returns true if a webVR device was detected
  20187. */
  20188. isVRDevicePresent(): boolean;
  20189. /**
  20190. * Gets the current webVR device
  20191. * @returns the current webVR device (or null)
  20192. */
  20193. getVRDevice(): any;
  20194. /**
  20195. * Initializes a webVR display and starts listening to display change events
  20196. * The onVRDisplayChangedObservable will be notified upon these changes
  20197. * @returns A promise containing a VRDisplay and if vr is supported
  20198. */
  20199. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  20200. /** @hidden */
  20201. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  20202. /**
  20203. * Gets or sets the presentation attributes used to configure VR rendering
  20204. */
  20205. vrPresentationAttributes?: IVRPresentationAttributes;
  20206. /**
  20207. * Call this function to switch to webVR mode
  20208. * Will do nothing if webVR is not supported or if there is no webVR device
  20209. * @param options the webvr options provided to the camera. mainly used for multiview
  20210. * @see http://doc.babylonjs.com/how_to/webvr_camera
  20211. */
  20212. enableVR(options: WebVROptions): void;
  20213. /** @hidden */
  20214. _onVRFullScreenTriggered(): void;
  20215. }
  20216. }
  20217. }
  20218. declare module "babylonjs/Cameras/VR/webVRCamera" {
  20219. import { Nullable } from "babylonjs/types";
  20220. import { Observable } from "babylonjs/Misc/observable";
  20221. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  20222. import { Scene } from "babylonjs/scene";
  20223. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20224. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  20225. import { Node } from "babylonjs/node";
  20226. import { Ray } from "babylonjs/Culling/ray";
  20227. import "babylonjs/Cameras/RigModes/webVRRigMode";
  20228. import "babylonjs/Engines/Extensions/engine.webVR";
  20229. /**
  20230. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  20231. * IMPORTANT!! The data is right-hand data.
  20232. * @export
  20233. * @interface DevicePose
  20234. */
  20235. export interface DevicePose {
  20236. /**
  20237. * The position of the device, values in array are [x,y,z].
  20238. */
  20239. readonly position: Nullable<Float32Array>;
  20240. /**
  20241. * The linearVelocity of the device, values in array are [x,y,z].
  20242. */
  20243. readonly linearVelocity: Nullable<Float32Array>;
  20244. /**
  20245. * The linearAcceleration of the device, values in array are [x,y,z].
  20246. */
  20247. readonly linearAcceleration: Nullable<Float32Array>;
  20248. /**
  20249. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  20250. */
  20251. readonly orientation: Nullable<Float32Array>;
  20252. /**
  20253. * The angularVelocity of the device, values in array are [x,y,z].
  20254. */
  20255. readonly angularVelocity: Nullable<Float32Array>;
  20256. /**
  20257. * The angularAcceleration of the device, values in array are [x,y,z].
  20258. */
  20259. readonly angularAcceleration: Nullable<Float32Array>;
  20260. }
  20261. /**
  20262. * Interface representing a pose controlled object in Babylon.
  20263. * A pose controlled object has both regular pose values as well as pose values
  20264. * from an external device such as a VR head mounted display
  20265. */
  20266. export interface PoseControlled {
  20267. /**
  20268. * The position of the object in babylon space.
  20269. */
  20270. position: Vector3;
  20271. /**
  20272. * The rotation quaternion of the object in babylon space.
  20273. */
  20274. rotationQuaternion: Quaternion;
  20275. /**
  20276. * The position of the device in babylon space.
  20277. */
  20278. devicePosition?: Vector3;
  20279. /**
  20280. * The rotation quaternion of the device in babylon space.
  20281. */
  20282. deviceRotationQuaternion: Quaternion;
  20283. /**
  20284. * The raw pose coming from the device.
  20285. */
  20286. rawPose: Nullable<DevicePose>;
  20287. /**
  20288. * The scale of the device to be used when translating from device space to babylon space.
  20289. */
  20290. deviceScaleFactor: number;
  20291. /**
  20292. * Updates the poseControlled values based on the input device pose.
  20293. * @param poseData the pose data to update the object with
  20294. */
  20295. updateFromDevice(poseData: DevicePose): void;
  20296. }
  20297. /**
  20298. * Set of options to customize the webVRCamera
  20299. */
  20300. export interface WebVROptions {
  20301. /**
  20302. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  20303. */
  20304. trackPosition?: boolean;
  20305. /**
  20306. * Sets the scale of the vrDevice in babylon space. (default: 1)
  20307. */
  20308. positionScale?: number;
  20309. /**
  20310. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  20311. */
  20312. displayName?: string;
  20313. /**
  20314. * Should the native controller meshes be initialized. (default: true)
  20315. */
  20316. controllerMeshes?: boolean;
  20317. /**
  20318. * Creating a default HemiLight only on controllers. (default: true)
  20319. */
  20320. defaultLightingOnControllers?: boolean;
  20321. /**
  20322. * If you don't want to use the default VR button of the helper. (default: false)
  20323. */
  20324. useCustomVRButton?: boolean;
  20325. /**
  20326. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  20327. */
  20328. customVRButton?: HTMLButtonElement;
  20329. /**
  20330. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  20331. */
  20332. rayLength?: number;
  20333. /**
  20334. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  20335. */
  20336. defaultHeight?: number;
  20337. /**
  20338. * If multiview should be used if availible (default: false)
  20339. */
  20340. useMultiview?: boolean;
  20341. }
  20342. /**
  20343. * This represents a WebVR camera.
  20344. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  20345. * @example http://doc.babylonjs.com/how_to/webvr_camera
  20346. */
  20347. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  20348. private webVROptions;
  20349. /**
  20350. * @hidden
  20351. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  20352. */
  20353. _vrDevice: any;
  20354. /**
  20355. * The rawPose of the vrDevice.
  20356. */
  20357. rawPose: Nullable<DevicePose>;
  20358. private _onVREnabled;
  20359. private _specsVersion;
  20360. private _attached;
  20361. private _frameData;
  20362. protected _descendants: Array<Node>;
  20363. private _deviceRoomPosition;
  20364. /** @hidden */
  20365. _deviceRoomRotationQuaternion: Quaternion;
  20366. private _standingMatrix;
  20367. /**
  20368. * Represents device position in babylon space.
  20369. */
  20370. devicePosition: Vector3;
  20371. /**
  20372. * Represents device rotation in babylon space.
  20373. */
  20374. deviceRotationQuaternion: Quaternion;
  20375. /**
  20376. * The scale of the device to be used when translating from device space to babylon space.
  20377. */
  20378. deviceScaleFactor: number;
  20379. private _deviceToWorld;
  20380. private _worldToDevice;
  20381. /**
  20382. * References to the webVR controllers for the vrDevice.
  20383. */
  20384. controllers: Array<WebVRController>;
  20385. /**
  20386. * Emits an event when a controller is attached.
  20387. */
  20388. onControllersAttachedObservable: Observable<WebVRController[]>;
  20389. /**
  20390. * Emits an event when a controller's mesh has been loaded;
  20391. */
  20392. onControllerMeshLoadedObservable: Observable<WebVRController>;
  20393. /**
  20394. * Emits an event when the HMD's pose has been updated.
  20395. */
  20396. onPoseUpdatedFromDeviceObservable: Observable<any>;
  20397. private _poseSet;
  20398. /**
  20399. * If the rig cameras be used as parent instead of this camera.
  20400. */
  20401. rigParenting: boolean;
  20402. private _lightOnControllers;
  20403. private _defaultHeight?;
  20404. /**
  20405. * Instantiates a WebVRFreeCamera.
  20406. * @param name The name of the WebVRFreeCamera
  20407. * @param position The starting anchor position for the camera
  20408. * @param scene The scene the camera belongs to
  20409. * @param webVROptions a set of customizable options for the webVRCamera
  20410. */
  20411. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  20412. /**
  20413. * Gets the device distance from the ground in meters.
  20414. * @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.
  20415. */
  20416. deviceDistanceToRoomGround(): number;
  20417. /**
  20418. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20419. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  20420. */
  20421. useStandingMatrix(callback?: (bool: boolean) => void): void;
  20422. /**
  20423. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20424. * @returns A promise with a boolean set to if the standing matrix is supported.
  20425. */
  20426. useStandingMatrixAsync(): Promise<boolean>;
  20427. /**
  20428. * Disposes the camera
  20429. */
  20430. dispose(): void;
  20431. /**
  20432. * Gets a vrController by name.
  20433. * @param name The name of the controller to retreive
  20434. * @returns the controller matching the name specified or null if not found
  20435. */
  20436. getControllerByName(name: string): Nullable<WebVRController>;
  20437. private _leftController;
  20438. /**
  20439. * The controller corresponding to the users left hand.
  20440. */
  20441. get leftController(): Nullable<WebVRController>;
  20442. private _rightController;
  20443. /**
  20444. * The controller corresponding to the users right hand.
  20445. */
  20446. get rightController(): Nullable<WebVRController>;
  20447. /**
  20448. * Casts a ray forward from the vrCamera's gaze.
  20449. * @param length Length of the ray (default: 100)
  20450. * @returns the ray corresponding to the gaze
  20451. */
  20452. getForwardRay(length?: number): Ray;
  20453. /**
  20454. * @hidden
  20455. * Updates the camera based on device's frame data
  20456. */
  20457. _checkInputs(): void;
  20458. /**
  20459. * Updates the poseControlled values based on the input device pose.
  20460. * @param poseData Pose coming from the device
  20461. */
  20462. updateFromDevice(poseData: DevicePose): void;
  20463. private _htmlElementAttached;
  20464. private _detachIfAttached;
  20465. /**
  20466. * WebVR's attach control will start broadcasting frames to the device.
  20467. * Note that in certain browsers (chrome for example) this function must be called
  20468. * within a user-interaction callback. Example:
  20469. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  20470. *
  20471. * @param element html element to attach the vrDevice to
  20472. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  20473. */
  20474. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  20475. /**
  20476. * Detaches the camera from the html element and disables VR
  20477. *
  20478. * @param element html element to detach from
  20479. */
  20480. detachControl(element: HTMLElement): void;
  20481. /**
  20482. * @returns the name of this class
  20483. */
  20484. getClassName(): string;
  20485. /**
  20486. * Calls resetPose on the vrDisplay
  20487. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  20488. */
  20489. resetToCurrentRotation(): void;
  20490. /**
  20491. * @hidden
  20492. * Updates the rig cameras (left and right eye)
  20493. */
  20494. _updateRigCameras(): void;
  20495. private _workingVector;
  20496. private _oneVector;
  20497. private _workingMatrix;
  20498. private updateCacheCalled;
  20499. private _correctPositionIfNotTrackPosition;
  20500. /**
  20501. * @hidden
  20502. * Updates the cached values of the camera
  20503. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  20504. */
  20505. _updateCache(ignoreParentClass?: boolean): void;
  20506. /**
  20507. * @hidden
  20508. * Get current device position in babylon world
  20509. */
  20510. _computeDevicePosition(): void;
  20511. /**
  20512. * Updates the current device position and rotation in the babylon world
  20513. */
  20514. update(): void;
  20515. /**
  20516. * @hidden
  20517. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  20518. * @returns an identity matrix
  20519. */
  20520. _getViewMatrix(): Matrix;
  20521. private _tmpMatrix;
  20522. /**
  20523. * This function is called by the two RIG cameras.
  20524. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  20525. * @hidden
  20526. */
  20527. _getWebVRViewMatrix(): Matrix;
  20528. /** @hidden */
  20529. _getWebVRProjectionMatrix(): Matrix;
  20530. private _onGamepadConnectedObserver;
  20531. private _onGamepadDisconnectedObserver;
  20532. private _updateCacheWhenTrackingDisabledObserver;
  20533. /**
  20534. * Initializes the controllers and their meshes
  20535. */
  20536. initControllers(): void;
  20537. }
  20538. }
  20539. declare module "babylonjs/Materials/materialHelper" {
  20540. import { Nullable } from "babylonjs/types";
  20541. import { Scene } from "babylonjs/scene";
  20542. import { Engine } from "babylonjs/Engines/engine";
  20543. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20544. import { Light } from "babylonjs/Lights/light";
  20545. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20546. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  20547. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20548. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  20549. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  20550. /**
  20551. * "Static Class" containing the most commonly used helper while dealing with material for
  20552. * rendering purpose.
  20553. *
  20554. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  20555. *
  20556. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  20557. */
  20558. export class MaterialHelper {
  20559. /**
  20560. * Bind the current view position to an effect.
  20561. * @param effect The effect to be bound
  20562. * @param scene The scene the eyes position is used from
  20563. * @param variableName name of the shader variable that will hold the eye position
  20564. */
  20565. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  20566. /**
  20567. * Helps preparing the defines values about the UVs in used in the effect.
  20568. * UVs are shared as much as we can accross channels in the shaders.
  20569. * @param texture The texture we are preparing the UVs for
  20570. * @param defines The defines to update
  20571. * @param key The channel key "diffuse", "specular"... used in the shader
  20572. */
  20573. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  20574. /**
  20575. * Binds a texture matrix value to its corrsponding uniform
  20576. * @param texture The texture to bind the matrix for
  20577. * @param uniformBuffer The uniform buffer receivin the data
  20578. * @param key The channel key "diffuse", "specular"... used in the shader
  20579. */
  20580. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  20581. /**
  20582. * Gets the current status of the fog (should it be enabled?)
  20583. * @param mesh defines the mesh to evaluate for fog support
  20584. * @param scene defines the hosting scene
  20585. * @returns true if fog must be enabled
  20586. */
  20587. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  20588. /**
  20589. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  20590. * @param mesh defines the current mesh
  20591. * @param scene defines the current scene
  20592. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  20593. * @param pointsCloud defines if point cloud rendering has to be turned on
  20594. * @param fogEnabled defines if fog has to be turned on
  20595. * @param alphaTest defines if alpha testing has to be turned on
  20596. * @param defines defines the current list of defines
  20597. */
  20598. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  20599. /**
  20600. * Helper used to prepare the list of defines associated with frame values for shader compilation
  20601. * @param scene defines the current scene
  20602. * @param engine defines the current engine
  20603. * @param defines specifies the list of active defines
  20604. * @param useInstances defines if instances have to be turned on
  20605. * @param useClipPlane defines if clip plane have to be turned on
  20606. */
  20607. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  20608. /**
  20609. * Prepares the defines for bones
  20610. * @param mesh The mesh containing the geometry data we will draw
  20611. * @param defines The defines to update
  20612. */
  20613. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  20614. /**
  20615. * Prepares the defines for morph targets
  20616. * @param mesh The mesh containing the geometry data we will draw
  20617. * @param defines The defines to update
  20618. */
  20619. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  20620. /**
  20621. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  20622. * @param mesh The mesh containing the geometry data we will draw
  20623. * @param defines The defines to update
  20624. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  20625. * @param useBones Precise whether bones should be used or not (override mesh info)
  20626. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  20627. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  20628. * @returns false if defines are considered not dirty and have not been checked
  20629. */
  20630. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  20631. /**
  20632. * Prepares the defines related to multiview
  20633. * @param scene The scene we are intending to draw
  20634. * @param defines The defines to update
  20635. */
  20636. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  20637. /**
  20638. * Prepares the defines related to the light information passed in parameter
  20639. * @param scene The scene we are intending to draw
  20640. * @param mesh The mesh the effect is compiling for
  20641. * @param light The light the effect is compiling for
  20642. * @param lightIndex The index of the light
  20643. * @param defines The defines to update
  20644. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20645. * @param state Defines the current state regarding what is needed (normals, etc...)
  20646. */
  20647. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  20648. needNormals: boolean;
  20649. needRebuild: boolean;
  20650. shadowEnabled: boolean;
  20651. specularEnabled: boolean;
  20652. lightmapMode: boolean;
  20653. }): void;
  20654. /**
  20655. * Prepares the defines related to the light information passed in parameter
  20656. * @param scene The scene we are intending to draw
  20657. * @param mesh The mesh the effect is compiling for
  20658. * @param defines The defines to update
  20659. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20660. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  20661. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  20662. * @returns true if normals will be required for the rest of the effect
  20663. */
  20664. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  20665. /**
  20666. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  20667. * @param lightIndex defines the light index
  20668. * @param uniformsList The uniform list
  20669. * @param samplersList The sampler list
  20670. * @param projectedLightTexture defines if projected texture must be used
  20671. * @param uniformBuffersList defines an optional list of uniform buffers
  20672. */
  20673. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  20674. /**
  20675. * Prepares the uniforms and samplers list to be used in the effect
  20676. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  20677. * @param samplersList The sampler list
  20678. * @param defines The defines helping in the list generation
  20679. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  20680. */
  20681. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  20682. /**
  20683. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  20684. * @param defines The defines to update while falling back
  20685. * @param fallbacks The authorized effect fallbacks
  20686. * @param maxSimultaneousLights The maximum number of lights allowed
  20687. * @param rank the current rank of the Effect
  20688. * @returns The newly affected rank
  20689. */
  20690. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  20691. private static _TmpMorphInfluencers;
  20692. /**
  20693. * Prepares the list of attributes required for morph targets according to the effect defines.
  20694. * @param attribs The current list of supported attribs
  20695. * @param mesh The mesh to prepare the morph targets attributes for
  20696. * @param influencers The number of influencers
  20697. */
  20698. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  20699. /**
  20700. * Prepares the list of attributes required for morph targets according to the effect defines.
  20701. * @param attribs The current list of supported attribs
  20702. * @param mesh The mesh to prepare the morph targets attributes for
  20703. * @param defines The current Defines of the effect
  20704. */
  20705. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  20706. /**
  20707. * Prepares the list of attributes required for bones according to the effect defines.
  20708. * @param attribs The current list of supported attribs
  20709. * @param mesh The mesh to prepare the bones attributes for
  20710. * @param defines The current Defines of the effect
  20711. * @param fallbacks The current efffect fallback strategy
  20712. */
  20713. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  20714. /**
  20715. * Check and prepare the list of attributes required for instances according to the effect defines.
  20716. * @param attribs The current list of supported attribs
  20717. * @param defines The current MaterialDefines of the effect
  20718. */
  20719. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  20720. /**
  20721. * Add the list of attributes required for instances to the attribs array.
  20722. * @param attribs The current list of supported attribs
  20723. */
  20724. static PushAttributesForInstances(attribs: string[]): void;
  20725. /**
  20726. * Binds the light information to the effect.
  20727. * @param light The light containing the generator
  20728. * @param effect The effect we are binding the data to
  20729. * @param lightIndex The light index in the effect used to render
  20730. */
  20731. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  20732. /**
  20733. * Binds the lights information from the scene to the effect for the given mesh.
  20734. * @param light Light to bind
  20735. * @param lightIndex Light index
  20736. * @param scene The scene where the light belongs to
  20737. * @param effect The effect we are binding the data to
  20738. * @param useSpecular Defines if specular is supported
  20739. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20740. */
  20741. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  20742. /**
  20743. * Binds the lights information from the scene to the effect for the given mesh.
  20744. * @param scene The scene the lights belongs to
  20745. * @param mesh The mesh we are binding the information to render
  20746. * @param effect The effect we are binding the data to
  20747. * @param defines The generated defines for the effect
  20748. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  20749. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20750. */
  20751. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  20752. private static _tempFogColor;
  20753. /**
  20754. * Binds the fog information from the scene to the effect for the given mesh.
  20755. * @param scene The scene the lights belongs to
  20756. * @param mesh The mesh we are binding the information to render
  20757. * @param effect The effect we are binding the data to
  20758. * @param linearSpace Defines if the fog effect is applied in linear space
  20759. */
  20760. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  20761. /**
  20762. * Binds the bones information from the mesh to the effect.
  20763. * @param mesh The mesh we are binding the information to render
  20764. * @param effect The effect we are binding the data to
  20765. */
  20766. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  20767. /**
  20768. * Binds the morph targets information from the mesh to the effect.
  20769. * @param abstractMesh The mesh we are binding the information to render
  20770. * @param effect The effect we are binding the data to
  20771. */
  20772. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  20773. /**
  20774. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  20775. * @param defines The generated defines used in the effect
  20776. * @param effect The effect we are binding the data to
  20777. * @param scene The scene we are willing to render with logarithmic scale for
  20778. */
  20779. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  20780. /**
  20781. * Binds the clip plane information from the scene to the effect.
  20782. * @param scene The scene the clip plane information are extracted from
  20783. * @param effect The effect we are binding the data to
  20784. */
  20785. static BindClipPlane(effect: Effect, scene: Scene): void;
  20786. }
  20787. }
  20788. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  20789. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  20790. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  20791. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  20792. import { Nullable } from "babylonjs/types";
  20793. import { Effect } from "babylonjs/Materials/effect";
  20794. import { Matrix } from "babylonjs/Maths/math.vector";
  20795. import { Scene } from "babylonjs/scene";
  20796. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  20797. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  20798. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  20799. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  20800. import { Observable } from "babylonjs/Misc/observable";
  20801. /**
  20802. * Block used to expose an input value
  20803. */
  20804. export class InputBlock extends NodeMaterialBlock {
  20805. private _mode;
  20806. private _associatedVariableName;
  20807. private _storedValue;
  20808. private _valueCallback;
  20809. private _type;
  20810. private _animationType;
  20811. /** Gets or set a value used to limit the range of float values */
  20812. min: number;
  20813. /** Gets or set a value used to limit the range of float values */
  20814. max: number;
  20815. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  20816. isBoolean: boolean;
  20817. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  20818. matrixMode: number;
  20819. /** @hidden */
  20820. _systemValue: Nullable<NodeMaterialSystemValues>;
  20821. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  20822. visibleInInspector: boolean;
  20823. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  20824. isConstant: boolean;
  20825. /** Gets or sets the group to use to display this block in the Inspector */
  20826. groupInInspector: string;
  20827. /** Gets an observable raised when the value is changed */
  20828. onValueChangedObservable: Observable<InputBlock>;
  20829. /**
  20830. * Gets or sets the connection point type (default is float)
  20831. */
  20832. get type(): NodeMaterialBlockConnectionPointTypes;
  20833. /**
  20834. * Creates a new InputBlock
  20835. * @param name defines the block name
  20836. * @param target defines the target of that block (Vertex by default)
  20837. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  20838. */
  20839. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  20840. /**
  20841. * Gets the output component
  20842. */
  20843. get output(): NodeMaterialConnectionPoint;
  20844. /**
  20845. * Set the source of this connection point to a vertex attribute
  20846. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  20847. * @returns the current connection point
  20848. */
  20849. setAsAttribute(attributeName?: string): InputBlock;
  20850. /**
  20851. * Set the source of this connection point to a system value
  20852. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  20853. * @returns the current connection point
  20854. */
  20855. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  20856. /**
  20857. * Gets or sets the value of that point.
  20858. * Please note that this value will be ignored if valueCallback is defined
  20859. */
  20860. get value(): any;
  20861. set value(value: any);
  20862. /**
  20863. * Gets or sets a callback used to get the value of that point.
  20864. * Please note that setting this value will force the connection point to ignore the value property
  20865. */
  20866. get valueCallback(): () => any;
  20867. set valueCallback(value: () => any);
  20868. /**
  20869. * Gets or sets the associated variable name in the shader
  20870. */
  20871. get associatedVariableName(): string;
  20872. set associatedVariableName(value: string);
  20873. /** Gets or sets the type of animation applied to the input */
  20874. get animationType(): AnimatedInputBlockTypes;
  20875. set animationType(value: AnimatedInputBlockTypes);
  20876. /**
  20877. * Gets a boolean indicating that this connection point not defined yet
  20878. */
  20879. get isUndefined(): boolean;
  20880. /**
  20881. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  20882. * In this case the connection point name must be the name of the uniform to use.
  20883. * Can only be set on inputs
  20884. */
  20885. get isUniform(): boolean;
  20886. set isUniform(value: boolean);
  20887. /**
  20888. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  20889. * In this case the connection point name must be the name of the attribute to use
  20890. * Can only be set on inputs
  20891. */
  20892. get isAttribute(): boolean;
  20893. set isAttribute(value: boolean);
  20894. /**
  20895. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  20896. * Can only be set on exit points
  20897. */
  20898. get isVarying(): boolean;
  20899. set isVarying(value: boolean);
  20900. /**
  20901. * Gets a boolean indicating that the current connection point is a system value
  20902. */
  20903. get isSystemValue(): boolean;
  20904. /**
  20905. * Gets or sets the current well known value or null if not defined as a system value
  20906. */
  20907. get systemValue(): Nullable<NodeMaterialSystemValues>;
  20908. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  20909. /**
  20910. * Gets the current class name
  20911. * @returns the class name
  20912. */
  20913. getClassName(): string;
  20914. /**
  20915. * Animate the input if animationType !== None
  20916. * @param scene defines the rendering scene
  20917. */
  20918. animate(scene: Scene): void;
  20919. private _emitDefine;
  20920. initialize(state: NodeMaterialBuildState): void;
  20921. /**
  20922. * Set the input block to its default value (based on its type)
  20923. */
  20924. setDefaultValue(): void;
  20925. private _emitConstant;
  20926. /** @hidden */
  20927. get _noContextSwitch(): boolean;
  20928. private _emit;
  20929. /** @hidden */
  20930. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  20931. /** @hidden */
  20932. _transmit(effect: Effect, scene: Scene): void;
  20933. protected _buildBlock(state: NodeMaterialBuildState): void;
  20934. protected _dumpPropertiesCode(): string;
  20935. dispose(): void;
  20936. serialize(): any;
  20937. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20938. }
  20939. }
  20940. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  20941. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  20942. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  20943. import { Nullable } from "babylonjs/types";
  20944. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  20945. import { Observable } from "babylonjs/Misc/observable";
  20946. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  20947. /**
  20948. * Enum used to define the compatibility state between two connection points
  20949. */
  20950. export enum NodeMaterialConnectionPointCompatibilityStates {
  20951. /** Points are compatibles */
  20952. Compatible = 0,
  20953. /** Points are incompatible because of their types */
  20954. TypeIncompatible = 1,
  20955. /** Points are incompatible because of their targets (vertex vs fragment) */
  20956. TargetIncompatible = 2
  20957. }
  20958. /**
  20959. * Defines the direction of a connection point
  20960. */
  20961. export enum NodeMaterialConnectionPointDirection {
  20962. /** Input */
  20963. Input = 0,
  20964. /** Output */
  20965. Output = 1
  20966. }
  20967. /**
  20968. * Defines a connection point for a block
  20969. */
  20970. export class NodeMaterialConnectionPoint {
  20971. /** @hidden */
  20972. _ownerBlock: NodeMaterialBlock;
  20973. /** @hidden */
  20974. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  20975. private _endpoints;
  20976. private _associatedVariableName;
  20977. private _direction;
  20978. /** @hidden */
  20979. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  20980. /** @hidden */
  20981. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  20982. private _type;
  20983. /** @hidden */
  20984. _enforceAssociatedVariableName: boolean;
  20985. /** Gets the direction of the point */
  20986. get direction(): NodeMaterialConnectionPointDirection;
  20987. /** Indicates that this connection point needs dual validation before being connected to another point */
  20988. needDualDirectionValidation: boolean;
  20989. /**
  20990. * Gets or sets the additional types supported by this connection point
  20991. */
  20992. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  20993. /**
  20994. * Gets or sets the additional types excluded by this connection point
  20995. */
  20996. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  20997. /**
  20998. * Observable triggered when this point is connected
  20999. */
  21000. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  21001. /**
  21002. * Gets or sets the associated variable name in the shader
  21003. */
  21004. get associatedVariableName(): string;
  21005. set associatedVariableName(value: string);
  21006. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  21007. get innerType(): NodeMaterialBlockConnectionPointTypes;
  21008. /**
  21009. * Gets or sets the connection point type (default is float)
  21010. */
  21011. get type(): NodeMaterialBlockConnectionPointTypes;
  21012. set type(value: NodeMaterialBlockConnectionPointTypes);
  21013. /**
  21014. * Gets or sets the connection point name
  21015. */
  21016. name: string;
  21017. /**
  21018. * Gets or sets the connection point name
  21019. */
  21020. displayName: string;
  21021. /**
  21022. * Gets or sets a boolean indicating that this connection point can be omitted
  21023. */
  21024. isOptional: boolean;
  21025. /**
  21026. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  21027. */
  21028. define: string;
  21029. /** @hidden */
  21030. _prioritizeVertex: boolean;
  21031. private _target;
  21032. /** Gets or sets the target of that connection point */
  21033. get target(): NodeMaterialBlockTargets;
  21034. set target(value: NodeMaterialBlockTargets);
  21035. /**
  21036. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  21037. */
  21038. get isConnected(): boolean;
  21039. /**
  21040. * Gets a boolean indicating that the current point is connected to an input block
  21041. */
  21042. get isConnectedToInputBlock(): boolean;
  21043. /**
  21044. * Gets a the connected input block (if any)
  21045. */
  21046. get connectInputBlock(): Nullable<InputBlock>;
  21047. /** Get the other side of the connection (if any) */
  21048. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  21049. /** Get the block that owns this connection point */
  21050. get ownerBlock(): NodeMaterialBlock;
  21051. /** Get the block connected on the other side of this connection (if any) */
  21052. get sourceBlock(): Nullable<NodeMaterialBlock>;
  21053. /** Get the block connected on the endpoints of this connection (if any) */
  21054. get connectedBlocks(): Array<NodeMaterialBlock>;
  21055. /** Gets the list of connected endpoints */
  21056. get endpoints(): NodeMaterialConnectionPoint[];
  21057. /** Gets a boolean indicating if that output point is connected to at least one input */
  21058. get hasEndpoints(): boolean;
  21059. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  21060. get isConnectedInVertexShader(): boolean;
  21061. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  21062. get isConnectedInFragmentShader(): boolean;
  21063. /**
  21064. * Creates a block suitable to be used as an input for this input point.
  21065. * If null is returned, a block based on the point type will be created.
  21066. * @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
  21067. */
  21068. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  21069. /**
  21070. * Creates a new connection point
  21071. * @param name defines the connection point name
  21072. * @param ownerBlock defines the block hosting this connection point
  21073. * @param direction defines the direction of the connection point
  21074. */
  21075. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  21076. /**
  21077. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  21078. * @returns the class name
  21079. */
  21080. getClassName(): string;
  21081. /**
  21082. * Gets a boolean indicating if the current point can be connected to another point
  21083. * @param connectionPoint defines the other connection point
  21084. * @returns a boolean
  21085. */
  21086. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  21087. /**
  21088. * Gets a number indicating if the current point can be connected to another point
  21089. * @param connectionPoint defines the other connection point
  21090. * @returns a number defining the compatibility state
  21091. */
  21092. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  21093. /**
  21094. * Connect this point to another connection point
  21095. * @param connectionPoint defines the other connection point
  21096. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  21097. * @returns the current connection point
  21098. */
  21099. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  21100. /**
  21101. * Disconnect this point from one of his endpoint
  21102. * @param endpoint defines the other connection point
  21103. * @returns the current connection point
  21104. */
  21105. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  21106. /**
  21107. * Serializes this point in a JSON representation
  21108. * @param isInput defines if the connection point is an input (default is true)
  21109. * @returns the serialized point object
  21110. */
  21111. serialize(isInput?: boolean): any;
  21112. /**
  21113. * Release resources
  21114. */
  21115. dispose(): void;
  21116. }
  21117. }
  21118. declare module "babylonjs/Materials/Node/Enums/nodeMaterialModes" {
  21119. /**
  21120. * Enum used to define the material modes
  21121. */
  21122. export enum NodeMaterialModes {
  21123. /** Regular material */
  21124. Material = 0,
  21125. /** For post process */
  21126. PostProcess = 1,
  21127. /** For particle system */
  21128. Particle = 2
  21129. }
  21130. }
  21131. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  21132. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21133. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21134. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21135. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21136. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21137. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21138. import { Effect } from "babylonjs/Materials/effect";
  21139. import { Mesh } from "babylonjs/Meshes/mesh";
  21140. import { Nullable } from "babylonjs/types";
  21141. import { Texture } from "babylonjs/Materials/Textures/texture";
  21142. import { Scene } from "babylonjs/scene";
  21143. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  21144. /**
  21145. * Block used to read a texture from a sampler
  21146. */
  21147. export class TextureBlock extends NodeMaterialBlock {
  21148. private _defineName;
  21149. private _linearDefineName;
  21150. private _gammaDefineName;
  21151. private _tempTextureRead;
  21152. private _samplerName;
  21153. private _transformedUVName;
  21154. private _textureTransformName;
  21155. private _textureInfoName;
  21156. private _mainUVName;
  21157. private _mainUVDefineName;
  21158. private _fragmentOnly;
  21159. /**
  21160. * Gets or sets the texture associated with the node
  21161. */
  21162. texture: Nullable<Texture>;
  21163. /**
  21164. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21165. */
  21166. convertToGammaSpace: boolean;
  21167. /**
  21168. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21169. */
  21170. convertToLinearSpace: boolean;
  21171. /**
  21172. * Create a new TextureBlock
  21173. * @param name defines the block name
  21174. */
  21175. constructor(name: string, fragmentOnly?: boolean);
  21176. /**
  21177. * Gets the current class name
  21178. * @returns the class name
  21179. */
  21180. getClassName(): string;
  21181. /**
  21182. * Gets the uv input component
  21183. */
  21184. get uv(): NodeMaterialConnectionPoint;
  21185. /**
  21186. * Gets the rgba output component
  21187. */
  21188. get rgba(): NodeMaterialConnectionPoint;
  21189. /**
  21190. * Gets the rgb output component
  21191. */
  21192. get rgb(): NodeMaterialConnectionPoint;
  21193. /**
  21194. * Gets the r output component
  21195. */
  21196. get r(): NodeMaterialConnectionPoint;
  21197. /**
  21198. * Gets the g output component
  21199. */
  21200. get g(): NodeMaterialConnectionPoint;
  21201. /**
  21202. * Gets the b output component
  21203. */
  21204. get b(): NodeMaterialConnectionPoint;
  21205. /**
  21206. * Gets the a output component
  21207. */
  21208. get a(): NodeMaterialConnectionPoint;
  21209. get target(): NodeMaterialBlockTargets;
  21210. autoConfigure(material: NodeMaterial): void;
  21211. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  21212. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21213. isReady(): boolean;
  21214. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  21215. private get _isMixed();
  21216. private _injectVertexCode;
  21217. private _writeTextureRead;
  21218. private _writeOutput;
  21219. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21220. protected _dumpPropertiesCode(): string;
  21221. serialize(): any;
  21222. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21223. }
  21224. }
  21225. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  21226. /** @hidden */
  21227. export var reflectionFunction: {
  21228. name: string;
  21229. shader: string;
  21230. };
  21231. }
  21232. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock" {
  21233. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21234. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21235. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21236. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21237. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21238. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21239. import { Effect } from "babylonjs/Materials/effect";
  21240. import { Mesh } from "babylonjs/Meshes/mesh";
  21241. import { Nullable } from "babylonjs/types";
  21242. import { Scene } from "babylonjs/scene";
  21243. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  21244. /**
  21245. * Base block used to read a reflection texture from a sampler
  21246. */
  21247. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  21248. /** @hidden */
  21249. _define3DName: string;
  21250. /** @hidden */
  21251. _defineCubicName: string;
  21252. /** @hidden */
  21253. _defineExplicitName: string;
  21254. /** @hidden */
  21255. _defineProjectionName: string;
  21256. /** @hidden */
  21257. _defineLocalCubicName: string;
  21258. /** @hidden */
  21259. _defineSphericalName: string;
  21260. /** @hidden */
  21261. _definePlanarName: string;
  21262. /** @hidden */
  21263. _defineEquirectangularName: string;
  21264. /** @hidden */
  21265. _defineMirroredEquirectangularFixedName: string;
  21266. /** @hidden */
  21267. _defineEquirectangularFixedName: string;
  21268. /** @hidden */
  21269. _defineSkyboxName: string;
  21270. /** @hidden */
  21271. _defineOppositeZ: string;
  21272. /** @hidden */
  21273. _cubeSamplerName: string;
  21274. /** @hidden */
  21275. _2DSamplerName: string;
  21276. protected _positionUVWName: string;
  21277. protected _directionWName: string;
  21278. protected _reflectionVectorName: string;
  21279. /** @hidden */
  21280. _reflectionCoordsName: string;
  21281. /** @hidden */
  21282. _reflectionMatrixName: string;
  21283. protected _reflectionColorName: string;
  21284. /**
  21285. * Gets or sets the texture associated with the node
  21286. */
  21287. texture: Nullable<BaseTexture>;
  21288. /**
  21289. * Create a new ReflectionTextureBaseBlock
  21290. * @param name defines the block name
  21291. */
  21292. constructor(name: string);
  21293. /**
  21294. * Gets the current class name
  21295. * @returns the class name
  21296. */
  21297. getClassName(): string;
  21298. /**
  21299. * Gets the world position input component
  21300. */
  21301. abstract get position(): NodeMaterialConnectionPoint;
  21302. /**
  21303. * Gets the world position input component
  21304. */
  21305. abstract get worldPosition(): NodeMaterialConnectionPoint;
  21306. /**
  21307. * Gets the world normal input component
  21308. */
  21309. abstract get worldNormal(): NodeMaterialConnectionPoint;
  21310. /**
  21311. * Gets the world input component
  21312. */
  21313. abstract get world(): NodeMaterialConnectionPoint;
  21314. /**
  21315. * Gets the camera (or eye) position component
  21316. */
  21317. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  21318. /**
  21319. * Gets the view input component
  21320. */
  21321. abstract get view(): NodeMaterialConnectionPoint;
  21322. protected _getTexture(): Nullable<BaseTexture>;
  21323. autoConfigure(material: NodeMaterial): void;
  21324. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21325. isReady(): boolean;
  21326. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  21327. /**
  21328. * Gets the code to inject in the vertex shader
  21329. * @param state current state of the node material building
  21330. * @returns the shader code
  21331. */
  21332. handleVertexSide(state: NodeMaterialBuildState): string;
  21333. /**
  21334. * Handles the inits for the fragment code path
  21335. * @param state node material build state
  21336. */
  21337. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  21338. /**
  21339. * Generates the reflection coords code for the fragment code path
  21340. * @param worldNormalVarName name of the world normal variable
  21341. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  21342. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  21343. * @returns the shader code
  21344. */
  21345. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  21346. /**
  21347. * Generates the reflection color code for the fragment code path
  21348. * @param lodVarName name of the lod variable
  21349. * @param swizzleLookupTexture swizzle to use for the final color variable
  21350. * @returns the shader code
  21351. */
  21352. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  21353. /**
  21354. * Generates the code corresponding to the connected output points
  21355. * @param state node material build state
  21356. * @param varName name of the variable to output
  21357. * @returns the shader code
  21358. */
  21359. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  21360. protected _buildBlock(state: NodeMaterialBuildState): this;
  21361. protected _dumpPropertiesCode(): string;
  21362. serialize(): any;
  21363. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21364. }
  21365. }
  21366. declare module "babylonjs/Materials/Node/nodeMaterialConnectionPointCustomObject" {
  21367. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21368. import { NodeMaterialConnectionPoint, NodeMaterialConnectionPointDirection, NodeMaterialConnectionPointCompatibilityStates } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21369. import { Nullable } from "babylonjs/types";
  21370. /**
  21371. * Defines a connection point to be used for points with a custom object type
  21372. */
  21373. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  21374. private _blockType;
  21375. private _blockName;
  21376. private _nameForCheking?;
  21377. /**
  21378. * Creates a new connection point
  21379. * @param name defines the connection point name
  21380. * @param ownerBlock defines the block hosting this connection point
  21381. * @param direction defines the direction of the connection point
  21382. */
  21383. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  21384. /**
  21385. * Gets a number indicating if the current point can be connected to another point
  21386. * @param connectionPoint defines the other connection point
  21387. * @returns a number defining the compatibility state
  21388. */
  21389. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  21390. /**
  21391. * Creates a block suitable to be used as an input for this input point.
  21392. * If null is returned, a block based on the point type will be created.
  21393. * @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
  21394. */
  21395. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  21396. }
  21397. }
  21398. declare module "babylonjs/Materials/Node/nodeMaterialDecorator" {
  21399. /**
  21400. * Enum defining the type of properties that can be edited in the property pages in the NME
  21401. */
  21402. export enum PropertyTypeForEdition {
  21403. /** property is a boolean */
  21404. Boolean = 0,
  21405. /** property is a float */
  21406. Float = 1,
  21407. /** property is a Vector2 */
  21408. Vector2 = 2,
  21409. /** property is a list of values */
  21410. List = 3
  21411. }
  21412. /**
  21413. * Interface that defines an option in a variable of type list
  21414. */
  21415. export interface IEditablePropertyListOption {
  21416. /** label of the option */
  21417. "label": string;
  21418. /** value of the option */
  21419. "value": number;
  21420. }
  21421. /**
  21422. * Interface that defines the options available for an editable property
  21423. */
  21424. export interface IEditablePropertyOption {
  21425. /** min value */
  21426. "min"?: number;
  21427. /** max value */
  21428. "max"?: number;
  21429. /** notifiers: indicates which actions to take when the property is changed */
  21430. "notifiers"?: {
  21431. /** the material should be rebuilt */
  21432. "rebuild"?: boolean;
  21433. /** the preview should be updated */
  21434. "update"?: boolean;
  21435. };
  21436. /** list of the options for a variable of type list */
  21437. "options"?: IEditablePropertyListOption[];
  21438. }
  21439. /**
  21440. * Interface that describes an editable property
  21441. */
  21442. export interface IPropertyDescriptionForEdition {
  21443. /** name of the property */
  21444. "propertyName": string;
  21445. /** display name of the property */
  21446. "displayName": string;
  21447. /** type of the property */
  21448. "type": PropertyTypeForEdition;
  21449. /** group of the property - all properties with the same group value will be displayed in a specific section */
  21450. "groupName": string;
  21451. /** options for the property */
  21452. "options": IEditablePropertyOption;
  21453. }
  21454. /**
  21455. * Decorator that flags a property in a node material block as being editable
  21456. */
  21457. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  21458. }
  21459. declare module "babylonjs/Materials/Node/Blocks/PBR/refractionBlock" {
  21460. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21461. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21462. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21463. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21464. import { Nullable } from "babylonjs/types";
  21465. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21466. import { Mesh } from "babylonjs/Meshes/mesh";
  21467. import { SubMesh } from "babylonjs/Meshes/subMesh";
  21468. import { Effect } from "babylonjs/Materials/effect";
  21469. import { Scene } from "babylonjs/scene";
  21470. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21471. /**
  21472. * Block used to implement the refraction part of the sub surface module of the PBR material
  21473. */
  21474. export class RefractionBlock extends NodeMaterialBlock {
  21475. /** @hidden */
  21476. _define3DName: string;
  21477. /** @hidden */
  21478. _refractionMatrixName: string;
  21479. /** @hidden */
  21480. _defineLODRefractionAlpha: string;
  21481. /** @hidden */
  21482. _defineLinearSpecularRefraction: string;
  21483. /** @hidden */
  21484. _defineOppositeZ: string;
  21485. /** @hidden */
  21486. _cubeSamplerName: string;
  21487. /** @hidden */
  21488. _2DSamplerName: string;
  21489. /** @hidden */
  21490. _vRefractionMicrosurfaceInfosName: string;
  21491. /** @hidden */
  21492. _vRefractionInfosName: string;
  21493. private _scene;
  21494. /**
  21495. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  21496. * Materials half opaque for instance using refraction could benefit from this control.
  21497. */
  21498. linkRefractionWithTransparency: boolean;
  21499. /**
  21500. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  21501. */
  21502. invertRefractionY: boolean;
  21503. /**
  21504. * Gets or sets the texture associated with the node
  21505. */
  21506. texture: Nullable<BaseTexture>;
  21507. /**
  21508. * Create a new RefractionBlock
  21509. * @param name defines the block name
  21510. */
  21511. constructor(name: string);
  21512. /**
  21513. * Gets the current class name
  21514. * @returns the class name
  21515. */
  21516. getClassName(): string;
  21517. /**
  21518. * Gets the intensity input component
  21519. */
  21520. get intensity(): NodeMaterialConnectionPoint;
  21521. /**
  21522. * Gets the index of refraction input component
  21523. */
  21524. get indexOfRefraction(): NodeMaterialConnectionPoint;
  21525. /**
  21526. * Gets the tint at distance input component
  21527. */
  21528. get tintAtDistance(): NodeMaterialConnectionPoint;
  21529. /**
  21530. * Gets the view input component
  21531. */
  21532. get view(): NodeMaterialConnectionPoint;
  21533. /**
  21534. * Gets the refraction object output component
  21535. */
  21536. get refraction(): NodeMaterialConnectionPoint;
  21537. /**
  21538. * Returns true if the block has a texture
  21539. */
  21540. get hasTexture(): boolean;
  21541. protected _getTexture(): Nullable<BaseTexture>;
  21542. autoConfigure(material: NodeMaterial): void;
  21543. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21544. isReady(): boolean;
  21545. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  21546. /**
  21547. * Gets the main code of the block (fragment side)
  21548. * @param state current state of the node material building
  21549. * @returns the shader code
  21550. */
  21551. getCode(state: NodeMaterialBuildState): string;
  21552. protected _buildBlock(state: NodeMaterialBuildState): this;
  21553. protected _dumpPropertiesCode(): string;
  21554. serialize(): any;
  21555. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21556. }
  21557. }
  21558. declare module "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock" {
  21559. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21560. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21561. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21562. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21563. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21564. import { NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21565. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21566. import { Nullable } from "babylonjs/types";
  21567. import { Scene } from "babylonjs/scene";
  21568. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  21569. /**
  21570. * Base block used as input for post process
  21571. */
  21572. export class CurrentScreenBlock extends NodeMaterialBlock {
  21573. private _samplerName;
  21574. private _linearDefineName;
  21575. private _gammaDefineName;
  21576. private _mainUVName;
  21577. private _tempTextureRead;
  21578. /**
  21579. * Gets or sets the texture associated with the node
  21580. */
  21581. texture: Nullable<BaseTexture>;
  21582. /**
  21583. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21584. */
  21585. convertToGammaSpace: boolean;
  21586. /**
  21587. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21588. */
  21589. convertToLinearSpace: boolean;
  21590. /**
  21591. * Create a new CurrentScreenBlock
  21592. * @param name defines the block name
  21593. */
  21594. constructor(name: string);
  21595. /**
  21596. * Gets the current class name
  21597. * @returns the class name
  21598. */
  21599. getClassName(): string;
  21600. /**
  21601. * Gets the uv input component
  21602. */
  21603. get uv(): NodeMaterialConnectionPoint;
  21604. /**
  21605. * Gets the rgba output component
  21606. */
  21607. get rgba(): NodeMaterialConnectionPoint;
  21608. /**
  21609. * Gets the rgb output component
  21610. */
  21611. get rgb(): NodeMaterialConnectionPoint;
  21612. /**
  21613. * Gets the r output component
  21614. */
  21615. get r(): NodeMaterialConnectionPoint;
  21616. /**
  21617. * Gets the g output component
  21618. */
  21619. get g(): NodeMaterialConnectionPoint;
  21620. /**
  21621. * Gets the b output component
  21622. */
  21623. get b(): NodeMaterialConnectionPoint;
  21624. /**
  21625. * Gets the a output component
  21626. */
  21627. get a(): NodeMaterialConnectionPoint;
  21628. /**
  21629. * Initialize the block and prepare the context for build
  21630. * @param state defines the state that will be used for the build
  21631. */
  21632. initialize(state: NodeMaterialBuildState): void;
  21633. get target(): NodeMaterialBlockTargets;
  21634. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21635. isReady(): boolean;
  21636. private _injectVertexCode;
  21637. private _writeTextureRead;
  21638. private _writeOutput;
  21639. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21640. serialize(): any;
  21641. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21642. }
  21643. }
  21644. declare module "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock" {
  21645. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21646. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21647. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21648. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21649. import { NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21650. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21651. import { Nullable } from "babylonjs/types";
  21652. import { Scene } from "babylonjs/scene";
  21653. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  21654. /**
  21655. * Base block used for the particle texture
  21656. */
  21657. export class ParticleTextureBlock extends NodeMaterialBlock {
  21658. private _samplerName;
  21659. private _linearDefineName;
  21660. private _gammaDefineName;
  21661. private _tempTextureRead;
  21662. /**
  21663. * Gets or sets the texture associated with the node
  21664. */
  21665. texture: Nullable<BaseTexture>;
  21666. /**
  21667. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21668. */
  21669. convertToGammaSpace: boolean;
  21670. /**
  21671. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21672. */
  21673. convertToLinearSpace: boolean;
  21674. /**
  21675. * Create a new ParticleTextureBlock
  21676. * @param name defines the block name
  21677. */
  21678. constructor(name: string);
  21679. /**
  21680. * Gets the current class name
  21681. * @returns the class name
  21682. */
  21683. getClassName(): string;
  21684. /**
  21685. * Gets the uv input component
  21686. */
  21687. get uv(): NodeMaterialConnectionPoint;
  21688. /**
  21689. * Gets the rgba output component
  21690. */
  21691. get rgba(): NodeMaterialConnectionPoint;
  21692. /**
  21693. * Gets the rgb output component
  21694. */
  21695. get rgb(): NodeMaterialConnectionPoint;
  21696. /**
  21697. * Gets the r output component
  21698. */
  21699. get r(): NodeMaterialConnectionPoint;
  21700. /**
  21701. * Gets the g output component
  21702. */
  21703. get g(): NodeMaterialConnectionPoint;
  21704. /**
  21705. * Gets the b output component
  21706. */
  21707. get b(): NodeMaterialConnectionPoint;
  21708. /**
  21709. * Gets the a output component
  21710. */
  21711. get a(): NodeMaterialConnectionPoint;
  21712. /**
  21713. * Initialize the block and prepare the context for build
  21714. * @param state defines the state that will be used for the build
  21715. */
  21716. initialize(state: NodeMaterialBuildState): void;
  21717. autoConfigure(material: NodeMaterial): void;
  21718. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21719. isReady(): boolean;
  21720. private _writeOutput;
  21721. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21722. serialize(): any;
  21723. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21724. }
  21725. }
  21726. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  21727. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21728. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21729. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  21730. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  21731. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  21732. import { RefractionBlock } from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  21733. import { CurrentScreenBlock } from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  21734. import { ParticleTextureBlock } from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  21735. import { Scene } from "babylonjs/scene";
  21736. /**
  21737. * Class used to store shared data between 2 NodeMaterialBuildState
  21738. */
  21739. export class NodeMaterialBuildStateSharedData {
  21740. /**
  21741. * Gets the list of emitted varyings
  21742. */
  21743. temps: string[];
  21744. /**
  21745. * Gets the list of emitted varyings
  21746. */
  21747. varyings: string[];
  21748. /**
  21749. * Gets the varying declaration string
  21750. */
  21751. varyingDeclaration: string;
  21752. /**
  21753. * Input blocks
  21754. */
  21755. inputBlocks: InputBlock[];
  21756. /**
  21757. * Input blocks
  21758. */
  21759. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  21760. /**
  21761. * Bindable blocks (Blocks that need to set data to the effect)
  21762. */
  21763. bindableBlocks: NodeMaterialBlock[];
  21764. /**
  21765. * List of blocks that can provide a compilation fallback
  21766. */
  21767. blocksWithFallbacks: NodeMaterialBlock[];
  21768. /**
  21769. * List of blocks that can provide a define update
  21770. */
  21771. blocksWithDefines: NodeMaterialBlock[];
  21772. /**
  21773. * List of blocks that can provide a repeatable content
  21774. */
  21775. repeatableContentBlocks: NodeMaterialBlock[];
  21776. /**
  21777. * List of blocks that can provide a dynamic list of uniforms
  21778. */
  21779. dynamicUniformBlocks: NodeMaterialBlock[];
  21780. /**
  21781. * List of blocks that can block the isReady function for the material
  21782. */
  21783. blockingBlocks: NodeMaterialBlock[];
  21784. /**
  21785. * Gets the list of animated inputs
  21786. */
  21787. animatedInputs: InputBlock[];
  21788. /**
  21789. * Build Id used to avoid multiple recompilations
  21790. */
  21791. buildId: number;
  21792. /** List of emitted variables */
  21793. variableNames: {
  21794. [key: string]: number;
  21795. };
  21796. /** List of emitted defines */
  21797. defineNames: {
  21798. [key: string]: number;
  21799. };
  21800. /** Should emit comments? */
  21801. emitComments: boolean;
  21802. /** Emit build activity */
  21803. verbose: boolean;
  21804. /** Gets or sets the hosting scene */
  21805. scene: Scene;
  21806. /**
  21807. * Gets the compilation hints emitted at compilation time
  21808. */
  21809. hints: {
  21810. needWorldViewMatrix: boolean;
  21811. needWorldViewProjectionMatrix: boolean;
  21812. needAlphaBlending: boolean;
  21813. needAlphaTesting: boolean;
  21814. };
  21815. /**
  21816. * List of compilation checks
  21817. */
  21818. checks: {
  21819. emitVertex: boolean;
  21820. emitFragment: boolean;
  21821. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  21822. };
  21823. /**
  21824. * Is vertex program allowed to be empty?
  21825. */
  21826. allowEmptyVertexProgram: boolean;
  21827. /** Creates a new shared data */
  21828. constructor();
  21829. /**
  21830. * Emits console errors and exceptions if there is a failing check
  21831. */
  21832. emitErrors(): void;
  21833. }
  21834. }
  21835. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  21836. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  21837. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21838. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  21839. /**
  21840. * Class used to store node based material build state
  21841. */
  21842. export class NodeMaterialBuildState {
  21843. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  21844. supportUniformBuffers: boolean;
  21845. /**
  21846. * Gets the list of emitted attributes
  21847. */
  21848. attributes: string[];
  21849. /**
  21850. * Gets the list of emitted uniforms
  21851. */
  21852. uniforms: string[];
  21853. /**
  21854. * Gets the list of emitted constants
  21855. */
  21856. constants: string[];
  21857. /**
  21858. * Gets the list of emitted samplers
  21859. */
  21860. samplers: string[];
  21861. /**
  21862. * Gets the list of emitted functions
  21863. */
  21864. functions: {
  21865. [key: string]: string;
  21866. };
  21867. /**
  21868. * Gets the list of emitted extensions
  21869. */
  21870. extensions: {
  21871. [key: string]: string;
  21872. };
  21873. /**
  21874. * Gets the target of the compilation state
  21875. */
  21876. target: NodeMaterialBlockTargets;
  21877. /**
  21878. * Gets the list of emitted counters
  21879. */
  21880. counters: {
  21881. [key: string]: number;
  21882. };
  21883. /**
  21884. * Shared data between multiple NodeMaterialBuildState instances
  21885. */
  21886. sharedData: NodeMaterialBuildStateSharedData;
  21887. /** @hidden */
  21888. _vertexState: NodeMaterialBuildState;
  21889. /** @hidden */
  21890. _attributeDeclaration: string;
  21891. /** @hidden */
  21892. _uniformDeclaration: string;
  21893. /** @hidden */
  21894. _constantDeclaration: string;
  21895. /** @hidden */
  21896. _samplerDeclaration: string;
  21897. /** @hidden */
  21898. _varyingTransfer: string;
  21899. /** @hidden */
  21900. _injectAtEnd: string;
  21901. private _repeatableContentAnchorIndex;
  21902. /** @hidden */
  21903. _builtCompilationString: string;
  21904. /**
  21905. * Gets the emitted compilation strings
  21906. */
  21907. compilationString: string;
  21908. /**
  21909. * Finalize the compilation strings
  21910. * @param state defines the current compilation state
  21911. */
  21912. finalize(state: NodeMaterialBuildState): void;
  21913. /** @hidden */
  21914. get _repeatableContentAnchor(): string;
  21915. /** @hidden */
  21916. _getFreeVariableName(prefix: string): string;
  21917. /** @hidden */
  21918. _getFreeDefineName(prefix: string): string;
  21919. /** @hidden */
  21920. _excludeVariableName(name: string): void;
  21921. /** @hidden */
  21922. _emit2DSampler(name: string): void;
  21923. /** @hidden */
  21924. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  21925. /** @hidden */
  21926. _emitExtension(name: string, extension: string, define?: string): void;
  21927. /** @hidden */
  21928. _emitFunction(name: string, code: string, comments: string): void;
  21929. /** @hidden */
  21930. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  21931. replaceStrings?: {
  21932. search: RegExp;
  21933. replace: string;
  21934. }[];
  21935. repeatKey?: string;
  21936. }): string;
  21937. /** @hidden */
  21938. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  21939. repeatKey?: string;
  21940. removeAttributes?: boolean;
  21941. removeUniforms?: boolean;
  21942. removeVaryings?: boolean;
  21943. removeIfDef?: boolean;
  21944. replaceStrings?: {
  21945. search: RegExp;
  21946. replace: string;
  21947. }[];
  21948. }, storeKey?: string): void;
  21949. /** @hidden */
  21950. _registerTempVariable(name: string): boolean;
  21951. /** @hidden */
  21952. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  21953. /** @hidden */
  21954. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  21955. /** @hidden */
  21956. _emitFloat(value: number): string;
  21957. }
  21958. }
  21959. declare module "babylonjs/Misc/uniqueIdGenerator" {
  21960. /**
  21961. * Helper class used to generate session unique ID
  21962. */
  21963. export class UniqueIdGenerator {
  21964. private static _UniqueIdCounter;
  21965. /**
  21966. * Gets an unique (relatively to the current scene) Id
  21967. */
  21968. static get UniqueId(): number;
  21969. }
  21970. }
  21971. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  21972. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  21973. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21974. import { Nullable } from "babylonjs/types";
  21975. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21976. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21977. import { Effect } from "babylonjs/Materials/effect";
  21978. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21979. import { Mesh } from "babylonjs/Meshes/mesh";
  21980. import { SubMesh } from "babylonjs/Meshes/subMesh";
  21981. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21982. import { Scene } from "babylonjs/scene";
  21983. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  21984. /**
  21985. * Defines a block that can be used inside a node based material
  21986. */
  21987. export class NodeMaterialBlock {
  21988. private _buildId;
  21989. private _buildTarget;
  21990. private _target;
  21991. private _isFinalMerger;
  21992. private _isInput;
  21993. protected _isUnique: boolean;
  21994. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  21995. inputsAreExclusive: boolean;
  21996. /** @hidden */
  21997. _codeVariableName: string;
  21998. /** @hidden */
  21999. _inputs: NodeMaterialConnectionPoint[];
  22000. /** @hidden */
  22001. _outputs: NodeMaterialConnectionPoint[];
  22002. /** @hidden */
  22003. _preparationId: number;
  22004. /**
  22005. * Gets or sets the name of the block
  22006. */
  22007. name: string;
  22008. /**
  22009. * Gets or sets the unique id of the node
  22010. */
  22011. uniqueId: number;
  22012. /**
  22013. * Gets or sets the comments associated with this block
  22014. */
  22015. comments: string;
  22016. /**
  22017. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  22018. */
  22019. get isUnique(): boolean;
  22020. /**
  22021. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  22022. */
  22023. get isFinalMerger(): boolean;
  22024. /**
  22025. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  22026. */
  22027. get isInput(): boolean;
  22028. /**
  22029. * Gets or sets the build Id
  22030. */
  22031. get buildId(): number;
  22032. set buildId(value: number);
  22033. /**
  22034. * Gets or sets the target of the block
  22035. */
  22036. get target(): NodeMaterialBlockTargets;
  22037. set target(value: NodeMaterialBlockTargets);
  22038. /**
  22039. * Gets the list of input points
  22040. */
  22041. get inputs(): NodeMaterialConnectionPoint[];
  22042. /** Gets the list of output points */
  22043. get outputs(): NodeMaterialConnectionPoint[];
  22044. /**
  22045. * Find an input by its name
  22046. * @param name defines the name of the input to look for
  22047. * @returns the input or null if not found
  22048. */
  22049. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  22050. /**
  22051. * Find an output by its name
  22052. * @param name defines the name of the outputto look for
  22053. * @returns the output or null if not found
  22054. */
  22055. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  22056. /**
  22057. * Creates a new NodeMaterialBlock
  22058. * @param name defines the block name
  22059. * @param target defines the target of that block (Vertex by default)
  22060. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  22061. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  22062. */
  22063. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  22064. /**
  22065. * Initialize the block and prepare the context for build
  22066. * @param state defines the state that will be used for the build
  22067. */
  22068. initialize(state: NodeMaterialBuildState): void;
  22069. /**
  22070. * Bind data to effect. Will only be called for blocks with isBindable === true
  22071. * @param effect defines the effect to bind data to
  22072. * @param nodeMaterial defines the hosting NodeMaterial
  22073. * @param mesh defines the mesh that will be rendered
  22074. * @param subMesh defines the submesh that will be rendered
  22075. */
  22076. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  22077. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  22078. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  22079. protected _writeFloat(value: number): string;
  22080. /**
  22081. * Gets the current class name e.g. "NodeMaterialBlock"
  22082. * @returns the class name
  22083. */
  22084. getClassName(): string;
  22085. /**
  22086. * Register a new input. Must be called inside a block constructor
  22087. * @param name defines the connection point name
  22088. * @param type defines the connection point type
  22089. * @param isOptional defines a boolean indicating that this input can be omitted
  22090. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  22091. * @param point an already created connection point. If not provided, create a new one
  22092. * @returns the current block
  22093. */
  22094. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  22095. /**
  22096. * Register a new output. Must be called inside a block constructor
  22097. * @param name defines the connection point name
  22098. * @param type defines the connection point type
  22099. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  22100. * @param point an already created connection point. If not provided, create a new one
  22101. * @returns the current block
  22102. */
  22103. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  22104. /**
  22105. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  22106. * @param forOutput defines an optional connection point to check compatibility with
  22107. * @returns the first available input or null
  22108. */
  22109. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  22110. /**
  22111. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  22112. * @param forBlock defines an optional block to check compatibility with
  22113. * @returns the first available input or null
  22114. */
  22115. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  22116. /**
  22117. * Gets the sibling of the given output
  22118. * @param current defines the current output
  22119. * @returns the next output in the list or null
  22120. */
  22121. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  22122. /**
  22123. * Connect current block with another block
  22124. * @param other defines the block to connect with
  22125. * @param options define the various options to help pick the right connections
  22126. * @returns the current block
  22127. */
  22128. connectTo(other: NodeMaterialBlock, options?: {
  22129. input?: string;
  22130. output?: string;
  22131. outputSwizzle?: string;
  22132. }): this | undefined;
  22133. protected _buildBlock(state: NodeMaterialBuildState): void;
  22134. /**
  22135. * Add uniforms, samplers and uniform buffers at compilation time
  22136. * @param state defines the state to update
  22137. * @param nodeMaterial defines the node material requesting the update
  22138. * @param defines defines the material defines to update
  22139. * @param uniformBuffers defines the list of uniform buffer names
  22140. */
  22141. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  22142. /**
  22143. * Add potential fallbacks if shader compilation fails
  22144. * @param mesh defines the mesh to be rendered
  22145. * @param fallbacks defines the current prioritized list of fallbacks
  22146. */
  22147. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  22148. /**
  22149. * Initialize defines for shader compilation
  22150. * @param mesh defines the mesh to be rendered
  22151. * @param nodeMaterial defines the node material requesting the update
  22152. * @param defines defines the material defines to update
  22153. * @param useInstances specifies that instances should be used
  22154. */
  22155. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  22156. /**
  22157. * Update defines for shader compilation
  22158. * @param mesh defines the mesh to be rendered
  22159. * @param nodeMaterial defines the node material requesting the update
  22160. * @param defines defines the material defines to update
  22161. * @param useInstances specifies that instances should be used
  22162. */
  22163. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  22164. /**
  22165. * Lets the block try to connect some inputs automatically
  22166. * @param material defines the hosting NodeMaterial
  22167. */
  22168. autoConfigure(material: NodeMaterial): void;
  22169. /**
  22170. * Function called when a block is declared as repeatable content generator
  22171. * @param vertexShaderState defines the current compilation state for the vertex shader
  22172. * @param fragmentShaderState defines the current compilation state for the fragment shader
  22173. * @param mesh defines the mesh to be rendered
  22174. * @param defines defines the material defines to update
  22175. */
  22176. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  22177. /**
  22178. * Checks if the block is ready
  22179. * @param mesh defines the mesh to be rendered
  22180. * @param nodeMaterial defines the node material requesting the update
  22181. * @param defines defines the material defines to update
  22182. * @param useInstances specifies that instances should be used
  22183. * @returns true if the block is ready
  22184. */
  22185. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  22186. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  22187. private _processBuild;
  22188. /**
  22189. * Compile the current node and generate the shader code
  22190. * @param state defines the current compilation state (uniforms, samplers, current string)
  22191. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  22192. * @returns true if already built
  22193. */
  22194. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  22195. protected _inputRename(name: string): string;
  22196. protected _outputRename(name: string): string;
  22197. protected _dumpPropertiesCode(): string;
  22198. /** @hidden */
  22199. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  22200. /** @hidden */
  22201. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  22202. /**
  22203. * Clone the current block to a new identical block
  22204. * @param scene defines the hosting scene
  22205. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22206. * @returns a copy of the current block
  22207. */
  22208. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  22209. /**
  22210. * Serializes this block in a JSON representation
  22211. * @returns the serialized block object
  22212. */
  22213. serialize(): any;
  22214. /** @hidden */
  22215. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22216. private _deserializePortDisplayNames;
  22217. /**
  22218. * Release resources
  22219. */
  22220. dispose(): void;
  22221. }
  22222. }
  22223. declare module "babylonjs/Materials/pushMaterial" {
  22224. import { Nullable } from "babylonjs/types";
  22225. import { Scene } from "babylonjs/scene";
  22226. import { Matrix } from "babylonjs/Maths/math.vector";
  22227. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22228. import { Mesh } from "babylonjs/Meshes/mesh";
  22229. import { Material } from "babylonjs/Materials/material";
  22230. import { Effect } from "babylonjs/Materials/effect";
  22231. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22232. /**
  22233. * Base class of materials working in push mode in babylon JS
  22234. * @hidden
  22235. */
  22236. export class PushMaterial extends Material {
  22237. protected _activeEffect: Effect;
  22238. protected _normalMatrix: Matrix;
  22239. /**
  22240. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  22241. * This means that the material can keep using a previous shader while a new one is being compiled.
  22242. * This is mostly used when shader parallel compilation is supported (true by default)
  22243. */
  22244. allowShaderHotSwapping: boolean;
  22245. constructor(name: string, scene: Scene);
  22246. getEffect(): Effect;
  22247. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  22248. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  22249. /**
  22250. * Binds the given world matrix to the active effect
  22251. *
  22252. * @param world the matrix to bind
  22253. */
  22254. bindOnlyWorldMatrix(world: Matrix): void;
  22255. /**
  22256. * Binds the given normal matrix to the active effect
  22257. *
  22258. * @param normalMatrix the matrix to bind
  22259. */
  22260. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  22261. bind(world: Matrix, mesh?: Mesh): void;
  22262. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  22263. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  22264. }
  22265. }
  22266. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  22267. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22268. /**
  22269. * Root class for all node material optimizers
  22270. */
  22271. export class NodeMaterialOptimizer {
  22272. /**
  22273. * Function used to optimize a NodeMaterial graph
  22274. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  22275. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  22276. */
  22277. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  22278. }
  22279. }
  22280. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  22281. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22282. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22283. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22284. import { Scene } from "babylonjs/scene";
  22285. /**
  22286. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  22287. */
  22288. export class TransformBlock extends NodeMaterialBlock {
  22289. /**
  22290. * Defines the value to use to complement W value to transform it to a Vector4
  22291. */
  22292. complementW: number;
  22293. /**
  22294. * Defines the value to use to complement z value to transform it to a Vector4
  22295. */
  22296. complementZ: number;
  22297. /**
  22298. * Creates a new TransformBlock
  22299. * @param name defines the block name
  22300. */
  22301. constructor(name: string);
  22302. /**
  22303. * Gets the current class name
  22304. * @returns the class name
  22305. */
  22306. getClassName(): string;
  22307. /**
  22308. * Gets the vector input
  22309. */
  22310. get vector(): NodeMaterialConnectionPoint;
  22311. /**
  22312. * Gets the output component
  22313. */
  22314. get output(): NodeMaterialConnectionPoint;
  22315. /**
  22316. * Gets the xyz output component
  22317. */
  22318. get xyz(): NodeMaterialConnectionPoint;
  22319. /**
  22320. * Gets the matrix transform input
  22321. */
  22322. get transform(): NodeMaterialConnectionPoint;
  22323. protected _buildBlock(state: NodeMaterialBuildState): this;
  22324. serialize(): any;
  22325. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22326. protected _dumpPropertiesCode(): string;
  22327. }
  22328. }
  22329. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  22330. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22331. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22332. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22333. /**
  22334. * Block used to output the vertex position
  22335. */
  22336. export class VertexOutputBlock extends NodeMaterialBlock {
  22337. /**
  22338. * Creates a new VertexOutputBlock
  22339. * @param name defines the block name
  22340. */
  22341. constructor(name: string);
  22342. /**
  22343. * Gets the current class name
  22344. * @returns the class name
  22345. */
  22346. getClassName(): string;
  22347. /**
  22348. * Gets the vector input component
  22349. */
  22350. get vector(): NodeMaterialConnectionPoint;
  22351. protected _buildBlock(state: NodeMaterialBuildState): this;
  22352. }
  22353. }
  22354. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  22355. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22356. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22357. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22358. /**
  22359. * Block used to output the final color
  22360. */
  22361. export class FragmentOutputBlock extends NodeMaterialBlock {
  22362. /**
  22363. * Create a new FragmentOutputBlock
  22364. * @param name defines the block name
  22365. */
  22366. constructor(name: string);
  22367. /**
  22368. * Gets the current class name
  22369. * @returns the class name
  22370. */
  22371. getClassName(): string;
  22372. /**
  22373. * Gets the rgba input component
  22374. */
  22375. get rgba(): NodeMaterialConnectionPoint;
  22376. /**
  22377. * Gets the rgb input component
  22378. */
  22379. get rgb(): NodeMaterialConnectionPoint;
  22380. /**
  22381. * Gets the a input component
  22382. */
  22383. get a(): NodeMaterialConnectionPoint;
  22384. protected _buildBlock(state: NodeMaterialBuildState): this;
  22385. }
  22386. }
  22387. declare module "babylonjs/Materials/Node/Blocks/Particle/particleRampGradientBlock" {
  22388. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22389. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22390. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22391. /**
  22392. * Block used for the particle ramp gradient section
  22393. */
  22394. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  22395. /**
  22396. * Create a new ParticleRampGradientBlock
  22397. * @param name defines the block name
  22398. */
  22399. constructor(name: string);
  22400. /**
  22401. * Gets the current class name
  22402. * @returns the class name
  22403. */
  22404. getClassName(): string;
  22405. /**
  22406. * Gets the color input component
  22407. */
  22408. get color(): NodeMaterialConnectionPoint;
  22409. /**
  22410. * Gets the rampColor output component
  22411. */
  22412. get rampColor(): NodeMaterialConnectionPoint;
  22413. /**
  22414. * Initialize the block and prepare the context for build
  22415. * @param state defines the state that will be used for the build
  22416. */
  22417. initialize(state: NodeMaterialBuildState): void;
  22418. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22419. }
  22420. }
  22421. declare module "babylonjs/Materials/Node/Blocks/Particle/particleBlendMultiplyBlock" {
  22422. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22423. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22424. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22425. /**
  22426. * Block used for the particle blend multiply section
  22427. */
  22428. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  22429. /**
  22430. * Create a new ParticleBlendMultiplyBlock
  22431. * @param name defines the block name
  22432. */
  22433. constructor(name: string);
  22434. /**
  22435. * Gets the current class name
  22436. * @returns the class name
  22437. */
  22438. getClassName(): string;
  22439. /**
  22440. * Gets the color input component
  22441. */
  22442. get color(): NodeMaterialConnectionPoint;
  22443. /**
  22444. * Gets the alphaTexture input component
  22445. */
  22446. get alphaTexture(): NodeMaterialConnectionPoint;
  22447. /**
  22448. * Gets the alphaColor input component
  22449. */
  22450. get alphaColor(): NodeMaterialConnectionPoint;
  22451. /**
  22452. * Gets the blendColor output component
  22453. */
  22454. get blendColor(): NodeMaterialConnectionPoint;
  22455. /**
  22456. * Initialize the block and prepare the context for build
  22457. * @param state defines the state that will be used for the build
  22458. */
  22459. initialize(state: NodeMaterialBuildState): void;
  22460. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22461. }
  22462. }
  22463. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  22464. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22465. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22466. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22467. /**
  22468. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  22469. */
  22470. export class VectorMergerBlock extends NodeMaterialBlock {
  22471. /**
  22472. * Create a new VectorMergerBlock
  22473. * @param name defines the block name
  22474. */
  22475. constructor(name: string);
  22476. /**
  22477. * Gets the current class name
  22478. * @returns the class name
  22479. */
  22480. getClassName(): string;
  22481. /**
  22482. * Gets the xyz component (input)
  22483. */
  22484. get xyzIn(): NodeMaterialConnectionPoint;
  22485. /**
  22486. * Gets the xy component (input)
  22487. */
  22488. get xyIn(): NodeMaterialConnectionPoint;
  22489. /**
  22490. * Gets the x component (input)
  22491. */
  22492. get x(): NodeMaterialConnectionPoint;
  22493. /**
  22494. * Gets the y component (input)
  22495. */
  22496. get y(): NodeMaterialConnectionPoint;
  22497. /**
  22498. * Gets the z component (input)
  22499. */
  22500. get z(): NodeMaterialConnectionPoint;
  22501. /**
  22502. * Gets the w component (input)
  22503. */
  22504. get w(): NodeMaterialConnectionPoint;
  22505. /**
  22506. * Gets the xyzw component (output)
  22507. */
  22508. get xyzw(): NodeMaterialConnectionPoint;
  22509. /**
  22510. * Gets the xyz component (output)
  22511. */
  22512. get xyzOut(): NodeMaterialConnectionPoint;
  22513. /**
  22514. * Gets the xy component (output)
  22515. */
  22516. get xyOut(): NodeMaterialConnectionPoint;
  22517. /**
  22518. * Gets the xy component (output)
  22519. * @deprecated Please use xyOut instead.
  22520. */
  22521. get xy(): NodeMaterialConnectionPoint;
  22522. /**
  22523. * Gets the xyz component (output)
  22524. * @deprecated Please use xyzOut instead.
  22525. */
  22526. get xyz(): NodeMaterialConnectionPoint;
  22527. protected _buildBlock(state: NodeMaterialBuildState): this;
  22528. }
  22529. }
  22530. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  22531. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22532. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22533. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22534. import { Vector2 } from "babylonjs/Maths/math.vector";
  22535. import { Scene } from "babylonjs/scene";
  22536. /**
  22537. * Block used to remap a float from a range to a new one
  22538. */
  22539. export class RemapBlock extends NodeMaterialBlock {
  22540. /**
  22541. * Gets or sets the source range
  22542. */
  22543. sourceRange: Vector2;
  22544. /**
  22545. * Gets or sets the target range
  22546. */
  22547. targetRange: Vector2;
  22548. /**
  22549. * Creates a new RemapBlock
  22550. * @param name defines the block name
  22551. */
  22552. constructor(name: string);
  22553. /**
  22554. * Gets the current class name
  22555. * @returns the class name
  22556. */
  22557. getClassName(): string;
  22558. /**
  22559. * Gets the input component
  22560. */
  22561. get input(): NodeMaterialConnectionPoint;
  22562. /**
  22563. * Gets the source min input component
  22564. */
  22565. get sourceMin(): NodeMaterialConnectionPoint;
  22566. /**
  22567. * Gets the source max input component
  22568. */
  22569. get sourceMax(): NodeMaterialConnectionPoint;
  22570. /**
  22571. * Gets the target min input component
  22572. */
  22573. get targetMin(): NodeMaterialConnectionPoint;
  22574. /**
  22575. * Gets the target max input component
  22576. */
  22577. get targetMax(): NodeMaterialConnectionPoint;
  22578. /**
  22579. * Gets the output component
  22580. */
  22581. get output(): NodeMaterialConnectionPoint;
  22582. protected _buildBlock(state: NodeMaterialBuildState): this;
  22583. protected _dumpPropertiesCode(): string;
  22584. serialize(): any;
  22585. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22586. }
  22587. }
  22588. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  22589. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22590. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22591. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22592. /**
  22593. * Block used to multiply 2 values
  22594. */
  22595. export class MultiplyBlock extends NodeMaterialBlock {
  22596. /**
  22597. * Creates a new MultiplyBlock
  22598. * @param name defines the block name
  22599. */
  22600. constructor(name: string);
  22601. /**
  22602. * Gets the current class name
  22603. * @returns the class name
  22604. */
  22605. getClassName(): string;
  22606. /**
  22607. * Gets the left operand input component
  22608. */
  22609. get left(): NodeMaterialConnectionPoint;
  22610. /**
  22611. * Gets the right operand input component
  22612. */
  22613. get right(): NodeMaterialConnectionPoint;
  22614. /**
  22615. * Gets the output component
  22616. */
  22617. get output(): NodeMaterialConnectionPoint;
  22618. protected _buildBlock(state: NodeMaterialBuildState): this;
  22619. }
  22620. }
  22621. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  22622. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22623. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22624. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22625. /**
  22626. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  22627. */
  22628. export class ColorSplitterBlock extends NodeMaterialBlock {
  22629. /**
  22630. * Create a new ColorSplitterBlock
  22631. * @param name defines the block name
  22632. */
  22633. constructor(name: string);
  22634. /**
  22635. * Gets the current class name
  22636. * @returns the class name
  22637. */
  22638. getClassName(): string;
  22639. /**
  22640. * Gets the rgba component (input)
  22641. */
  22642. get rgba(): NodeMaterialConnectionPoint;
  22643. /**
  22644. * Gets the rgb component (input)
  22645. */
  22646. get rgbIn(): NodeMaterialConnectionPoint;
  22647. /**
  22648. * Gets the rgb component (output)
  22649. */
  22650. get rgbOut(): NodeMaterialConnectionPoint;
  22651. /**
  22652. * Gets the r component (output)
  22653. */
  22654. get r(): NodeMaterialConnectionPoint;
  22655. /**
  22656. * Gets the g component (output)
  22657. */
  22658. get g(): NodeMaterialConnectionPoint;
  22659. /**
  22660. * Gets the b component (output)
  22661. */
  22662. get b(): NodeMaterialConnectionPoint;
  22663. /**
  22664. * Gets the a component (output)
  22665. */
  22666. get a(): NodeMaterialConnectionPoint;
  22667. protected _inputRename(name: string): string;
  22668. protected _outputRename(name: string): string;
  22669. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22670. }
  22671. }
  22672. declare module "babylonjs/Materials/Node/nodeMaterial" {
  22673. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22674. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  22675. import { Scene } from "babylonjs/scene";
  22676. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22677. import { Matrix } from "babylonjs/Maths/math.vector";
  22678. import { Mesh } from "babylonjs/Meshes/mesh";
  22679. import { Engine } from "babylonjs/Engines/engine";
  22680. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22681. import { Observable } from "babylonjs/Misc/observable";
  22682. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22683. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22684. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  22685. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  22686. import { Nullable } from "babylonjs/types";
  22687. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  22688. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  22689. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  22690. import { RefractionBlock } from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  22691. import { CurrentScreenBlock } from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  22692. import { ParticleTextureBlock } from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  22693. import { Effect } from "babylonjs/Materials/effect";
  22694. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  22695. import { Camera } from "babylonjs/Cameras/camera";
  22696. import { NodeMaterialModes } from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  22697. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  22698. /**
  22699. * Interface used to configure the node material editor
  22700. */
  22701. export interface INodeMaterialEditorOptions {
  22702. /** Define the URl to load node editor script */
  22703. editorURL?: string;
  22704. }
  22705. /** @hidden */
  22706. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  22707. NORMAL: boolean;
  22708. TANGENT: boolean;
  22709. UV1: boolean;
  22710. /** BONES */
  22711. NUM_BONE_INFLUENCERS: number;
  22712. BonesPerMesh: number;
  22713. BONETEXTURE: boolean;
  22714. /** MORPH TARGETS */
  22715. MORPHTARGETS: boolean;
  22716. MORPHTARGETS_NORMAL: boolean;
  22717. MORPHTARGETS_TANGENT: boolean;
  22718. MORPHTARGETS_UV: boolean;
  22719. NUM_MORPH_INFLUENCERS: number;
  22720. /** IMAGE PROCESSING */
  22721. IMAGEPROCESSING: boolean;
  22722. VIGNETTE: boolean;
  22723. VIGNETTEBLENDMODEMULTIPLY: boolean;
  22724. VIGNETTEBLENDMODEOPAQUE: boolean;
  22725. TONEMAPPING: boolean;
  22726. TONEMAPPING_ACES: boolean;
  22727. CONTRAST: boolean;
  22728. EXPOSURE: boolean;
  22729. COLORCURVES: boolean;
  22730. COLORGRADING: boolean;
  22731. COLORGRADING3D: boolean;
  22732. SAMPLER3DGREENDEPTH: boolean;
  22733. SAMPLER3DBGRMAP: boolean;
  22734. IMAGEPROCESSINGPOSTPROCESS: boolean;
  22735. /** MISC. */
  22736. BUMPDIRECTUV: number;
  22737. constructor();
  22738. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  22739. }
  22740. /**
  22741. * Class used to configure NodeMaterial
  22742. */
  22743. export interface INodeMaterialOptions {
  22744. /**
  22745. * Defines if blocks should emit comments
  22746. */
  22747. emitComments: boolean;
  22748. }
  22749. /**
  22750. * Class used to create a node based material built by assembling shader blocks
  22751. */
  22752. export class NodeMaterial extends PushMaterial {
  22753. private static _BuildIdGenerator;
  22754. private _options;
  22755. private _vertexCompilationState;
  22756. private _fragmentCompilationState;
  22757. private _sharedData;
  22758. private _buildId;
  22759. private _buildWasSuccessful;
  22760. private _cachedWorldViewMatrix;
  22761. private _cachedWorldViewProjectionMatrix;
  22762. private _optimizers;
  22763. private _animationFrame;
  22764. /** Define the Url to load node editor script */
  22765. static EditorURL: string;
  22766. /** Define the Url to load snippets */
  22767. static SnippetUrl: string;
  22768. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  22769. static IgnoreTexturesAtLoadTime: boolean;
  22770. private BJSNODEMATERIALEDITOR;
  22771. /** Get the inspector from bundle or global */
  22772. private _getGlobalNodeMaterialEditor;
  22773. /**
  22774. * Snippet ID if the material was created from the snippet server
  22775. */
  22776. snippetId: string;
  22777. /**
  22778. * Gets or sets data used by visual editor
  22779. * @see https://nme.babylonjs.com
  22780. */
  22781. editorData: any;
  22782. /**
  22783. * 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)
  22784. */
  22785. ignoreAlpha: boolean;
  22786. /**
  22787. * Defines the maximum number of lights that can be used in the material
  22788. */
  22789. maxSimultaneousLights: number;
  22790. /**
  22791. * Observable raised when the material is built
  22792. */
  22793. onBuildObservable: Observable<NodeMaterial>;
  22794. /**
  22795. * Gets or sets the root nodes of the material vertex shader
  22796. */
  22797. _vertexOutputNodes: NodeMaterialBlock[];
  22798. /**
  22799. * Gets or sets the root nodes of the material fragment (pixel) shader
  22800. */
  22801. _fragmentOutputNodes: NodeMaterialBlock[];
  22802. /** Gets or sets options to control the node material overall behavior */
  22803. get options(): INodeMaterialOptions;
  22804. set options(options: INodeMaterialOptions);
  22805. /**
  22806. * Default configuration related to image processing available in the standard Material.
  22807. */
  22808. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  22809. /**
  22810. * Gets the image processing configuration used either in this material.
  22811. */
  22812. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  22813. /**
  22814. * Sets the Default image processing configuration used either in the this material.
  22815. *
  22816. * If sets to null, the scene one is in use.
  22817. */
  22818. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  22819. /**
  22820. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  22821. */
  22822. attachedBlocks: NodeMaterialBlock[];
  22823. /**
  22824. * Specifies the mode of the node material
  22825. * @hidden
  22826. */
  22827. _mode: NodeMaterialModes;
  22828. /**
  22829. * Gets the mode property
  22830. */
  22831. get mode(): NodeMaterialModes;
  22832. /**
  22833. * Create a new node based material
  22834. * @param name defines the material name
  22835. * @param scene defines the hosting scene
  22836. * @param options defines creation option
  22837. */
  22838. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  22839. /**
  22840. * Gets the current class name of the material e.g. "NodeMaterial"
  22841. * @returns the class name
  22842. */
  22843. getClassName(): string;
  22844. /**
  22845. * Keep track of the image processing observer to allow dispose and replace.
  22846. */
  22847. private _imageProcessingObserver;
  22848. /**
  22849. * Attaches a new image processing configuration to the Standard Material.
  22850. * @param configuration
  22851. */
  22852. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  22853. /**
  22854. * Get a block by its name
  22855. * @param name defines the name of the block to retrieve
  22856. * @returns the required block or null if not found
  22857. */
  22858. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  22859. /**
  22860. * Get a block by its name
  22861. * @param predicate defines the predicate used to find the good candidate
  22862. * @returns the required block or null if not found
  22863. */
  22864. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  22865. /**
  22866. * Get an input block by its name
  22867. * @param predicate defines the predicate used to find the good candidate
  22868. * @returns the required input block or null if not found
  22869. */
  22870. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  22871. /**
  22872. * Gets the list of input blocks attached to this material
  22873. * @returns an array of InputBlocks
  22874. */
  22875. getInputBlocks(): InputBlock[];
  22876. /**
  22877. * Adds a new optimizer to the list of optimizers
  22878. * @param optimizer defines the optimizers to add
  22879. * @returns the current material
  22880. */
  22881. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22882. /**
  22883. * Remove an optimizer from the list of optimizers
  22884. * @param optimizer defines the optimizers to remove
  22885. * @returns the current material
  22886. */
  22887. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22888. /**
  22889. * Add a new block to the list of output nodes
  22890. * @param node defines the node to add
  22891. * @returns the current material
  22892. */
  22893. addOutputNode(node: NodeMaterialBlock): this;
  22894. /**
  22895. * Remove a block from the list of root nodes
  22896. * @param node defines the node to remove
  22897. * @returns the current material
  22898. */
  22899. removeOutputNode(node: NodeMaterialBlock): this;
  22900. private _addVertexOutputNode;
  22901. private _removeVertexOutputNode;
  22902. private _addFragmentOutputNode;
  22903. private _removeFragmentOutputNode;
  22904. /**
  22905. * Specifies if the material will require alpha blending
  22906. * @returns a boolean specifying if alpha blending is needed
  22907. */
  22908. needAlphaBlending(): boolean;
  22909. /**
  22910. * Specifies if this material should be rendered in alpha test mode
  22911. * @returns a boolean specifying if an alpha test is needed.
  22912. */
  22913. needAlphaTesting(): boolean;
  22914. private _initializeBlock;
  22915. private _resetDualBlocks;
  22916. /**
  22917. * Remove a block from the current node material
  22918. * @param block defines the block to remove
  22919. */
  22920. removeBlock(block: NodeMaterialBlock): void;
  22921. /**
  22922. * Build the material and generates the inner effect
  22923. * @param verbose defines if the build should log activity
  22924. */
  22925. build(verbose?: boolean): void;
  22926. /**
  22927. * Runs an otpimization phase to try to improve the shader code
  22928. */
  22929. optimize(): void;
  22930. private _prepareDefinesForAttributes;
  22931. /**
  22932. * Create a post process from the material
  22933. * @param camera The camera to apply the render pass to.
  22934. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22935. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22936. * @param engine The engine which the post process will be applied. (default: current engine)
  22937. * @param reusable If the post process can be reused on the same frame. (default: false)
  22938. * @param textureType Type of textures used when performing the post process. (default: 0)
  22939. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  22940. * @returns the post process created
  22941. */
  22942. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): PostProcess;
  22943. /**
  22944. * Create the post process effect from the material
  22945. * @param postProcess The post process to create the effect for
  22946. */
  22947. createEffectForPostProcess(postProcess: PostProcess): void;
  22948. private _createEffectOrPostProcess;
  22949. private _createEffectForParticles;
  22950. /**
  22951. * Create the effect to be used as the custom effect for a particle system
  22952. * @param particleSystem Particle system to create the effect for
  22953. * @param onCompiled defines a function to call when the effect creation is successful
  22954. * @param onError defines a function to call when the effect creation has failed
  22955. */
  22956. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22957. private _processDefines;
  22958. /**
  22959. * Get if the submesh is ready to be used and all its information available.
  22960. * Child classes can use it to update shaders
  22961. * @param mesh defines the mesh to check
  22962. * @param subMesh defines which submesh to check
  22963. * @param useInstances specifies that instances should be used
  22964. * @returns a boolean indicating that the submesh is ready or not
  22965. */
  22966. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  22967. /**
  22968. * Get a string representing the shaders built by the current node graph
  22969. */
  22970. get compiledShaders(): string;
  22971. /**
  22972. * Binds the world matrix to the material
  22973. * @param world defines the world transformation matrix
  22974. */
  22975. bindOnlyWorldMatrix(world: Matrix): void;
  22976. /**
  22977. * Binds the submesh to this material by preparing the effect and shader to draw
  22978. * @param world defines the world transformation matrix
  22979. * @param mesh defines the mesh containing the submesh
  22980. * @param subMesh defines the submesh to bind the material to
  22981. */
  22982. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22983. /**
  22984. * Gets the active textures from the material
  22985. * @returns an array of textures
  22986. */
  22987. getActiveTextures(): BaseTexture[];
  22988. /**
  22989. * Gets the list of texture blocks
  22990. * @returns an array of texture blocks
  22991. */
  22992. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  22993. /**
  22994. * Specifies if the material uses a texture
  22995. * @param texture defines the texture to check against the material
  22996. * @returns a boolean specifying if the material uses the texture
  22997. */
  22998. hasTexture(texture: BaseTexture): boolean;
  22999. /**
  23000. * Disposes the material
  23001. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  23002. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  23003. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  23004. */
  23005. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  23006. /** Creates the node editor window. */
  23007. private _createNodeEditor;
  23008. /**
  23009. * Launch the node material editor
  23010. * @param config Define the configuration of the editor
  23011. * @return a promise fulfilled when the node editor is visible
  23012. */
  23013. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  23014. /**
  23015. * Clear the current material
  23016. */
  23017. clear(): void;
  23018. /**
  23019. * Clear the current material and set it to a default state
  23020. */
  23021. setToDefault(): void;
  23022. /**
  23023. * Clear the current material and set it to a default state for post process
  23024. */
  23025. setToDefaultPostProcess(): void;
  23026. /**
  23027. * Clear the current material and set it to a default state for particle
  23028. */
  23029. setToDefaultParticle(): void;
  23030. /**
  23031. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  23032. * @param url defines the url to load from
  23033. * @returns a promise that will fullfil when the material is fully loaded
  23034. */
  23035. loadAsync(url: string): Promise<void>;
  23036. private _gatherBlocks;
  23037. /**
  23038. * Generate a string containing the code declaration required to create an equivalent of this material
  23039. * @returns a string
  23040. */
  23041. generateCode(): string;
  23042. /**
  23043. * Serializes this material in a JSON representation
  23044. * @returns the serialized material object
  23045. */
  23046. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  23047. private _restoreConnections;
  23048. /**
  23049. * Clear the current graph and load a new one from a serialization object
  23050. * @param source defines the JSON representation of the material
  23051. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23052. */
  23053. loadFromSerialization(source: any, rootUrl?: string): void;
  23054. /**
  23055. * Makes a duplicate of the current material.
  23056. * @param name - name to use for the new material.
  23057. */
  23058. clone(name: string): NodeMaterial;
  23059. /**
  23060. * Creates a node material from parsed material data
  23061. * @param source defines the JSON representation of the material
  23062. * @param scene defines the hosting scene
  23063. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23064. * @returns a new node material
  23065. */
  23066. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  23067. /**
  23068. * Creates a node material from a snippet saved in a remote file
  23069. * @param name defines the name of the material to create
  23070. * @param url defines the url to load from
  23071. * @param scene defines the hosting scene
  23072. * @returns a promise that will resolve to the new node material
  23073. */
  23074. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  23075. /**
  23076. * Creates a node material from a snippet saved by the node material editor
  23077. * @param snippetId defines the snippet to load
  23078. * @param scene defines the hosting scene
  23079. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23080. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  23081. * @returns a promise that will resolve to the new node material
  23082. */
  23083. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  23084. /**
  23085. * Creates a new node material set to default basic configuration
  23086. * @param name defines the name of the material
  23087. * @param scene defines the hosting scene
  23088. * @returns a new NodeMaterial
  23089. */
  23090. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  23091. }
  23092. }
  23093. declare module "babylonjs/PostProcesses/postProcess" {
  23094. import { Nullable } from "babylonjs/types";
  23095. import { SmartArray } from "babylonjs/Misc/smartArray";
  23096. import { Observable } from "babylonjs/Misc/observable";
  23097. import { Vector2 } from "babylonjs/Maths/math.vector";
  23098. import { Camera } from "babylonjs/Cameras/camera";
  23099. import { Effect } from "babylonjs/Materials/effect";
  23100. import "babylonjs/Shaders/postprocess.vertex";
  23101. import { IInspectable } from "babylonjs/Misc/iInspectable";
  23102. import { Engine } from "babylonjs/Engines/engine";
  23103. import { Color4 } from "babylonjs/Maths/math.color";
  23104. import "babylonjs/Engines/Extensions/engine.renderTarget";
  23105. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  23106. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  23107. /**
  23108. * Size options for a post process
  23109. */
  23110. export type PostProcessOptions = {
  23111. width: number;
  23112. height: number;
  23113. };
  23114. /**
  23115. * PostProcess can be used to apply a shader to a texture after it has been rendered
  23116. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  23117. */
  23118. export class PostProcess {
  23119. /** Name of the PostProcess. */
  23120. name: string;
  23121. /**
  23122. * Gets or sets the unique id of the post process
  23123. */
  23124. uniqueId: number;
  23125. /**
  23126. * Width of the texture to apply the post process on
  23127. */
  23128. width: number;
  23129. /**
  23130. * Height of the texture to apply the post process on
  23131. */
  23132. height: number;
  23133. /**
  23134. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  23135. */
  23136. nodeMaterialSource: Nullable<NodeMaterial>;
  23137. /**
  23138. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  23139. * @hidden
  23140. */
  23141. _outputTexture: Nullable<InternalTexture>;
  23142. /**
  23143. * Sampling mode used by the shader
  23144. * See https://doc.babylonjs.com/classes/3.1/texture
  23145. */
  23146. renderTargetSamplingMode: number;
  23147. /**
  23148. * Clear color to use when screen clearing
  23149. */
  23150. clearColor: Color4;
  23151. /**
  23152. * If the buffer needs to be cleared before applying the post process. (default: true)
  23153. * Should be set to false if shader will overwrite all previous pixels.
  23154. */
  23155. autoClear: boolean;
  23156. /**
  23157. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  23158. */
  23159. alphaMode: number;
  23160. /**
  23161. * Sets the setAlphaBlendConstants of the babylon engine
  23162. */
  23163. alphaConstants: Color4;
  23164. /**
  23165. * Animations to be used for the post processing
  23166. */
  23167. animations: import("babylonjs/Animations/animation").Animation[];
  23168. /**
  23169. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  23170. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  23171. */
  23172. enablePixelPerfectMode: boolean;
  23173. /**
  23174. * Force the postprocess to be applied without taking in account viewport
  23175. */
  23176. forceFullscreenViewport: boolean;
  23177. /**
  23178. * List of inspectable custom properties (used by the Inspector)
  23179. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23180. */
  23181. inspectableCustomProperties: IInspectable[];
  23182. /**
  23183. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  23184. *
  23185. * | Value | Type | Description |
  23186. * | ----- | ----------------------------------- | ----------- |
  23187. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  23188. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  23189. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  23190. *
  23191. */
  23192. scaleMode: number;
  23193. /**
  23194. * Force textures to be a power of two (default: false)
  23195. */
  23196. alwaysForcePOT: boolean;
  23197. private _samples;
  23198. /**
  23199. * Number of sample textures (default: 1)
  23200. */
  23201. get samples(): number;
  23202. set samples(n: number);
  23203. /**
  23204. * Modify the scale of the post process to be the same as the viewport (default: false)
  23205. */
  23206. adaptScaleToCurrentViewport: boolean;
  23207. private _camera;
  23208. private _scene;
  23209. private _engine;
  23210. private _options;
  23211. private _reusable;
  23212. private _textureType;
  23213. private _textureFormat;
  23214. /**
  23215. * Smart array of input and output textures for the post process.
  23216. * @hidden
  23217. */
  23218. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  23219. /**
  23220. * The index in _textures that corresponds to the output texture.
  23221. * @hidden
  23222. */
  23223. _currentRenderTextureInd: number;
  23224. private _effect;
  23225. private _samplers;
  23226. private _fragmentUrl;
  23227. private _vertexUrl;
  23228. private _parameters;
  23229. private _scaleRatio;
  23230. protected _indexParameters: any;
  23231. private _shareOutputWithPostProcess;
  23232. private _texelSize;
  23233. private _forcedOutputTexture;
  23234. /**
  23235. * Returns the fragment url or shader name used in the post process.
  23236. * @returns the fragment url or name in the shader store.
  23237. */
  23238. getEffectName(): string;
  23239. /**
  23240. * An event triggered when the postprocess is activated.
  23241. */
  23242. onActivateObservable: Observable<Camera>;
  23243. private _onActivateObserver;
  23244. /**
  23245. * A function that is added to the onActivateObservable
  23246. */
  23247. set onActivate(callback: Nullable<(camera: Camera) => void>);
  23248. /**
  23249. * An event triggered when the postprocess changes its size.
  23250. */
  23251. onSizeChangedObservable: Observable<PostProcess>;
  23252. private _onSizeChangedObserver;
  23253. /**
  23254. * A function that is added to the onSizeChangedObservable
  23255. */
  23256. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  23257. /**
  23258. * An event triggered when the postprocess applies its effect.
  23259. */
  23260. onApplyObservable: Observable<Effect>;
  23261. private _onApplyObserver;
  23262. /**
  23263. * A function that is added to the onApplyObservable
  23264. */
  23265. set onApply(callback: (effect: Effect) => void);
  23266. /**
  23267. * An event triggered before rendering the postprocess
  23268. */
  23269. onBeforeRenderObservable: Observable<Effect>;
  23270. private _onBeforeRenderObserver;
  23271. /**
  23272. * A function that is added to the onBeforeRenderObservable
  23273. */
  23274. set onBeforeRender(callback: (effect: Effect) => void);
  23275. /**
  23276. * An event triggered after rendering the postprocess
  23277. */
  23278. onAfterRenderObservable: Observable<Effect>;
  23279. private _onAfterRenderObserver;
  23280. /**
  23281. * A function that is added to the onAfterRenderObservable
  23282. */
  23283. set onAfterRender(callback: (efect: Effect) => void);
  23284. /**
  23285. * 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
  23286. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  23287. */
  23288. get inputTexture(): InternalTexture;
  23289. set inputTexture(value: InternalTexture);
  23290. /**
  23291. * Gets the camera which post process is applied to.
  23292. * @returns The camera the post process is applied to.
  23293. */
  23294. getCamera(): Camera;
  23295. /**
  23296. * Gets the texel size of the postprocess.
  23297. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  23298. */
  23299. get texelSize(): Vector2;
  23300. /**
  23301. * Creates a new instance PostProcess
  23302. * @param name The name of the PostProcess.
  23303. * @param fragmentUrl The url of the fragment shader to be used.
  23304. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  23305. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  23306. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23307. * @param camera The camera to apply the render pass to.
  23308. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23309. * @param engine The engine which the post process will be applied. (default: current engine)
  23310. * @param reusable If the post process can be reused on the same frame. (default: false)
  23311. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  23312. * @param textureType Type of textures used when performing the post process. (default: 0)
  23313. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  23314. * @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
  23315. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  23316. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  23317. */
  23318. constructor(
  23319. /** Name of the PostProcess. */
  23320. 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);
  23321. /**
  23322. * Gets a string idenfifying the name of the class
  23323. * @returns "PostProcess" string
  23324. */
  23325. getClassName(): string;
  23326. /**
  23327. * Gets the engine which this post process belongs to.
  23328. * @returns The engine the post process was enabled with.
  23329. */
  23330. getEngine(): Engine;
  23331. /**
  23332. * The effect that is created when initializing the post process.
  23333. * @returns The created effect corresponding the the postprocess.
  23334. */
  23335. getEffect(): Effect;
  23336. /**
  23337. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  23338. * @param postProcess The post process to share the output with.
  23339. * @returns This post process.
  23340. */
  23341. shareOutputWith(postProcess: PostProcess): PostProcess;
  23342. /**
  23343. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  23344. * This should be called if the post process that shares output with this post process is disabled/disposed.
  23345. */
  23346. useOwnOutput(): void;
  23347. /**
  23348. * Updates the effect with the current post process compile time values and recompiles the shader.
  23349. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  23350. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  23351. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  23352. * @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
  23353. * @param onCompiled Called when the shader has been compiled.
  23354. * @param onError Called if there is an error when compiling a shader.
  23355. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  23356. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  23357. */
  23358. 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;
  23359. /**
  23360. * The post process is reusable if it can be used multiple times within one frame.
  23361. * @returns If the post process is reusable
  23362. */
  23363. isReusable(): boolean;
  23364. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  23365. markTextureDirty(): void;
  23366. /**
  23367. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  23368. * 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.
  23369. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  23370. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  23371. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  23372. * @returns The target texture that was bound to be written to.
  23373. */
  23374. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  23375. /**
  23376. * If the post process is supported.
  23377. */
  23378. get isSupported(): boolean;
  23379. /**
  23380. * The aspect ratio of the output texture.
  23381. */
  23382. get aspectRatio(): number;
  23383. /**
  23384. * Get a value indicating if the post-process is ready to be used
  23385. * @returns true if the post-process is ready (shader is compiled)
  23386. */
  23387. isReady(): boolean;
  23388. /**
  23389. * Binds all textures and uniforms to the shader, this will be run on every pass.
  23390. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  23391. */
  23392. apply(): Nullable<Effect>;
  23393. private _disposeTextures;
  23394. /**
  23395. * Disposes the post process.
  23396. * @param camera The camera to dispose the post process on.
  23397. */
  23398. dispose(camera?: Camera): void;
  23399. }
  23400. }
  23401. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  23402. /** @hidden */
  23403. export var kernelBlurVaryingDeclaration: {
  23404. name: string;
  23405. shader: string;
  23406. };
  23407. }
  23408. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  23409. /** @hidden */
  23410. export var kernelBlurFragment: {
  23411. name: string;
  23412. shader: string;
  23413. };
  23414. }
  23415. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  23416. /** @hidden */
  23417. export var kernelBlurFragment2: {
  23418. name: string;
  23419. shader: string;
  23420. };
  23421. }
  23422. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  23423. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  23424. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  23425. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  23426. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  23427. /** @hidden */
  23428. export var kernelBlurPixelShader: {
  23429. name: string;
  23430. shader: string;
  23431. };
  23432. }
  23433. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  23434. /** @hidden */
  23435. export var kernelBlurVertex: {
  23436. name: string;
  23437. shader: string;
  23438. };
  23439. }
  23440. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  23441. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  23442. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  23443. /** @hidden */
  23444. export var kernelBlurVertexShader: {
  23445. name: string;
  23446. shader: string;
  23447. };
  23448. }
  23449. declare module "babylonjs/PostProcesses/blurPostProcess" {
  23450. import { Vector2 } from "babylonjs/Maths/math.vector";
  23451. import { Nullable } from "babylonjs/types";
  23452. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  23453. import { Camera } from "babylonjs/Cameras/camera";
  23454. import { Effect } from "babylonjs/Materials/effect";
  23455. import { Engine } from "babylonjs/Engines/engine";
  23456. import "babylonjs/Shaders/kernelBlur.fragment";
  23457. import "babylonjs/Shaders/kernelBlur.vertex";
  23458. /**
  23459. * The Blur Post Process which blurs an image based on a kernel and direction.
  23460. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  23461. */
  23462. export class BlurPostProcess extends PostProcess {
  23463. /** The direction in which to blur the image. */
  23464. direction: Vector2;
  23465. private blockCompilation;
  23466. protected _kernel: number;
  23467. protected _idealKernel: number;
  23468. protected _packedFloat: boolean;
  23469. private _staticDefines;
  23470. /**
  23471. * Sets the length in pixels of the blur sample region
  23472. */
  23473. set kernel(v: number);
  23474. /**
  23475. * Gets the length in pixels of the blur sample region
  23476. */
  23477. get kernel(): number;
  23478. /**
  23479. * Sets wether or not the blur needs to unpack/repack floats
  23480. */
  23481. set packedFloat(v: boolean);
  23482. /**
  23483. * Gets wether or not the blur is unpacking/repacking floats
  23484. */
  23485. get packedFloat(): boolean;
  23486. /**
  23487. * Creates a new instance BlurPostProcess
  23488. * @param name The name of the effect.
  23489. * @param direction The direction in which to blur the image.
  23490. * @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.
  23491. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23492. * @param camera The camera to apply the render pass to.
  23493. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23494. * @param engine The engine which the post process will be applied. (default: current engine)
  23495. * @param reusable If the post process can be reused on the same frame. (default: false)
  23496. * @param textureType Type of textures used when performing the post process. (default: 0)
  23497. * @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)
  23498. */
  23499. constructor(name: string,
  23500. /** The direction in which to blur the image. */
  23501. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  23502. /**
  23503. * Updates the effect with the current post process compile time values and recompiles the shader.
  23504. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  23505. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  23506. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  23507. * @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
  23508. * @param onCompiled Called when the shader has been compiled.
  23509. * @param onError Called if there is an error when compiling a shader.
  23510. */
  23511. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23512. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23513. /**
  23514. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  23515. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  23516. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  23517. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  23518. * The gaps between physical kernels are compensated for in the weighting of the samples
  23519. * @param idealKernel Ideal blur kernel.
  23520. * @return Nearest best kernel.
  23521. */
  23522. protected _nearestBestKernel(idealKernel: number): number;
  23523. /**
  23524. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  23525. * @param x The point on the Gaussian distribution to sample.
  23526. * @return the value of the Gaussian function at x.
  23527. */
  23528. protected _gaussianWeight(x: number): number;
  23529. /**
  23530. * Generates a string that can be used as a floating point number in GLSL.
  23531. * @param x Value to print.
  23532. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  23533. * @return GLSL float string.
  23534. */
  23535. protected _glslFloat(x: number, decimalFigures?: number): string;
  23536. }
  23537. }
  23538. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  23539. import { Scene } from "babylonjs/scene";
  23540. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  23541. import { Plane } from "babylonjs/Maths/math.plane";
  23542. /**
  23543. * Mirror texture can be used to simulate the view from a mirror in a scene.
  23544. * It will dynamically be rendered every frame to adapt to the camera point of view.
  23545. * You can then easily use it as a reflectionTexture on a flat surface.
  23546. * In case the surface is not a plane, please consider relying on reflection probes.
  23547. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23548. */
  23549. export class MirrorTexture extends RenderTargetTexture {
  23550. private scene;
  23551. /**
  23552. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  23553. * 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.
  23554. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23555. */
  23556. mirrorPlane: Plane;
  23557. /**
  23558. * Define the blur ratio used to blur the reflection if needed.
  23559. */
  23560. set blurRatio(value: number);
  23561. get blurRatio(): number;
  23562. /**
  23563. * Define the adaptive blur kernel used to blur the reflection if needed.
  23564. * This will autocompute the closest best match for the `blurKernel`
  23565. */
  23566. set adaptiveBlurKernel(value: number);
  23567. /**
  23568. * Define the blur kernel used to blur the reflection if needed.
  23569. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23570. */
  23571. set blurKernel(value: number);
  23572. /**
  23573. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  23574. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23575. */
  23576. set blurKernelX(value: number);
  23577. get blurKernelX(): number;
  23578. /**
  23579. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  23580. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23581. */
  23582. set blurKernelY(value: number);
  23583. get blurKernelY(): number;
  23584. private _autoComputeBlurKernel;
  23585. protected _onRatioRescale(): void;
  23586. private _updateGammaSpace;
  23587. private _imageProcessingConfigChangeObserver;
  23588. private _transformMatrix;
  23589. private _mirrorMatrix;
  23590. private _savedViewMatrix;
  23591. private _blurX;
  23592. private _blurY;
  23593. private _adaptiveBlurKernel;
  23594. private _blurKernelX;
  23595. private _blurKernelY;
  23596. private _blurRatio;
  23597. /**
  23598. * Instantiates a Mirror Texture.
  23599. * Mirror texture can be used to simulate the view from a mirror in a scene.
  23600. * It will dynamically be rendered every frame to adapt to the camera point of view.
  23601. * You can then easily use it as a reflectionTexture on a flat surface.
  23602. * In case the surface is not a plane, please consider relying on reflection probes.
  23603. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23604. * @param name
  23605. * @param size
  23606. * @param scene
  23607. * @param generateMipMaps
  23608. * @param type
  23609. * @param samplingMode
  23610. * @param generateDepthBuffer
  23611. */
  23612. constructor(name: string, size: number | {
  23613. width: number;
  23614. height: number;
  23615. } | {
  23616. ratio: number;
  23617. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  23618. private _preparePostProcesses;
  23619. /**
  23620. * Clone the mirror texture.
  23621. * @returns the cloned texture
  23622. */
  23623. clone(): MirrorTexture;
  23624. /**
  23625. * Serialize the texture to a JSON representation you could use in Parse later on
  23626. * @returns the serialized JSON representation
  23627. */
  23628. serialize(): any;
  23629. /**
  23630. * Dispose the texture and release its associated resources.
  23631. */
  23632. dispose(): void;
  23633. }
  23634. }
  23635. declare module "babylonjs/Materials/Textures/texture" {
  23636. import { Observable } from "babylonjs/Misc/observable";
  23637. import { Nullable } from "babylonjs/types";
  23638. import { Matrix } from "babylonjs/Maths/math.vector";
  23639. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  23640. import { IInspectable } from "babylonjs/Misc/iInspectable";
  23641. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  23642. import { Scene } from "babylonjs/scene";
  23643. /**
  23644. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23645. * @see http://doc.babylonjs.com/babylon101/materials#texture
  23646. */
  23647. export class Texture extends BaseTexture {
  23648. /**
  23649. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  23650. */
  23651. static SerializeBuffers: boolean;
  23652. /** @hidden */
  23653. static _CubeTextureParser: (jsonTexture: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  23654. /** @hidden */
  23655. static _CreateMirror: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  23656. /** @hidden */
  23657. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  23658. /** nearest is mag = nearest and min = nearest and mip = linear */
  23659. static readonly NEAREST_SAMPLINGMODE: number;
  23660. /** nearest is mag = nearest and min = nearest and mip = linear */
  23661. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  23662. /** Bilinear is mag = linear and min = linear and mip = nearest */
  23663. static readonly BILINEAR_SAMPLINGMODE: number;
  23664. /** Bilinear is mag = linear and min = linear and mip = nearest */
  23665. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  23666. /** Trilinear is mag = linear and min = linear and mip = linear */
  23667. static readonly TRILINEAR_SAMPLINGMODE: number;
  23668. /** Trilinear is mag = linear and min = linear and mip = linear */
  23669. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  23670. /** mag = nearest and min = nearest and mip = nearest */
  23671. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  23672. /** mag = nearest and min = linear and mip = nearest */
  23673. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  23674. /** mag = nearest and min = linear and mip = linear */
  23675. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  23676. /** mag = nearest and min = linear and mip = none */
  23677. static readonly NEAREST_LINEAR: number;
  23678. /** mag = nearest and min = nearest and mip = none */
  23679. static readonly NEAREST_NEAREST: number;
  23680. /** mag = linear and min = nearest and mip = nearest */
  23681. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  23682. /** mag = linear and min = nearest and mip = linear */
  23683. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  23684. /** mag = linear and min = linear and mip = none */
  23685. static readonly LINEAR_LINEAR: number;
  23686. /** mag = linear and min = nearest and mip = none */
  23687. static readonly LINEAR_NEAREST: number;
  23688. /** Explicit coordinates mode */
  23689. static readonly EXPLICIT_MODE: number;
  23690. /** Spherical coordinates mode */
  23691. static readonly SPHERICAL_MODE: number;
  23692. /** Planar coordinates mode */
  23693. static readonly PLANAR_MODE: number;
  23694. /** Cubic coordinates mode */
  23695. static readonly CUBIC_MODE: number;
  23696. /** Projection coordinates mode */
  23697. static readonly PROJECTION_MODE: number;
  23698. /** Inverse Cubic coordinates mode */
  23699. static readonly SKYBOX_MODE: number;
  23700. /** Inverse Cubic coordinates mode */
  23701. static readonly INVCUBIC_MODE: number;
  23702. /** Equirectangular coordinates mode */
  23703. static readonly EQUIRECTANGULAR_MODE: number;
  23704. /** Equirectangular Fixed coordinates mode */
  23705. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  23706. /** Equirectangular Fixed Mirrored coordinates mode */
  23707. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  23708. /** Texture is not repeating outside of 0..1 UVs */
  23709. static readonly CLAMP_ADDRESSMODE: number;
  23710. /** Texture is repeating outside of 0..1 UVs */
  23711. static readonly WRAP_ADDRESSMODE: number;
  23712. /** Texture is repeating and mirrored */
  23713. static readonly MIRROR_ADDRESSMODE: number;
  23714. /**
  23715. * 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
  23716. */
  23717. static UseSerializedUrlIfAny: boolean;
  23718. /**
  23719. * Define the url of the texture.
  23720. */
  23721. url: Nullable<string>;
  23722. /**
  23723. * Define an offset on the texture to offset the u coordinates of the UVs
  23724. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  23725. */
  23726. uOffset: number;
  23727. /**
  23728. * Define an offset on the texture to offset the v coordinates of the UVs
  23729. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  23730. */
  23731. vOffset: number;
  23732. /**
  23733. * Define an offset on the texture to scale the u coordinates of the UVs
  23734. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  23735. */
  23736. uScale: number;
  23737. /**
  23738. * Define an offset on the texture to scale the v coordinates of the UVs
  23739. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  23740. */
  23741. vScale: number;
  23742. /**
  23743. * Define an offset on the texture to rotate around the u coordinates of the UVs
  23744. * @see http://doc.babylonjs.com/how_to/more_materials
  23745. */
  23746. uAng: number;
  23747. /**
  23748. * Define an offset on the texture to rotate around the v coordinates of the UVs
  23749. * @see http://doc.babylonjs.com/how_to/more_materials
  23750. */
  23751. vAng: number;
  23752. /**
  23753. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  23754. * @see http://doc.babylonjs.com/how_to/more_materials
  23755. */
  23756. wAng: number;
  23757. /**
  23758. * Defines the center of rotation (U)
  23759. */
  23760. uRotationCenter: number;
  23761. /**
  23762. * Defines the center of rotation (V)
  23763. */
  23764. vRotationCenter: number;
  23765. /**
  23766. * Defines the center of rotation (W)
  23767. */
  23768. wRotationCenter: number;
  23769. /**
  23770. * Are mip maps generated for this texture or not.
  23771. */
  23772. get noMipmap(): boolean;
  23773. /**
  23774. * List of inspectable custom properties (used by the Inspector)
  23775. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23776. */
  23777. inspectableCustomProperties: Nullable<IInspectable[]>;
  23778. private _noMipmap;
  23779. /** @hidden */
  23780. _invertY: boolean;
  23781. private _rowGenerationMatrix;
  23782. private _cachedTextureMatrix;
  23783. private _projectionModeMatrix;
  23784. private _t0;
  23785. private _t1;
  23786. private _t2;
  23787. private _cachedUOffset;
  23788. private _cachedVOffset;
  23789. private _cachedUScale;
  23790. private _cachedVScale;
  23791. private _cachedUAng;
  23792. private _cachedVAng;
  23793. private _cachedWAng;
  23794. private _cachedProjectionMatrixId;
  23795. private _cachedCoordinatesMode;
  23796. /** @hidden */
  23797. protected _initialSamplingMode: number;
  23798. /** @hidden */
  23799. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  23800. private _deleteBuffer;
  23801. protected _format: Nullable<number>;
  23802. private _delayedOnLoad;
  23803. private _delayedOnError;
  23804. private _mimeType?;
  23805. /**
  23806. * Observable triggered once the texture has been loaded.
  23807. */
  23808. onLoadObservable: Observable<Texture>;
  23809. protected _isBlocking: boolean;
  23810. /**
  23811. * Is the texture preventing material to render while loading.
  23812. * If false, a default texture will be used instead of the loading one during the preparation step.
  23813. */
  23814. set isBlocking(value: boolean);
  23815. get isBlocking(): boolean;
  23816. /**
  23817. * Get the current sampling mode associated with the texture.
  23818. */
  23819. get samplingMode(): number;
  23820. /**
  23821. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  23822. */
  23823. get invertY(): boolean;
  23824. /**
  23825. * Instantiates a new texture.
  23826. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23827. * @see http://doc.babylonjs.com/babylon101/materials#texture
  23828. * @param url defines the url of the picture to load as a texture
  23829. * @param sceneOrEngine defines the scene or engine the texture will belong to
  23830. * @param noMipmap defines if the texture will require mip maps or not
  23831. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  23832. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23833. * @param onLoad defines a callback triggered when the texture has been loaded
  23834. * @param onError defines a callback triggered when an error occurred during the loading session
  23835. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  23836. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  23837. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23838. * @param mimeType defines an optional mime type information
  23839. */
  23840. 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);
  23841. /**
  23842. * Update the url (and optional buffer) of this texture if url was null during construction.
  23843. * @param url the url of the texture
  23844. * @param buffer the buffer of the texture (defaults to null)
  23845. * @param onLoad callback called when the texture is loaded (defaults to null)
  23846. */
  23847. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  23848. /**
  23849. * Finish the loading sequence of a texture flagged as delayed load.
  23850. * @hidden
  23851. */
  23852. delayLoad(): void;
  23853. private _prepareRowForTextureGeneration;
  23854. /**
  23855. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  23856. * @returns the transform matrix of the texture.
  23857. */
  23858. getTextureMatrix(uBase?: number): Matrix;
  23859. /**
  23860. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  23861. * @returns The reflection texture transform
  23862. */
  23863. getReflectionTextureMatrix(): Matrix;
  23864. /**
  23865. * Clones the texture.
  23866. * @returns the cloned texture
  23867. */
  23868. clone(): Texture;
  23869. /**
  23870. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  23871. * @returns The JSON representation of the texture
  23872. */
  23873. serialize(): any;
  23874. /**
  23875. * Get the current class name of the texture useful for serialization or dynamic coding.
  23876. * @returns "Texture"
  23877. */
  23878. getClassName(): string;
  23879. /**
  23880. * Dispose the texture and release its associated resources.
  23881. */
  23882. dispose(): void;
  23883. /**
  23884. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  23885. * @param parsedTexture Define the JSON representation of the texture
  23886. * @param scene Define the scene the parsed texture should be instantiated in
  23887. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  23888. * @returns The parsed texture if successful
  23889. */
  23890. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  23891. /**
  23892. * Creates a texture from its base 64 representation.
  23893. * @param data Define the base64 payload without the data: prefix
  23894. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23895. * @param scene Define the scene the texture should belong to
  23896. * @param noMipmap Forces the texture to not create mip map information if true
  23897. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23898. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23899. * @param onLoad define a callback triggered when the texture has been loaded
  23900. * @param onError define a callback triggered when an error occurred during the loading session
  23901. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23902. * @returns the created texture
  23903. */
  23904. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  23905. /**
  23906. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  23907. * @param data Define the base64 payload without the data: prefix
  23908. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23909. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  23910. * @param scene Define the scene the texture should belong to
  23911. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  23912. * @param noMipmap Forces the texture to not create mip map information if true
  23913. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23914. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23915. * @param onLoad define a callback triggered when the texture has been loaded
  23916. * @param onError define a callback triggered when an error occurred during the loading session
  23917. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23918. * @returns the created texture
  23919. */
  23920. 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;
  23921. }
  23922. }
  23923. declare module "babylonjs/PostProcesses/postProcessManager" {
  23924. import { Nullable } from "babylonjs/types";
  23925. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  23926. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  23927. import { Scene } from "babylonjs/scene";
  23928. /**
  23929. * PostProcessManager is used to manage one or more post processes or post process pipelines
  23930. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  23931. */
  23932. export class PostProcessManager {
  23933. private _scene;
  23934. private _indexBuffer;
  23935. private _vertexBuffers;
  23936. /**
  23937. * Creates a new instance PostProcess
  23938. * @param scene The scene that the post process is associated with.
  23939. */
  23940. constructor(scene: Scene);
  23941. private _prepareBuffers;
  23942. private _buildIndexBuffer;
  23943. /**
  23944. * Rebuilds the vertex buffers of the manager.
  23945. * @hidden
  23946. */
  23947. _rebuild(): void;
  23948. /**
  23949. * Prepares a frame to be run through a post process.
  23950. * @param sourceTexture The input texture to the post procesess. (default: null)
  23951. * @param postProcesses An array of post processes to be run. (default: null)
  23952. * @returns True if the post processes were able to be run.
  23953. * @hidden
  23954. */
  23955. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  23956. /**
  23957. * Manually render a set of post processes to a texture.
  23958. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  23959. * @param postProcesses An array of post processes to be run.
  23960. * @param targetTexture The target texture to render to.
  23961. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  23962. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  23963. * @param lodLevel defines which lod of the texture to render to
  23964. */
  23965. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  23966. /**
  23967. * Finalize the result of the output of the postprocesses.
  23968. * @param doNotPresent If true the result will not be displayed to the screen.
  23969. * @param targetTexture The target texture to render to.
  23970. * @param faceIndex The index of the face to bind the target texture to.
  23971. * @param postProcesses The array of post processes to render.
  23972. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  23973. * @hidden
  23974. */
  23975. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  23976. /**
  23977. * Disposes of the post process manager.
  23978. */
  23979. dispose(): void;
  23980. }
  23981. }
  23982. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  23983. import { Observable } from "babylonjs/Misc/observable";
  23984. import { SmartArray } from "babylonjs/Misc/smartArray";
  23985. import { Nullable, Immutable } from "babylonjs/types";
  23986. import { Camera } from "babylonjs/Cameras/camera";
  23987. import { Scene } from "babylonjs/scene";
  23988. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  23989. import { Color4 } from "babylonjs/Maths/math.color";
  23990. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  23991. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23992. import { SubMesh } from "babylonjs/Meshes/subMesh";
  23993. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  23994. import { Texture } from "babylonjs/Materials/Textures/texture";
  23995. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  23996. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  23997. import "babylonjs/Engines/Extensions/engine.renderTarget";
  23998. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  23999. import { Engine } from "babylonjs/Engines/engine";
  24000. /**
  24001. * This Helps creating a texture that will be created from a camera in your scene.
  24002. * It is basically a dynamic texture that could be used to create special effects for instance.
  24003. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  24004. */
  24005. export class RenderTargetTexture extends Texture {
  24006. isCube: boolean;
  24007. /**
  24008. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  24009. */
  24010. static readonly REFRESHRATE_RENDER_ONCE: number;
  24011. /**
  24012. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  24013. */
  24014. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  24015. /**
  24016. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  24017. * the central point of your effect and can save a lot of performances.
  24018. */
  24019. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  24020. /**
  24021. * Use this predicate to dynamically define the list of mesh you want to render.
  24022. * If set, the renderList property will be overwritten.
  24023. */
  24024. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  24025. private _renderList;
  24026. /**
  24027. * Use this list to define the list of mesh you want to render.
  24028. */
  24029. get renderList(): Nullable<Array<AbstractMesh>>;
  24030. set renderList(value: Nullable<Array<AbstractMesh>>);
  24031. /**
  24032. * Use this function to overload the renderList array at rendering time.
  24033. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  24034. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  24035. * the cube (if the RTT is a cube, else layerOrFace=0).
  24036. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  24037. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  24038. * hold dummy elements!
  24039. */
  24040. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  24041. private _hookArray;
  24042. /**
  24043. * Define if particles should be rendered in your texture.
  24044. */
  24045. renderParticles: boolean;
  24046. /**
  24047. * Define if sprites should be rendered in your texture.
  24048. */
  24049. renderSprites: boolean;
  24050. /**
  24051. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  24052. */
  24053. coordinatesMode: number;
  24054. /**
  24055. * Define the camera used to render the texture.
  24056. */
  24057. activeCamera: Nullable<Camera>;
  24058. /**
  24059. * Override the mesh isReady function with your own one.
  24060. */
  24061. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  24062. /**
  24063. * Override the render function of the texture with your own one.
  24064. */
  24065. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  24066. /**
  24067. * Define if camera post processes should be use while rendering the texture.
  24068. */
  24069. useCameraPostProcesses: boolean;
  24070. /**
  24071. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  24072. */
  24073. ignoreCameraViewport: boolean;
  24074. private _postProcessManager;
  24075. private _postProcesses;
  24076. private _resizeObserver;
  24077. /**
  24078. * An event triggered when the texture is unbind.
  24079. */
  24080. onBeforeBindObservable: Observable<RenderTargetTexture>;
  24081. /**
  24082. * An event triggered when the texture is unbind.
  24083. */
  24084. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  24085. private _onAfterUnbindObserver;
  24086. /**
  24087. * Set a after unbind callback in the texture.
  24088. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  24089. */
  24090. set onAfterUnbind(callback: () => void);
  24091. /**
  24092. * An event triggered before rendering the texture
  24093. */
  24094. onBeforeRenderObservable: Observable<number>;
  24095. private _onBeforeRenderObserver;
  24096. /**
  24097. * Set a before render callback in the texture.
  24098. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  24099. */
  24100. set onBeforeRender(callback: (faceIndex: number) => void);
  24101. /**
  24102. * An event triggered after rendering the texture
  24103. */
  24104. onAfterRenderObservable: Observable<number>;
  24105. private _onAfterRenderObserver;
  24106. /**
  24107. * Set a after render callback in the texture.
  24108. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  24109. */
  24110. set onAfterRender(callback: (faceIndex: number) => void);
  24111. /**
  24112. * An event triggered after the texture clear
  24113. */
  24114. onClearObservable: Observable<Engine>;
  24115. private _onClearObserver;
  24116. /**
  24117. * Set a clear callback in the texture.
  24118. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  24119. */
  24120. set onClear(callback: (Engine: Engine) => void);
  24121. /**
  24122. * An event triggered when the texture is resized.
  24123. */
  24124. onResizeObservable: Observable<RenderTargetTexture>;
  24125. /**
  24126. * Define the clear color of the Render Target if it should be different from the scene.
  24127. */
  24128. clearColor: Color4;
  24129. protected _size: number | {
  24130. width: number;
  24131. height: number;
  24132. layers?: number;
  24133. };
  24134. protected _initialSizeParameter: number | {
  24135. width: number;
  24136. height: number;
  24137. } | {
  24138. ratio: number;
  24139. };
  24140. protected _sizeRatio: Nullable<number>;
  24141. /** @hidden */
  24142. _generateMipMaps: boolean;
  24143. protected _renderingManager: RenderingManager;
  24144. /** @hidden */
  24145. _waitingRenderList: string[];
  24146. protected _doNotChangeAspectRatio: boolean;
  24147. protected _currentRefreshId: number;
  24148. protected _refreshRate: number;
  24149. protected _textureMatrix: Matrix;
  24150. protected _samples: number;
  24151. protected _renderTargetOptions: RenderTargetCreationOptions;
  24152. /**
  24153. * Gets render target creation options that were used.
  24154. */
  24155. get renderTargetOptions(): RenderTargetCreationOptions;
  24156. protected _onRatioRescale(): void;
  24157. /**
  24158. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  24159. * It must define where the camera used to render the texture is set
  24160. */
  24161. boundingBoxPosition: Vector3;
  24162. private _boundingBoxSize;
  24163. /**
  24164. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  24165. * When defined, the cubemap will switch to local mode
  24166. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  24167. * @example https://www.babylonjs-playground.com/#RNASML
  24168. */
  24169. set boundingBoxSize(value: Vector3);
  24170. get boundingBoxSize(): Vector3;
  24171. /**
  24172. * In case the RTT has been created with a depth texture, get the associated
  24173. * depth texture.
  24174. * Otherwise, return null.
  24175. */
  24176. get depthStencilTexture(): Nullable<InternalTexture>;
  24177. /**
  24178. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  24179. * or used a shadow, depth texture...
  24180. * @param name The friendly name of the texture
  24181. * @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)
  24182. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  24183. * @param generateMipMaps True if mip maps need to be generated after render.
  24184. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  24185. * @param type The type of the buffer in the RTT (int, half float, float...)
  24186. * @param isCube True if a cube texture needs to be created
  24187. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  24188. * @param generateDepthBuffer True to generate a depth buffer
  24189. * @param generateStencilBuffer True to generate a stencil buffer
  24190. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  24191. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  24192. * @param delayAllocation if the texture allocation should be delayed (default: false)
  24193. */
  24194. constructor(name: string, size: number | {
  24195. width: number;
  24196. height: number;
  24197. layers?: number;
  24198. } | {
  24199. ratio: number;
  24200. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  24201. /**
  24202. * Creates a depth stencil texture.
  24203. * This is only available in WebGL 2 or with the depth texture extension available.
  24204. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  24205. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  24206. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  24207. */
  24208. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  24209. private _processSizeParameter;
  24210. /**
  24211. * Define the number of samples to use in case of MSAA.
  24212. * It defaults to one meaning no MSAA has been enabled.
  24213. */
  24214. get samples(): number;
  24215. set samples(value: number);
  24216. /**
  24217. * Resets the refresh counter of the texture and start bak from scratch.
  24218. * Could be useful to regenerate the texture if it is setup to render only once.
  24219. */
  24220. resetRefreshCounter(): void;
  24221. /**
  24222. * Define the refresh rate of the texture or the rendering frequency.
  24223. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  24224. */
  24225. get refreshRate(): number;
  24226. set refreshRate(value: number);
  24227. /**
  24228. * Adds a post process to the render target rendering passes.
  24229. * @param postProcess define the post process to add
  24230. */
  24231. addPostProcess(postProcess: PostProcess): void;
  24232. /**
  24233. * Clear all the post processes attached to the render target
  24234. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  24235. */
  24236. clearPostProcesses(dispose?: boolean): void;
  24237. /**
  24238. * Remove one of the post process from the list of attached post processes to the texture
  24239. * @param postProcess define the post process to remove from the list
  24240. */
  24241. removePostProcess(postProcess: PostProcess): void;
  24242. /** @hidden */
  24243. _shouldRender(): boolean;
  24244. /**
  24245. * Gets the actual render size of the texture.
  24246. * @returns the width of the render size
  24247. */
  24248. getRenderSize(): number;
  24249. /**
  24250. * Gets the actual render width of the texture.
  24251. * @returns the width of the render size
  24252. */
  24253. getRenderWidth(): number;
  24254. /**
  24255. * Gets the actual render height of the texture.
  24256. * @returns the height of the render size
  24257. */
  24258. getRenderHeight(): number;
  24259. /**
  24260. * Gets the actual number of layers of the texture.
  24261. * @returns the number of layers
  24262. */
  24263. getRenderLayers(): number;
  24264. /**
  24265. * Get if the texture can be rescaled or not.
  24266. */
  24267. get canRescale(): boolean;
  24268. /**
  24269. * Resize the texture using a ratio.
  24270. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  24271. */
  24272. scale(ratio: number): void;
  24273. /**
  24274. * Get the texture reflection matrix used to rotate/transform the reflection.
  24275. * @returns the reflection matrix
  24276. */
  24277. getReflectionTextureMatrix(): Matrix;
  24278. /**
  24279. * Resize the texture to a new desired size.
  24280. * Be carrefull as it will recreate all the data in the new texture.
  24281. * @param size Define the new size. It can be:
  24282. * - a number for squared texture,
  24283. * - an object containing { width: number, height: number }
  24284. * - or an object containing a ratio { ratio: number }
  24285. */
  24286. resize(size: number | {
  24287. width: number;
  24288. height: number;
  24289. } | {
  24290. ratio: number;
  24291. }): void;
  24292. private _defaultRenderListPrepared;
  24293. /**
  24294. * Renders all the objects from the render list into the texture.
  24295. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  24296. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  24297. */
  24298. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  24299. private _bestReflectionRenderTargetDimension;
  24300. private _prepareRenderingManager;
  24301. /**
  24302. * @hidden
  24303. * @param faceIndex face index to bind to if this is a cubetexture
  24304. * @param layer defines the index of the texture to bind in the array
  24305. */
  24306. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  24307. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  24308. private renderToTarget;
  24309. /**
  24310. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  24311. * This allowed control for front to back rendering or reversly depending of the special needs.
  24312. *
  24313. * @param renderingGroupId The rendering group id corresponding to its index
  24314. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  24315. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  24316. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  24317. */
  24318. 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;
  24319. /**
  24320. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  24321. *
  24322. * @param renderingGroupId The rendering group id corresponding to its index
  24323. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  24324. */
  24325. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  24326. /**
  24327. * Clones the texture.
  24328. * @returns the cloned texture
  24329. */
  24330. clone(): RenderTargetTexture;
  24331. /**
  24332. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  24333. * @returns The JSON representation of the texture
  24334. */
  24335. serialize(): any;
  24336. /**
  24337. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  24338. */
  24339. disposeFramebufferObjects(): void;
  24340. /**
  24341. * Dispose the texture and release its associated resources.
  24342. */
  24343. dispose(): void;
  24344. /** @hidden */
  24345. _rebuild(): void;
  24346. /**
  24347. * Clear the info related to rendering groups preventing retention point in material dispose.
  24348. */
  24349. freeRenderingGroups(): void;
  24350. /**
  24351. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  24352. * @returns the view count
  24353. */
  24354. getViewCount(): number;
  24355. }
  24356. }
  24357. declare module "babylonjs/Misc/guid" {
  24358. /**
  24359. * Class used to manipulate GUIDs
  24360. */
  24361. export class GUID {
  24362. /**
  24363. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  24364. * Be aware Math.random() could cause collisions, but:
  24365. * "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"
  24366. * @returns a pseudo random id
  24367. */
  24368. static RandomId(): string;
  24369. }
  24370. }
  24371. declare module "babylonjs/Materials/shadowDepthWrapper" {
  24372. import { Nullable } from "babylonjs/types";
  24373. import { Scene } from "babylonjs/scene";
  24374. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24375. import { Material } from "babylonjs/Materials/material";
  24376. import { Effect } from "babylonjs/Materials/effect";
  24377. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  24378. /**
  24379. * Options to be used when creating a shadow depth material
  24380. */
  24381. export interface IIOptionShadowDepthMaterial {
  24382. /** Variables in the vertex shader code that need to have their names remapped.
  24383. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  24384. * "var_name" should be either: worldPos or vNormalW
  24385. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  24386. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  24387. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  24388. */
  24389. remappedVariables?: string[];
  24390. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  24391. standalone?: boolean;
  24392. }
  24393. /**
  24394. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  24395. */
  24396. export class ShadowDepthWrapper {
  24397. private _scene;
  24398. private _options?;
  24399. private _baseMaterial;
  24400. private _onEffectCreatedObserver;
  24401. private _subMeshToEffect;
  24402. private _subMeshToDepthEffect;
  24403. private _meshes;
  24404. /** @hidden */
  24405. _matriceNames: any;
  24406. /** Gets the standalone status of the wrapper */
  24407. get standalone(): boolean;
  24408. /** Gets the base material the wrapper is built upon */
  24409. get baseMaterial(): Material;
  24410. /**
  24411. * Instantiate a new shadow depth wrapper.
  24412. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  24413. * generate the shadow depth map. For more information, please refer to the documentation:
  24414. * https://doc.babylonjs.com/babylon101/shadows
  24415. * @param baseMaterial Material to wrap
  24416. * @param scene Define the scene the material belongs to
  24417. * @param options Options used to create the wrapper
  24418. */
  24419. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  24420. /**
  24421. * Gets the effect to use to generate the depth map
  24422. * @param subMesh subMesh to get the effect for
  24423. * @param shadowGenerator shadow generator to get the effect for
  24424. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  24425. */
  24426. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  24427. /**
  24428. * Specifies that the submesh is ready to be used for depth rendering
  24429. * @param subMesh submesh to check
  24430. * @param defines the list of defines to take into account when checking the effect
  24431. * @param shadowGenerator combined with subMesh, it defines the effect to check
  24432. * @param useInstances specifies that instances should be used
  24433. * @returns a boolean indicating that the submesh is ready or not
  24434. */
  24435. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  24436. /**
  24437. * Disposes the resources
  24438. */
  24439. dispose(): void;
  24440. private _makeEffect;
  24441. }
  24442. }
  24443. declare module "babylonjs/Materials/material" {
  24444. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  24445. import { SmartArray } from "babylonjs/Misc/smartArray";
  24446. import { Observable } from "babylonjs/Misc/observable";
  24447. import { Nullable } from "babylonjs/types";
  24448. import { Scene } from "babylonjs/scene";
  24449. import { Matrix } from "babylonjs/Maths/math.vector";
  24450. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  24451. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24452. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  24453. import { Effect } from "babylonjs/Materials/effect";
  24454. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  24455. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  24456. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  24457. import { IInspectable } from "babylonjs/Misc/iInspectable";
  24458. import { ShadowDepthWrapper } from "babylonjs/Materials/shadowDepthWrapper";
  24459. import { Mesh } from "babylonjs/Meshes/mesh";
  24460. import { Animation } from "babylonjs/Animations/animation";
  24461. /**
  24462. * Options for compiling materials.
  24463. */
  24464. export interface IMaterialCompilationOptions {
  24465. /**
  24466. * Defines whether clip planes are enabled.
  24467. */
  24468. clipPlane: boolean;
  24469. /**
  24470. * Defines whether instances are enabled.
  24471. */
  24472. useInstances: boolean;
  24473. }
  24474. /**
  24475. * Base class for the main features of a material in Babylon.js
  24476. */
  24477. export class Material implements IAnimatable {
  24478. /**
  24479. * Returns the triangle fill mode
  24480. */
  24481. static readonly TriangleFillMode: number;
  24482. /**
  24483. * Returns the wireframe mode
  24484. */
  24485. static readonly WireFrameFillMode: number;
  24486. /**
  24487. * Returns the point fill mode
  24488. */
  24489. static readonly PointFillMode: number;
  24490. /**
  24491. * Returns the point list draw mode
  24492. */
  24493. static readonly PointListDrawMode: number;
  24494. /**
  24495. * Returns the line list draw mode
  24496. */
  24497. static readonly LineListDrawMode: number;
  24498. /**
  24499. * Returns the line loop draw mode
  24500. */
  24501. static readonly LineLoopDrawMode: number;
  24502. /**
  24503. * Returns the line strip draw mode
  24504. */
  24505. static readonly LineStripDrawMode: number;
  24506. /**
  24507. * Returns the triangle strip draw mode
  24508. */
  24509. static readonly TriangleStripDrawMode: number;
  24510. /**
  24511. * Returns the triangle fan draw mode
  24512. */
  24513. static readonly TriangleFanDrawMode: number;
  24514. /**
  24515. * Stores the clock-wise side orientation
  24516. */
  24517. static readonly ClockWiseSideOrientation: number;
  24518. /**
  24519. * Stores the counter clock-wise side orientation
  24520. */
  24521. static readonly CounterClockWiseSideOrientation: number;
  24522. /**
  24523. * The dirty texture flag value
  24524. */
  24525. static readonly TextureDirtyFlag: number;
  24526. /**
  24527. * The dirty light flag value
  24528. */
  24529. static readonly LightDirtyFlag: number;
  24530. /**
  24531. * The dirty fresnel flag value
  24532. */
  24533. static readonly FresnelDirtyFlag: number;
  24534. /**
  24535. * The dirty attribute flag value
  24536. */
  24537. static readonly AttributesDirtyFlag: number;
  24538. /**
  24539. * The dirty misc flag value
  24540. */
  24541. static readonly MiscDirtyFlag: number;
  24542. /**
  24543. * The all dirty flag value
  24544. */
  24545. static readonly AllDirtyFlag: number;
  24546. /**
  24547. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  24548. */
  24549. static readonly MATERIAL_OPAQUE: number;
  24550. /**
  24551. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  24552. */
  24553. static readonly MATERIAL_ALPHATEST: number;
  24554. /**
  24555. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  24556. */
  24557. static readonly MATERIAL_ALPHABLEND: number;
  24558. /**
  24559. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  24560. * They are also discarded below the alpha cutoff threshold to improve performances.
  24561. */
  24562. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  24563. /**
  24564. * Custom callback helping to override the default shader used in the material.
  24565. */
  24566. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[]) => string;
  24567. /**
  24568. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  24569. */
  24570. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  24571. /**
  24572. * The ID of the material
  24573. */
  24574. id: string;
  24575. /**
  24576. * Gets or sets the unique id of the material
  24577. */
  24578. uniqueId: number;
  24579. /**
  24580. * The name of the material
  24581. */
  24582. name: string;
  24583. /**
  24584. * Gets or sets user defined metadata
  24585. */
  24586. metadata: any;
  24587. /**
  24588. * For internal use only. Please do not use.
  24589. */
  24590. reservedDataStore: any;
  24591. /**
  24592. * Specifies if the ready state should be checked on each call
  24593. */
  24594. checkReadyOnEveryCall: boolean;
  24595. /**
  24596. * Specifies if the ready state should be checked once
  24597. */
  24598. checkReadyOnlyOnce: boolean;
  24599. /**
  24600. * The state of the material
  24601. */
  24602. state: string;
  24603. /**
  24604. * The alpha value of the material
  24605. */
  24606. protected _alpha: number;
  24607. /**
  24608. * List of inspectable custom properties (used by the Inspector)
  24609. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  24610. */
  24611. inspectableCustomProperties: IInspectable[];
  24612. /**
  24613. * Sets the alpha value of the material
  24614. */
  24615. set alpha(value: number);
  24616. /**
  24617. * Gets the alpha value of the material
  24618. */
  24619. get alpha(): number;
  24620. /**
  24621. * Specifies if back face culling is enabled
  24622. */
  24623. protected _backFaceCulling: boolean;
  24624. /**
  24625. * Sets the back-face culling state
  24626. */
  24627. set backFaceCulling(value: boolean);
  24628. /**
  24629. * Gets the back-face culling state
  24630. */
  24631. get backFaceCulling(): boolean;
  24632. /**
  24633. * Stores the value for side orientation
  24634. */
  24635. sideOrientation: number;
  24636. /**
  24637. * Callback triggered when the material is compiled
  24638. */
  24639. onCompiled: Nullable<(effect: Effect) => void>;
  24640. /**
  24641. * Callback triggered when an error occurs
  24642. */
  24643. onError: Nullable<(effect: Effect, errors: string) => void>;
  24644. /**
  24645. * Callback triggered to get the render target textures
  24646. */
  24647. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  24648. /**
  24649. * Gets a boolean indicating that current material needs to register RTT
  24650. */
  24651. get hasRenderTargetTextures(): boolean;
  24652. /**
  24653. * Specifies if the material should be serialized
  24654. */
  24655. doNotSerialize: boolean;
  24656. /**
  24657. * @hidden
  24658. */
  24659. _storeEffectOnSubMeshes: boolean;
  24660. /**
  24661. * Stores the animations for the material
  24662. */
  24663. animations: Nullable<Array<Animation>>;
  24664. /**
  24665. * An event triggered when the material is disposed
  24666. */
  24667. onDisposeObservable: Observable<Material>;
  24668. /**
  24669. * An observer which watches for dispose events
  24670. */
  24671. private _onDisposeObserver;
  24672. private _onUnBindObservable;
  24673. /**
  24674. * Called during a dispose event
  24675. */
  24676. set onDispose(callback: () => void);
  24677. private _onBindObservable;
  24678. /**
  24679. * An event triggered when the material is bound
  24680. */
  24681. get onBindObservable(): Observable<AbstractMesh>;
  24682. /**
  24683. * An observer which watches for bind events
  24684. */
  24685. private _onBindObserver;
  24686. /**
  24687. * Called during a bind event
  24688. */
  24689. set onBind(callback: (Mesh: AbstractMesh) => void);
  24690. /**
  24691. * An event triggered when the material is unbound
  24692. */
  24693. get onUnBindObservable(): Observable<Material>;
  24694. protected _onEffectCreatedObservable: Nullable<Observable<{
  24695. effect: Effect;
  24696. subMesh: Nullable<SubMesh>;
  24697. }>>;
  24698. /**
  24699. * An event triggered when the effect is (re)created
  24700. */
  24701. get onEffectCreatedObservable(): Observable<{
  24702. effect: Effect;
  24703. subMesh: Nullable<SubMesh>;
  24704. }>;
  24705. /**
  24706. * Stores the value of the alpha mode
  24707. */
  24708. private _alphaMode;
  24709. /**
  24710. * Sets the value of the alpha mode.
  24711. *
  24712. * | Value | Type | Description |
  24713. * | --- | --- | --- |
  24714. * | 0 | ALPHA_DISABLE | |
  24715. * | 1 | ALPHA_ADD | |
  24716. * | 2 | ALPHA_COMBINE | |
  24717. * | 3 | ALPHA_SUBTRACT | |
  24718. * | 4 | ALPHA_MULTIPLY | |
  24719. * | 5 | ALPHA_MAXIMIZED | |
  24720. * | 6 | ALPHA_ONEONE | |
  24721. * | 7 | ALPHA_PREMULTIPLIED | |
  24722. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  24723. * | 9 | ALPHA_INTERPOLATE | |
  24724. * | 10 | ALPHA_SCREENMODE | |
  24725. *
  24726. */
  24727. set alphaMode(value: number);
  24728. /**
  24729. * Gets the value of the alpha mode
  24730. */
  24731. get alphaMode(): number;
  24732. /**
  24733. * Stores the state of the need depth pre-pass value
  24734. */
  24735. private _needDepthPrePass;
  24736. /**
  24737. * Sets the need depth pre-pass value
  24738. */
  24739. set needDepthPrePass(value: boolean);
  24740. /**
  24741. * Gets the depth pre-pass value
  24742. */
  24743. get needDepthPrePass(): boolean;
  24744. /**
  24745. * Specifies if depth writing should be disabled
  24746. */
  24747. disableDepthWrite: boolean;
  24748. /**
  24749. * Specifies if color writing should be disabled
  24750. */
  24751. disableColorWrite: boolean;
  24752. /**
  24753. * Specifies if depth writing should be forced
  24754. */
  24755. forceDepthWrite: boolean;
  24756. /**
  24757. * Specifies the depth function that should be used. 0 means the default engine function
  24758. */
  24759. depthFunction: number;
  24760. /**
  24761. * Specifies if there should be a separate pass for culling
  24762. */
  24763. separateCullingPass: boolean;
  24764. /**
  24765. * Stores the state specifing if fog should be enabled
  24766. */
  24767. private _fogEnabled;
  24768. /**
  24769. * Sets the state for enabling fog
  24770. */
  24771. set fogEnabled(value: boolean);
  24772. /**
  24773. * Gets the value of the fog enabled state
  24774. */
  24775. get fogEnabled(): boolean;
  24776. /**
  24777. * Stores the size of points
  24778. */
  24779. pointSize: number;
  24780. /**
  24781. * Stores the z offset value
  24782. */
  24783. zOffset: number;
  24784. get wireframe(): boolean;
  24785. /**
  24786. * Sets the state of wireframe mode
  24787. */
  24788. set wireframe(value: boolean);
  24789. /**
  24790. * Gets the value specifying if point clouds are enabled
  24791. */
  24792. get pointsCloud(): boolean;
  24793. /**
  24794. * Sets the state of point cloud mode
  24795. */
  24796. set pointsCloud(value: boolean);
  24797. /**
  24798. * Gets the material fill mode
  24799. */
  24800. get fillMode(): number;
  24801. /**
  24802. * Sets the material fill mode
  24803. */
  24804. set fillMode(value: number);
  24805. /**
  24806. * @hidden
  24807. * Stores the effects for the material
  24808. */
  24809. _effect: Nullable<Effect>;
  24810. /**
  24811. * Specifies if uniform buffers should be used
  24812. */
  24813. private _useUBO;
  24814. /**
  24815. * Stores a reference to the scene
  24816. */
  24817. private _scene;
  24818. /**
  24819. * Stores the fill mode state
  24820. */
  24821. private _fillMode;
  24822. /**
  24823. * Specifies if the depth write state should be cached
  24824. */
  24825. private _cachedDepthWriteState;
  24826. /**
  24827. * Specifies if the color write state should be cached
  24828. */
  24829. private _cachedColorWriteState;
  24830. /**
  24831. * Specifies if the depth function state should be cached
  24832. */
  24833. private _cachedDepthFunctionState;
  24834. /**
  24835. * Stores the uniform buffer
  24836. */
  24837. protected _uniformBuffer: UniformBuffer;
  24838. /** @hidden */
  24839. _indexInSceneMaterialArray: number;
  24840. /** @hidden */
  24841. meshMap: Nullable<{
  24842. [id: string]: AbstractMesh | undefined;
  24843. }>;
  24844. /**
  24845. * Creates a material instance
  24846. * @param name defines the name of the material
  24847. * @param scene defines the scene to reference
  24848. * @param doNotAdd specifies if the material should be added to the scene
  24849. */
  24850. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  24851. /**
  24852. * Returns a string representation of the current material
  24853. * @param fullDetails defines a boolean indicating which levels of logging is desired
  24854. * @returns a string with material information
  24855. */
  24856. toString(fullDetails?: boolean): string;
  24857. /**
  24858. * Gets the class name of the material
  24859. * @returns a string with the class name of the material
  24860. */
  24861. getClassName(): string;
  24862. /**
  24863. * Specifies if updates for the material been locked
  24864. */
  24865. get isFrozen(): boolean;
  24866. /**
  24867. * Locks updates for the material
  24868. */
  24869. freeze(): void;
  24870. /**
  24871. * Unlocks updates for the material
  24872. */
  24873. unfreeze(): void;
  24874. /**
  24875. * Specifies if the material is ready to be used
  24876. * @param mesh defines the mesh to check
  24877. * @param useInstances specifies if instances should be used
  24878. * @returns a boolean indicating if the material is ready to be used
  24879. */
  24880. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  24881. /**
  24882. * Specifies that the submesh is ready to be used
  24883. * @param mesh defines the mesh to check
  24884. * @param subMesh defines which submesh to check
  24885. * @param useInstances specifies that instances should be used
  24886. * @returns a boolean indicating that the submesh is ready or not
  24887. */
  24888. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  24889. /**
  24890. * Returns the material effect
  24891. * @returns the effect associated with the material
  24892. */
  24893. getEffect(): Nullable<Effect>;
  24894. /**
  24895. * Returns the current scene
  24896. * @returns a Scene
  24897. */
  24898. getScene(): Scene;
  24899. /**
  24900. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  24901. */
  24902. protected _forceAlphaTest: boolean;
  24903. /**
  24904. * The transparency mode of the material.
  24905. */
  24906. protected _transparencyMode: Nullable<number>;
  24907. /**
  24908. * Gets the current transparency mode.
  24909. */
  24910. get transparencyMode(): Nullable<number>;
  24911. /**
  24912. * Sets the transparency mode of the material.
  24913. *
  24914. * | Value | Type | Description |
  24915. * | ----- | ----------------------------------- | ----------- |
  24916. * | 0 | OPAQUE | |
  24917. * | 1 | ALPHATEST | |
  24918. * | 2 | ALPHABLEND | |
  24919. * | 3 | ALPHATESTANDBLEND | |
  24920. *
  24921. */
  24922. set transparencyMode(value: Nullable<number>);
  24923. /**
  24924. * Returns true if alpha blending should be disabled.
  24925. */
  24926. protected get _disableAlphaBlending(): boolean;
  24927. /**
  24928. * Specifies whether or not this material should be rendered in alpha blend mode.
  24929. * @returns a boolean specifying if alpha blending is needed
  24930. */
  24931. needAlphaBlending(): boolean;
  24932. /**
  24933. * Specifies if the mesh will require alpha blending
  24934. * @param mesh defines the mesh to check
  24935. * @returns a boolean specifying if alpha blending is needed for the mesh
  24936. */
  24937. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  24938. /**
  24939. * Specifies whether or not this material should be rendered in alpha test mode.
  24940. * @returns a boolean specifying if an alpha test is needed.
  24941. */
  24942. needAlphaTesting(): boolean;
  24943. /**
  24944. * Specifies if material alpha testing should be turned on for the mesh
  24945. * @param mesh defines the mesh to check
  24946. */
  24947. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  24948. /**
  24949. * Gets the texture used for the alpha test
  24950. * @returns the texture to use for alpha testing
  24951. */
  24952. getAlphaTestTexture(): Nullable<BaseTexture>;
  24953. /**
  24954. * Marks the material to indicate that it needs to be re-calculated
  24955. */
  24956. markDirty(): void;
  24957. /** @hidden */
  24958. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  24959. /**
  24960. * Binds the material to the mesh
  24961. * @param world defines the world transformation matrix
  24962. * @param mesh defines the mesh to bind the material to
  24963. */
  24964. bind(world: Matrix, mesh?: Mesh): void;
  24965. /**
  24966. * Binds the submesh to the material
  24967. * @param world defines the world transformation matrix
  24968. * @param mesh defines the mesh containing the submesh
  24969. * @param subMesh defines the submesh to bind the material to
  24970. */
  24971. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  24972. /**
  24973. * Binds the world matrix to the material
  24974. * @param world defines the world transformation matrix
  24975. */
  24976. bindOnlyWorldMatrix(world: Matrix): void;
  24977. /**
  24978. * Binds the scene's uniform buffer to the effect.
  24979. * @param effect defines the effect to bind to the scene uniform buffer
  24980. * @param sceneUbo defines the uniform buffer storing scene data
  24981. */
  24982. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  24983. /**
  24984. * Binds the view matrix to the effect
  24985. * @param effect defines the effect to bind the view matrix to
  24986. */
  24987. bindView(effect: Effect): void;
  24988. /**
  24989. * Binds the view projection matrix to the effect
  24990. * @param effect defines the effect to bind the view projection matrix to
  24991. */
  24992. bindViewProjection(effect: Effect): void;
  24993. /**
  24994. * Processes to execute after binding the material to a mesh
  24995. * @param mesh defines the rendered mesh
  24996. */
  24997. protected _afterBind(mesh?: Mesh): void;
  24998. /**
  24999. * Unbinds the material from the mesh
  25000. */
  25001. unbind(): void;
  25002. /**
  25003. * Gets the active textures from the material
  25004. * @returns an array of textures
  25005. */
  25006. getActiveTextures(): BaseTexture[];
  25007. /**
  25008. * Specifies if the material uses a texture
  25009. * @param texture defines the texture to check against the material
  25010. * @returns a boolean specifying if the material uses the texture
  25011. */
  25012. hasTexture(texture: BaseTexture): boolean;
  25013. /**
  25014. * Makes a duplicate of the material, and gives it a new name
  25015. * @param name defines the new name for the duplicated material
  25016. * @returns the cloned material
  25017. */
  25018. clone(name: string): Nullable<Material>;
  25019. /**
  25020. * Gets the meshes bound to the material
  25021. * @returns an array of meshes bound to the material
  25022. */
  25023. getBindedMeshes(): AbstractMesh[];
  25024. /**
  25025. * Force shader compilation
  25026. * @param mesh defines the mesh associated with this material
  25027. * @param onCompiled defines a function to execute once the material is compiled
  25028. * @param options defines the options to configure the compilation
  25029. * @param onError defines a function to execute if the material fails compiling
  25030. */
  25031. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  25032. /**
  25033. * Force shader compilation
  25034. * @param mesh defines the mesh that will use this material
  25035. * @param options defines additional options for compiling the shaders
  25036. * @returns a promise that resolves when the compilation completes
  25037. */
  25038. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  25039. private static readonly _AllDirtyCallBack;
  25040. private static readonly _ImageProcessingDirtyCallBack;
  25041. private static readonly _TextureDirtyCallBack;
  25042. private static readonly _FresnelDirtyCallBack;
  25043. private static readonly _MiscDirtyCallBack;
  25044. private static readonly _LightsDirtyCallBack;
  25045. private static readonly _AttributeDirtyCallBack;
  25046. private static _FresnelAndMiscDirtyCallBack;
  25047. private static _TextureAndMiscDirtyCallBack;
  25048. private static readonly _DirtyCallbackArray;
  25049. private static readonly _RunDirtyCallBacks;
  25050. /**
  25051. * Marks a define in the material to indicate that it needs to be re-computed
  25052. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  25053. */
  25054. markAsDirty(flag: number): void;
  25055. /**
  25056. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  25057. * @param func defines a function which checks material defines against the submeshes
  25058. */
  25059. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  25060. /**
  25061. * Indicates that we need to re-calculated for all submeshes
  25062. */
  25063. protected _markAllSubMeshesAsAllDirty(): void;
  25064. /**
  25065. * Indicates that image processing needs to be re-calculated for all submeshes
  25066. */
  25067. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  25068. /**
  25069. * Indicates that textures need to be re-calculated for all submeshes
  25070. */
  25071. protected _markAllSubMeshesAsTexturesDirty(): void;
  25072. /**
  25073. * Indicates that fresnel needs to be re-calculated for all submeshes
  25074. */
  25075. protected _markAllSubMeshesAsFresnelDirty(): void;
  25076. /**
  25077. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  25078. */
  25079. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  25080. /**
  25081. * Indicates that lights need to be re-calculated for all submeshes
  25082. */
  25083. protected _markAllSubMeshesAsLightsDirty(): void;
  25084. /**
  25085. * Indicates that attributes need to be re-calculated for all submeshes
  25086. */
  25087. protected _markAllSubMeshesAsAttributesDirty(): void;
  25088. /**
  25089. * Indicates that misc needs to be re-calculated for all submeshes
  25090. */
  25091. protected _markAllSubMeshesAsMiscDirty(): void;
  25092. /**
  25093. * Indicates that textures and misc need to be re-calculated for all submeshes
  25094. */
  25095. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  25096. /**
  25097. * Disposes the material
  25098. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  25099. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  25100. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  25101. */
  25102. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  25103. /** @hidden */
  25104. private releaseVertexArrayObject;
  25105. /**
  25106. * Serializes this material
  25107. * @returns the serialized material object
  25108. */
  25109. serialize(): any;
  25110. /**
  25111. * Creates a material from parsed material data
  25112. * @param parsedMaterial defines parsed material data
  25113. * @param scene defines the hosting scene
  25114. * @param rootUrl defines the root URL to use to load textures
  25115. * @returns a new material
  25116. */
  25117. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  25118. }
  25119. }
  25120. declare module "babylonjs/Materials/multiMaterial" {
  25121. import { Nullable } from "babylonjs/types";
  25122. import { Scene } from "babylonjs/scene";
  25123. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25124. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  25125. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  25126. import { Material } from "babylonjs/Materials/material";
  25127. /**
  25128. * A multi-material is used to apply different materials to different parts of the same object without the need of
  25129. * separate meshes. This can be use to improve performances.
  25130. * @see http://doc.babylonjs.com/how_to/multi_materials
  25131. */
  25132. export class MultiMaterial extends Material {
  25133. private _subMaterials;
  25134. /**
  25135. * Gets or Sets the list of Materials used within the multi material.
  25136. * They need to be ordered according to the submeshes order in the associated mesh
  25137. */
  25138. get subMaterials(): Nullable<Material>[];
  25139. set subMaterials(value: Nullable<Material>[]);
  25140. /**
  25141. * Function used to align with Node.getChildren()
  25142. * @returns the list of Materials used within the multi material
  25143. */
  25144. getChildren(): Nullable<Material>[];
  25145. /**
  25146. * Instantiates a new Multi Material
  25147. * A multi-material is used to apply different materials to different parts of the same object without the need of
  25148. * separate meshes. This can be use to improve performances.
  25149. * @see http://doc.babylonjs.com/how_to/multi_materials
  25150. * @param name Define the name in the scene
  25151. * @param scene Define the scene the material belongs to
  25152. */
  25153. constructor(name: string, scene: Scene);
  25154. private _hookArray;
  25155. /**
  25156. * Get one of the submaterial by its index in the submaterials array
  25157. * @param index The index to look the sub material at
  25158. * @returns The Material if the index has been defined
  25159. */
  25160. getSubMaterial(index: number): Nullable<Material>;
  25161. /**
  25162. * Get the list of active textures for the whole sub materials list.
  25163. * @returns All the textures that will be used during the rendering
  25164. */
  25165. getActiveTextures(): BaseTexture[];
  25166. /**
  25167. * Gets the current class name of the material e.g. "MultiMaterial"
  25168. * Mainly use in serialization.
  25169. * @returns the class name
  25170. */
  25171. getClassName(): string;
  25172. /**
  25173. * Checks if the material is ready to render the requested sub mesh
  25174. * @param mesh Define the mesh the submesh belongs to
  25175. * @param subMesh Define the sub mesh to look readyness for
  25176. * @param useInstances Define whether or not the material is used with instances
  25177. * @returns true if ready, otherwise false
  25178. */
  25179. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  25180. /**
  25181. * Clones the current material and its related sub materials
  25182. * @param name Define the name of the newly cloned material
  25183. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  25184. * @returns the cloned material
  25185. */
  25186. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  25187. /**
  25188. * Serializes the materials into a JSON representation.
  25189. * @returns the JSON representation
  25190. */
  25191. serialize(): any;
  25192. /**
  25193. * Dispose the material and release its associated resources
  25194. * @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)
  25195. * @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)
  25196. * @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)
  25197. */
  25198. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  25199. /**
  25200. * Creates a MultiMaterial from parsed MultiMaterial data.
  25201. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  25202. * @param scene defines the hosting scene
  25203. * @returns a new MultiMaterial
  25204. */
  25205. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  25206. }
  25207. }
  25208. declare module "babylonjs/Meshes/subMesh" {
  25209. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  25210. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  25211. import { Engine } from "babylonjs/Engines/engine";
  25212. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  25213. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  25214. import { Effect } from "babylonjs/Materials/effect";
  25215. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  25216. import { Plane } from "babylonjs/Maths/math.plane";
  25217. import { Collider } from "babylonjs/Collisions/collider";
  25218. import { Material } from "babylonjs/Materials/material";
  25219. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  25220. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25221. import { Mesh } from "babylonjs/Meshes/mesh";
  25222. import { Ray } from "babylonjs/Culling/ray";
  25223. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  25224. /**
  25225. * Base class for submeshes
  25226. */
  25227. export class BaseSubMesh {
  25228. /** @hidden */
  25229. _materialDefines: Nullable<MaterialDefines>;
  25230. /** @hidden */
  25231. _materialEffect: Nullable<Effect>;
  25232. /** @hidden */
  25233. _effectOverride: Nullable<Effect>;
  25234. /**
  25235. * Gets material defines used by the effect associated to the sub mesh
  25236. */
  25237. get materialDefines(): Nullable<MaterialDefines>;
  25238. /**
  25239. * Sets material defines used by the effect associated to the sub mesh
  25240. */
  25241. set materialDefines(defines: Nullable<MaterialDefines>);
  25242. /**
  25243. * Gets associated effect
  25244. */
  25245. get effect(): Nullable<Effect>;
  25246. /**
  25247. * Sets associated effect (effect used to render this submesh)
  25248. * @param effect defines the effect to associate with
  25249. * @param defines defines the set of defines used to compile this effect
  25250. */
  25251. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  25252. }
  25253. /**
  25254. * Defines a subdivision inside a mesh
  25255. */
  25256. export class SubMesh extends BaseSubMesh implements ICullable {
  25257. /** the material index to use */
  25258. materialIndex: number;
  25259. /** vertex index start */
  25260. verticesStart: number;
  25261. /** vertices count */
  25262. verticesCount: number;
  25263. /** index start */
  25264. indexStart: number;
  25265. /** indices count */
  25266. indexCount: number;
  25267. /** @hidden */
  25268. _linesIndexCount: number;
  25269. private _mesh;
  25270. private _renderingMesh;
  25271. private _boundingInfo;
  25272. private _linesIndexBuffer;
  25273. /** @hidden */
  25274. _lastColliderWorldVertices: Nullable<Vector3[]>;
  25275. /** @hidden */
  25276. _trianglePlanes: Plane[];
  25277. /** @hidden */
  25278. _lastColliderTransformMatrix: Nullable<Matrix>;
  25279. /** @hidden */
  25280. _renderId: number;
  25281. /** @hidden */
  25282. _alphaIndex: number;
  25283. /** @hidden */
  25284. _distanceToCamera: number;
  25285. /** @hidden */
  25286. _id: number;
  25287. private _currentMaterial;
  25288. /**
  25289. * Add a new submesh to a mesh
  25290. * @param materialIndex defines the material index to use
  25291. * @param verticesStart defines vertex index start
  25292. * @param verticesCount defines vertices count
  25293. * @param indexStart defines index start
  25294. * @param indexCount defines indices count
  25295. * @param mesh defines the parent mesh
  25296. * @param renderingMesh defines an optional rendering mesh
  25297. * @param createBoundingBox defines if bounding box should be created for this submesh
  25298. * @returns the new submesh
  25299. */
  25300. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  25301. /**
  25302. * Creates a new submesh
  25303. * @param materialIndex defines the material index to use
  25304. * @param verticesStart defines vertex index start
  25305. * @param verticesCount defines vertices count
  25306. * @param indexStart defines index start
  25307. * @param indexCount defines indices count
  25308. * @param mesh defines the parent mesh
  25309. * @param renderingMesh defines an optional rendering mesh
  25310. * @param createBoundingBox defines if bounding box should be created for this submesh
  25311. */
  25312. constructor(
  25313. /** the material index to use */
  25314. materialIndex: number,
  25315. /** vertex index start */
  25316. verticesStart: number,
  25317. /** vertices count */
  25318. verticesCount: number,
  25319. /** index start */
  25320. indexStart: number,
  25321. /** indices count */
  25322. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  25323. /**
  25324. * Returns true if this submesh covers the entire parent mesh
  25325. * @ignorenaming
  25326. */
  25327. get IsGlobal(): boolean;
  25328. /**
  25329. * Returns the submesh BoudingInfo object
  25330. * @returns current bounding info (or mesh's one if the submesh is global)
  25331. */
  25332. getBoundingInfo(): BoundingInfo;
  25333. /**
  25334. * Sets the submesh BoundingInfo
  25335. * @param boundingInfo defines the new bounding info to use
  25336. * @returns the SubMesh
  25337. */
  25338. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  25339. /**
  25340. * Returns the mesh of the current submesh
  25341. * @return the parent mesh
  25342. */
  25343. getMesh(): AbstractMesh;
  25344. /**
  25345. * Returns the rendering mesh of the submesh
  25346. * @returns the rendering mesh (could be different from parent mesh)
  25347. */
  25348. getRenderingMesh(): Mesh;
  25349. /**
  25350. * Returns the submesh material
  25351. * @returns null or the current material
  25352. */
  25353. getMaterial(): Nullable<Material>;
  25354. /**
  25355. * Sets a new updated BoundingInfo object to the submesh
  25356. * @param data defines an optional position array to use to determine the bounding info
  25357. * @returns the SubMesh
  25358. */
  25359. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  25360. /** @hidden */
  25361. _checkCollision(collider: Collider): boolean;
  25362. /**
  25363. * Updates the submesh BoundingInfo
  25364. * @param world defines the world matrix to use to update the bounding info
  25365. * @returns the submesh
  25366. */
  25367. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  25368. /**
  25369. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  25370. * @param frustumPlanes defines the frustum planes
  25371. * @returns true if the submesh is intersecting with the frustum
  25372. */
  25373. isInFrustum(frustumPlanes: Plane[]): boolean;
  25374. /**
  25375. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  25376. * @param frustumPlanes defines the frustum planes
  25377. * @returns true if the submesh is inside the frustum
  25378. */
  25379. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  25380. /**
  25381. * Renders the submesh
  25382. * @param enableAlphaMode defines if alpha needs to be used
  25383. * @returns the submesh
  25384. */
  25385. render(enableAlphaMode: boolean): SubMesh;
  25386. /**
  25387. * @hidden
  25388. */
  25389. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  25390. /**
  25391. * Checks if the submesh intersects with a ray
  25392. * @param ray defines the ray to test
  25393. * @returns true is the passed ray intersects the submesh bounding box
  25394. */
  25395. canIntersects(ray: Ray): boolean;
  25396. /**
  25397. * Intersects current submesh with a ray
  25398. * @param ray defines the ray to test
  25399. * @param positions defines mesh's positions array
  25400. * @param indices defines mesh's indices array
  25401. * @param fastCheck defines if the first intersection will be used (and not the closest)
  25402. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  25403. * @returns intersection info or null if no intersection
  25404. */
  25405. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  25406. /** @hidden */
  25407. private _intersectLines;
  25408. /** @hidden */
  25409. private _intersectUnIndexedLines;
  25410. /** @hidden */
  25411. private _intersectTriangles;
  25412. /** @hidden */
  25413. private _intersectUnIndexedTriangles;
  25414. /** @hidden */
  25415. _rebuild(): void;
  25416. /**
  25417. * Creates a new submesh from the passed mesh
  25418. * @param newMesh defines the new hosting mesh
  25419. * @param newRenderingMesh defines an optional rendering mesh
  25420. * @returns the new submesh
  25421. */
  25422. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  25423. /**
  25424. * Release associated resources
  25425. */
  25426. dispose(): void;
  25427. /**
  25428. * Gets the class name
  25429. * @returns the string "SubMesh".
  25430. */
  25431. getClassName(): string;
  25432. /**
  25433. * Creates a new submesh from indices data
  25434. * @param materialIndex the index of the main mesh material
  25435. * @param startIndex the index where to start the copy in the mesh indices array
  25436. * @param indexCount the number of indices to copy then from the startIndex
  25437. * @param mesh the main mesh to create the submesh from
  25438. * @param renderingMesh the optional rendering mesh
  25439. * @returns a new submesh
  25440. */
  25441. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  25442. }
  25443. }
  25444. declare module "babylonjs/Loading/sceneLoaderFlags" {
  25445. /**
  25446. * Class used to represent data loading progression
  25447. */
  25448. export class SceneLoaderFlags {
  25449. private static _ForceFullSceneLoadingForIncremental;
  25450. private static _ShowLoadingScreen;
  25451. private static _CleanBoneMatrixWeights;
  25452. private static _loggingLevel;
  25453. /**
  25454. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  25455. */
  25456. static get ForceFullSceneLoadingForIncremental(): boolean;
  25457. static set ForceFullSceneLoadingForIncremental(value: boolean);
  25458. /**
  25459. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  25460. */
  25461. static get ShowLoadingScreen(): boolean;
  25462. static set ShowLoadingScreen(value: boolean);
  25463. /**
  25464. * Defines the current logging level (while loading the scene)
  25465. * @ignorenaming
  25466. */
  25467. static get loggingLevel(): number;
  25468. static set loggingLevel(value: number);
  25469. /**
  25470. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  25471. */
  25472. static get CleanBoneMatrixWeights(): boolean;
  25473. static set CleanBoneMatrixWeights(value: boolean);
  25474. }
  25475. }
  25476. declare module "babylonjs/Meshes/geometry" {
  25477. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  25478. import { Scene } from "babylonjs/scene";
  25479. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  25480. import { Engine } from "babylonjs/Engines/engine";
  25481. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  25482. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  25483. import { Effect } from "babylonjs/Materials/effect";
  25484. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  25485. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  25486. import { Mesh } from "babylonjs/Meshes/mesh";
  25487. /**
  25488. * Class used to store geometry data (vertex buffers + index buffer)
  25489. */
  25490. export class Geometry implements IGetSetVerticesData {
  25491. /**
  25492. * Gets or sets the ID of the geometry
  25493. */
  25494. id: string;
  25495. /**
  25496. * Gets or sets the unique ID of the geometry
  25497. */
  25498. uniqueId: number;
  25499. /**
  25500. * Gets the delay loading state of the geometry (none by default which means not delayed)
  25501. */
  25502. delayLoadState: number;
  25503. /**
  25504. * Gets the file containing the data to load when running in delay load state
  25505. */
  25506. delayLoadingFile: Nullable<string>;
  25507. /**
  25508. * Callback called when the geometry is updated
  25509. */
  25510. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  25511. private _scene;
  25512. private _engine;
  25513. private _meshes;
  25514. private _totalVertices;
  25515. /** @hidden */
  25516. _indices: IndicesArray;
  25517. /** @hidden */
  25518. _vertexBuffers: {
  25519. [key: string]: VertexBuffer;
  25520. };
  25521. private _isDisposed;
  25522. private _extend;
  25523. private _boundingBias;
  25524. /** @hidden */
  25525. _delayInfo: Array<string>;
  25526. private _indexBuffer;
  25527. private _indexBufferIsUpdatable;
  25528. /** @hidden */
  25529. _boundingInfo: Nullable<BoundingInfo>;
  25530. /** @hidden */
  25531. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  25532. /** @hidden */
  25533. _softwareSkinningFrameId: number;
  25534. private _vertexArrayObjects;
  25535. private _updatable;
  25536. /** @hidden */
  25537. _positions: Nullable<Vector3[]>;
  25538. /**
  25539. * 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
  25540. */
  25541. get boundingBias(): Vector2;
  25542. /**
  25543. * 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
  25544. */
  25545. set boundingBias(value: Vector2);
  25546. /**
  25547. * Static function used to attach a new empty geometry to a mesh
  25548. * @param mesh defines the mesh to attach the geometry to
  25549. * @returns the new Geometry
  25550. */
  25551. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  25552. /** Get the list of meshes using this geometry */
  25553. get meshes(): Mesh[];
  25554. /**
  25555. * Creates a new geometry
  25556. * @param id defines the unique ID
  25557. * @param scene defines the hosting scene
  25558. * @param vertexData defines the VertexData used to get geometry data
  25559. * @param updatable defines if geometry must be updatable (false by default)
  25560. * @param mesh defines the mesh that will be associated with the geometry
  25561. */
  25562. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  25563. /**
  25564. * Gets the current extend of the geometry
  25565. */
  25566. get extend(): {
  25567. minimum: Vector3;
  25568. maximum: Vector3;
  25569. };
  25570. /**
  25571. * Gets the hosting scene
  25572. * @returns the hosting Scene
  25573. */
  25574. getScene(): Scene;
  25575. /**
  25576. * Gets the hosting engine
  25577. * @returns the hosting Engine
  25578. */
  25579. getEngine(): Engine;
  25580. /**
  25581. * Defines if the geometry is ready to use
  25582. * @returns true if the geometry is ready to be used
  25583. */
  25584. isReady(): boolean;
  25585. /**
  25586. * Gets a value indicating that the geometry should not be serialized
  25587. */
  25588. get doNotSerialize(): boolean;
  25589. /** @hidden */
  25590. _rebuild(): void;
  25591. /**
  25592. * Affects all geometry data in one call
  25593. * @param vertexData defines the geometry data
  25594. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  25595. */
  25596. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  25597. /**
  25598. * Set specific vertex data
  25599. * @param kind defines the data kind (Position, normal, etc...)
  25600. * @param data defines the vertex data to use
  25601. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  25602. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  25603. */
  25604. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  25605. /**
  25606. * Removes a specific vertex data
  25607. * @param kind defines the data kind (Position, normal, etc...)
  25608. */
  25609. removeVerticesData(kind: string): void;
  25610. /**
  25611. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  25612. * @param buffer defines the vertex buffer to use
  25613. * @param totalVertices defines the total number of vertices for position kind (could be null)
  25614. */
  25615. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  25616. /**
  25617. * Update a specific vertex buffer
  25618. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  25619. * It will do nothing if the buffer is not updatable
  25620. * @param kind defines the data kind (Position, normal, etc...)
  25621. * @param data defines the data to use
  25622. * @param offset defines the offset in the target buffer where to store the data
  25623. * @param useBytes set to true if the offset is in bytes
  25624. */
  25625. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  25626. /**
  25627. * Update a specific vertex buffer
  25628. * This function will create a new buffer if the current one is not updatable
  25629. * @param kind defines the data kind (Position, normal, etc...)
  25630. * @param data defines the data to use
  25631. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  25632. */
  25633. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  25634. private _updateBoundingInfo;
  25635. /** @hidden */
  25636. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  25637. /**
  25638. * Gets total number of vertices
  25639. * @returns the total number of vertices
  25640. */
  25641. getTotalVertices(): number;
  25642. /**
  25643. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  25644. * @param kind defines the data kind (Position, normal, etc...)
  25645. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25646. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25647. * @returns a float array containing vertex data
  25648. */
  25649. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25650. /**
  25651. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  25652. * @param kind defines the data kind (Position, normal, etc...)
  25653. * @returns true if the vertex buffer with the specified kind is updatable
  25654. */
  25655. isVertexBufferUpdatable(kind: string): boolean;
  25656. /**
  25657. * Gets a specific vertex buffer
  25658. * @param kind defines the data kind (Position, normal, etc...)
  25659. * @returns a VertexBuffer
  25660. */
  25661. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  25662. /**
  25663. * Returns all vertex buffers
  25664. * @return an object holding all vertex buffers indexed by kind
  25665. */
  25666. getVertexBuffers(): Nullable<{
  25667. [key: string]: VertexBuffer;
  25668. }>;
  25669. /**
  25670. * Gets a boolean indicating if specific vertex buffer is present
  25671. * @param kind defines the data kind (Position, normal, etc...)
  25672. * @returns true if data is present
  25673. */
  25674. isVerticesDataPresent(kind: string): boolean;
  25675. /**
  25676. * Gets a list of all attached data kinds (Position, normal, etc...)
  25677. * @returns a list of string containing all kinds
  25678. */
  25679. getVerticesDataKinds(): string[];
  25680. /**
  25681. * Update index buffer
  25682. * @param indices defines the indices to store in the index buffer
  25683. * @param offset defines the offset in the target buffer where to store the data
  25684. * @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)
  25685. */
  25686. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  25687. /**
  25688. * Creates a new index buffer
  25689. * @param indices defines the indices to store in the index buffer
  25690. * @param totalVertices defines the total number of vertices (could be null)
  25691. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  25692. */
  25693. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  25694. /**
  25695. * Return the total number of indices
  25696. * @returns the total number of indices
  25697. */
  25698. getTotalIndices(): number;
  25699. /**
  25700. * Gets the index buffer array
  25701. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25702. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25703. * @returns the index buffer array
  25704. */
  25705. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25706. /**
  25707. * Gets the index buffer
  25708. * @return the index buffer
  25709. */
  25710. getIndexBuffer(): Nullable<DataBuffer>;
  25711. /** @hidden */
  25712. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  25713. /**
  25714. * Release the associated resources for a specific mesh
  25715. * @param mesh defines the source mesh
  25716. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  25717. */
  25718. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  25719. /**
  25720. * Apply current geometry to a given mesh
  25721. * @param mesh defines the mesh to apply geometry to
  25722. */
  25723. applyToMesh(mesh: Mesh): void;
  25724. private _updateExtend;
  25725. private _applyToMesh;
  25726. private notifyUpdate;
  25727. /**
  25728. * Load the geometry if it was flagged as delay loaded
  25729. * @param scene defines the hosting scene
  25730. * @param onLoaded defines a callback called when the geometry is loaded
  25731. */
  25732. load(scene: Scene, onLoaded?: () => void): void;
  25733. private _queueLoad;
  25734. /**
  25735. * Invert the geometry to move from a right handed system to a left handed one.
  25736. */
  25737. toLeftHanded(): void;
  25738. /** @hidden */
  25739. _resetPointsArrayCache(): void;
  25740. /** @hidden */
  25741. _generatePointsArray(): boolean;
  25742. /**
  25743. * Gets a value indicating if the geometry is disposed
  25744. * @returns true if the geometry was disposed
  25745. */
  25746. isDisposed(): boolean;
  25747. private _disposeVertexArrayObjects;
  25748. /**
  25749. * Free all associated resources
  25750. */
  25751. dispose(): void;
  25752. /**
  25753. * Clone the current geometry into a new geometry
  25754. * @param id defines the unique ID of the new geometry
  25755. * @returns a new geometry object
  25756. */
  25757. copy(id: string): Geometry;
  25758. /**
  25759. * Serialize the current geometry info (and not the vertices data) into a JSON object
  25760. * @return a JSON representation of the current geometry data (without the vertices data)
  25761. */
  25762. serialize(): any;
  25763. private toNumberArray;
  25764. /**
  25765. * Serialize all vertices data into a JSON oject
  25766. * @returns a JSON representation of the current geometry data
  25767. */
  25768. serializeVerticeData(): any;
  25769. /**
  25770. * Extracts a clone of a mesh geometry
  25771. * @param mesh defines the source mesh
  25772. * @param id defines the unique ID of the new geometry object
  25773. * @returns the new geometry object
  25774. */
  25775. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  25776. /**
  25777. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  25778. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  25779. * Be aware Math.random() could cause collisions, but:
  25780. * "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"
  25781. * @returns a string containing a new GUID
  25782. */
  25783. static RandomId(): string;
  25784. /** @hidden */
  25785. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  25786. private static _CleanMatricesWeights;
  25787. /**
  25788. * Create a new geometry from persisted data (Using .babylon file format)
  25789. * @param parsedVertexData defines the persisted data
  25790. * @param scene defines the hosting scene
  25791. * @param rootUrl defines the root url to use to load assets (like delayed data)
  25792. * @returns the new geometry object
  25793. */
  25794. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  25795. }
  25796. }
  25797. declare module "babylonjs/Meshes/mesh.vertexData" {
  25798. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  25799. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  25800. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  25801. import { Geometry } from "babylonjs/Meshes/geometry";
  25802. import { Mesh } from "babylonjs/Meshes/mesh";
  25803. /**
  25804. * Define an interface for all classes that will get and set the data on vertices
  25805. */
  25806. export interface IGetSetVerticesData {
  25807. /**
  25808. * Gets a boolean indicating if specific vertex data is present
  25809. * @param kind defines the vertex data kind to use
  25810. * @returns true is data kind is present
  25811. */
  25812. isVerticesDataPresent(kind: string): boolean;
  25813. /**
  25814. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  25815. * @param kind defines the data kind (Position, normal, etc...)
  25816. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25817. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25818. * @returns a float array containing vertex data
  25819. */
  25820. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25821. /**
  25822. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  25823. * @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.
  25824. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25825. * @returns the indices array or an empty array if the mesh has no geometry
  25826. */
  25827. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25828. /**
  25829. * Set specific vertex data
  25830. * @param kind defines the data kind (Position, normal, etc...)
  25831. * @param data defines the vertex data to use
  25832. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  25833. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  25834. */
  25835. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  25836. /**
  25837. * Update a specific associated vertex buffer
  25838. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25839. * - VertexBuffer.PositionKind
  25840. * - VertexBuffer.UVKind
  25841. * - VertexBuffer.UV2Kind
  25842. * - VertexBuffer.UV3Kind
  25843. * - VertexBuffer.UV4Kind
  25844. * - VertexBuffer.UV5Kind
  25845. * - VertexBuffer.UV6Kind
  25846. * - VertexBuffer.ColorKind
  25847. * - VertexBuffer.MatricesIndicesKind
  25848. * - VertexBuffer.MatricesIndicesExtraKind
  25849. * - VertexBuffer.MatricesWeightsKind
  25850. * - VertexBuffer.MatricesWeightsExtraKind
  25851. * @param data defines the data source
  25852. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  25853. * @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)
  25854. */
  25855. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  25856. /**
  25857. * Creates a new index buffer
  25858. * @param indices defines the indices to store in the index buffer
  25859. * @param totalVertices defines the total number of vertices (could be null)
  25860. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  25861. */
  25862. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  25863. }
  25864. /**
  25865. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  25866. */
  25867. export class VertexData {
  25868. /**
  25869. * Mesh side orientation : usually the external or front surface
  25870. */
  25871. static readonly FRONTSIDE: number;
  25872. /**
  25873. * Mesh side orientation : usually the internal or back surface
  25874. */
  25875. static readonly BACKSIDE: number;
  25876. /**
  25877. * Mesh side orientation : both internal and external or front and back surfaces
  25878. */
  25879. static readonly DOUBLESIDE: number;
  25880. /**
  25881. * Mesh side orientation : by default, `FRONTSIDE`
  25882. */
  25883. static readonly DEFAULTSIDE: number;
  25884. /**
  25885. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  25886. */
  25887. positions: Nullable<FloatArray>;
  25888. /**
  25889. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  25890. */
  25891. normals: Nullable<FloatArray>;
  25892. /**
  25893. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  25894. */
  25895. tangents: Nullable<FloatArray>;
  25896. /**
  25897. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25898. */
  25899. uvs: Nullable<FloatArray>;
  25900. /**
  25901. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25902. */
  25903. uvs2: Nullable<FloatArray>;
  25904. /**
  25905. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25906. */
  25907. uvs3: Nullable<FloatArray>;
  25908. /**
  25909. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25910. */
  25911. uvs4: Nullable<FloatArray>;
  25912. /**
  25913. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25914. */
  25915. uvs5: Nullable<FloatArray>;
  25916. /**
  25917. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25918. */
  25919. uvs6: Nullable<FloatArray>;
  25920. /**
  25921. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  25922. */
  25923. colors: Nullable<FloatArray>;
  25924. /**
  25925. * 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).
  25926. */
  25927. matricesIndices: Nullable<FloatArray>;
  25928. /**
  25929. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  25930. */
  25931. matricesWeights: Nullable<FloatArray>;
  25932. /**
  25933. * An array extending the number of possible indices
  25934. */
  25935. matricesIndicesExtra: Nullable<FloatArray>;
  25936. /**
  25937. * An array extending the number of possible weights when the number of indices is extended
  25938. */
  25939. matricesWeightsExtra: Nullable<FloatArray>;
  25940. /**
  25941. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  25942. */
  25943. indices: Nullable<IndicesArray>;
  25944. /**
  25945. * Uses the passed data array to set the set the values for the specified kind of data
  25946. * @param data a linear array of floating numbers
  25947. * @param kind the type of data that is being set, eg positions, colors etc
  25948. */
  25949. set(data: FloatArray, kind: string): void;
  25950. /**
  25951. * Associates the vertexData to the passed Mesh.
  25952. * Sets it as updatable or not (default `false`)
  25953. * @param mesh the mesh the vertexData is applied to
  25954. * @param updatable when used and having the value true allows new data to update the vertexData
  25955. * @returns the VertexData
  25956. */
  25957. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  25958. /**
  25959. * Associates the vertexData to the passed Geometry.
  25960. * Sets it as updatable or not (default `false`)
  25961. * @param geometry the geometry the vertexData is applied to
  25962. * @param updatable when used and having the value true allows new data to update the vertexData
  25963. * @returns VertexData
  25964. */
  25965. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  25966. /**
  25967. * Updates the associated mesh
  25968. * @param mesh the mesh to be updated
  25969. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  25970. * @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
  25971. * @returns VertexData
  25972. */
  25973. updateMesh(mesh: Mesh): VertexData;
  25974. /**
  25975. * Updates the associated geometry
  25976. * @param geometry the geometry to be updated
  25977. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  25978. * @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
  25979. * @returns VertexData.
  25980. */
  25981. updateGeometry(geometry: Geometry): VertexData;
  25982. private _applyTo;
  25983. private _update;
  25984. /**
  25985. * Transforms each position and each normal of the vertexData according to the passed Matrix
  25986. * @param matrix the transforming matrix
  25987. * @returns the VertexData
  25988. */
  25989. transform(matrix: Matrix): VertexData;
  25990. /**
  25991. * Merges the passed VertexData into the current one
  25992. * @param other the VertexData to be merged into the current one
  25993. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  25994. * @returns the modified VertexData
  25995. */
  25996. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  25997. private _mergeElement;
  25998. private _validate;
  25999. /**
  26000. * Serializes the VertexData
  26001. * @returns a serialized object
  26002. */
  26003. serialize(): any;
  26004. /**
  26005. * Extracts the vertexData from a mesh
  26006. * @param mesh the mesh from which to extract the VertexData
  26007. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  26008. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  26009. * @returns the object VertexData associated to the passed mesh
  26010. */
  26011. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  26012. /**
  26013. * Extracts the vertexData from the geometry
  26014. * @param geometry the geometry from which to extract the VertexData
  26015. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  26016. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  26017. * @returns the object VertexData associated to the passed mesh
  26018. */
  26019. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  26020. private static _ExtractFrom;
  26021. /**
  26022. * Creates the VertexData for a Ribbon
  26023. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  26024. * * pathArray array of paths, each of which an array of successive Vector3
  26025. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  26026. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  26027. * * 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
  26028. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26029. * * 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)
  26030. * * 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)
  26031. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  26032. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  26033. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  26034. * @returns the VertexData of the ribbon
  26035. */
  26036. static CreateRibbon(options: {
  26037. pathArray: Vector3[][];
  26038. closeArray?: boolean;
  26039. closePath?: boolean;
  26040. offset?: number;
  26041. sideOrientation?: number;
  26042. frontUVs?: Vector4;
  26043. backUVs?: Vector4;
  26044. invertUV?: boolean;
  26045. uvs?: Vector2[];
  26046. colors?: Color4[];
  26047. }): VertexData;
  26048. /**
  26049. * Creates the VertexData for a box
  26050. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26051. * * size sets the width, height and depth of the box to the value of size, optional default 1
  26052. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  26053. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  26054. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  26055. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  26056. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  26057. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26058. * * 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)
  26059. * * 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)
  26060. * @returns the VertexData of the box
  26061. */
  26062. static CreateBox(options: {
  26063. size?: number;
  26064. width?: number;
  26065. height?: number;
  26066. depth?: number;
  26067. faceUV?: Vector4[];
  26068. faceColors?: Color4[];
  26069. sideOrientation?: number;
  26070. frontUVs?: Vector4;
  26071. backUVs?: Vector4;
  26072. }): VertexData;
  26073. /**
  26074. * Creates the VertexData for a tiled box
  26075. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26076. * * faceTiles sets the pattern, tile size and number of tiles for a face
  26077. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  26078. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  26079. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26080. * @returns the VertexData of the box
  26081. */
  26082. static CreateTiledBox(options: {
  26083. pattern?: number;
  26084. width?: number;
  26085. height?: number;
  26086. depth?: number;
  26087. tileSize?: number;
  26088. tileWidth?: number;
  26089. tileHeight?: number;
  26090. alignHorizontal?: number;
  26091. alignVertical?: number;
  26092. faceUV?: Vector4[];
  26093. faceColors?: Color4[];
  26094. sideOrientation?: number;
  26095. }): VertexData;
  26096. /**
  26097. * Creates the VertexData for a tiled plane
  26098. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26099. * * pattern a limited pattern arrangement depending on the number
  26100. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  26101. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  26102. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  26103. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26104. * * 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)
  26105. * * 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)
  26106. * @returns the VertexData of the tiled plane
  26107. */
  26108. static CreateTiledPlane(options: {
  26109. pattern?: number;
  26110. tileSize?: number;
  26111. tileWidth?: number;
  26112. tileHeight?: number;
  26113. size?: number;
  26114. width?: number;
  26115. height?: number;
  26116. alignHorizontal?: number;
  26117. alignVertical?: number;
  26118. sideOrientation?: number;
  26119. frontUVs?: Vector4;
  26120. backUVs?: Vector4;
  26121. }): VertexData;
  26122. /**
  26123. * Creates the VertexData for an ellipsoid, defaults to a sphere
  26124. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26125. * * segments sets the number of horizontal strips optional, default 32
  26126. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  26127. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  26128. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  26129. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  26130. * * 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
  26131. * * 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
  26132. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26133. * * 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)
  26134. * * 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)
  26135. * @returns the VertexData of the ellipsoid
  26136. */
  26137. static CreateSphere(options: {
  26138. segments?: number;
  26139. diameter?: number;
  26140. diameterX?: number;
  26141. diameterY?: number;
  26142. diameterZ?: number;
  26143. arc?: number;
  26144. slice?: number;
  26145. sideOrientation?: number;
  26146. frontUVs?: Vector4;
  26147. backUVs?: Vector4;
  26148. }): VertexData;
  26149. /**
  26150. * Creates the VertexData for a cylinder, cone or prism
  26151. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26152. * * height sets the height (y direction) of the cylinder, optional, default 2
  26153. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  26154. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  26155. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  26156. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  26157. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  26158. * * 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
  26159. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  26160. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  26161. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  26162. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  26163. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26164. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  26165. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  26166. * @returns the VertexData of the cylinder, cone or prism
  26167. */
  26168. static CreateCylinder(options: {
  26169. height?: number;
  26170. diameterTop?: number;
  26171. diameterBottom?: number;
  26172. diameter?: number;
  26173. tessellation?: number;
  26174. subdivisions?: number;
  26175. arc?: number;
  26176. faceColors?: Color4[];
  26177. faceUV?: Vector4[];
  26178. hasRings?: boolean;
  26179. enclose?: boolean;
  26180. sideOrientation?: number;
  26181. frontUVs?: Vector4;
  26182. backUVs?: Vector4;
  26183. }): VertexData;
  26184. /**
  26185. * Creates the VertexData for a torus
  26186. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26187. * * diameter the diameter of the torus, optional default 1
  26188. * * thickness the diameter of the tube forming the torus, optional default 0.5
  26189. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  26190. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26191. * * 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)
  26192. * * 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)
  26193. * @returns the VertexData of the torus
  26194. */
  26195. static CreateTorus(options: {
  26196. diameter?: number;
  26197. thickness?: number;
  26198. tessellation?: number;
  26199. sideOrientation?: number;
  26200. frontUVs?: Vector4;
  26201. backUVs?: Vector4;
  26202. }): VertexData;
  26203. /**
  26204. * Creates the VertexData of the LineSystem
  26205. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  26206. * - lines an array of lines, each line being an array of successive Vector3
  26207. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  26208. * @returns the VertexData of the LineSystem
  26209. */
  26210. static CreateLineSystem(options: {
  26211. lines: Vector3[][];
  26212. colors?: Nullable<Color4[][]>;
  26213. }): VertexData;
  26214. /**
  26215. * Create the VertexData for a DashedLines
  26216. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  26217. * - points an array successive Vector3
  26218. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  26219. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  26220. * - dashNb the intended total number of dashes, optional, default 200
  26221. * @returns the VertexData for the DashedLines
  26222. */
  26223. static CreateDashedLines(options: {
  26224. points: Vector3[];
  26225. dashSize?: number;
  26226. gapSize?: number;
  26227. dashNb?: number;
  26228. }): VertexData;
  26229. /**
  26230. * Creates the VertexData for a Ground
  26231. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  26232. * - width the width (x direction) of the ground, optional, default 1
  26233. * - height the height (z direction) of the ground, optional, default 1
  26234. * - subdivisions the number of subdivisions per side, optional, default 1
  26235. * @returns the VertexData of the Ground
  26236. */
  26237. static CreateGround(options: {
  26238. width?: number;
  26239. height?: number;
  26240. subdivisions?: number;
  26241. subdivisionsX?: number;
  26242. subdivisionsY?: number;
  26243. }): VertexData;
  26244. /**
  26245. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  26246. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  26247. * * xmin the ground minimum X coordinate, optional, default -1
  26248. * * zmin the ground minimum Z coordinate, optional, default -1
  26249. * * xmax the ground maximum X coordinate, optional, default 1
  26250. * * zmax the ground maximum Z coordinate, optional, default 1
  26251. * * 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}
  26252. * * 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}
  26253. * @returns the VertexData of the TiledGround
  26254. */
  26255. static CreateTiledGround(options: {
  26256. xmin: number;
  26257. zmin: number;
  26258. xmax: number;
  26259. zmax: number;
  26260. subdivisions?: {
  26261. w: number;
  26262. h: number;
  26263. };
  26264. precision?: {
  26265. w: number;
  26266. h: number;
  26267. };
  26268. }): VertexData;
  26269. /**
  26270. * Creates the VertexData of the Ground designed from a heightmap
  26271. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  26272. * * width the width (x direction) of the ground
  26273. * * height the height (z direction) of the ground
  26274. * * subdivisions the number of subdivisions per side
  26275. * * minHeight the minimum altitude on the ground, optional, default 0
  26276. * * maxHeight the maximum altitude on the ground, optional default 1
  26277. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  26278. * * buffer the array holding the image color data
  26279. * * bufferWidth the width of image
  26280. * * bufferHeight the height of image
  26281. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  26282. * @returns the VertexData of the Ground designed from a heightmap
  26283. */
  26284. static CreateGroundFromHeightMap(options: {
  26285. width: number;
  26286. height: number;
  26287. subdivisions: number;
  26288. minHeight: number;
  26289. maxHeight: number;
  26290. colorFilter: Color3;
  26291. buffer: Uint8Array;
  26292. bufferWidth: number;
  26293. bufferHeight: number;
  26294. alphaFilter: number;
  26295. }): VertexData;
  26296. /**
  26297. * Creates the VertexData for a Plane
  26298. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  26299. * * size sets the width and height of the plane to the value of size, optional default 1
  26300. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  26301. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  26302. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26303. * * 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)
  26304. * * 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)
  26305. * @returns the VertexData of the box
  26306. */
  26307. static CreatePlane(options: {
  26308. size?: number;
  26309. width?: number;
  26310. height?: number;
  26311. sideOrientation?: number;
  26312. frontUVs?: Vector4;
  26313. backUVs?: Vector4;
  26314. }): VertexData;
  26315. /**
  26316. * Creates the VertexData of the Disc or regular Polygon
  26317. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  26318. * * radius the radius of the disc, optional default 0.5
  26319. * * tessellation the number of polygon sides, optional, default 64
  26320. * * 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
  26321. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26322. * * 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)
  26323. * * 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)
  26324. * @returns the VertexData of the box
  26325. */
  26326. static CreateDisc(options: {
  26327. radius?: number;
  26328. tessellation?: number;
  26329. arc?: number;
  26330. sideOrientation?: number;
  26331. frontUVs?: Vector4;
  26332. backUVs?: Vector4;
  26333. }): VertexData;
  26334. /**
  26335. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  26336. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  26337. * @param polygon a mesh built from polygonTriangulation.build()
  26338. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26339. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  26340. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  26341. * @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)
  26342. * @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)
  26343. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  26344. * @returns the VertexData of the Polygon
  26345. */
  26346. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  26347. /**
  26348. * Creates the VertexData of the IcoSphere
  26349. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  26350. * * radius the radius of the IcoSphere, optional default 1
  26351. * * radiusX allows stretching in the x direction, optional, default radius
  26352. * * radiusY allows stretching in the y direction, optional, default radius
  26353. * * radiusZ allows stretching in the z direction, optional, default radius
  26354. * * flat when true creates a flat shaded mesh, optional, default true
  26355. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  26356. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26357. * * 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)
  26358. * * 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)
  26359. * @returns the VertexData of the IcoSphere
  26360. */
  26361. static CreateIcoSphere(options: {
  26362. radius?: number;
  26363. radiusX?: number;
  26364. radiusY?: number;
  26365. radiusZ?: number;
  26366. flat?: boolean;
  26367. subdivisions?: number;
  26368. sideOrientation?: number;
  26369. frontUVs?: Vector4;
  26370. backUVs?: Vector4;
  26371. }): VertexData;
  26372. /**
  26373. * Creates the VertexData for a Polyhedron
  26374. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  26375. * * type provided types are:
  26376. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  26377. * * 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)
  26378. * * size the size of the IcoSphere, optional default 1
  26379. * * sizeX allows stretching in the x direction, optional, default size
  26380. * * sizeY allows stretching in the y direction, optional, default size
  26381. * * sizeZ allows stretching in the z direction, optional, default size
  26382. * * 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
  26383. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  26384. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  26385. * * flat when true creates a flat shaded mesh, optional, default true
  26386. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  26387. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26388. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  26389. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  26390. * @returns the VertexData of the Polyhedron
  26391. */
  26392. static CreatePolyhedron(options: {
  26393. type?: number;
  26394. size?: number;
  26395. sizeX?: number;
  26396. sizeY?: number;
  26397. sizeZ?: number;
  26398. custom?: any;
  26399. faceUV?: Vector4[];
  26400. faceColors?: Color4[];
  26401. flat?: boolean;
  26402. sideOrientation?: number;
  26403. frontUVs?: Vector4;
  26404. backUVs?: Vector4;
  26405. }): VertexData;
  26406. /**
  26407. * Creates the VertexData for a TorusKnot
  26408. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  26409. * * radius the radius of the torus knot, optional, default 2
  26410. * * tube the thickness of the tube, optional, default 0.5
  26411. * * radialSegments the number of sides on each tube segments, optional, default 32
  26412. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  26413. * * p the number of windings around the z axis, optional, default 2
  26414. * * q the number of windings around the x axis, optional, default 3
  26415. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26416. * * 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)
  26417. * * 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)
  26418. * @returns the VertexData of the Torus Knot
  26419. */
  26420. static CreateTorusKnot(options: {
  26421. radius?: number;
  26422. tube?: number;
  26423. radialSegments?: number;
  26424. tubularSegments?: number;
  26425. p?: number;
  26426. q?: number;
  26427. sideOrientation?: number;
  26428. frontUVs?: Vector4;
  26429. backUVs?: Vector4;
  26430. }): VertexData;
  26431. /**
  26432. * Compute normals for given positions and indices
  26433. * @param positions an array of vertex positions, [...., x, y, z, ......]
  26434. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  26435. * @param normals an array of vertex normals, [...., x, y, z, ......]
  26436. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  26437. * * facetNormals : optional array of facet normals (vector3)
  26438. * * facetPositions : optional array of facet positions (vector3)
  26439. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  26440. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  26441. * * bInfo : optional bounding info, required for facetPartitioning computation
  26442. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  26443. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  26444. * * useRightHandedSystem: optional boolean to for right handed system computation
  26445. * * depthSort : optional boolean to enable the facet depth sort computation
  26446. * * distanceTo : optional Vector3 to compute the facet depth from this location
  26447. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  26448. */
  26449. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  26450. facetNormals?: any;
  26451. facetPositions?: any;
  26452. facetPartitioning?: any;
  26453. ratio?: number;
  26454. bInfo?: any;
  26455. bbSize?: Vector3;
  26456. subDiv?: any;
  26457. useRightHandedSystem?: boolean;
  26458. depthSort?: boolean;
  26459. distanceTo?: Vector3;
  26460. depthSortedFacets?: any;
  26461. }): void;
  26462. /** @hidden */
  26463. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  26464. /**
  26465. * Applies VertexData created from the imported parameters to the geometry
  26466. * @param parsedVertexData the parsed data from an imported file
  26467. * @param geometry the geometry to apply the VertexData to
  26468. */
  26469. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  26470. }
  26471. }
  26472. declare module "babylonjs/Morph/morphTarget" {
  26473. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  26474. import { Observable } from "babylonjs/Misc/observable";
  26475. import { Nullable, FloatArray } from "babylonjs/types";
  26476. import { Scene } from "babylonjs/scene";
  26477. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26478. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  26479. /**
  26480. * Defines a target to use with MorphTargetManager
  26481. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  26482. */
  26483. export class MorphTarget implements IAnimatable {
  26484. /** defines the name of the target */
  26485. name: string;
  26486. /**
  26487. * Gets or sets the list of animations
  26488. */
  26489. animations: import("babylonjs/Animations/animation").Animation[];
  26490. private _scene;
  26491. private _positions;
  26492. private _normals;
  26493. private _tangents;
  26494. private _uvs;
  26495. private _influence;
  26496. private _uniqueId;
  26497. /**
  26498. * Observable raised when the influence changes
  26499. */
  26500. onInfluenceChanged: Observable<boolean>;
  26501. /** @hidden */
  26502. _onDataLayoutChanged: Observable<void>;
  26503. /**
  26504. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  26505. */
  26506. get influence(): number;
  26507. set influence(influence: number);
  26508. /**
  26509. * Gets or sets the id of the morph Target
  26510. */
  26511. id: string;
  26512. private _animationPropertiesOverride;
  26513. /**
  26514. * Gets or sets the animation properties override
  26515. */
  26516. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  26517. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  26518. /**
  26519. * Creates a new MorphTarget
  26520. * @param name defines the name of the target
  26521. * @param influence defines the influence to use
  26522. * @param scene defines the scene the morphtarget belongs to
  26523. */
  26524. constructor(
  26525. /** defines the name of the target */
  26526. name: string, influence?: number, scene?: Nullable<Scene>);
  26527. /**
  26528. * Gets the unique ID of this manager
  26529. */
  26530. get uniqueId(): number;
  26531. /**
  26532. * Gets a boolean defining if the target contains position data
  26533. */
  26534. get hasPositions(): boolean;
  26535. /**
  26536. * Gets a boolean defining if the target contains normal data
  26537. */
  26538. get hasNormals(): boolean;
  26539. /**
  26540. * Gets a boolean defining if the target contains tangent data
  26541. */
  26542. get hasTangents(): boolean;
  26543. /**
  26544. * Gets a boolean defining if the target contains texture coordinates data
  26545. */
  26546. get hasUVs(): boolean;
  26547. /**
  26548. * Affects position data to this target
  26549. * @param data defines the position data to use
  26550. */
  26551. setPositions(data: Nullable<FloatArray>): void;
  26552. /**
  26553. * Gets the position data stored in this target
  26554. * @returns a FloatArray containing the position data (or null if not present)
  26555. */
  26556. getPositions(): Nullable<FloatArray>;
  26557. /**
  26558. * Affects normal data to this target
  26559. * @param data defines the normal data to use
  26560. */
  26561. setNormals(data: Nullable<FloatArray>): void;
  26562. /**
  26563. * Gets the normal data stored in this target
  26564. * @returns a FloatArray containing the normal data (or null if not present)
  26565. */
  26566. getNormals(): Nullable<FloatArray>;
  26567. /**
  26568. * Affects tangent data to this target
  26569. * @param data defines the tangent data to use
  26570. */
  26571. setTangents(data: Nullable<FloatArray>): void;
  26572. /**
  26573. * Gets the tangent data stored in this target
  26574. * @returns a FloatArray containing the tangent data (or null if not present)
  26575. */
  26576. getTangents(): Nullable<FloatArray>;
  26577. /**
  26578. * Affects texture coordinates data to this target
  26579. * @param data defines the texture coordinates data to use
  26580. */
  26581. setUVs(data: Nullable<FloatArray>): void;
  26582. /**
  26583. * Gets the texture coordinates data stored in this target
  26584. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  26585. */
  26586. getUVs(): Nullable<FloatArray>;
  26587. /**
  26588. * Clone the current target
  26589. * @returns a new MorphTarget
  26590. */
  26591. clone(): MorphTarget;
  26592. /**
  26593. * Serializes the current target into a Serialization object
  26594. * @returns the serialized object
  26595. */
  26596. serialize(): any;
  26597. /**
  26598. * Returns the string "MorphTarget"
  26599. * @returns "MorphTarget"
  26600. */
  26601. getClassName(): string;
  26602. /**
  26603. * Creates a new target from serialized data
  26604. * @param serializationObject defines the serialized data to use
  26605. * @returns a new MorphTarget
  26606. */
  26607. static Parse(serializationObject: any): MorphTarget;
  26608. /**
  26609. * Creates a MorphTarget from mesh data
  26610. * @param mesh defines the source mesh
  26611. * @param name defines the name to use for the new target
  26612. * @param influence defines the influence to attach to the target
  26613. * @returns a new MorphTarget
  26614. */
  26615. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  26616. }
  26617. }
  26618. declare module "babylonjs/Morph/morphTargetManager" {
  26619. import { Nullable } from "babylonjs/types";
  26620. import { Scene } from "babylonjs/scene";
  26621. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  26622. /**
  26623. * This class is used to deform meshes using morphing between different targets
  26624. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  26625. */
  26626. export class MorphTargetManager {
  26627. private _targets;
  26628. private _targetInfluenceChangedObservers;
  26629. private _targetDataLayoutChangedObservers;
  26630. private _activeTargets;
  26631. private _scene;
  26632. private _influences;
  26633. private _supportsNormals;
  26634. private _supportsTangents;
  26635. private _supportsUVs;
  26636. private _vertexCount;
  26637. private _uniqueId;
  26638. private _tempInfluences;
  26639. /**
  26640. * Gets or sets a boolean indicating if normals must be morphed
  26641. */
  26642. enableNormalMorphing: boolean;
  26643. /**
  26644. * Gets or sets a boolean indicating if tangents must be morphed
  26645. */
  26646. enableTangentMorphing: boolean;
  26647. /**
  26648. * Gets or sets a boolean indicating if UV must be morphed
  26649. */
  26650. enableUVMorphing: boolean;
  26651. /**
  26652. * Creates a new MorphTargetManager
  26653. * @param scene defines the current scene
  26654. */
  26655. constructor(scene?: Nullable<Scene>);
  26656. /**
  26657. * Gets the unique ID of this manager
  26658. */
  26659. get uniqueId(): number;
  26660. /**
  26661. * Gets the number of vertices handled by this manager
  26662. */
  26663. get vertexCount(): number;
  26664. /**
  26665. * Gets a boolean indicating if this manager supports morphing of normals
  26666. */
  26667. get supportsNormals(): boolean;
  26668. /**
  26669. * Gets a boolean indicating if this manager supports morphing of tangents
  26670. */
  26671. get supportsTangents(): boolean;
  26672. /**
  26673. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  26674. */
  26675. get supportsUVs(): boolean;
  26676. /**
  26677. * Gets the number of targets stored in this manager
  26678. */
  26679. get numTargets(): number;
  26680. /**
  26681. * Gets the number of influencers (ie. the number of targets with influences > 0)
  26682. */
  26683. get numInfluencers(): number;
  26684. /**
  26685. * Gets the list of influences (one per target)
  26686. */
  26687. get influences(): Float32Array;
  26688. /**
  26689. * Gets the active target at specified index. An active target is a target with an influence > 0
  26690. * @param index defines the index to check
  26691. * @returns the requested target
  26692. */
  26693. getActiveTarget(index: number): MorphTarget;
  26694. /**
  26695. * Gets the target at specified index
  26696. * @param index defines the index to check
  26697. * @returns the requested target
  26698. */
  26699. getTarget(index: number): MorphTarget;
  26700. /**
  26701. * Add a new target to this manager
  26702. * @param target defines the target to add
  26703. */
  26704. addTarget(target: MorphTarget): void;
  26705. /**
  26706. * Removes a target from the manager
  26707. * @param target defines the target to remove
  26708. */
  26709. removeTarget(target: MorphTarget): void;
  26710. /**
  26711. * Clone the current manager
  26712. * @returns a new MorphTargetManager
  26713. */
  26714. clone(): MorphTargetManager;
  26715. /**
  26716. * Serializes the current manager into a Serialization object
  26717. * @returns the serialized object
  26718. */
  26719. serialize(): any;
  26720. private _syncActiveTargets;
  26721. /**
  26722. * Syncrhonize the targets with all the meshes using this morph target manager
  26723. */
  26724. synchronize(): void;
  26725. /**
  26726. * Creates a new MorphTargetManager from serialized data
  26727. * @param serializationObject defines the serialized data
  26728. * @param scene defines the hosting scene
  26729. * @returns the new MorphTargetManager
  26730. */
  26731. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  26732. }
  26733. }
  26734. declare module "babylonjs/Meshes/meshLODLevel" {
  26735. import { Mesh } from "babylonjs/Meshes/mesh";
  26736. import { Nullable } from "babylonjs/types";
  26737. /**
  26738. * Class used to represent a specific level of detail of a mesh
  26739. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  26740. */
  26741. export class MeshLODLevel {
  26742. /** Defines the distance where this level should start being displayed */
  26743. distance: number;
  26744. /** Defines the mesh to use to render this level */
  26745. mesh: Nullable<Mesh>;
  26746. /**
  26747. * Creates a new LOD level
  26748. * @param distance defines the distance where this level should star being displayed
  26749. * @param mesh defines the mesh to use to render this level
  26750. */
  26751. constructor(
  26752. /** Defines the distance where this level should start being displayed */
  26753. distance: number,
  26754. /** Defines the mesh to use to render this level */
  26755. mesh: Nullable<Mesh>);
  26756. }
  26757. }
  26758. declare module "babylonjs/Meshes/groundMesh" {
  26759. import { Scene } from "babylonjs/scene";
  26760. import { Vector3 } from "babylonjs/Maths/math.vector";
  26761. import { Mesh } from "babylonjs/Meshes/mesh";
  26762. /**
  26763. * Mesh representing the gorund
  26764. */
  26765. export class GroundMesh extends Mesh {
  26766. /** If octree should be generated */
  26767. generateOctree: boolean;
  26768. private _heightQuads;
  26769. /** @hidden */
  26770. _subdivisionsX: number;
  26771. /** @hidden */
  26772. _subdivisionsY: number;
  26773. /** @hidden */
  26774. _width: number;
  26775. /** @hidden */
  26776. _height: number;
  26777. /** @hidden */
  26778. _minX: number;
  26779. /** @hidden */
  26780. _maxX: number;
  26781. /** @hidden */
  26782. _minZ: number;
  26783. /** @hidden */
  26784. _maxZ: number;
  26785. constructor(name: string, scene: Scene);
  26786. /**
  26787. * "GroundMesh"
  26788. * @returns "GroundMesh"
  26789. */
  26790. getClassName(): string;
  26791. /**
  26792. * The minimum of x and y subdivisions
  26793. */
  26794. get subdivisions(): number;
  26795. /**
  26796. * X subdivisions
  26797. */
  26798. get subdivisionsX(): number;
  26799. /**
  26800. * Y subdivisions
  26801. */
  26802. get subdivisionsY(): number;
  26803. /**
  26804. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  26805. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  26806. * @param chunksCount the number of subdivisions for x and y
  26807. * @param octreeBlocksSize (Default: 32)
  26808. */
  26809. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  26810. /**
  26811. * Returns a height (y) value in the Worl system :
  26812. * the ground altitude at the coordinates (x, z) expressed in the World system.
  26813. * @param x x coordinate
  26814. * @param z z coordinate
  26815. * @returns the ground y position if (x, z) are outside the ground surface.
  26816. */
  26817. getHeightAtCoordinates(x: number, z: number): number;
  26818. /**
  26819. * Returns a normalized vector (Vector3) orthogonal to the ground
  26820. * at the ground coordinates (x, z) expressed in the World system.
  26821. * @param x x coordinate
  26822. * @param z z coordinate
  26823. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  26824. */
  26825. getNormalAtCoordinates(x: number, z: number): Vector3;
  26826. /**
  26827. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  26828. * at the ground coordinates (x, z) expressed in the World system.
  26829. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  26830. * @param x x coordinate
  26831. * @param z z coordinate
  26832. * @param ref vector to store the result
  26833. * @returns the GroundMesh.
  26834. */
  26835. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  26836. /**
  26837. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  26838. * if the ground has been updated.
  26839. * This can be used in the render loop.
  26840. * @returns the GroundMesh.
  26841. */
  26842. updateCoordinateHeights(): GroundMesh;
  26843. private _getFacetAt;
  26844. private _initHeightQuads;
  26845. private _computeHeightQuads;
  26846. /**
  26847. * Serializes this ground mesh
  26848. * @param serializationObject object to write serialization to
  26849. */
  26850. serialize(serializationObject: any): void;
  26851. /**
  26852. * Parses a serialized ground mesh
  26853. * @param parsedMesh the serialized mesh
  26854. * @param scene the scene to create the ground mesh in
  26855. * @returns the created ground mesh
  26856. */
  26857. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  26858. }
  26859. }
  26860. declare module "babylonjs/Physics/physicsJoint" {
  26861. import { Vector3 } from "babylonjs/Maths/math.vector";
  26862. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  26863. /**
  26864. * Interface for Physics-Joint data
  26865. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26866. */
  26867. export interface PhysicsJointData {
  26868. /**
  26869. * The main pivot of the joint
  26870. */
  26871. mainPivot?: Vector3;
  26872. /**
  26873. * The connected pivot of the joint
  26874. */
  26875. connectedPivot?: Vector3;
  26876. /**
  26877. * The main axis of the joint
  26878. */
  26879. mainAxis?: Vector3;
  26880. /**
  26881. * The connected axis of the joint
  26882. */
  26883. connectedAxis?: Vector3;
  26884. /**
  26885. * The collision of the joint
  26886. */
  26887. collision?: boolean;
  26888. /**
  26889. * Native Oimo/Cannon/Energy data
  26890. */
  26891. nativeParams?: any;
  26892. }
  26893. /**
  26894. * This is a holder class for the physics joint created by the physics plugin
  26895. * It holds a set of functions to control the underlying joint
  26896. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26897. */
  26898. export class PhysicsJoint {
  26899. /**
  26900. * The type of the physics joint
  26901. */
  26902. type: number;
  26903. /**
  26904. * The data for the physics joint
  26905. */
  26906. jointData: PhysicsJointData;
  26907. private _physicsJoint;
  26908. protected _physicsPlugin: IPhysicsEnginePlugin;
  26909. /**
  26910. * Initializes the physics joint
  26911. * @param type The type of the physics joint
  26912. * @param jointData The data for the physics joint
  26913. */
  26914. constructor(
  26915. /**
  26916. * The type of the physics joint
  26917. */
  26918. type: number,
  26919. /**
  26920. * The data for the physics joint
  26921. */
  26922. jointData: PhysicsJointData);
  26923. /**
  26924. * Gets the physics joint
  26925. */
  26926. get physicsJoint(): any;
  26927. /**
  26928. * Sets the physics joint
  26929. */
  26930. set physicsJoint(newJoint: any);
  26931. /**
  26932. * Sets the physics plugin
  26933. */
  26934. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  26935. /**
  26936. * Execute a function that is physics-plugin specific.
  26937. * @param {Function} func the function that will be executed.
  26938. * It accepts two parameters: the physics world and the physics joint
  26939. */
  26940. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  26941. /**
  26942. * Distance-Joint type
  26943. */
  26944. static DistanceJoint: number;
  26945. /**
  26946. * Hinge-Joint type
  26947. */
  26948. static HingeJoint: number;
  26949. /**
  26950. * Ball-and-Socket joint type
  26951. */
  26952. static BallAndSocketJoint: number;
  26953. /**
  26954. * Wheel-Joint type
  26955. */
  26956. static WheelJoint: number;
  26957. /**
  26958. * Slider-Joint type
  26959. */
  26960. static SliderJoint: number;
  26961. /**
  26962. * Prismatic-Joint type
  26963. */
  26964. static PrismaticJoint: number;
  26965. /**
  26966. * Universal-Joint type
  26967. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  26968. */
  26969. static UniversalJoint: number;
  26970. /**
  26971. * Hinge-Joint 2 type
  26972. */
  26973. static Hinge2Joint: number;
  26974. /**
  26975. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  26976. */
  26977. static PointToPointJoint: number;
  26978. /**
  26979. * Spring-Joint type
  26980. */
  26981. static SpringJoint: number;
  26982. /**
  26983. * Lock-Joint type
  26984. */
  26985. static LockJoint: number;
  26986. }
  26987. /**
  26988. * A class representing a physics distance joint
  26989. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26990. */
  26991. export class DistanceJoint extends PhysicsJoint {
  26992. /**
  26993. *
  26994. * @param jointData The data for the Distance-Joint
  26995. */
  26996. constructor(jointData: DistanceJointData);
  26997. /**
  26998. * Update the predefined distance.
  26999. * @param maxDistance The maximum preferred distance
  27000. * @param minDistance The minimum preferred distance
  27001. */
  27002. updateDistance(maxDistance: number, minDistance?: number): void;
  27003. }
  27004. /**
  27005. * Represents a Motor-Enabled Joint
  27006. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27007. */
  27008. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  27009. /**
  27010. * Initializes the Motor-Enabled Joint
  27011. * @param type The type of the joint
  27012. * @param jointData The physica joint data for the joint
  27013. */
  27014. constructor(type: number, jointData: PhysicsJointData);
  27015. /**
  27016. * Set the motor values.
  27017. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27018. * @param force the force to apply
  27019. * @param maxForce max force for this motor.
  27020. */
  27021. setMotor(force?: number, maxForce?: number): void;
  27022. /**
  27023. * Set the motor's limits.
  27024. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27025. * @param upperLimit The upper limit of the motor
  27026. * @param lowerLimit The lower limit of the motor
  27027. */
  27028. setLimit(upperLimit: number, lowerLimit?: number): void;
  27029. }
  27030. /**
  27031. * This class represents a single physics Hinge-Joint
  27032. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27033. */
  27034. export class HingeJoint extends MotorEnabledJoint {
  27035. /**
  27036. * Initializes the Hinge-Joint
  27037. * @param jointData The joint data for the Hinge-Joint
  27038. */
  27039. constructor(jointData: PhysicsJointData);
  27040. /**
  27041. * Set the motor values.
  27042. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27043. * @param {number} force the force to apply
  27044. * @param {number} maxForce max force for this motor.
  27045. */
  27046. setMotor(force?: number, maxForce?: number): void;
  27047. /**
  27048. * Set the motor's limits.
  27049. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27050. * @param upperLimit The upper limit of the motor
  27051. * @param lowerLimit The lower limit of the motor
  27052. */
  27053. setLimit(upperLimit: number, lowerLimit?: number): void;
  27054. }
  27055. /**
  27056. * This class represents a dual hinge physics joint (same as wheel joint)
  27057. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27058. */
  27059. export class Hinge2Joint extends MotorEnabledJoint {
  27060. /**
  27061. * Initializes the Hinge2-Joint
  27062. * @param jointData The joint data for the Hinge2-Joint
  27063. */
  27064. constructor(jointData: PhysicsJointData);
  27065. /**
  27066. * Set the motor values.
  27067. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27068. * @param {number} targetSpeed the speed the motor is to reach
  27069. * @param {number} maxForce max force for this motor.
  27070. * @param {motorIndex} the motor's index, 0 or 1.
  27071. */
  27072. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  27073. /**
  27074. * Set the motor limits.
  27075. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27076. * @param {number} upperLimit the upper limit
  27077. * @param {number} lowerLimit lower limit
  27078. * @param {motorIndex} the motor's index, 0 or 1.
  27079. */
  27080. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  27081. }
  27082. /**
  27083. * Interface for a motor enabled joint
  27084. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27085. */
  27086. export interface IMotorEnabledJoint {
  27087. /**
  27088. * Physics joint
  27089. */
  27090. physicsJoint: any;
  27091. /**
  27092. * Sets the motor of the motor-enabled joint
  27093. * @param force The force of the motor
  27094. * @param maxForce The maximum force of the motor
  27095. * @param motorIndex The index of the motor
  27096. */
  27097. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  27098. /**
  27099. * Sets the limit of the motor
  27100. * @param upperLimit The upper limit of the motor
  27101. * @param lowerLimit The lower limit of the motor
  27102. * @param motorIndex The index of the motor
  27103. */
  27104. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  27105. }
  27106. /**
  27107. * Joint data for a Distance-Joint
  27108. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27109. */
  27110. export interface DistanceJointData extends PhysicsJointData {
  27111. /**
  27112. * Max distance the 2 joint objects can be apart
  27113. */
  27114. maxDistance: number;
  27115. }
  27116. /**
  27117. * Joint data from a spring joint
  27118. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27119. */
  27120. export interface SpringJointData extends PhysicsJointData {
  27121. /**
  27122. * Length of the spring
  27123. */
  27124. length: number;
  27125. /**
  27126. * Stiffness of the spring
  27127. */
  27128. stiffness: number;
  27129. /**
  27130. * Damping of the spring
  27131. */
  27132. damping: number;
  27133. /** this callback will be called when applying the force to the impostors. */
  27134. forceApplicationCallback: () => void;
  27135. }
  27136. }
  27137. declare module "babylonjs/Physics/physicsRaycastResult" {
  27138. import { Vector3 } from "babylonjs/Maths/math.vector";
  27139. /**
  27140. * Holds the data for the raycast result
  27141. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27142. */
  27143. export class PhysicsRaycastResult {
  27144. private _hasHit;
  27145. private _hitDistance;
  27146. private _hitNormalWorld;
  27147. private _hitPointWorld;
  27148. private _rayFromWorld;
  27149. private _rayToWorld;
  27150. /**
  27151. * Gets if there was a hit
  27152. */
  27153. get hasHit(): boolean;
  27154. /**
  27155. * Gets the distance from the hit
  27156. */
  27157. get hitDistance(): number;
  27158. /**
  27159. * Gets the hit normal/direction in the world
  27160. */
  27161. get hitNormalWorld(): Vector3;
  27162. /**
  27163. * Gets the hit point in the world
  27164. */
  27165. get hitPointWorld(): Vector3;
  27166. /**
  27167. * Gets the ray "start point" of the ray in the world
  27168. */
  27169. get rayFromWorld(): Vector3;
  27170. /**
  27171. * Gets the ray "end point" of the ray in the world
  27172. */
  27173. get rayToWorld(): Vector3;
  27174. /**
  27175. * Sets the hit data (normal & point in world space)
  27176. * @param hitNormalWorld defines the normal in world space
  27177. * @param hitPointWorld defines the point in world space
  27178. */
  27179. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  27180. /**
  27181. * Sets the distance from the start point to the hit point
  27182. * @param distance
  27183. */
  27184. setHitDistance(distance: number): void;
  27185. /**
  27186. * Calculates the distance manually
  27187. */
  27188. calculateHitDistance(): void;
  27189. /**
  27190. * Resets all the values to default
  27191. * @param from The from point on world space
  27192. * @param to The to point on world space
  27193. */
  27194. reset(from?: Vector3, to?: Vector3): void;
  27195. }
  27196. /**
  27197. * Interface for the size containing width and height
  27198. */
  27199. interface IXYZ {
  27200. /**
  27201. * X
  27202. */
  27203. x: number;
  27204. /**
  27205. * Y
  27206. */
  27207. y: number;
  27208. /**
  27209. * Z
  27210. */
  27211. z: number;
  27212. }
  27213. }
  27214. declare module "babylonjs/Physics/IPhysicsEngine" {
  27215. import { Nullable } from "babylonjs/types";
  27216. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  27217. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27218. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  27219. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  27220. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  27221. /**
  27222. * Interface used to describe a physics joint
  27223. */
  27224. export interface PhysicsImpostorJoint {
  27225. /** Defines the main impostor to which the joint is linked */
  27226. mainImpostor: PhysicsImpostor;
  27227. /** Defines the impostor that is connected to the main impostor using this joint */
  27228. connectedImpostor: PhysicsImpostor;
  27229. /** Defines the joint itself */
  27230. joint: PhysicsJoint;
  27231. }
  27232. /** @hidden */
  27233. export interface IPhysicsEnginePlugin {
  27234. world: any;
  27235. name: string;
  27236. setGravity(gravity: Vector3): void;
  27237. setTimeStep(timeStep: number): void;
  27238. getTimeStep(): number;
  27239. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  27240. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  27241. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  27242. generatePhysicsBody(impostor: PhysicsImpostor): void;
  27243. removePhysicsBody(impostor: PhysicsImpostor): void;
  27244. generateJoint(joint: PhysicsImpostorJoint): void;
  27245. removeJoint(joint: PhysicsImpostorJoint): void;
  27246. isSupported(): boolean;
  27247. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  27248. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  27249. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  27250. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  27251. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  27252. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  27253. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  27254. getBodyMass(impostor: PhysicsImpostor): number;
  27255. getBodyFriction(impostor: PhysicsImpostor): number;
  27256. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  27257. getBodyRestitution(impostor: PhysicsImpostor): number;
  27258. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  27259. getBodyPressure?(impostor: PhysicsImpostor): number;
  27260. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  27261. getBodyStiffness?(impostor: PhysicsImpostor): number;
  27262. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  27263. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  27264. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  27265. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  27266. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  27267. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  27268. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  27269. sleepBody(impostor: PhysicsImpostor): void;
  27270. wakeUpBody(impostor: PhysicsImpostor): void;
  27271. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  27272. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  27273. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  27274. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  27275. getRadius(impostor: PhysicsImpostor): number;
  27276. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  27277. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  27278. dispose(): void;
  27279. }
  27280. /**
  27281. * Interface used to define a physics engine
  27282. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  27283. */
  27284. export interface IPhysicsEngine {
  27285. /**
  27286. * Gets the gravity vector used by the simulation
  27287. */
  27288. gravity: Vector3;
  27289. /**
  27290. * Sets the gravity vector used by the simulation
  27291. * @param gravity defines the gravity vector to use
  27292. */
  27293. setGravity(gravity: Vector3): void;
  27294. /**
  27295. * Set the time step of the physics engine.
  27296. * Default is 1/60.
  27297. * To slow it down, enter 1/600 for example.
  27298. * To speed it up, 1/30
  27299. * @param newTimeStep the new timestep to apply to this world.
  27300. */
  27301. setTimeStep(newTimeStep: number): void;
  27302. /**
  27303. * Get the time step of the physics engine.
  27304. * @returns the current time step
  27305. */
  27306. getTimeStep(): number;
  27307. /**
  27308. * Set the sub time step of the physics engine.
  27309. * Default is 0 meaning there is no sub steps
  27310. * To increase physics resolution precision, set a small value (like 1 ms)
  27311. * @param subTimeStep defines the new sub timestep used for physics resolution.
  27312. */
  27313. setSubTimeStep(subTimeStep: number): void;
  27314. /**
  27315. * Get the sub time step of the physics engine.
  27316. * @returns the current sub time step
  27317. */
  27318. getSubTimeStep(): number;
  27319. /**
  27320. * Release all resources
  27321. */
  27322. dispose(): void;
  27323. /**
  27324. * Gets the name of the current physics plugin
  27325. * @returns the name of the plugin
  27326. */
  27327. getPhysicsPluginName(): string;
  27328. /**
  27329. * Adding a new impostor for the impostor tracking.
  27330. * This will be done by the impostor itself.
  27331. * @param impostor the impostor to add
  27332. */
  27333. addImpostor(impostor: PhysicsImpostor): void;
  27334. /**
  27335. * Remove an impostor from the engine.
  27336. * This impostor and its mesh will not longer be updated by the physics engine.
  27337. * @param impostor the impostor to remove
  27338. */
  27339. removeImpostor(impostor: PhysicsImpostor): void;
  27340. /**
  27341. * Add a joint to the physics engine
  27342. * @param mainImpostor defines the main impostor to which the joint is added.
  27343. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  27344. * @param joint defines the joint that will connect both impostors.
  27345. */
  27346. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  27347. /**
  27348. * Removes a joint from the simulation
  27349. * @param mainImpostor defines the impostor used with the joint
  27350. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  27351. * @param joint defines the joint to remove
  27352. */
  27353. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  27354. /**
  27355. * Gets the current plugin used to run the simulation
  27356. * @returns current plugin
  27357. */
  27358. getPhysicsPlugin(): IPhysicsEnginePlugin;
  27359. /**
  27360. * Gets the list of physic impostors
  27361. * @returns an array of PhysicsImpostor
  27362. */
  27363. getImpostors(): Array<PhysicsImpostor>;
  27364. /**
  27365. * Gets the impostor for a physics enabled object
  27366. * @param object defines the object impersonated by the impostor
  27367. * @returns the PhysicsImpostor or null if not found
  27368. */
  27369. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  27370. /**
  27371. * Gets the impostor for a physics body object
  27372. * @param body defines physics body used by the impostor
  27373. * @returns the PhysicsImpostor or null if not found
  27374. */
  27375. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  27376. /**
  27377. * Does a raycast in the physics world
  27378. * @param from when should the ray start?
  27379. * @param to when should the ray end?
  27380. * @returns PhysicsRaycastResult
  27381. */
  27382. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  27383. /**
  27384. * Called by the scene. No need to call it.
  27385. * @param delta defines the timespam between frames
  27386. */
  27387. _step(delta: number): void;
  27388. }
  27389. }
  27390. declare module "babylonjs/Physics/physicsImpostor" {
  27391. import { Nullable, IndicesArray } from "babylonjs/types";
  27392. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  27393. import { TransformNode } from "babylonjs/Meshes/transformNode";
  27394. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27395. import { Scene } from "babylonjs/scene";
  27396. import { Bone } from "babylonjs/Bones/bone";
  27397. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  27398. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  27399. import { Space } from "babylonjs/Maths/math.axis";
  27400. /**
  27401. * The interface for the physics imposter parameters
  27402. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27403. */
  27404. export interface PhysicsImpostorParameters {
  27405. /**
  27406. * The mass of the physics imposter
  27407. */
  27408. mass: number;
  27409. /**
  27410. * The friction of the physics imposter
  27411. */
  27412. friction?: number;
  27413. /**
  27414. * The coefficient of restitution of the physics imposter
  27415. */
  27416. restitution?: number;
  27417. /**
  27418. * The native options of the physics imposter
  27419. */
  27420. nativeOptions?: any;
  27421. /**
  27422. * Specifies if the parent should be ignored
  27423. */
  27424. ignoreParent?: boolean;
  27425. /**
  27426. * Specifies if bi-directional transformations should be disabled
  27427. */
  27428. disableBidirectionalTransformation?: boolean;
  27429. /**
  27430. * The pressure inside the physics imposter, soft object only
  27431. */
  27432. pressure?: number;
  27433. /**
  27434. * The stiffness the physics imposter, soft object only
  27435. */
  27436. stiffness?: number;
  27437. /**
  27438. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  27439. */
  27440. velocityIterations?: number;
  27441. /**
  27442. * The number of iterations used in maintaining consistent vertex positions, soft object only
  27443. */
  27444. positionIterations?: number;
  27445. /**
  27446. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  27447. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  27448. * Add to fix multiple points
  27449. */
  27450. fixedPoints?: number;
  27451. /**
  27452. * The collision margin around a soft object
  27453. */
  27454. margin?: number;
  27455. /**
  27456. * The collision margin around a soft object
  27457. */
  27458. damping?: number;
  27459. /**
  27460. * The path for a rope based on an extrusion
  27461. */
  27462. path?: any;
  27463. /**
  27464. * The shape of an extrusion used for a rope based on an extrusion
  27465. */
  27466. shape?: any;
  27467. }
  27468. /**
  27469. * Interface for a physics-enabled object
  27470. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27471. */
  27472. export interface IPhysicsEnabledObject {
  27473. /**
  27474. * The position of the physics-enabled object
  27475. */
  27476. position: Vector3;
  27477. /**
  27478. * The rotation of the physics-enabled object
  27479. */
  27480. rotationQuaternion: Nullable<Quaternion>;
  27481. /**
  27482. * The scale of the physics-enabled object
  27483. */
  27484. scaling: Vector3;
  27485. /**
  27486. * The rotation of the physics-enabled object
  27487. */
  27488. rotation?: Vector3;
  27489. /**
  27490. * The parent of the physics-enabled object
  27491. */
  27492. parent?: any;
  27493. /**
  27494. * The bounding info of the physics-enabled object
  27495. * @returns The bounding info of the physics-enabled object
  27496. */
  27497. getBoundingInfo(): BoundingInfo;
  27498. /**
  27499. * Computes the world matrix
  27500. * @param force Specifies if the world matrix should be computed by force
  27501. * @returns A world matrix
  27502. */
  27503. computeWorldMatrix(force: boolean): Matrix;
  27504. /**
  27505. * Gets the world matrix
  27506. * @returns A world matrix
  27507. */
  27508. getWorldMatrix?(): Matrix;
  27509. /**
  27510. * Gets the child meshes
  27511. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  27512. * @returns An array of abstract meshes
  27513. */
  27514. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  27515. /**
  27516. * Gets the vertex data
  27517. * @param kind The type of vertex data
  27518. * @returns A nullable array of numbers, or a float32 array
  27519. */
  27520. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  27521. /**
  27522. * Gets the indices from the mesh
  27523. * @returns A nullable array of index arrays
  27524. */
  27525. getIndices?(): Nullable<IndicesArray>;
  27526. /**
  27527. * Gets the scene from the mesh
  27528. * @returns the indices array or null
  27529. */
  27530. getScene?(): Scene;
  27531. /**
  27532. * Gets the absolute position from the mesh
  27533. * @returns the absolute position
  27534. */
  27535. getAbsolutePosition(): Vector3;
  27536. /**
  27537. * Gets the absolute pivot point from the mesh
  27538. * @returns the absolute pivot point
  27539. */
  27540. getAbsolutePivotPoint(): Vector3;
  27541. /**
  27542. * Rotates the mesh
  27543. * @param axis The axis of rotation
  27544. * @param amount The amount of rotation
  27545. * @param space The space of the rotation
  27546. * @returns The rotation transform node
  27547. */
  27548. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  27549. /**
  27550. * Translates the mesh
  27551. * @param axis The axis of translation
  27552. * @param distance The distance of translation
  27553. * @param space The space of the translation
  27554. * @returns The transform node
  27555. */
  27556. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  27557. /**
  27558. * Sets the absolute position of the mesh
  27559. * @param absolutePosition The absolute position of the mesh
  27560. * @returns The transform node
  27561. */
  27562. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  27563. /**
  27564. * Gets the class name of the mesh
  27565. * @returns The class name
  27566. */
  27567. getClassName(): string;
  27568. }
  27569. /**
  27570. * Represents a physics imposter
  27571. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27572. */
  27573. export class PhysicsImpostor {
  27574. /**
  27575. * The physics-enabled object used as the physics imposter
  27576. */
  27577. object: IPhysicsEnabledObject;
  27578. /**
  27579. * The type of the physics imposter
  27580. */
  27581. type: number;
  27582. private _options;
  27583. private _scene?;
  27584. /**
  27585. * The default object size of the imposter
  27586. */
  27587. static DEFAULT_OBJECT_SIZE: Vector3;
  27588. /**
  27589. * The identity quaternion of the imposter
  27590. */
  27591. static IDENTITY_QUATERNION: Quaternion;
  27592. /** @hidden */
  27593. _pluginData: any;
  27594. private _physicsEngine;
  27595. private _physicsBody;
  27596. private _bodyUpdateRequired;
  27597. private _onBeforePhysicsStepCallbacks;
  27598. private _onAfterPhysicsStepCallbacks;
  27599. /** @hidden */
  27600. _onPhysicsCollideCallbacks: Array<{
  27601. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  27602. otherImpostors: Array<PhysicsImpostor>;
  27603. }>;
  27604. private _deltaPosition;
  27605. private _deltaRotation;
  27606. private _deltaRotationConjugated;
  27607. /** @hidden */
  27608. _isFromLine: boolean;
  27609. private _parent;
  27610. private _isDisposed;
  27611. private static _tmpVecs;
  27612. private static _tmpQuat;
  27613. /**
  27614. * Specifies if the physics imposter is disposed
  27615. */
  27616. get isDisposed(): boolean;
  27617. /**
  27618. * Gets the mass of the physics imposter
  27619. */
  27620. get mass(): number;
  27621. set mass(value: number);
  27622. /**
  27623. * Gets the coefficient of friction
  27624. */
  27625. get friction(): number;
  27626. /**
  27627. * Sets the coefficient of friction
  27628. */
  27629. set friction(value: number);
  27630. /**
  27631. * Gets the coefficient of restitution
  27632. */
  27633. get restitution(): number;
  27634. /**
  27635. * Sets the coefficient of restitution
  27636. */
  27637. set restitution(value: number);
  27638. /**
  27639. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  27640. */
  27641. get pressure(): number;
  27642. /**
  27643. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  27644. */
  27645. set pressure(value: number);
  27646. /**
  27647. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  27648. */
  27649. get stiffness(): number;
  27650. /**
  27651. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  27652. */
  27653. set stiffness(value: number);
  27654. /**
  27655. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  27656. */
  27657. get velocityIterations(): number;
  27658. /**
  27659. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  27660. */
  27661. set velocityIterations(value: number);
  27662. /**
  27663. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  27664. */
  27665. get positionIterations(): number;
  27666. /**
  27667. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  27668. */
  27669. set positionIterations(value: number);
  27670. /**
  27671. * The unique id of the physics imposter
  27672. * set by the physics engine when adding this impostor to the array
  27673. */
  27674. uniqueId: number;
  27675. /**
  27676. * @hidden
  27677. */
  27678. soft: boolean;
  27679. /**
  27680. * @hidden
  27681. */
  27682. segments: number;
  27683. private _joints;
  27684. /**
  27685. * Initializes the physics imposter
  27686. * @param object The physics-enabled object used as the physics imposter
  27687. * @param type The type of the physics imposter
  27688. * @param _options The options for the physics imposter
  27689. * @param _scene The Babylon scene
  27690. */
  27691. constructor(
  27692. /**
  27693. * The physics-enabled object used as the physics imposter
  27694. */
  27695. object: IPhysicsEnabledObject,
  27696. /**
  27697. * The type of the physics imposter
  27698. */
  27699. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  27700. /**
  27701. * This function will completly initialize this impostor.
  27702. * It will create a new body - but only if this mesh has no parent.
  27703. * If it has, this impostor will not be used other than to define the impostor
  27704. * of the child mesh.
  27705. * @hidden
  27706. */
  27707. _init(): void;
  27708. private _getPhysicsParent;
  27709. /**
  27710. * Should a new body be generated.
  27711. * @returns boolean specifying if body initialization is required
  27712. */
  27713. isBodyInitRequired(): boolean;
  27714. /**
  27715. * Sets the updated scaling
  27716. * @param updated Specifies if the scaling is updated
  27717. */
  27718. setScalingUpdated(): void;
  27719. /**
  27720. * Force a regeneration of this or the parent's impostor's body.
  27721. * Use under cautious - This will remove all joints already implemented.
  27722. */
  27723. forceUpdate(): void;
  27724. /**
  27725. * Gets the body that holds this impostor. Either its own, or its parent.
  27726. */
  27727. get physicsBody(): any;
  27728. /**
  27729. * Get the parent of the physics imposter
  27730. * @returns Physics imposter or null
  27731. */
  27732. get parent(): Nullable<PhysicsImpostor>;
  27733. /**
  27734. * Sets the parent of the physics imposter
  27735. */
  27736. set parent(value: Nullable<PhysicsImpostor>);
  27737. /**
  27738. * Set the physics body. Used mainly by the physics engine/plugin
  27739. */
  27740. set physicsBody(physicsBody: any);
  27741. /**
  27742. * Resets the update flags
  27743. */
  27744. resetUpdateFlags(): void;
  27745. /**
  27746. * Gets the object extend size
  27747. * @returns the object extend size
  27748. */
  27749. getObjectExtendSize(): Vector3;
  27750. /**
  27751. * Gets the object center
  27752. * @returns The object center
  27753. */
  27754. getObjectCenter(): Vector3;
  27755. /**
  27756. * Get a specific parameter from the options parameters
  27757. * @param paramName The object parameter name
  27758. * @returns The object parameter
  27759. */
  27760. getParam(paramName: string): any;
  27761. /**
  27762. * Sets a specific parameter in the options given to the physics plugin
  27763. * @param paramName The parameter name
  27764. * @param value The value of the parameter
  27765. */
  27766. setParam(paramName: string, value: number): void;
  27767. /**
  27768. * Specifically change the body's mass option. Won't recreate the physics body object
  27769. * @param mass The mass of the physics imposter
  27770. */
  27771. setMass(mass: number): void;
  27772. /**
  27773. * Gets the linear velocity
  27774. * @returns linear velocity or null
  27775. */
  27776. getLinearVelocity(): Nullable<Vector3>;
  27777. /**
  27778. * Sets the linear velocity
  27779. * @param velocity linear velocity or null
  27780. */
  27781. setLinearVelocity(velocity: Nullable<Vector3>): void;
  27782. /**
  27783. * Gets the angular velocity
  27784. * @returns angular velocity or null
  27785. */
  27786. getAngularVelocity(): Nullable<Vector3>;
  27787. /**
  27788. * Sets the angular velocity
  27789. * @param velocity The velocity or null
  27790. */
  27791. setAngularVelocity(velocity: Nullable<Vector3>): void;
  27792. /**
  27793. * Execute a function with the physics plugin native code
  27794. * Provide a function the will have two variables - the world object and the physics body object
  27795. * @param func The function to execute with the physics plugin native code
  27796. */
  27797. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  27798. /**
  27799. * Register a function that will be executed before the physics world is stepping forward
  27800. * @param func The function to execute before the physics world is stepped forward
  27801. */
  27802. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27803. /**
  27804. * Unregister a function that will be executed before the physics world is stepping forward
  27805. * @param func The function to execute before the physics world is stepped forward
  27806. */
  27807. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27808. /**
  27809. * Register a function that will be executed after the physics step
  27810. * @param func The function to execute after physics step
  27811. */
  27812. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27813. /**
  27814. * Unregisters a function that will be executed after the physics step
  27815. * @param func The function to execute after physics step
  27816. */
  27817. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27818. /**
  27819. * register a function that will be executed when this impostor collides against a different body
  27820. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  27821. * @param func Callback that is executed on collision
  27822. */
  27823. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  27824. /**
  27825. * Unregisters the physics imposter on contact
  27826. * @param collideAgainst The physics object to collide against
  27827. * @param func Callback to execute on collision
  27828. */
  27829. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  27830. private _tmpQuat;
  27831. private _tmpQuat2;
  27832. /**
  27833. * Get the parent rotation
  27834. * @returns The parent rotation
  27835. */
  27836. getParentsRotation(): Quaternion;
  27837. /**
  27838. * this function is executed by the physics engine.
  27839. */
  27840. beforeStep: () => void;
  27841. /**
  27842. * this function is executed by the physics engine
  27843. */
  27844. afterStep: () => void;
  27845. /**
  27846. * Legacy collision detection event support
  27847. */
  27848. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  27849. /**
  27850. * event and body object due to cannon's event-based architecture.
  27851. */
  27852. onCollide: (e: {
  27853. body: any;
  27854. }) => void;
  27855. /**
  27856. * Apply a force
  27857. * @param force The force to apply
  27858. * @param contactPoint The contact point for the force
  27859. * @returns The physics imposter
  27860. */
  27861. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  27862. /**
  27863. * Apply an impulse
  27864. * @param force The impulse force
  27865. * @param contactPoint The contact point for the impulse force
  27866. * @returns The physics imposter
  27867. */
  27868. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  27869. /**
  27870. * A help function to create a joint
  27871. * @param otherImpostor A physics imposter used to create a joint
  27872. * @param jointType The type of joint
  27873. * @param jointData The data for the joint
  27874. * @returns The physics imposter
  27875. */
  27876. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  27877. /**
  27878. * Add a joint to this impostor with a different impostor
  27879. * @param otherImpostor A physics imposter used to add a joint
  27880. * @param joint The joint to add
  27881. * @returns The physics imposter
  27882. */
  27883. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  27884. /**
  27885. * Add an anchor to a cloth impostor
  27886. * @param otherImpostor rigid impostor to anchor to
  27887. * @param width ratio across width from 0 to 1
  27888. * @param height ratio up height from 0 to 1
  27889. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  27890. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  27891. * @returns impostor the soft imposter
  27892. */
  27893. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  27894. /**
  27895. * Add a hook to a rope impostor
  27896. * @param otherImpostor rigid impostor to anchor to
  27897. * @param length ratio across rope from 0 to 1
  27898. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  27899. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  27900. * @returns impostor the rope imposter
  27901. */
  27902. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  27903. /**
  27904. * Will keep this body still, in a sleep mode.
  27905. * @returns the physics imposter
  27906. */
  27907. sleep(): PhysicsImpostor;
  27908. /**
  27909. * Wake the body up.
  27910. * @returns The physics imposter
  27911. */
  27912. wakeUp(): PhysicsImpostor;
  27913. /**
  27914. * Clones the physics imposter
  27915. * @param newObject The physics imposter clones to this physics-enabled object
  27916. * @returns A nullable physics imposter
  27917. */
  27918. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  27919. /**
  27920. * Disposes the physics imposter
  27921. */
  27922. dispose(): void;
  27923. /**
  27924. * Sets the delta position
  27925. * @param position The delta position amount
  27926. */
  27927. setDeltaPosition(position: Vector3): void;
  27928. /**
  27929. * Sets the delta rotation
  27930. * @param rotation The delta rotation amount
  27931. */
  27932. setDeltaRotation(rotation: Quaternion): void;
  27933. /**
  27934. * Gets the box size of the physics imposter and stores the result in the input parameter
  27935. * @param result Stores the box size
  27936. * @returns The physics imposter
  27937. */
  27938. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  27939. /**
  27940. * Gets the radius of the physics imposter
  27941. * @returns Radius of the physics imposter
  27942. */
  27943. getRadius(): number;
  27944. /**
  27945. * Sync a bone with this impostor
  27946. * @param bone The bone to sync to the impostor.
  27947. * @param boneMesh The mesh that the bone is influencing.
  27948. * @param jointPivot The pivot of the joint / bone in local space.
  27949. * @param distToJoint Optional distance from the impostor to the joint.
  27950. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  27951. */
  27952. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  27953. /**
  27954. * Sync impostor to a bone
  27955. * @param bone The bone that the impostor will be synced to.
  27956. * @param boneMesh The mesh that the bone is influencing.
  27957. * @param jointPivot The pivot of the joint / bone in local space.
  27958. * @param distToJoint Optional distance from the impostor to the joint.
  27959. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  27960. * @param boneAxis Optional vector3 axis the bone is aligned with
  27961. */
  27962. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  27963. /**
  27964. * No-Imposter type
  27965. */
  27966. static NoImpostor: number;
  27967. /**
  27968. * Sphere-Imposter type
  27969. */
  27970. static SphereImpostor: number;
  27971. /**
  27972. * Box-Imposter type
  27973. */
  27974. static BoxImpostor: number;
  27975. /**
  27976. * Plane-Imposter type
  27977. */
  27978. static PlaneImpostor: number;
  27979. /**
  27980. * Mesh-imposter type
  27981. */
  27982. static MeshImpostor: number;
  27983. /**
  27984. * Capsule-Impostor type (Ammo.js plugin only)
  27985. */
  27986. static CapsuleImpostor: number;
  27987. /**
  27988. * Cylinder-Imposter type
  27989. */
  27990. static CylinderImpostor: number;
  27991. /**
  27992. * Particle-Imposter type
  27993. */
  27994. static ParticleImpostor: number;
  27995. /**
  27996. * Heightmap-Imposter type
  27997. */
  27998. static HeightmapImpostor: number;
  27999. /**
  28000. * ConvexHull-Impostor type (Ammo.js plugin only)
  28001. */
  28002. static ConvexHullImpostor: number;
  28003. /**
  28004. * Custom-Imposter type (Ammo.js plugin only)
  28005. */
  28006. static CustomImpostor: number;
  28007. /**
  28008. * Rope-Imposter type
  28009. */
  28010. static RopeImpostor: number;
  28011. /**
  28012. * Cloth-Imposter type
  28013. */
  28014. static ClothImpostor: number;
  28015. /**
  28016. * Softbody-Imposter type
  28017. */
  28018. static SoftbodyImpostor: number;
  28019. }
  28020. }
  28021. declare module "babylonjs/Meshes/mesh" {
  28022. import { Observable } from "babylonjs/Misc/observable";
  28023. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28024. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  28025. import { Camera } from "babylonjs/Cameras/camera";
  28026. import { Scene } from "babylonjs/scene";
  28027. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  28028. import { Color4 } from "babylonjs/Maths/math.color";
  28029. import { Engine } from "babylonjs/Engines/engine";
  28030. import { Node } from "babylonjs/node";
  28031. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  28032. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  28033. import { Buffer } from "babylonjs/Meshes/buffer";
  28034. import { Geometry } from "babylonjs/Meshes/geometry";
  28035. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28036. import { SubMesh } from "babylonjs/Meshes/subMesh";
  28037. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  28038. import { Effect } from "babylonjs/Materials/effect";
  28039. import { Material } from "babylonjs/Materials/material";
  28040. import { Skeleton } from "babylonjs/Bones/skeleton";
  28041. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  28042. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  28043. import { Path3D } from "babylonjs/Maths/math.path";
  28044. import { Plane } from "babylonjs/Maths/math.plane";
  28045. import { TransformNode } from "babylonjs/Meshes/transformNode";
  28046. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  28047. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  28048. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  28049. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  28050. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  28051. /**
  28052. * @hidden
  28053. **/
  28054. export class _CreationDataStorage {
  28055. closePath?: boolean;
  28056. closeArray?: boolean;
  28057. idx: number[];
  28058. dashSize: number;
  28059. gapSize: number;
  28060. path3D: Path3D;
  28061. pathArray: Vector3[][];
  28062. arc: number;
  28063. radius: number;
  28064. cap: number;
  28065. tessellation: number;
  28066. }
  28067. /**
  28068. * @hidden
  28069. **/
  28070. class _InstanceDataStorage {
  28071. visibleInstances: any;
  28072. batchCache: _InstancesBatch;
  28073. instancesBufferSize: number;
  28074. instancesBuffer: Nullable<Buffer>;
  28075. instancesData: Float32Array;
  28076. overridenInstanceCount: number;
  28077. isFrozen: boolean;
  28078. previousBatch: Nullable<_InstancesBatch>;
  28079. hardwareInstancedRendering: boolean;
  28080. sideOrientation: number;
  28081. manualUpdate: boolean;
  28082. }
  28083. /**
  28084. * @hidden
  28085. **/
  28086. export class _InstancesBatch {
  28087. mustReturn: boolean;
  28088. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  28089. renderSelf: boolean[];
  28090. hardwareInstancedRendering: boolean[];
  28091. }
  28092. /**
  28093. * Class used to represent renderable models
  28094. */
  28095. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  28096. /**
  28097. * Mesh side orientation : usually the external or front surface
  28098. */
  28099. static readonly FRONTSIDE: number;
  28100. /**
  28101. * Mesh side orientation : usually the internal or back surface
  28102. */
  28103. static readonly BACKSIDE: number;
  28104. /**
  28105. * Mesh side orientation : both internal and external or front and back surfaces
  28106. */
  28107. static readonly DOUBLESIDE: number;
  28108. /**
  28109. * Mesh side orientation : by default, `FRONTSIDE`
  28110. */
  28111. static readonly DEFAULTSIDE: number;
  28112. /**
  28113. * Mesh cap setting : no cap
  28114. */
  28115. static readonly NO_CAP: number;
  28116. /**
  28117. * Mesh cap setting : one cap at the beginning of the mesh
  28118. */
  28119. static readonly CAP_START: number;
  28120. /**
  28121. * Mesh cap setting : one cap at the end of the mesh
  28122. */
  28123. static readonly CAP_END: number;
  28124. /**
  28125. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  28126. */
  28127. static readonly CAP_ALL: number;
  28128. /**
  28129. * Mesh pattern setting : no flip or rotate
  28130. */
  28131. static readonly NO_FLIP: number;
  28132. /**
  28133. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  28134. */
  28135. static readonly FLIP_TILE: number;
  28136. /**
  28137. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  28138. */
  28139. static readonly ROTATE_TILE: number;
  28140. /**
  28141. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  28142. */
  28143. static readonly FLIP_ROW: number;
  28144. /**
  28145. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  28146. */
  28147. static readonly ROTATE_ROW: number;
  28148. /**
  28149. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  28150. */
  28151. static readonly FLIP_N_ROTATE_TILE: number;
  28152. /**
  28153. * Mesh pattern setting : rotate pattern and rotate
  28154. */
  28155. static readonly FLIP_N_ROTATE_ROW: number;
  28156. /**
  28157. * Mesh tile positioning : part tiles same on left/right or top/bottom
  28158. */
  28159. static readonly CENTER: number;
  28160. /**
  28161. * Mesh tile positioning : part tiles on left
  28162. */
  28163. static readonly LEFT: number;
  28164. /**
  28165. * Mesh tile positioning : part tiles on right
  28166. */
  28167. static readonly RIGHT: number;
  28168. /**
  28169. * Mesh tile positioning : part tiles on top
  28170. */
  28171. static readonly TOP: number;
  28172. /**
  28173. * Mesh tile positioning : part tiles on bottom
  28174. */
  28175. static readonly BOTTOM: number;
  28176. /**
  28177. * Gets the default side orientation.
  28178. * @param orientation the orientation to value to attempt to get
  28179. * @returns the default orientation
  28180. * @hidden
  28181. */
  28182. static _GetDefaultSideOrientation(orientation?: number): number;
  28183. private _internalMeshDataInfo;
  28184. /**
  28185. * An event triggered before rendering the mesh
  28186. */
  28187. get onBeforeRenderObservable(): Observable<Mesh>;
  28188. /**
  28189. * An event triggered before binding the mesh
  28190. */
  28191. get onBeforeBindObservable(): Observable<Mesh>;
  28192. /**
  28193. * An event triggered after rendering the mesh
  28194. */
  28195. get onAfterRenderObservable(): Observable<Mesh>;
  28196. /**
  28197. * An event triggered before drawing the mesh
  28198. */
  28199. get onBeforeDrawObservable(): Observable<Mesh>;
  28200. private _onBeforeDrawObserver;
  28201. /**
  28202. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  28203. */
  28204. set onBeforeDraw(callback: () => void);
  28205. get hasInstances(): boolean;
  28206. /**
  28207. * Gets the delay loading state of the mesh (when delay loading is turned on)
  28208. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  28209. */
  28210. delayLoadState: number;
  28211. /**
  28212. * Gets the list of instances created from this mesh
  28213. * it is not supposed to be modified manually.
  28214. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  28215. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  28216. */
  28217. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  28218. /**
  28219. * Gets the file containing delay loading data for this mesh
  28220. */
  28221. delayLoadingFile: string;
  28222. /** @hidden */
  28223. _binaryInfo: any;
  28224. /**
  28225. * User defined function used to change how LOD level selection is done
  28226. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  28227. */
  28228. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  28229. /**
  28230. * Gets or sets the morph target manager
  28231. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  28232. */
  28233. get morphTargetManager(): Nullable<MorphTargetManager>;
  28234. set morphTargetManager(value: Nullable<MorphTargetManager>);
  28235. /** @hidden */
  28236. _creationDataStorage: Nullable<_CreationDataStorage>;
  28237. /** @hidden */
  28238. _geometry: Nullable<Geometry>;
  28239. /** @hidden */
  28240. _delayInfo: Array<string>;
  28241. /** @hidden */
  28242. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  28243. /** @hidden */
  28244. _instanceDataStorage: _InstanceDataStorage;
  28245. private _effectiveMaterial;
  28246. /** @hidden */
  28247. _shouldGenerateFlatShading: boolean;
  28248. /** @hidden */
  28249. _originalBuilderSideOrientation: number;
  28250. /**
  28251. * Use this property to change the original side orientation defined at construction time
  28252. */
  28253. overrideMaterialSideOrientation: Nullable<number>;
  28254. /**
  28255. * Gets the source mesh (the one used to clone this one from)
  28256. */
  28257. get source(): Nullable<Mesh>;
  28258. /**
  28259. * Gets or sets a boolean indicating that this mesh does not use index buffer
  28260. */
  28261. get isUnIndexed(): boolean;
  28262. set isUnIndexed(value: boolean);
  28263. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  28264. get worldMatrixInstancedBuffer(): Float32Array;
  28265. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  28266. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  28267. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  28268. /**
  28269. * @constructor
  28270. * @param name The value used by scene.getMeshByName() to do a lookup.
  28271. * @param scene The scene to add this mesh to.
  28272. * @param parent The parent of this mesh, if it has one
  28273. * @param source An optional Mesh from which geometry is shared, cloned.
  28274. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  28275. * When false, achieved by calling a clone(), also passing False.
  28276. * This will make creation of children, recursive.
  28277. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  28278. */
  28279. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  28280. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  28281. doNotInstantiate: boolean;
  28282. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  28283. /**
  28284. * Gets the class name
  28285. * @returns the string "Mesh".
  28286. */
  28287. getClassName(): string;
  28288. /** @hidden */
  28289. get _isMesh(): boolean;
  28290. /**
  28291. * Returns a description of this mesh
  28292. * @param fullDetails define if full details about this mesh must be used
  28293. * @returns a descriptive string representing this mesh
  28294. */
  28295. toString(fullDetails?: boolean): string;
  28296. /** @hidden */
  28297. _unBindEffect(): void;
  28298. /**
  28299. * Gets a boolean indicating if this mesh has LOD
  28300. */
  28301. get hasLODLevels(): boolean;
  28302. /**
  28303. * Gets the list of MeshLODLevel associated with the current mesh
  28304. * @returns an array of MeshLODLevel
  28305. */
  28306. getLODLevels(): MeshLODLevel[];
  28307. private _sortLODLevels;
  28308. /**
  28309. * Add a mesh as LOD level triggered at the given distance.
  28310. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28311. * @param distance The distance from the center of the object to show this level
  28312. * @param mesh The mesh to be added as LOD level (can be null)
  28313. * @return This mesh (for chaining)
  28314. */
  28315. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  28316. /**
  28317. * Returns the LOD level mesh at the passed distance or null if not found.
  28318. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28319. * @param distance The distance from the center of the object to show this level
  28320. * @returns a Mesh or `null`
  28321. */
  28322. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  28323. /**
  28324. * Remove a mesh from the LOD array
  28325. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28326. * @param mesh defines the mesh to be removed
  28327. * @return This mesh (for chaining)
  28328. */
  28329. removeLODLevel(mesh: Mesh): Mesh;
  28330. /**
  28331. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  28332. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28333. * @param camera defines the camera to use to compute distance
  28334. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  28335. * @return This mesh (for chaining)
  28336. */
  28337. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  28338. /**
  28339. * Gets the mesh internal Geometry object
  28340. */
  28341. get geometry(): Nullable<Geometry>;
  28342. /**
  28343. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  28344. * @returns the total number of vertices
  28345. */
  28346. getTotalVertices(): number;
  28347. /**
  28348. * Returns the content of an associated vertex buffer
  28349. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  28350. * - VertexBuffer.PositionKind
  28351. * - VertexBuffer.UVKind
  28352. * - VertexBuffer.UV2Kind
  28353. * - VertexBuffer.UV3Kind
  28354. * - VertexBuffer.UV4Kind
  28355. * - VertexBuffer.UV5Kind
  28356. * - VertexBuffer.UV6Kind
  28357. * - VertexBuffer.ColorKind
  28358. * - VertexBuffer.MatricesIndicesKind
  28359. * - VertexBuffer.MatricesIndicesExtraKind
  28360. * - VertexBuffer.MatricesWeightsKind
  28361. * - VertexBuffer.MatricesWeightsExtraKind
  28362. * @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
  28363. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  28364. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  28365. */
  28366. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  28367. /**
  28368. * Returns the mesh VertexBuffer object from the requested `kind`
  28369. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  28370. * - VertexBuffer.PositionKind
  28371. * - VertexBuffer.NormalKind
  28372. * - VertexBuffer.UVKind
  28373. * - VertexBuffer.UV2Kind
  28374. * - VertexBuffer.UV3Kind
  28375. * - VertexBuffer.UV4Kind
  28376. * - VertexBuffer.UV5Kind
  28377. * - VertexBuffer.UV6Kind
  28378. * - VertexBuffer.ColorKind
  28379. * - VertexBuffer.MatricesIndicesKind
  28380. * - VertexBuffer.MatricesIndicesExtraKind
  28381. * - VertexBuffer.MatricesWeightsKind
  28382. * - VertexBuffer.MatricesWeightsExtraKind
  28383. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  28384. */
  28385. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  28386. /**
  28387. * Tests if a specific vertex buffer is associated with this mesh
  28388. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  28389. * - VertexBuffer.PositionKind
  28390. * - VertexBuffer.NormalKind
  28391. * - VertexBuffer.UVKind
  28392. * - VertexBuffer.UV2Kind
  28393. * - VertexBuffer.UV3Kind
  28394. * - VertexBuffer.UV4Kind
  28395. * - VertexBuffer.UV5Kind
  28396. * - VertexBuffer.UV6Kind
  28397. * - VertexBuffer.ColorKind
  28398. * - VertexBuffer.MatricesIndicesKind
  28399. * - VertexBuffer.MatricesIndicesExtraKind
  28400. * - VertexBuffer.MatricesWeightsKind
  28401. * - VertexBuffer.MatricesWeightsExtraKind
  28402. * @returns a boolean
  28403. */
  28404. isVerticesDataPresent(kind: string): boolean;
  28405. /**
  28406. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  28407. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  28408. * - VertexBuffer.PositionKind
  28409. * - VertexBuffer.UVKind
  28410. * - VertexBuffer.UV2Kind
  28411. * - VertexBuffer.UV3Kind
  28412. * - VertexBuffer.UV4Kind
  28413. * - VertexBuffer.UV5Kind
  28414. * - VertexBuffer.UV6Kind
  28415. * - VertexBuffer.ColorKind
  28416. * - VertexBuffer.MatricesIndicesKind
  28417. * - VertexBuffer.MatricesIndicesExtraKind
  28418. * - VertexBuffer.MatricesWeightsKind
  28419. * - VertexBuffer.MatricesWeightsExtraKind
  28420. * @returns a boolean
  28421. */
  28422. isVertexBufferUpdatable(kind: string): boolean;
  28423. /**
  28424. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  28425. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  28426. * - VertexBuffer.PositionKind
  28427. * - VertexBuffer.NormalKind
  28428. * - VertexBuffer.UVKind
  28429. * - VertexBuffer.UV2Kind
  28430. * - VertexBuffer.UV3Kind
  28431. * - VertexBuffer.UV4Kind
  28432. * - VertexBuffer.UV5Kind
  28433. * - VertexBuffer.UV6Kind
  28434. * - VertexBuffer.ColorKind
  28435. * - VertexBuffer.MatricesIndicesKind
  28436. * - VertexBuffer.MatricesIndicesExtraKind
  28437. * - VertexBuffer.MatricesWeightsKind
  28438. * - VertexBuffer.MatricesWeightsExtraKind
  28439. * @returns an array of strings
  28440. */
  28441. getVerticesDataKinds(): string[];
  28442. /**
  28443. * Returns a positive integer : the total number of indices in this mesh geometry.
  28444. * @returns the numner of indices or zero if the mesh has no geometry.
  28445. */
  28446. getTotalIndices(): number;
  28447. /**
  28448. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  28449. * @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.
  28450. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  28451. * @returns the indices array or an empty array if the mesh has no geometry
  28452. */
  28453. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  28454. get isBlocked(): boolean;
  28455. /**
  28456. * Determine if the current mesh is ready to be rendered
  28457. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  28458. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  28459. * @returns true if all associated assets are ready (material, textures, shaders)
  28460. */
  28461. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  28462. /**
  28463. * 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.
  28464. */
  28465. get areNormalsFrozen(): boolean;
  28466. /**
  28467. * 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.
  28468. * @returns the current mesh
  28469. */
  28470. freezeNormals(): Mesh;
  28471. /**
  28472. * 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
  28473. * @returns the current mesh
  28474. */
  28475. unfreezeNormals(): Mesh;
  28476. /**
  28477. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  28478. */
  28479. set overridenInstanceCount(count: number);
  28480. /** @hidden */
  28481. _preActivate(): Mesh;
  28482. /** @hidden */
  28483. _preActivateForIntermediateRendering(renderId: number): Mesh;
  28484. /** @hidden */
  28485. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  28486. /**
  28487. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  28488. * This means the mesh underlying bounding box and sphere are recomputed.
  28489. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  28490. * @returns the current mesh
  28491. */
  28492. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  28493. /** @hidden */
  28494. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  28495. /**
  28496. * This function will subdivide the mesh into multiple submeshes
  28497. * @param count defines the expected number of submeshes
  28498. */
  28499. subdivide(count: number): void;
  28500. /**
  28501. * Copy a FloatArray into a specific associated vertex buffer
  28502. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  28503. * - VertexBuffer.PositionKind
  28504. * - VertexBuffer.UVKind
  28505. * - VertexBuffer.UV2Kind
  28506. * - VertexBuffer.UV3Kind
  28507. * - VertexBuffer.UV4Kind
  28508. * - VertexBuffer.UV5Kind
  28509. * - VertexBuffer.UV6Kind
  28510. * - VertexBuffer.ColorKind
  28511. * - VertexBuffer.MatricesIndicesKind
  28512. * - VertexBuffer.MatricesIndicesExtraKind
  28513. * - VertexBuffer.MatricesWeightsKind
  28514. * - VertexBuffer.MatricesWeightsExtraKind
  28515. * @param data defines the data source
  28516. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  28517. * @param stride defines the data stride size (can be null)
  28518. * @returns the current mesh
  28519. */
  28520. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  28521. /**
  28522. * Delete a vertex buffer associated with this mesh
  28523. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  28524. * - VertexBuffer.PositionKind
  28525. * - VertexBuffer.UVKind
  28526. * - VertexBuffer.UV2Kind
  28527. * - VertexBuffer.UV3Kind
  28528. * - VertexBuffer.UV4Kind
  28529. * - VertexBuffer.UV5Kind
  28530. * - VertexBuffer.UV6Kind
  28531. * - VertexBuffer.ColorKind
  28532. * - VertexBuffer.MatricesIndicesKind
  28533. * - VertexBuffer.MatricesIndicesExtraKind
  28534. * - VertexBuffer.MatricesWeightsKind
  28535. * - VertexBuffer.MatricesWeightsExtraKind
  28536. */
  28537. removeVerticesData(kind: string): void;
  28538. /**
  28539. * Flags an associated vertex buffer as updatable
  28540. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  28541. * - VertexBuffer.PositionKind
  28542. * - VertexBuffer.UVKind
  28543. * - VertexBuffer.UV2Kind
  28544. * - VertexBuffer.UV3Kind
  28545. * - VertexBuffer.UV4Kind
  28546. * - VertexBuffer.UV5Kind
  28547. * - VertexBuffer.UV6Kind
  28548. * - VertexBuffer.ColorKind
  28549. * - VertexBuffer.MatricesIndicesKind
  28550. * - VertexBuffer.MatricesIndicesExtraKind
  28551. * - VertexBuffer.MatricesWeightsKind
  28552. * - VertexBuffer.MatricesWeightsExtraKind
  28553. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  28554. */
  28555. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  28556. /**
  28557. * Sets the mesh global Vertex Buffer
  28558. * @param buffer defines the buffer to use
  28559. * @returns the current mesh
  28560. */
  28561. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  28562. /**
  28563. * Update a specific associated vertex buffer
  28564. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  28565. * - VertexBuffer.PositionKind
  28566. * - VertexBuffer.UVKind
  28567. * - VertexBuffer.UV2Kind
  28568. * - VertexBuffer.UV3Kind
  28569. * - VertexBuffer.UV4Kind
  28570. * - VertexBuffer.UV5Kind
  28571. * - VertexBuffer.UV6Kind
  28572. * - VertexBuffer.ColorKind
  28573. * - VertexBuffer.MatricesIndicesKind
  28574. * - VertexBuffer.MatricesIndicesExtraKind
  28575. * - VertexBuffer.MatricesWeightsKind
  28576. * - VertexBuffer.MatricesWeightsExtraKind
  28577. * @param data defines the data source
  28578. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  28579. * @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)
  28580. * @returns the current mesh
  28581. */
  28582. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  28583. /**
  28584. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  28585. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  28586. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  28587. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  28588. * @returns the current mesh
  28589. */
  28590. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  28591. /**
  28592. * Creates a un-shared specific occurence of the geometry for the mesh.
  28593. * @returns the current mesh
  28594. */
  28595. makeGeometryUnique(): Mesh;
  28596. /**
  28597. * Set the index buffer of this mesh
  28598. * @param indices defines the source data
  28599. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  28600. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  28601. * @returns the current mesh
  28602. */
  28603. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  28604. /**
  28605. * Update the current index buffer
  28606. * @param indices defines the source data
  28607. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  28608. * @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)
  28609. * @returns the current mesh
  28610. */
  28611. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  28612. /**
  28613. * Invert the geometry to move from a right handed system to a left handed one.
  28614. * @returns the current mesh
  28615. */
  28616. toLeftHanded(): Mesh;
  28617. /** @hidden */
  28618. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  28619. /** @hidden */
  28620. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  28621. /**
  28622. * Registers for this mesh a javascript function called just before the rendering process
  28623. * @param func defines the function to call before rendering this mesh
  28624. * @returns the current mesh
  28625. */
  28626. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  28627. /**
  28628. * Disposes a previously registered javascript function called before the rendering
  28629. * @param func defines the function to remove
  28630. * @returns the current mesh
  28631. */
  28632. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  28633. /**
  28634. * Registers for this mesh a javascript function called just after the rendering is complete
  28635. * @param func defines the function to call after rendering this mesh
  28636. * @returns the current mesh
  28637. */
  28638. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  28639. /**
  28640. * Disposes a previously registered javascript function called after the rendering.
  28641. * @param func defines the function to remove
  28642. * @returns the current mesh
  28643. */
  28644. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  28645. /** @hidden */
  28646. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  28647. /** @hidden */
  28648. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  28649. /** @hidden */
  28650. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  28651. /** @hidden */
  28652. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  28653. /** @hidden */
  28654. _rebuild(): void;
  28655. /** @hidden */
  28656. _freeze(): void;
  28657. /** @hidden */
  28658. _unFreeze(): void;
  28659. /**
  28660. * 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
  28661. * @param subMesh defines the subMesh to render
  28662. * @param enableAlphaMode defines if alpha mode can be changed
  28663. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  28664. * @returns the current mesh
  28665. */
  28666. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  28667. private _onBeforeDraw;
  28668. /**
  28669. * Renormalize the mesh and patch it up if there are no weights
  28670. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  28671. * However in the case of zero weights then we set just a single influence to 1.
  28672. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  28673. */
  28674. cleanMatrixWeights(): void;
  28675. private normalizeSkinFourWeights;
  28676. private normalizeSkinWeightsAndExtra;
  28677. /**
  28678. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  28679. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  28680. * the user know there was an issue with importing the mesh
  28681. * @returns a validation object with skinned, valid and report string
  28682. */
  28683. validateSkinning(): {
  28684. skinned: boolean;
  28685. valid: boolean;
  28686. report: string;
  28687. };
  28688. /** @hidden */
  28689. _checkDelayState(): Mesh;
  28690. private _queueLoad;
  28691. /**
  28692. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  28693. * A mesh is in the frustum if its bounding box intersects the frustum
  28694. * @param frustumPlanes defines the frustum to test
  28695. * @returns true if the mesh is in the frustum planes
  28696. */
  28697. isInFrustum(frustumPlanes: Plane[]): boolean;
  28698. /**
  28699. * Sets the mesh material by the material or multiMaterial `id` property
  28700. * @param id is a string identifying the material or the multiMaterial
  28701. * @returns the current mesh
  28702. */
  28703. setMaterialByID(id: string): Mesh;
  28704. /**
  28705. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  28706. * @returns an array of IAnimatable
  28707. */
  28708. getAnimatables(): IAnimatable[];
  28709. /**
  28710. * Modifies the mesh geometry according to the passed transformation matrix.
  28711. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  28712. * The mesh normals are modified using the same transformation.
  28713. * Note that, under the hood, this method sets a new VertexBuffer each call.
  28714. * @param transform defines the transform matrix to use
  28715. * @see http://doc.babylonjs.com/resources/baking_transformations
  28716. * @returns the current mesh
  28717. */
  28718. bakeTransformIntoVertices(transform: Matrix): Mesh;
  28719. /**
  28720. * Modifies the mesh geometry according to its own current World Matrix.
  28721. * The mesh World Matrix is then reset.
  28722. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  28723. * Note that, under the hood, this method sets a new VertexBuffer each call.
  28724. * @see http://doc.babylonjs.com/resources/baking_transformations
  28725. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  28726. * @returns the current mesh
  28727. */
  28728. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  28729. /** @hidden */
  28730. get _positions(): Nullable<Vector3[]>;
  28731. /** @hidden */
  28732. _resetPointsArrayCache(): Mesh;
  28733. /** @hidden */
  28734. _generatePointsArray(): boolean;
  28735. /**
  28736. * Returns a new Mesh object generated from the current mesh properties.
  28737. * This method must not get confused with createInstance()
  28738. * @param name is a string, the name given to the new mesh
  28739. * @param newParent can be any Node object (default `null`)
  28740. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  28741. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  28742. * @returns a new mesh
  28743. */
  28744. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  28745. /**
  28746. * Releases resources associated with this mesh.
  28747. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28748. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28749. */
  28750. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28751. /** @hidden */
  28752. _disposeInstanceSpecificData(): void;
  28753. /**
  28754. * Modifies the mesh geometry according to a displacement map.
  28755. * 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.
  28756. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  28757. * @param url is a string, the URL from the image file is to be downloaded.
  28758. * @param minHeight is the lower limit of the displacement.
  28759. * @param maxHeight is the upper limit of the displacement.
  28760. * @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.
  28761. * @param uvOffset is an optional vector2 used to offset UV.
  28762. * @param uvScale is an optional vector2 used to scale UV.
  28763. * @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.
  28764. * @returns the Mesh.
  28765. */
  28766. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  28767. /**
  28768. * Modifies the mesh geometry according to a displacementMap buffer.
  28769. * 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.
  28770. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  28771. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  28772. * @param heightMapWidth is the width of the buffer image.
  28773. * @param heightMapHeight is the height of the buffer image.
  28774. * @param minHeight is the lower limit of the displacement.
  28775. * @param maxHeight is the upper limit of the displacement.
  28776. * @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.
  28777. * @param uvOffset is an optional vector2 used to offset UV.
  28778. * @param uvScale is an optional vector2 used to scale UV.
  28779. * @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.
  28780. * @returns the Mesh.
  28781. */
  28782. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  28783. /**
  28784. * Modify the mesh to get a flat shading rendering.
  28785. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  28786. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  28787. * @returns current mesh
  28788. */
  28789. convertToFlatShadedMesh(): Mesh;
  28790. /**
  28791. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  28792. * In other words, more vertices, no more indices and a single bigger VBO.
  28793. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  28794. * @returns current mesh
  28795. */
  28796. convertToUnIndexedMesh(): Mesh;
  28797. /**
  28798. * Inverses facet orientations.
  28799. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  28800. * @param flipNormals will also inverts the normals
  28801. * @returns current mesh
  28802. */
  28803. flipFaces(flipNormals?: boolean): Mesh;
  28804. /**
  28805. * Increase the number of facets and hence vertices in a mesh
  28806. * Vertex normals are interpolated from existing vertex normals
  28807. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  28808. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  28809. */
  28810. increaseVertices(numberPerEdge: number): void;
  28811. /**
  28812. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  28813. * This will undo any application of covertToFlatShadedMesh
  28814. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  28815. */
  28816. forceSharedVertices(): void;
  28817. /** @hidden */
  28818. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  28819. /** @hidden */
  28820. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  28821. /**
  28822. * Creates a new InstancedMesh object from the mesh model.
  28823. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  28824. * @param name defines the name of the new instance
  28825. * @returns a new InstancedMesh
  28826. */
  28827. createInstance(name: string): InstancedMesh;
  28828. /**
  28829. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  28830. * After this call, all the mesh instances have the same submeshes than the current mesh.
  28831. * @returns the current mesh
  28832. */
  28833. synchronizeInstances(): Mesh;
  28834. /**
  28835. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  28836. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  28837. * This should be used together with the simplification to avoid disappearing triangles.
  28838. * @param successCallback an optional success callback to be called after the optimization finished.
  28839. * @returns the current mesh
  28840. */
  28841. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  28842. /**
  28843. * Serialize current mesh
  28844. * @param serializationObject defines the object which will receive the serialization data
  28845. */
  28846. serialize(serializationObject: any): void;
  28847. /** @hidden */
  28848. _syncGeometryWithMorphTargetManager(): void;
  28849. /** @hidden */
  28850. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  28851. /**
  28852. * Returns a new Mesh object parsed from the source provided.
  28853. * @param parsedMesh is the source
  28854. * @param scene defines the hosting scene
  28855. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  28856. * @returns a new Mesh
  28857. */
  28858. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  28859. /**
  28860. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  28861. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  28862. * @param name defines the name of the mesh to create
  28863. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  28864. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  28865. * @param closePath creates a seam between the first and the last points of each path of the path array
  28866. * @param offset is taken in account only if the `pathArray` is containing a single path
  28867. * @param scene defines the hosting scene
  28868. * @param updatable defines if the mesh must be flagged as updatable
  28869. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28870. * @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)
  28871. * @returns a new Mesh
  28872. */
  28873. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  28874. /**
  28875. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  28876. * @param name defines the name of the mesh to create
  28877. * @param radius sets the radius size (float) of the polygon (default 0.5)
  28878. * @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
  28879. * @param scene defines the hosting scene
  28880. * @param updatable defines if the mesh must be flagged as updatable
  28881. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28882. * @returns a new Mesh
  28883. */
  28884. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  28885. /**
  28886. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  28887. * @param name defines the name of the mesh to create
  28888. * @param size sets the size (float) of each box side (default 1)
  28889. * @param scene defines the hosting scene
  28890. * @param updatable defines if the mesh must be flagged as updatable
  28891. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28892. * @returns a new Mesh
  28893. */
  28894. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  28895. /**
  28896. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  28897. * @param name defines the name of the mesh to create
  28898. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  28899. * @param diameter sets the diameter size (float) of the sphere (default 1)
  28900. * @param scene defines the hosting scene
  28901. * @param updatable defines if the mesh must be flagged as updatable
  28902. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28903. * @returns a new Mesh
  28904. */
  28905. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28906. /**
  28907. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  28908. * @param name defines the name of the mesh to create
  28909. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  28910. * @param diameter sets the diameter size (float) of the sphere (default 1)
  28911. * @param scene defines the hosting scene
  28912. * @returns a new Mesh
  28913. */
  28914. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  28915. /**
  28916. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  28917. * @param name defines the name of the mesh to create
  28918. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  28919. * @param diameterTop set the top cap diameter (floats, default 1)
  28920. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  28921. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  28922. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  28923. * @param scene defines the hosting scene
  28924. * @param updatable defines if the mesh must be flagged as updatable
  28925. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28926. * @returns a new Mesh
  28927. */
  28928. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  28929. /**
  28930. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  28931. * @param name defines the name of the mesh to create
  28932. * @param diameter sets the diameter size (float) of the torus (default 1)
  28933. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  28934. * @param tessellation sets the number of torus sides (postive integer, default 16)
  28935. * @param scene defines the hosting scene
  28936. * @param updatable defines if the mesh must be flagged as updatable
  28937. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28938. * @returns a new Mesh
  28939. */
  28940. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28941. /**
  28942. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  28943. * @param name defines the name of the mesh to create
  28944. * @param radius sets the global radius size (float) of the torus knot (default 2)
  28945. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  28946. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  28947. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  28948. * @param p the number of windings on X axis (positive integers, default 2)
  28949. * @param q the number of windings on Y axis (positive integers, default 3)
  28950. * @param scene defines the hosting scene
  28951. * @param updatable defines if the mesh must be flagged as updatable
  28952. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28953. * @returns a new Mesh
  28954. */
  28955. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28956. /**
  28957. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  28958. * @param name defines the name of the mesh to create
  28959. * @param points is an array successive Vector3
  28960. * @param scene defines the hosting scene
  28961. * @param updatable defines if the mesh must be flagged as updatable
  28962. * @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).
  28963. * @returns a new Mesh
  28964. */
  28965. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  28966. /**
  28967. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  28968. * @param name defines the name of the mesh to create
  28969. * @param points is an array successive Vector3
  28970. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  28971. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  28972. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  28973. * @param scene defines the hosting scene
  28974. * @param updatable defines if the mesh must be flagged as updatable
  28975. * @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)
  28976. * @returns a new Mesh
  28977. */
  28978. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  28979. /**
  28980. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  28981. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  28982. * 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.
  28983. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  28984. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28985. * Remember you can only change the shape positions, not their number when updating a polygon.
  28986. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  28987. * @param name defines the name of the mesh to create
  28988. * @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
  28989. * @param scene defines the hosting scene
  28990. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  28991. * @param updatable defines if the mesh must be flagged as updatable
  28992. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28993. * @param earcutInjection can be used to inject your own earcut reference
  28994. * @returns a new Mesh
  28995. */
  28996. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  28997. /**
  28998. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  28999. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  29000. * @param name defines the name of the mesh to create
  29001. * @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
  29002. * @param depth defines the height of extrusion
  29003. * @param scene defines the hosting scene
  29004. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  29005. * @param updatable defines if the mesh must be flagged as updatable
  29006. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29007. * @param earcutInjection can be used to inject your own earcut reference
  29008. * @returns a new Mesh
  29009. */
  29010. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  29011. /**
  29012. * Creates an extruded shape mesh.
  29013. * 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
  29014. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  29015. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  29016. * @param name defines the name of the mesh to create
  29017. * @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
  29018. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  29019. * @param scale is the value to scale the shape
  29020. * @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
  29021. * @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
  29022. * @param scene defines the hosting scene
  29023. * @param updatable defines if the mesh must be flagged as updatable
  29024. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29025. * @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)
  29026. * @returns a new Mesh
  29027. */
  29028. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  29029. /**
  29030. * Creates an custom extruded shape mesh.
  29031. * The custom extrusion is a parametric shape.
  29032. * It has no predefined shape. Its final shape will depend on the input parameters.
  29033. * Please consider using the same method from the MeshBuilder class instead
  29034. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  29035. * @param name defines the name of the mesh to create
  29036. * @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
  29037. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  29038. * @param scaleFunction is a custom Javascript function called on each path point
  29039. * @param rotationFunction is a custom Javascript function called on each path point
  29040. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  29041. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  29042. * @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
  29043. * @param scene defines the hosting scene
  29044. * @param updatable defines if the mesh must be flagged as updatable
  29045. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29046. * @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)
  29047. * @returns a new Mesh
  29048. */
  29049. 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;
  29050. /**
  29051. * Creates lathe mesh.
  29052. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  29053. * Please consider using the same method from the MeshBuilder class instead
  29054. * @param name defines the name of the mesh to create
  29055. * @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
  29056. * @param radius is the radius value of the lathe
  29057. * @param tessellation is the side number of the lathe.
  29058. * @param scene defines the hosting scene
  29059. * @param updatable defines if the mesh must be flagged as updatable
  29060. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29061. * @returns a new Mesh
  29062. */
  29063. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29064. /**
  29065. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  29066. * @param name defines the name of the mesh to create
  29067. * @param size sets the size (float) of both sides of the plane at once (default 1)
  29068. * @param scene defines the hosting scene
  29069. * @param updatable defines if the mesh must be flagged as updatable
  29070. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29071. * @returns a new Mesh
  29072. */
  29073. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29074. /**
  29075. * Creates a ground mesh.
  29076. * Please consider using the same method from the MeshBuilder class instead
  29077. * @param name defines the name of the mesh to create
  29078. * @param width set the width of the ground
  29079. * @param height set the height of the ground
  29080. * @param subdivisions sets the number of subdivisions per side
  29081. * @param scene defines the hosting scene
  29082. * @param updatable defines if the mesh must be flagged as updatable
  29083. * @returns a new Mesh
  29084. */
  29085. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  29086. /**
  29087. * Creates a tiled ground mesh.
  29088. * Please consider using the same method from the MeshBuilder class instead
  29089. * @param name defines the name of the mesh to create
  29090. * @param xmin set the ground minimum X coordinate
  29091. * @param zmin set the ground minimum Y coordinate
  29092. * @param xmax set the ground maximum X coordinate
  29093. * @param zmax set the ground maximum Z coordinate
  29094. * @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
  29095. * @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
  29096. * @param scene defines the hosting scene
  29097. * @param updatable defines if the mesh must be flagged as updatable
  29098. * @returns a new Mesh
  29099. */
  29100. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  29101. w: number;
  29102. h: number;
  29103. }, precision: {
  29104. w: number;
  29105. h: number;
  29106. }, scene: Scene, updatable?: boolean): Mesh;
  29107. /**
  29108. * Creates a ground mesh from a height map.
  29109. * Please consider using the same method from the MeshBuilder class instead
  29110. * @see http://doc.babylonjs.com/babylon101/height_map
  29111. * @param name defines the name of the mesh to create
  29112. * @param url sets the URL of the height map image resource
  29113. * @param width set the ground width size
  29114. * @param height set the ground height size
  29115. * @param subdivisions sets the number of subdivision per side
  29116. * @param minHeight is the minimum altitude on the ground
  29117. * @param maxHeight is the maximum altitude on the ground
  29118. * @param scene defines the hosting scene
  29119. * @param updatable defines if the mesh must be flagged as updatable
  29120. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  29121. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  29122. * @returns a new Mesh
  29123. */
  29124. 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;
  29125. /**
  29126. * Creates a tube mesh.
  29127. * The tube is a parametric shape.
  29128. * It has no predefined shape. Its final shape will depend on the input parameters.
  29129. * Please consider using the same method from the MeshBuilder class instead
  29130. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  29131. * @param name defines the name of the mesh to create
  29132. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  29133. * @param radius sets the tube radius size
  29134. * @param tessellation is the number of sides on the tubular surface
  29135. * @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
  29136. * @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
  29137. * @param scene defines the hosting scene
  29138. * @param updatable defines if the mesh must be flagged as updatable
  29139. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29140. * @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)
  29141. * @returns a new Mesh
  29142. */
  29143. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  29144. (i: number, distance: number): number;
  29145. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  29146. /**
  29147. * Creates a polyhedron mesh.
  29148. * Please consider using the same method from the MeshBuilder class instead.
  29149. * * 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
  29150. * * The parameter `size` (positive float, default 1) sets the polygon size
  29151. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  29152. * * 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`
  29153. * * 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
  29154. * * 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)`)
  29155. * * 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
  29156. * * 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
  29157. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  29158. * * If you create a double-sided mesh, you can choose what parts of 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
  29159. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  29160. * @param name defines the name of the mesh to create
  29161. * @param options defines the options used to create the mesh
  29162. * @param scene defines the hosting scene
  29163. * @returns a new Mesh
  29164. */
  29165. static CreatePolyhedron(name: string, options: {
  29166. type?: number;
  29167. size?: number;
  29168. sizeX?: number;
  29169. sizeY?: number;
  29170. sizeZ?: number;
  29171. custom?: any;
  29172. faceUV?: Vector4[];
  29173. faceColors?: Color4[];
  29174. updatable?: boolean;
  29175. sideOrientation?: number;
  29176. }, scene: Scene): Mesh;
  29177. /**
  29178. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  29179. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  29180. * * 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`)
  29181. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  29182. * * 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
  29183. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  29184. * * If you create a double-sided mesh, you can choose what parts of 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
  29185. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  29186. * @param name defines the name of the mesh
  29187. * @param options defines the options used to create the mesh
  29188. * @param scene defines the hosting scene
  29189. * @returns a new Mesh
  29190. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  29191. */
  29192. static CreateIcoSphere(name: string, options: {
  29193. radius?: number;
  29194. flat?: boolean;
  29195. subdivisions?: number;
  29196. sideOrientation?: number;
  29197. updatable?: boolean;
  29198. }, scene: Scene): Mesh;
  29199. /**
  29200. * Creates a decal mesh.
  29201. * Please consider using the same method from the MeshBuilder class instead.
  29202. * A decal is a mesh usually applied as a model onto the surface of another mesh
  29203. * @param name defines the name of the mesh
  29204. * @param sourceMesh defines the mesh receiving the decal
  29205. * @param position sets the position of the decal in world coordinates
  29206. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  29207. * @param size sets the decal scaling
  29208. * @param angle sets the angle to rotate the decal
  29209. * @returns a new Mesh
  29210. */
  29211. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  29212. /**
  29213. * Prepare internal position array for software CPU skinning
  29214. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  29215. */
  29216. setPositionsForCPUSkinning(): Float32Array;
  29217. /**
  29218. * Prepare internal normal array for software CPU skinning
  29219. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  29220. */
  29221. setNormalsForCPUSkinning(): Float32Array;
  29222. /**
  29223. * Updates the vertex buffer by applying transformation from the bones
  29224. * @param skeleton defines the skeleton to apply to current mesh
  29225. * @returns the current mesh
  29226. */
  29227. applySkeleton(skeleton: Skeleton): Mesh;
  29228. /**
  29229. * 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
  29230. * @param meshes defines the list of meshes to scan
  29231. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  29232. */
  29233. static MinMax(meshes: AbstractMesh[]): {
  29234. min: Vector3;
  29235. max: Vector3;
  29236. };
  29237. /**
  29238. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  29239. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  29240. * @returns a vector3
  29241. */
  29242. static Center(meshesOrMinMaxVector: {
  29243. min: Vector3;
  29244. max: Vector3;
  29245. } | AbstractMesh[]): Vector3;
  29246. /**
  29247. * Merge the array of meshes into a single mesh for performance reasons.
  29248. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  29249. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  29250. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  29251. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  29252. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  29253. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  29254. * @returns a new mesh
  29255. */
  29256. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  29257. /** @hidden */
  29258. addInstance(instance: InstancedMesh): void;
  29259. /** @hidden */
  29260. removeInstance(instance: InstancedMesh): void;
  29261. }
  29262. }
  29263. declare module "babylonjs/Cameras/camera" {
  29264. import { SmartArray } from "babylonjs/Misc/smartArray";
  29265. import { Observable } from "babylonjs/Misc/observable";
  29266. import { Nullable } from "babylonjs/types";
  29267. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  29268. import { Scene } from "babylonjs/scene";
  29269. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  29270. import { Node } from "babylonjs/node";
  29271. import { Mesh } from "babylonjs/Meshes/mesh";
  29272. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29273. import { ICullable } from "babylonjs/Culling/boundingInfo";
  29274. import { Viewport } from "babylonjs/Maths/math.viewport";
  29275. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  29276. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  29277. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  29278. import { Ray } from "babylonjs/Culling/ray";
  29279. /**
  29280. * This is the base class of all the camera used in the application.
  29281. * @see http://doc.babylonjs.com/features/cameras
  29282. */
  29283. export class Camera extends Node {
  29284. /** @hidden */
  29285. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  29286. /**
  29287. * This is the default projection mode used by the cameras.
  29288. * It helps recreating a feeling of perspective and better appreciate depth.
  29289. * This is the best way to simulate real life cameras.
  29290. */
  29291. static readonly PERSPECTIVE_CAMERA: number;
  29292. /**
  29293. * This helps creating camera with an orthographic mode.
  29294. * 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.
  29295. */
  29296. static readonly ORTHOGRAPHIC_CAMERA: number;
  29297. /**
  29298. * This is the default FOV mode for perspective cameras.
  29299. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  29300. */
  29301. static readonly FOVMODE_VERTICAL_FIXED: number;
  29302. /**
  29303. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  29304. */
  29305. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  29306. /**
  29307. * This specifies ther is no need for a camera rig.
  29308. * Basically only one eye is rendered corresponding to the camera.
  29309. */
  29310. static readonly RIG_MODE_NONE: number;
  29311. /**
  29312. * Simulates a camera Rig with one blue eye and one red eye.
  29313. * This can be use with 3d blue and red glasses.
  29314. */
  29315. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  29316. /**
  29317. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  29318. */
  29319. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  29320. /**
  29321. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  29322. */
  29323. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  29324. /**
  29325. * Defines that both eyes of the camera will be rendered over under each other.
  29326. */
  29327. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  29328. /**
  29329. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  29330. */
  29331. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  29332. /**
  29333. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  29334. */
  29335. static readonly RIG_MODE_VR: number;
  29336. /**
  29337. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  29338. */
  29339. static readonly RIG_MODE_WEBVR: number;
  29340. /**
  29341. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  29342. */
  29343. static readonly RIG_MODE_CUSTOM: number;
  29344. /**
  29345. * Defines if by default attaching controls should prevent the default javascript event to continue.
  29346. */
  29347. static ForceAttachControlToAlwaysPreventDefault: boolean;
  29348. /**
  29349. * Define the input manager associated with the camera.
  29350. */
  29351. inputs: CameraInputsManager<Camera>;
  29352. /** @hidden */
  29353. _position: Vector3;
  29354. /**
  29355. * Define the current local position of the camera in the scene
  29356. */
  29357. get position(): Vector3;
  29358. set position(newPosition: Vector3);
  29359. /**
  29360. * The vector the camera should consider as up.
  29361. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  29362. */
  29363. upVector: Vector3;
  29364. /**
  29365. * Define the current limit on the left side for an orthographic camera
  29366. * In scene unit
  29367. */
  29368. orthoLeft: Nullable<number>;
  29369. /**
  29370. * Define the current limit on the right side for an orthographic camera
  29371. * In scene unit
  29372. */
  29373. orthoRight: Nullable<number>;
  29374. /**
  29375. * Define the current limit on the bottom side for an orthographic camera
  29376. * In scene unit
  29377. */
  29378. orthoBottom: Nullable<number>;
  29379. /**
  29380. * Define the current limit on the top side for an orthographic camera
  29381. * In scene unit
  29382. */
  29383. orthoTop: Nullable<number>;
  29384. /**
  29385. * Field Of View is set in Radians. (default is 0.8)
  29386. */
  29387. fov: number;
  29388. /**
  29389. * Define the minimum distance the camera can see from.
  29390. * This is important to note that the depth buffer are not infinite and the closer it starts
  29391. * the more your scene might encounter depth fighting issue.
  29392. */
  29393. minZ: number;
  29394. /**
  29395. * Define the maximum distance the camera can see to.
  29396. * This is important to note that the depth buffer are not infinite and the further it end
  29397. * the more your scene might encounter depth fighting issue.
  29398. */
  29399. maxZ: number;
  29400. /**
  29401. * Define the default inertia of the camera.
  29402. * This helps giving a smooth feeling to the camera movement.
  29403. */
  29404. inertia: number;
  29405. /**
  29406. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  29407. */
  29408. mode: number;
  29409. /**
  29410. * Define whether the camera is intermediate.
  29411. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  29412. */
  29413. isIntermediate: boolean;
  29414. /**
  29415. * Define the viewport of the camera.
  29416. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  29417. */
  29418. viewport: Viewport;
  29419. /**
  29420. * Restricts the camera to viewing objects with the same layerMask.
  29421. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  29422. */
  29423. layerMask: number;
  29424. /**
  29425. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  29426. */
  29427. fovMode: number;
  29428. /**
  29429. * Rig mode of the camera.
  29430. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  29431. * This is normally controlled byt the camera themselves as internal use.
  29432. */
  29433. cameraRigMode: number;
  29434. /**
  29435. * Defines the distance between both "eyes" in case of a RIG
  29436. */
  29437. interaxialDistance: number;
  29438. /**
  29439. * Defines if stereoscopic rendering is done side by side or over under.
  29440. */
  29441. isStereoscopicSideBySide: boolean;
  29442. /**
  29443. * 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
  29444. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  29445. * else in the scene. (Eg. security camera)
  29446. *
  29447. * 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)
  29448. */
  29449. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  29450. /**
  29451. * When set, the camera will render to this render target instead of the default canvas
  29452. *
  29453. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  29454. */
  29455. outputRenderTarget: Nullable<RenderTargetTexture>;
  29456. /**
  29457. * Observable triggered when the camera view matrix has changed.
  29458. */
  29459. onViewMatrixChangedObservable: Observable<Camera>;
  29460. /**
  29461. * Observable triggered when the camera Projection matrix has changed.
  29462. */
  29463. onProjectionMatrixChangedObservable: Observable<Camera>;
  29464. /**
  29465. * Observable triggered when the inputs have been processed.
  29466. */
  29467. onAfterCheckInputsObservable: Observable<Camera>;
  29468. /**
  29469. * Observable triggered when reset has been called and applied to the camera.
  29470. */
  29471. onRestoreStateObservable: Observable<Camera>;
  29472. /**
  29473. * Is this camera a part of a rig system?
  29474. */
  29475. isRigCamera: boolean;
  29476. /**
  29477. * If isRigCamera set to true this will be set with the parent camera.
  29478. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  29479. */
  29480. rigParent?: Camera;
  29481. /** @hidden */
  29482. _cameraRigParams: any;
  29483. /** @hidden */
  29484. _rigCameras: Camera[];
  29485. /** @hidden */
  29486. _rigPostProcess: Nullable<PostProcess>;
  29487. protected _webvrViewMatrix: Matrix;
  29488. /** @hidden */
  29489. _skipRendering: boolean;
  29490. /** @hidden */
  29491. _projectionMatrix: Matrix;
  29492. /** @hidden */
  29493. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  29494. /** @hidden */
  29495. _activeMeshes: SmartArray<AbstractMesh>;
  29496. protected _globalPosition: Vector3;
  29497. /** @hidden */
  29498. _computedViewMatrix: Matrix;
  29499. private _doNotComputeProjectionMatrix;
  29500. private _transformMatrix;
  29501. private _frustumPlanes;
  29502. private _refreshFrustumPlanes;
  29503. private _storedFov;
  29504. private _stateStored;
  29505. /**
  29506. * Instantiates a new camera object.
  29507. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  29508. * @see http://doc.babylonjs.com/features/cameras
  29509. * @param name Defines the name of the camera in the scene
  29510. * @param position Defines the position of the camera
  29511. * @param scene Defines the scene the camera belongs too
  29512. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  29513. */
  29514. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  29515. /**
  29516. * Store current camera state (fov, position, etc..)
  29517. * @returns the camera
  29518. */
  29519. storeState(): Camera;
  29520. /**
  29521. * Restores the camera state values if it has been stored. You must call storeState() first
  29522. */
  29523. protected _restoreStateValues(): boolean;
  29524. /**
  29525. * Restored camera state. You must call storeState() first.
  29526. * @returns true if restored and false otherwise
  29527. */
  29528. restoreState(): boolean;
  29529. /**
  29530. * Gets the class name of the camera.
  29531. * @returns the class name
  29532. */
  29533. getClassName(): string;
  29534. /** @hidden */
  29535. readonly _isCamera: boolean;
  29536. /**
  29537. * Gets a string representation of the camera useful for debug purpose.
  29538. * @param fullDetails Defines that a more verboe level of logging is required
  29539. * @returns the string representation
  29540. */
  29541. toString(fullDetails?: boolean): string;
  29542. /**
  29543. * Gets the current world space position of the camera.
  29544. */
  29545. get globalPosition(): Vector3;
  29546. /**
  29547. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  29548. * @returns the active meshe list
  29549. */
  29550. getActiveMeshes(): SmartArray<AbstractMesh>;
  29551. /**
  29552. * Check whether a mesh is part of the current active mesh list of the camera
  29553. * @param mesh Defines the mesh to check
  29554. * @returns true if active, false otherwise
  29555. */
  29556. isActiveMesh(mesh: Mesh): boolean;
  29557. /**
  29558. * Is this camera ready to be used/rendered
  29559. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  29560. * @return true if the camera is ready
  29561. */
  29562. isReady(completeCheck?: boolean): boolean;
  29563. /** @hidden */
  29564. _initCache(): void;
  29565. /** @hidden */
  29566. _updateCache(ignoreParentClass?: boolean): void;
  29567. /** @hidden */
  29568. _isSynchronized(): boolean;
  29569. /** @hidden */
  29570. _isSynchronizedViewMatrix(): boolean;
  29571. /** @hidden */
  29572. _isSynchronizedProjectionMatrix(): boolean;
  29573. /**
  29574. * Attach the input controls to a specific dom element to get the input from.
  29575. * @param element Defines the element the controls should be listened from
  29576. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  29577. */
  29578. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29579. /**
  29580. * Detach the current controls from the specified dom element.
  29581. * @param element Defines the element to stop listening the inputs from
  29582. */
  29583. detachControl(element: HTMLElement): void;
  29584. /**
  29585. * Update the camera state according to the different inputs gathered during the frame.
  29586. */
  29587. update(): void;
  29588. /** @hidden */
  29589. _checkInputs(): void;
  29590. /** @hidden */
  29591. get rigCameras(): Camera[];
  29592. /**
  29593. * Gets the post process used by the rig cameras
  29594. */
  29595. get rigPostProcess(): Nullable<PostProcess>;
  29596. /**
  29597. * Internal, gets the first post proces.
  29598. * @returns the first post process to be run on this camera.
  29599. */
  29600. _getFirstPostProcess(): Nullable<PostProcess>;
  29601. private _cascadePostProcessesToRigCams;
  29602. /**
  29603. * Attach a post process to the camera.
  29604. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  29605. * @param postProcess The post process to attach to the camera
  29606. * @param insertAt The position of the post process in case several of them are in use in the scene
  29607. * @returns the position the post process has been inserted at
  29608. */
  29609. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  29610. /**
  29611. * Detach a post process to the camera.
  29612. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  29613. * @param postProcess The post process to detach from the camera
  29614. */
  29615. detachPostProcess(postProcess: PostProcess): void;
  29616. /**
  29617. * Gets the current world matrix of the camera
  29618. */
  29619. getWorldMatrix(): Matrix;
  29620. /** @hidden */
  29621. _getViewMatrix(): Matrix;
  29622. /**
  29623. * Gets the current view matrix of the camera.
  29624. * @param force forces the camera to recompute the matrix without looking at the cached state
  29625. * @returns the view matrix
  29626. */
  29627. getViewMatrix(force?: boolean): Matrix;
  29628. /**
  29629. * Freeze the projection matrix.
  29630. * It will prevent the cache check of the camera projection compute and can speed up perf
  29631. * if no parameter of the camera are meant to change
  29632. * @param projection Defines manually a projection if necessary
  29633. */
  29634. freezeProjectionMatrix(projection?: Matrix): void;
  29635. /**
  29636. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  29637. */
  29638. unfreezeProjectionMatrix(): void;
  29639. /**
  29640. * Gets the current projection matrix of the camera.
  29641. * @param force forces the camera to recompute the matrix without looking at the cached state
  29642. * @returns the projection matrix
  29643. */
  29644. getProjectionMatrix(force?: boolean): Matrix;
  29645. /**
  29646. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  29647. * @returns a Matrix
  29648. */
  29649. getTransformationMatrix(): Matrix;
  29650. private _updateFrustumPlanes;
  29651. /**
  29652. * Checks if a cullable object (mesh...) is in the camera frustum
  29653. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  29654. * @param target The object to check
  29655. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  29656. * @returns true if the object is in frustum otherwise false
  29657. */
  29658. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  29659. /**
  29660. * Checks if a cullable object (mesh...) is in the camera frustum
  29661. * Unlike isInFrustum this cheks the full bounding box
  29662. * @param target The object to check
  29663. * @returns true if the object is in frustum otherwise false
  29664. */
  29665. isCompletelyInFrustum(target: ICullable): boolean;
  29666. /**
  29667. * Gets a ray in the forward direction from the camera.
  29668. * @param length Defines the length of the ray to create
  29669. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  29670. * @param origin Defines the start point of the ray which defaults to the camera position
  29671. * @returns the forward ray
  29672. */
  29673. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  29674. /**
  29675. * Releases resources associated with this node.
  29676. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29677. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29678. */
  29679. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29680. /** @hidden */
  29681. _isLeftCamera: boolean;
  29682. /**
  29683. * Gets the left camera of a rig setup in case of Rigged Camera
  29684. */
  29685. get isLeftCamera(): boolean;
  29686. /** @hidden */
  29687. _isRightCamera: boolean;
  29688. /**
  29689. * Gets the right camera of a rig setup in case of Rigged Camera
  29690. */
  29691. get isRightCamera(): boolean;
  29692. /**
  29693. * Gets the left camera of a rig setup in case of Rigged Camera
  29694. */
  29695. get leftCamera(): Nullable<FreeCamera>;
  29696. /**
  29697. * Gets the right camera of a rig setup in case of Rigged Camera
  29698. */
  29699. get rightCamera(): Nullable<FreeCamera>;
  29700. /**
  29701. * Gets the left camera target of a rig setup in case of Rigged Camera
  29702. * @returns the target position
  29703. */
  29704. getLeftTarget(): Nullable<Vector3>;
  29705. /**
  29706. * Gets the right camera target of a rig setup in case of Rigged Camera
  29707. * @returns the target position
  29708. */
  29709. getRightTarget(): Nullable<Vector3>;
  29710. /**
  29711. * @hidden
  29712. */
  29713. setCameraRigMode(mode: number, rigParams: any): void;
  29714. /** @hidden */
  29715. static _setStereoscopicRigMode(camera: Camera): void;
  29716. /** @hidden */
  29717. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  29718. /** @hidden */
  29719. static _setVRRigMode(camera: Camera, rigParams: any): void;
  29720. /** @hidden */
  29721. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  29722. /** @hidden */
  29723. _getVRProjectionMatrix(): Matrix;
  29724. protected _updateCameraRotationMatrix(): void;
  29725. protected _updateWebVRCameraRotationMatrix(): void;
  29726. /**
  29727. * This function MUST be overwritten by the different WebVR cameras available.
  29728. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  29729. * @hidden
  29730. */
  29731. _getWebVRProjectionMatrix(): Matrix;
  29732. /**
  29733. * This function MUST be overwritten by the different WebVR cameras available.
  29734. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  29735. * @hidden
  29736. */
  29737. _getWebVRViewMatrix(): Matrix;
  29738. /** @hidden */
  29739. setCameraRigParameter(name: string, value: any): void;
  29740. /**
  29741. * needs to be overridden by children so sub has required properties to be copied
  29742. * @hidden
  29743. */
  29744. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  29745. /**
  29746. * May need to be overridden by children
  29747. * @hidden
  29748. */
  29749. _updateRigCameras(): void;
  29750. /** @hidden */
  29751. _setupInputs(): void;
  29752. /**
  29753. * Serialiaze the camera setup to a json represention
  29754. * @returns the JSON representation
  29755. */
  29756. serialize(): any;
  29757. /**
  29758. * Clones the current camera.
  29759. * @param name The cloned camera name
  29760. * @returns the cloned camera
  29761. */
  29762. clone(name: string): Camera;
  29763. /**
  29764. * Gets the direction of the camera relative to a given local axis.
  29765. * @param localAxis Defines the reference axis to provide a relative direction.
  29766. * @return the direction
  29767. */
  29768. getDirection(localAxis: Vector3): Vector3;
  29769. /**
  29770. * Returns the current camera absolute rotation
  29771. */
  29772. get absoluteRotation(): Quaternion;
  29773. /**
  29774. * Gets the direction of the camera relative to a given local axis into a passed vector.
  29775. * @param localAxis Defines the reference axis to provide a relative direction.
  29776. * @param result Defines the vector to store the result in
  29777. */
  29778. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  29779. /**
  29780. * Gets a camera constructor for a given camera type
  29781. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  29782. * @param name The name of the camera the result will be able to instantiate
  29783. * @param scene The scene the result will construct the camera in
  29784. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  29785. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  29786. * @returns a factory method to construc the camera
  29787. */
  29788. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  29789. /**
  29790. * Compute the world matrix of the camera.
  29791. * @returns the camera world matrix
  29792. */
  29793. computeWorldMatrix(): Matrix;
  29794. /**
  29795. * Parse a JSON and creates the camera from the parsed information
  29796. * @param parsedCamera The JSON to parse
  29797. * @param scene The scene to instantiate the camera in
  29798. * @returns the newly constructed camera
  29799. */
  29800. static Parse(parsedCamera: any, scene: Scene): Camera;
  29801. }
  29802. }
  29803. declare module "babylonjs/Meshes/Builders/discBuilder" {
  29804. import { Nullable } from "babylonjs/types";
  29805. import { Scene } from "babylonjs/scene";
  29806. import { Vector4 } from "babylonjs/Maths/math.vector";
  29807. import { Mesh } from "babylonjs/Meshes/mesh";
  29808. /**
  29809. * Class containing static functions to help procedurally build meshes
  29810. */
  29811. export class DiscBuilder {
  29812. /**
  29813. * Creates a plane polygonal mesh. By default, this is a disc
  29814. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  29815. * * 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
  29816. * * 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
  29817. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  29818. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  29819. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  29820. * @param name defines the name of the mesh
  29821. * @param options defines the options used to create the mesh
  29822. * @param scene defines the hosting scene
  29823. * @returns the plane polygonal mesh
  29824. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  29825. */
  29826. static CreateDisc(name: string, options: {
  29827. radius?: number;
  29828. tessellation?: number;
  29829. arc?: number;
  29830. updatable?: boolean;
  29831. sideOrientation?: number;
  29832. frontUVs?: Vector4;
  29833. backUVs?: Vector4;
  29834. }, scene?: Nullable<Scene>): Mesh;
  29835. }
  29836. }
  29837. declare module "babylonjs/Materials/fresnelParameters" {
  29838. import { DeepImmutable } from "babylonjs/types";
  29839. import { Color3 } from "babylonjs/Maths/math.color";
  29840. /**
  29841. * Options to be used when creating a FresnelParameters.
  29842. */
  29843. export type IFresnelParametersCreationOptions = {
  29844. /**
  29845. * Define the color used on edges (grazing angle)
  29846. */
  29847. leftColor?: Color3;
  29848. /**
  29849. * Define the color used on center
  29850. */
  29851. rightColor?: Color3;
  29852. /**
  29853. * Define bias applied to computed fresnel term
  29854. */
  29855. bias?: number;
  29856. /**
  29857. * Defined the power exponent applied to fresnel term
  29858. */
  29859. power?: number;
  29860. /**
  29861. * Define if the fresnel effect is enable or not.
  29862. */
  29863. isEnabled?: boolean;
  29864. };
  29865. /**
  29866. * Serialized format for FresnelParameters.
  29867. */
  29868. export type IFresnelParametersSerialized = {
  29869. /**
  29870. * Define the color used on edges (grazing angle) [as an array]
  29871. */
  29872. leftColor: number[];
  29873. /**
  29874. * Define the color used on center [as an array]
  29875. */
  29876. rightColor: number[];
  29877. /**
  29878. * Define bias applied to computed fresnel term
  29879. */
  29880. bias: number;
  29881. /**
  29882. * Defined the power exponent applied to fresnel term
  29883. */
  29884. power?: number;
  29885. /**
  29886. * Define if the fresnel effect is enable or not.
  29887. */
  29888. isEnabled: boolean;
  29889. };
  29890. /**
  29891. * This represents all the required information to add a fresnel effect on a material:
  29892. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29893. */
  29894. export class FresnelParameters {
  29895. private _isEnabled;
  29896. /**
  29897. * Define if the fresnel effect is enable or not.
  29898. */
  29899. get isEnabled(): boolean;
  29900. set isEnabled(value: boolean);
  29901. /**
  29902. * Define the color used on edges (grazing angle)
  29903. */
  29904. leftColor: Color3;
  29905. /**
  29906. * Define the color used on center
  29907. */
  29908. rightColor: Color3;
  29909. /**
  29910. * Define bias applied to computed fresnel term
  29911. */
  29912. bias: number;
  29913. /**
  29914. * Defined the power exponent applied to fresnel term
  29915. */
  29916. power: number;
  29917. /**
  29918. * Creates a new FresnelParameters object.
  29919. *
  29920. * @param options provide your own settings to optionally to override defaults
  29921. */
  29922. constructor(options?: IFresnelParametersCreationOptions);
  29923. /**
  29924. * Clones the current fresnel and its valuues
  29925. * @returns a clone fresnel configuration
  29926. */
  29927. clone(): FresnelParameters;
  29928. /**
  29929. * Determines equality between FresnelParameters objects
  29930. * @param otherFresnelParameters defines the second operand
  29931. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  29932. */
  29933. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  29934. /**
  29935. * Serializes the current fresnel parameters to a JSON representation.
  29936. * @return the JSON serialization
  29937. */
  29938. serialize(): IFresnelParametersSerialized;
  29939. /**
  29940. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  29941. * @param parsedFresnelParameters Define the JSON representation
  29942. * @returns the parsed parameters
  29943. */
  29944. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  29945. }
  29946. }
  29947. declare module "babylonjs/Materials/materialFlags" {
  29948. /**
  29949. * This groups all the flags used to control the materials channel.
  29950. */
  29951. export class MaterialFlags {
  29952. private static _DiffuseTextureEnabled;
  29953. /**
  29954. * Are diffuse textures enabled in the application.
  29955. */
  29956. static get DiffuseTextureEnabled(): boolean;
  29957. static set DiffuseTextureEnabled(value: boolean);
  29958. private static _AmbientTextureEnabled;
  29959. /**
  29960. * Are ambient textures enabled in the application.
  29961. */
  29962. static get AmbientTextureEnabled(): boolean;
  29963. static set AmbientTextureEnabled(value: boolean);
  29964. private static _OpacityTextureEnabled;
  29965. /**
  29966. * Are opacity textures enabled in the application.
  29967. */
  29968. static get OpacityTextureEnabled(): boolean;
  29969. static set OpacityTextureEnabled(value: boolean);
  29970. private static _ReflectionTextureEnabled;
  29971. /**
  29972. * Are reflection textures enabled in the application.
  29973. */
  29974. static get ReflectionTextureEnabled(): boolean;
  29975. static set ReflectionTextureEnabled(value: boolean);
  29976. private static _EmissiveTextureEnabled;
  29977. /**
  29978. * Are emissive textures enabled in the application.
  29979. */
  29980. static get EmissiveTextureEnabled(): boolean;
  29981. static set EmissiveTextureEnabled(value: boolean);
  29982. private static _SpecularTextureEnabled;
  29983. /**
  29984. * Are specular textures enabled in the application.
  29985. */
  29986. static get SpecularTextureEnabled(): boolean;
  29987. static set SpecularTextureEnabled(value: boolean);
  29988. private static _BumpTextureEnabled;
  29989. /**
  29990. * Are bump textures enabled in the application.
  29991. */
  29992. static get BumpTextureEnabled(): boolean;
  29993. static set BumpTextureEnabled(value: boolean);
  29994. private static _LightmapTextureEnabled;
  29995. /**
  29996. * Are lightmap textures enabled in the application.
  29997. */
  29998. static get LightmapTextureEnabled(): boolean;
  29999. static set LightmapTextureEnabled(value: boolean);
  30000. private static _RefractionTextureEnabled;
  30001. /**
  30002. * Are refraction textures enabled in the application.
  30003. */
  30004. static get RefractionTextureEnabled(): boolean;
  30005. static set RefractionTextureEnabled(value: boolean);
  30006. private static _ColorGradingTextureEnabled;
  30007. /**
  30008. * Are color grading textures enabled in the application.
  30009. */
  30010. static get ColorGradingTextureEnabled(): boolean;
  30011. static set ColorGradingTextureEnabled(value: boolean);
  30012. private static _FresnelEnabled;
  30013. /**
  30014. * Are fresnels enabled in the application.
  30015. */
  30016. static get FresnelEnabled(): boolean;
  30017. static set FresnelEnabled(value: boolean);
  30018. private static _ClearCoatTextureEnabled;
  30019. /**
  30020. * Are clear coat textures enabled in the application.
  30021. */
  30022. static get ClearCoatTextureEnabled(): boolean;
  30023. static set ClearCoatTextureEnabled(value: boolean);
  30024. private static _ClearCoatBumpTextureEnabled;
  30025. /**
  30026. * Are clear coat bump textures enabled in the application.
  30027. */
  30028. static get ClearCoatBumpTextureEnabled(): boolean;
  30029. static set ClearCoatBumpTextureEnabled(value: boolean);
  30030. private static _ClearCoatTintTextureEnabled;
  30031. /**
  30032. * Are clear coat tint textures enabled in the application.
  30033. */
  30034. static get ClearCoatTintTextureEnabled(): boolean;
  30035. static set ClearCoatTintTextureEnabled(value: boolean);
  30036. private static _SheenTextureEnabled;
  30037. /**
  30038. * Are sheen textures enabled in the application.
  30039. */
  30040. static get SheenTextureEnabled(): boolean;
  30041. static set SheenTextureEnabled(value: boolean);
  30042. private static _AnisotropicTextureEnabled;
  30043. /**
  30044. * Are anisotropic textures enabled in the application.
  30045. */
  30046. static get AnisotropicTextureEnabled(): boolean;
  30047. static set AnisotropicTextureEnabled(value: boolean);
  30048. private static _ThicknessTextureEnabled;
  30049. /**
  30050. * Are thickness textures enabled in the application.
  30051. */
  30052. static get ThicknessTextureEnabled(): boolean;
  30053. static set ThicknessTextureEnabled(value: boolean);
  30054. }
  30055. }
  30056. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  30057. /** @hidden */
  30058. export var defaultFragmentDeclaration: {
  30059. name: string;
  30060. shader: string;
  30061. };
  30062. }
  30063. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  30064. /** @hidden */
  30065. export var defaultUboDeclaration: {
  30066. name: string;
  30067. shader: string;
  30068. };
  30069. }
  30070. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  30071. /** @hidden */
  30072. export var lightFragmentDeclaration: {
  30073. name: string;
  30074. shader: string;
  30075. };
  30076. }
  30077. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  30078. /** @hidden */
  30079. export var lightUboDeclaration: {
  30080. name: string;
  30081. shader: string;
  30082. };
  30083. }
  30084. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  30085. /** @hidden */
  30086. export var lightsFragmentFunctions: {
  30087. name: string;
  30088. shader: string;
  30089. };
  30090. }
  30091. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  30092. /** @hidden */
  30093. export var shadowsFragmentFunctions: {
  30094. name: string;
  30095. shader: string;
  30096. };
  30097. }
  30098. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  30099. /** @hidden */
  30100. export var fresnelFunction: {
  30101. name: string;
  30102. shader: string;
  30103. };
  30104. }
  30105. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions" {
  30106. /** @hidden */
  30107. export var bumpFragmentMainFunctions: {
  30108. name: string;
  30109. shader: string;
  30110. };
  30111. }
  30112. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  30113. /** @hidden */
  30114. export var bumpFragmentFunctions: {
  30115. name: string;
  30116. shader: string;
  30117. };
  30118. }
  30119. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  30120. /** @hidden */
  30121. export var logDepthDeclaration: {
  30122. name: string;
  30123. shader: string;
  30124. };
  30125. }
  30126. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  30127. /** @hidden */
  30128. export var bumpFragment: {
  30129. name: string;
  30130. shader: string;
  30131. };
  30132. }
  30133. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  30134. /** @hidden */
  30135. export var depthPrePass: {
  30136. name: string;
  30137. shader: string;
  30138. };
  30139. }
  30140. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  30141. /** @hidden */
  30142. export var lightFragment: {
  30143. name: string;
  30144. shader: string;
  30145. };
  30146. }
  30147. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  30148. /** @hidden */
  30149. export var logDepthFragment: {
  30150. name: string;
  30151. shader: string;
  30152. };
  30153. }
  30154. declare module "babylonjs/Shaders/default.fragment" {
  30155. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  30156. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  30157. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  30158. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  30159. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  30160. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  30161. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  30162. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  30163. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  30164. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  30165. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  30166. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  30167. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  30168. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  30169. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  30170. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  30171. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  30172. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  30173. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  30174. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  30175. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  30176. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  30177. /** @hidden */
  30178. export var defaultPixelShader: {
  30179. name: string;
  30180. shader: string;
  30181. };
  30182. }
  30183. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  30184. /** @hidden */
  30185. export var defaultVertexDeclaration: {
  30186. name: string;
  30187. shader: string;
  30188. };
  30189. }
  30190. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  30191. /** @hidden */
  30192. export var bumpVertexDeclaration: {
  30193. name: string;
  30194. shader: string;
  30195. };
  30196. }
  30197. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  30198. /** @hidden */
  30199. export var bumpVertex: {
  30200. name: string;
  30201. shader: string;
  30202. };
  30203. }
  30204. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  30205. /** @hidden */
  30206. export var fogVertex: {
  30207. name: string;
  30208. shader: string;
  30209. };
  30210. }
  30211. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  30212. /** @hidden */
  30213. export var shadowsVertex: {
  30214. name: string;
  30215. shader: string;
  30216. };
  30217. }
  30218. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  30219. /** @hidden */
  30220. export var pointCloudVertex: {
  30221. name: string;
  30222. shader: string;
  30223. };
  30224. }
  30225. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  30226. /** @hidden */
  30227. export var logDepthVertex: {
  30228. name: string;
  30229. shader: string;
  30230. };
  30231. }
  30232. declare module "babylonjs/Shaders/default.vertex" {
  30233. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  30234. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  30235. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  30236. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  30237. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  30238. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  30239. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  30240. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  30241. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  30242. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  30243. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  30244. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  30245. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  30246. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  30247. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  30248. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  30249. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  30250. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  30251. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  30252. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  30253. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  30254. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  30255. /** @hidden */
  30256. export var defaultVertexShader: {
  30257. name: string;
  30258. shader: string;
  30259. };
  30260. }
  30261. declare module "babylonjs/Materials/standardMaterial" {
  30262. import { SmartArray } from "babylonjs/Misc/smartArray";
  30263. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30264. import { Nullable } from "babylonjs/types";
  30265. import { Scene } from "babylonjs/scene";
  30266. import { Matrix } from "babylonjs/Maths/math.vector";
  30267. import { Color3 } from "babylonjs/Maths/math.color";
  30268. import { SubMesh } from "babylonjs/Meshes/subMesh";
  30269. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30270. import { Mesh } from "babylonjs/Meshes/mesh";
  30271. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  30272. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  30273. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  30274. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  30275. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  30276. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30277. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30278. import "babylonjs/Shaders/default.fragment";
  30279. import "babylonjs/Shaders/default.vertex";
  30280. /** @hidden */
  30281. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  30282. MAINUV1: boolean;
  30283. MAINUV2: boolean;
  30284. DIFFUSE: boolean;
  30285. DIFFUSEDIRECTUV: number;
  30286. AMBIENT: boolean;
  30287. AMBIENTDIRECTUV: number;
  30288. OPACITY: boolean;
  30289. OPACITYDIRECTUV: number;
  30290. OPACITYRGB: boolean;
  30291. REFLECTION: boolean;
  30292. EMISSIVE: boolean;
  30293. EMISSIVEDIRECTUV: number;
  30294. SPECULAR: boolean;
  30295. SPECULARDIRECTUV: number;
  30296. BUMP: boolean;
  30297. BUMPDIRECTUV: number;
  30298. PARALLAX: boolean;
  30299. PARALLAXOCCLUSION: boolean;
  30300. SPECULAROVERALPHA: boolean;
  30301. CLIPPLANE: boolean;
  30302. CLIPPLANE2: boolean;
  30303. CLIPPLANE3: boolean;
  30304. CLIPPLANE4: boolean;
  30305. CLIPPLANE5: boolean;
  30306. CLIPPLANE6: boolean;
  30307. ALPHATEST: boolean;
  30308. DEPTHPREPASS: boolean;
  30309. ALPHAFROMDIFFUSE: boolean;
  30310. POINTSIZE: boolean;
  30311. FOG: boolean;
  30312. SPECULARTERM: boolean;
  30313. DIFFUSEFRESNEL: boolean;
  30314. OPACITYFRESNEL: boolean;
  30315. REFLECTIONFRESNEL: boolean;
  30316. REFRACTIONFRESNEL: boolean;
  30317. EMISSIVEFRESNEL: boolean;
  30318. FRESNEL: boolean;
  30319. NORMAL: boolean;
  30320. UV1: boolean;
  30321. UV2: boolean;
  30322. VERTEXCOLOR: boolean;
  30323. VERTEXALPHA: boolean;
  30324. NUM_BONE_INFLUENCERS: number;
  30325. BonesPerMesh: number;
  30326. BONETEXTURE: boolean;
  30327. INSTANCES: boolean;
  30328. GLOSSINESS: boolean;
  30329. ROUGHNESS: boolean;
  30330. EMISSIVEASILLUMINATION: boolean;
  30331. LINKEMISSIVEWITHDIFFUSE: boolean;
  30332. REFLECTIONFRESNELFROMSPECULAR: boolean;
  30333. LIGHTMAP: boolean;
  30334. LIGHTMAPDIRECTUV: number;
  30335. OBJECTSPACE_NORMALMAP: boolean;
  30336. USELIGHTMAPASSHADOWMAP: boolean;
  30337. REFLECTIONMAP_3D: boolean;
  30338. REFLECTIONMAP_SPHERICAL: boolean;
  30339. REFLECTIONMAP_PLANAR: boolean;
  30340. REFLECTIONMAP_CUBIC: boolean;
  30341. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  30342. REFLECTIONMAP_PROJECTION: boolean;
  30343. REFLECTIONMAP_SKYBOX: boolean;
  30344. REFLECTIONMAP_EXPLICIT: boolean;
  30345. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  30346. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  30347. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  30348. INVERTCUBICMAP: boolean;
  30349. LOGARITHMICDEPTH: boolean;
  30350. REFRACTION: boolean;
  30351. REFRACTIONMAP_3D: boolean;
  30352. REFLECTIONOVERALPHA: boolean;
  30353. TWOSIDEDLIGHTING: boolean;
  30354. SHADOWFLOAT: boolean;
  30355. MORPHTARGETS: boolean;
  30356. MORPHTARGETS_NORMAL: boolean;
  30357. MORPHTARGETS_TANGENT: boolean;
  30358. MORPHTARGETS_UV: boolean;
  30359. NUM_MORPH_INFLUENCERS: number;
  30360. NONUNIFORMSCALING: boolean;
  30361. PREMULTIPLYALPHA: boolean;
  30362. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  30363. ALPHABLEND: boolean;
  30364. RGBDLIGHTMAP: boolean;
  30365. RGBDREFLECTION: boolean;
  30366. RGBDREFRACTION: boolean;
  30367. IMAGEPROCESSING: boolean;
  30368. VIGNETTE: boolean;
  30369. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30370. VIGNETTEBLENDMODEOPAQUE: boolean;
  30371. TONEMAPPING: boolean;
  30372. TONEMAPPING_ACES: boolean;
  30373. CONTRAST: boolean;
  30374. COLORCURVES: boolean;
  30375. COLORGRADING: boolean;
  30376. COLORGRADING3D: boolean;
  30377. SAMPLER3DGREENDEPTH: boolean;
  30378. SAMPLER3DBGRMAP: boolean;
  30379. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30380. MULTIVIEW: boolean;
  30381. /**
  30382. * If the reflection texture on this material is in linear color space
  30383. * @hidden
  30384. */
  30385. IS_REFLECTION_LINEAR: boolean;
  30386. /**
  30387. * If the refraction texture on this material is in linear color space
  30388. * @hidden
  30389. */
  30390. IS_REFRACTION_LINEAR: boolean;
  30391. EXPOSURE: boolean;
  30392. constructor();
  30393. setReflectionMode(modeToEnable: string): void;
  30394. }
  30395. /**
  30396. * This is the default material used in Babylon. It is the best trade off between quality
  30397. * and performances.
  30398. * @see http://doc.babylonjs.com/babylon101/materials
  30399. */
  30400. export class StandardMaterial extends PushMaterial {
  30401. private _diffuseTexture;
  30402. /**
  30403. * The basic texture of the material as viewed under a light.
  30404. */
  30405. diffuseTexture: Nullable<BaseTexture>;
  30406. private _ambientTexture;
  30407. /**
  30408. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  30409. */
  30410. ambientTexture: Nullable<BaseTexture>;
  30411. private _opacityTexture;
  30412. /**
  30413. * Define the transparency of the material from a texture.
  30414. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  30415. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  30416. */
  30417. opacityTexture: Nullable<BaseTexture>;
  30418. private _reflectionTexture;
  30419. /**
  30420. * Define the texture used to display the reflection.
  30421. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30422. */
  30423. reflectionTexture: Nullable<BaseTexture>;
  30424. private _emissiveTexture;
  30425. /**
  30426. * Define texture of the material as if self lit.
  30427. * This will be mixed in the final result even in the absence of light.
  30428. */
  30429. emissiveTexture: Nullable<BaseTexture>;
  30430. private _specularTexture;
  30431. /**
  30432. * Define how the color and intensity of the highlight given by the light in the material.
  30433. */
  30434. specularTexture: Nullable<BaseTexture>;
  30435. private _bumpTexture;
  30436. /**
  30437. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  30438. * 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.
  30439. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  30440. */
  30441. bumpTexture: Nullable<BaseTexture>;
  30442. private _lightmapTexture;
  30443. /**
  30444. * Complex lighting can be computationally expensive to compute at runtime.
  30445. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  30446. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  30447. */
  30448. lightmapTexture: Nullable<BaseTexture>;
  30449. private _refractionTexture;
  30450. /**
  30451. * Define the texture used to display the refraction.
  30452. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30453. */
  30454. refractionTexture: Nullable<BaseTexture>;
  30455. /**
  30456. * The color of the material lit by the environmental background lighting.
  30457. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  30458. */
  30459. ambientColor: Color3;
  30460. /**
  30461. * The basic color of the material as viewed under a light.
  30462. */
  30463. diffuseColor: Color3;
  30464. /**
  30465. * Define how the color and intensity of the highlight given by the light in the material.
  30466. */
  30467. specularColor: Color3;
  30468. /**
  30469. * Define the color of the material as if self lit.
  30470. * This will be mixed in the final result even in the absence of light.
  30471. */
  30472. emissiveColor: Color3;
  30473. /**
  30474. * Defines how sharp are the highlights in the material.
  30475. * The bigger the value the sharper giving a more glossy feeling to the result.
  30476. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  30477. */
  30478. specularPower: number;
  30479. private _useAlphaFromDiffuseTexture;
  30480. /**
  30481. * Does the transparency come from the diffuse texture alpha channel.
  30482. */
  30483. useAlphaFromDiffuseTexture: boolean;
  30484. private _useEmissiveAsIllumination;
  30485. /**
  30486. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  30487. */
  30488. useEmissiveAsIllumination: boolean;
  30489. private _linkEmissiveWithDiffuse;
  30490. /**
  30491. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  30492. * the emissive level when the final color is close to one.
  30493. */
  30494. linkEmissiveWithDiffuse: boolean;
  30495. private _useSpecularOverAlpha;
  30496. /**
  30497. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  30498. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  30499. */
  30500. useSpecularOverAlpha: boolean;
  30501. private _useReflectionOverAlpha;
  30502. /**
  30503. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  30504. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  30505. */
  30506. useReflectionOverAlpha: boolean;
  30507. private _disableLighting;
  30508. /**
  30509. * Does lights from the scene impacts this material.
  30510. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  30511. */
  30512. disableLighting: boolean;
  30513. private _useObjectSpaceNormalMap;
  30514. /**
  30515. * Allows using an object space normal map (instead of tangent space).
  30516. */
  30517. useObjectSpaceNormalMap: boolean;
  30518. private _useParallax;
  30519. /**
  30520. * Is parallax enabled or not.
  30521. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  30522. */
  30523. useParallax: boolean;
  30524. private _useParallaxOcclusion;
  30525. /**
  30526. * Is parallax occlusion enabled or not.
  30527. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  30528. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  30529. */
  30530. useParallaxOcclusion: boolean;
  30531. /**
  30532. * 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.
  30533. */
  30534. parallaxScaleBias: number;
  30535. private _roughness;
  30536. /**
  30537. * Helps to define how blurry the reflections should appears in the material.
  30538. */
  30539. roughness: number;
  30540. /**
  30541. * In case of refraction, define the value of the index of refraction.
  30542. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30543. */
  30544. indexOfRefraction: number;
  30545. /**
  30546. * Invert the refraction texture alongside the y axis.
  30547. * It can be useful with procedural textures or probe for instance.
  30548. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30549. */
  30550. invertRefractionY: boolean;
  30551. /**
  30552. * Defines the alpha limits in alpha test mode.
  30553. */
  30554. alphaCutOff: number;
  30555. private _useLightmapAsShadowmap;
  30556. /**
  30557. * In case of light mapping, define whether the map contains light or shadow informations.
  30558. */
  30559. useLightmapAsShadowmap: boolean;
  30560. private _diffuseFresnelParameters;
  30561. /**
  30562. * Define the diffuse fresnel parameters of the material.
  30563. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30564. */
  30565. diffuseFresnelParameters: FresnelParameters;
  30566. private _opacityFresnelParameters;
  30567. /**
  30568. * Define the opacity fresnel parameters of the material.
  30569. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30570. */
  30571. opacityFresnelParameters: FresnelParameters;
  30572. private _reflectionFresnelParameters;
  30573. /**
  30574. * Define the reflection fresnel parameters of the material.
  30575. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30576. */
  30577. reflectionFresnelParameters: FresnelParameters;
  30578. private _refractionFresnelParameters;
  30579. /**
  30580. * Define the refraction fresnel parameters of the material.
  30581. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30582. */
  30583. refractionFresnelParameters: FresnelParameters;
  30584. private _emissiveFresnelParameters;
  30585. /**
  30586. * Define the emissive fresnel parameters of the material.
  30587. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30588. */
  30589. emissiveFresnelParameters: FresnelParameters;
  30590. private _useReflectionFresnelFromSpecular;
  30591. /**
  30592. * If true automatically deducts the fresnels values from the material specularity.
  30593. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30594. */
  30595. useReflectionFresnelFromSpecular: boolean;
  30596. private _useGlossinessFromSpecularMapAlpha;
  30597. /**
  30598. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  30599. */
  30600. useGlossinessFromSpecularMapAlpha: boolean;
  30601. private _maxSimultaneousLights;
  30602. /**
  30603. * Defines the maximum number of lights that can be used in the material
  30604. */
  30605. maxSimultaneousLights: number;
  30606. private _invertNormalMapX;
  30607. /**
  30608. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  30609. */
  30610. invertNormalMapX: boolean;
  30611. private _invertNormalMapY;
  30612. /**
  30613. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  30614. */
  30615. invertNormalMapY: boolean;
  30616. private _twoSidedLighting;
  30617. /**
  30618. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  30619. */
  30620. twoSidedLighting: boolean;
  30621. /**
  30622. * Default configuration related to image processing available in the standard Material.
  30623. */
  30624. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  30625. /**
  30626. * Gets the image processing configuration used either in this material.
  30627. */
  30628. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  30629. /**
  30630. * Sets the Default image processing configuration used either in the this material.
  30631. *
  30632. * If sets to null, the scene one is in use.
  30633. */
  30634. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  30635. /**
  30636. * Keep track of the image processing observer to allow dispose and replace.
  30637. */
  30638. private _imageProcessingObserver;
  30639. /**
  30640. * Attaches a new image processing configuration to the Standard Material.
  30641. * @param configuration
  30642. */
  30643. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  30644. /**
  30645. * Gets wether the color curves effect is enabled.
  30646. */
  30647. get cameraColorCurvesEnabled(): boolean;
  30648. /**
  30649. * Sets wether the color curves effect is enabled.
  30650. */
  30651. set cameraColorCurvesEnabled(value: boolean);
  30652. /**
  30653. * Gets wether the color grading effect is enabled.
  30654. */
  30655. get cameraColorGradingEnabled(): boolean;
  30656. /**
  30657. * Gets wether the color grading effect is enabled.
  30658. */
  30659. set cameraColorGradingEnabled(value: boolean);
  30660. /**
  30661. * Gets wether tonemapping is enabled or not.
  30662. */
  30663. get cameraToneMappingEnabled(): boolean;
  30664. /**
  30665. * Sets wether tonemapping is enabled or not
  30666. */
  30667. set cameraToneMappingEnabled(value: boolean);
  30668. /**
  30669. * The camera exposure used on this material.
  30670. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  30671. * This corresponds to a photographic exposure.
  30672. */
  30673. get cameraExposure(): number;
  30674. /**
  30675. * The camera exposure used on this material.
  30676. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  30677. * This corresponds to a photographic exposure.
  30678. */
  30679. set cameraExposure(value: number);
  30680. /**
  30681. * Gets The camera contrast used on this material.
  30682. */
  30683. get cameraContrast(): number;
  30684. /**
  30685. * Sets The camera contrast used on this material.
  30686. */
  30687. set cameraContrast(value: number);
  30688. /**
  30689. * Gets the Color Grading 2D Lookup Texture.
  30690. */
  30691. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  30692. /**
  30693. * Sets the Color Grading 2D Lookup Texture.
  30694. */
  30695. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  30696. /**
  30697. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  30698. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  30699. * 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;
  30700. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  30701. */
  30702. get cameraColorCurves(): Nullable<ColorCurves>;
  30703. /**
  30704. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  30705. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  30706. * 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;
  30707. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  30708. */
  30709. set cameraColorCurves(value: Nullable<ColorCurves>);
  30710. protected _renderTargets: SmartArray<RenderTargetTexture>;
  30711. protected _worldViewProjectionMatrix: Matrix;
  30712. protected _globalAmbientColor: Color3;
  30713. protected _useLogarithmicDepth: boolean;
  30714. protected _rebuildInParallel: boolean;
  30715. /**
  30716. * Instantiates a new standard material.
  30717. * This is the default material used in Babylon. It is the best trade off between quality
  30718. * and performances.
  30719. * @see http://doc.babylonjs.com/babylon101/materials
  30720. * @param name Define the name of the material in the scene
  30721. * @param scene Define the scene the material belong to
  30722. */
  30723. constructor(name: string, scene: Scene);
  30724. /**
  30725. * Gets a boolean indicating that current material needs to register RTT
  30726. */
  30727. get hasRenderTargetTextures(): boolean;
  30728. /**
  30729. * Gets the current class name of the material e.g. "StandardMaterial"
  30730. * Mainly use in serialization.
  30731. * @returns the class name
  30732. */
  30733. getClassName(): string;
  30734. /**
  30735. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  30736. * You can try switching to logarithmic depth.
  30737. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  30738. */
  30739. get useLogarithmicDepth(): boolean;
  30740. set useLogarithmicDepth(value: boolean);
  30741. /**
  30742. * Specifies if the material will require alpha blending
  30743. * @returns a boolean specifying if alpha blending is needed
  30744. */
  30745. needAlphaBlending(): boolean;
  30746. /**
  30747. * Specifies if this material should be rendered in alpha test mode
  30748. * @returns a boolean specifying if an alpha test is needed.
  30749. */
  30750. needAlphaTesting(): boolean;
  30751. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  30752. /**
  30753. * Get the texture used for alpha test purpose.
  30754. * @returns the diffuse texture in case of the standard material.
  30755. */
  30756. getAlphaTestTexture(): Nullable<BaseTexture>;
  30757. /**
  30758. * Get if the submesh is ready to be used and all its information available.
  30759. * Child classes can use it to update shaders
  30760. * @param mesh defines the mesh to check
  30761. * @param subMesh defines which submesh to check
  30762. * @param useInstances specifies that instances should be used
  30763. * @returns a boolean indicating that the submesh is ready or not
  30764. */
  30765. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  30766. /**
  30767. * Builds the material UBO layouts.
  30768. * Used internally during the effect preparation.
  30769. */
  30770. buildUniformLayout(): void;
  30771. /**
  30772. * Unbinds the material from the mesh
  30773. */
  30774. unbind(): void;
  30775. /**
  30776. * Binds the submesh to this material by preparing the effect and shader to draw
  30777. * @param world defines the world transformation matrix
  30778. * @param mesh defines the mesh containing the submesh
  30779. * @param subMesh defines the submesh to bind the material to
  30780. */
  30781. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  30782. /**
  30783. * Get the list of animatables in the material.
  30784. * @returns the list of animatables object used in the material
  30785. */
  30786. getAnimatables(): IAnimatable[];
  30787. /**
  30788. * Gets the active textures from the material
  30789. * @returns an array of textures
  30790. */
  30791. getActiveTextures(): BaseTexture[];
  30792. /**
  30793. * Specifies if the material uses a texture
  30794. * @param texture defines the texture to check against the material
  30795. * @returns a boolean specifying if the material uses the texture
  30796. */
  30797. hasTexture(texture: BaseTexture): boolean;
  30798. /**
  30799. * Disposes the material
  30800. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  30801. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  30802. */
  30803. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  30804. /**
  30805. * Makes a duplicate of the material, and gives it a new name
  30806. * @param name defines the new name for the duplicated material
  30807. * @returns the cloned material
  30808. */
  30809. clone(name: string): StandardMaterial;
  30810. /**
  30811. * Serializes this material in a JSON representation
  30812. * @returns the serialized material object
  30813. */
  30814. serialize(): any;
  30815. /**
  30816. * Creates a standard material from parsed material data
  30817. * @param source defines the JSON representation of the material
  30818. * @param scene defines the hosting scene
  30819. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  30820. * @returns a new standard material
  30821. */
  30822. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  30823. /**
  30824. * Are diffuse textures enabled in the application.
  30825. */
  30826. static get DiffuseTextureEnabled(): boolean;
  30827. static set DiffuseTextureEnabled(value: boolean);
  30828. /**
  30829. * Are ambient textures enabled in the application.
  30830. */
  30831. static get AmbientTextureEnabled(): boolean;
  30832. static set AmbientTextureEnabled(value: boolean);
  30833. /**
  30834. * Are opacity textures enabled in the application.
  30835. */
  30836. static get OpacityTextureEnabled(): boolean;
  30837. static set OpacityTextureEnabled(value: boolean);
  30838. /**
  30839. * Are reflection textures enabled in the application.
  30840. */
  30841. static get ReflectionTextureEnabled(): boolean;
  30842. static set ReflectionTextureEnabled(value: boolean);
  30843. /**
  30844. * Are emissive textures enabled in the application.
  30845. */
  30846. static get EmissiveTextureEnabled(): boolean;
  30847. static set EmissiveTextureEnabled(value: boolean);
  30848. /**
  30849. * Are specular textures enabled in the application.
  30850. */
  30851. static get SpecularTextureEnabled(): boolean;
  30852. static set SpecularTextureEnabled(value: boolean);
  30853. /**
  30854. * Are bump textures enabled in the application.
  30855. */
  30856. static get BumpTextureEnabled(): boolean;
  30857. static set BumpTextureEnabled(value: boolean);
  30858. /**
  30859. * Are lightmap textures enabled in the application.
  30860. */
  30861. static get LightmapTextureEnabled(): boolean;
  30862. static set LightmapTextureEnabled(value: boolean);
  30863. /**
  30864. * Are refraction textures enabled in the application.
  30865. */
  30866. static get RefractionTextureEnabled(): boolean;
  30867. static set RefractionTextureEnabled(value: boolean);
  30868. /**
  30869. * Are color grading textures enabled in the application.
  30870. */
  30871. static get ColorGradingTextureEnabled(): boolean;
  30872. static set ColorGradingTextureEnabled(value: boolean);
  30873. /**
  30874. * Are fresnels enabled in the application.
  30875. */
  30876. static get FresnelEnabled(): boolean;
  30877. static set FresnelEnabled(value: boolean);
  30878. }
  30879. }
  30880. declare module "babylonjs/Particles/solidParticleSystem" {
  30881. import { Nullable } from "babylonjs/types";
  30882. import { Mesh } from "babylonjs/Meshes/mesh";
  30883. import { Scene, IDisposable } from "babylonjs/scene";
  30884. import { DepthSortedParticle, SolidParticle, SolidParticleVertex } from "babylonjs/Particles/solidParticle";
  30885. import { Material } from "babylonjs/Materials/material";
  30886. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  30887. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  30888. /**
  30889. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  30890. *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.
  30891. * The SPS is also a particle system. It provides some methods to manage the particles.
  30892. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  30893. *
  30894. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  30895. */
  30896. export class SolidParticleSystem implements IDisposable {
  30897. /**
  30898. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  30899. * Example : var p = SPS.particles[i];
  30900. */
  30901. particles: SolidParticle[];
  30902. /**
  30903. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  30904. */
  30905. nbParticles: number;
  30906. /**
  30907. * If the particles must ever face the camera (default false). Useful for planar particles.
  30908. */
  30909. billboard: boolean;
  30910. /**
  30911. * Recompute normals when adding a shape
  30912. */
  30913. recomputeNormals: boolean;
  30914. /**
  30915. * This a counter ofr your own usage. It's not set by any SPS functions.
  30916. */
  30917. counter: number;
  30918. /**
  30919. * The SPS name. This name is also given to the underlying mesh.
  30920. */
  30921. name: string;
  30922. /**
  30923. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  30924. */
  30925. mesh: Mesh;
  30926. /**
  30927. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  30928. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  30929. */
  30930. vars: any;
  30931. /**
  30932. * This array is populated when the SPS is set as 'pickable'.
  30933. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  30934. * Each element of this array is an object `{idx: int, faceId: int}`.
  30935. * `idx` is the picked particle index in the `SPS.particles` array
  30936. * `faceId` is the picked face index counted within this particle.
  30937. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  30938. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  30939. * Use the method SPS.pickedParticle(pickingInfo) instead.
  30940. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  30941. */
  30942. pickedParticles: {
  30943. idx: number;
  30944. faceId: number;
  30945. }[];
  30946. /**
  30947. * This array is populated when the SPS is set as 'pickable'
  30948. * Each key of this array is a submesh index.
  30949. * Each element of this array is a second array defined like this :
  30950. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  30951. * Each element of this second array is an object `{idx: int, faceId: int}`.
  30952. * `idx` is the picked particle index in the `SPS.particles` array
  30953. * `faceId` is the picked face index counted within this particle.
  30954. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  30955. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  30956. */
  30957. pickedBySubMesh: {
  30958. idx: number;
  30959. faceId: number;
  30960. }[][];
  30961. /**
  30962. * This array is populated when `enableDepthSort` is set to true.
  30963. * Each element of this array is an instance of the class DepthSortedParticle.
  30964. */
  30965. depthSortedParticles: DepthSortedParticle[];
  30966. /**
  30967. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  30968. * @hidden
  30969. */
  30970. _bSphereOnly: boolean;
  30971. /**
  30972. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  30973. * @hidden
  30974. */
  30975. _bSphereRadiusFactor: number;
  30976. private _scene;
  30977. private _positions;
  30978. private _indices;
  30979. private _normals;
  30980. private _colors;
  30981. private _uvs;
  30982. private _indices32;
  30983. private _positions32;
  30984. private _normals32;
  30985. private _fixedNormal32;
  30986. private _colors32;
  30987. private _uvs32;
  30988. private _index;
  30989. private _updatable;
  30990. private _pickable;
  30991. private _isVisibilityBoxLocked;
  30992. private _alwaysVisible;
  30993. private _depthSort;
  30994. private _expandable;
  30995. private _shapeCounter;
  30996. private _copy;
  30997. private _color;
  30998. private _computeParticleColor;
  30999. private _computeParticleTexture;
  31000. private _computeParticleRotation;
  31001. private _computeParticleVertex;
  31002. private _computeBoundingBox;
  31003. private _depthSortParticles;
  31004. private _camera;
  31005. private _mustUnrotateFixedNormals;
  31006. private _particlesIntersect;
  31007. private _needs32Bits;
  31008. private _isNotBuilt;
  31009. private _lastParticleId;
  31010. private _idxOfId;
  31011. private _multimaterialEnabled;
  31012. private _useModelMaterial;
  31013. private _indicesByMaterial;
  31014. private _materialIndexes;
  31015. private _depthSortFunction;
  31016. private _materialSortFunction;
  31017. private _materials;
  31018. private _multimaterial;
  31019. private _materialIndexesById;
  31020. private _defaultMaterial;
  31021. private _autoUpdateSubMeshes;
  31022. private _tmpVertex;
  31023. /**
  31024. * Creates a SPS (Solid Particle System) object.
  31025. * @param name (String) is the SPS name, this will be the underlying mesh name.
  31026. * @param scene (Scene) is the scene in which the SPS is added.
  31027. * @param options defines the options of the sps e.g.
  31028. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  31029. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  31030. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  31031. * * 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.
  31032. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  31033. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  31034. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  31035. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  31036. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  31037. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  31038. */
  31039. constructor(name: string, scene: Scene, options?: {
  31040. updatable?: boolean;
  31041. isPickable?: boolean;
  31042. enableDepthSort?: boolean;
  31043. particleIntersection?: boolean;
  31044. boundingSphereOnly?: boolean;
  31045. bSphereRadiusFactor?: number;
  31046. expandable?: boolean;
  31047. useModelMaterial?: boolean;
  31048. enableMultiMaterial?: boolean;
  31049. });
  31050. /**
  31051. * Builds the SPS underlying mesh. Returns a standard Mesh.
  31052. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  31053. * @returns the created mesh
  31054. */
  31055. buildMesh(): Mesh;
  31056. /**
  31057. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  31058. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  31059. * Thus the particles generated from `digest()` have their property `position` set yet.
  31060. * @param mesh ( Mesh ) is the mesh to be digested
  31061. * @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
  31062. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  31063. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  31064. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  31065. * @returns the current SPS
  31066. */
  31067. digest(mesh: Mesh, options?: {
  31068. facetNb?: number;
  31069. number?: number;
  31070. delta?: number;
  31071. storage?: [];
  31072. }): SolidParticleSystem;
  31073. /**
  31074. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  31075. * @hidden
  31076. */
  31077. private _unrotateFixedNormals;
  31078. /**
  31079. * Resets the temporary working copy particle
  31080. * @hidden
  31081. */
  31082. private _resetCopy;
  31083. /**
  31084. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  31085. * @param p the current index in the positions array to be updated
  31086. * @param ind the current index in the indices array
  31087. * @param shape a Vector3 array, the shape geometry
  31088. * @param positions the positions array to be updated
  31089. * @param meshInd the shape indices array
  31090. * @param indices the indices array to be updated
  31091. * @param meshUV the shape uv array
  31092. * @param uvs the uv array to be updated
  31093. * @param meshCol the shape color array
  31094. * @param colors the color array to be updated
  31095. * @param meshNor the shape normals array
  31096. * @param normals the normals array to be updated
  31097. * @param idx the particle index
  31098. * @param idxInShape the particle index in its shape
  31099. * @param options the addShape() method passed options
  31100. * @model the particle model
  31101. * @hidden
  31102. */
  31103. private _meshBuilder;
  31104. /**
  31105. * Returns a shape Vector3 array from positions float array
  31106. * @param positions float array
  31107. * @returns a vector3 array
  31108. * @hidden
  31109. */
  31110. private _posToShape;
  31111. /**
  31112. * Returns a shapeUV array from a float uvs (array deep copy)
  31113. * @param uvs as a float array
  31114. * @returns a shapeUV array
  31115. * @hidden
  31116. */
  31117. private _uvsToShapeUV;
  31118. /**
  31119. * Adds a new particle object in the particles array
  31120. * @param idx particle index in particles array
  31121. * @param id particle id
  31122. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  31123. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  31124. * @param model particle ModelShape object
  31125. * @param shapeId model shape identifier
  31126. * @param idxInShape index of the particle in the current model
  31127. * @param bInfo model bounding info object
  31128. * @param storage target storage array, if any
  31129. * @hidden
  31130. */
  31131. private _addParticle;
  31132. /**
  31133. * Adds some particles to the SPS from the model shape. Returns the shape id.
  31134. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  31135. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  31136. * @param nb (positive integer) the number of particles to be created from this model
  31137. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  31138. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  31139. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  31140. * @returns the number of shapes in the system
  31141. */
  31142. addShape(mesh: Mesh, nb: number, options?: {
  31143. positionFunction?: any;
  31144. vertexFunction?: any;
  31145. storage?: [];
  31146. }): number;
  31147. /**
  31148. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  31149. * @hidden
  31150. */
  31151. private _rebuildParticle;
  31152. /**
  31153. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  31154. * @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.
  31155. * @returns the SPS.
  31156. */
  31157. rebuildMesh(reset?: boolean): SolidParticleSystem;
  31158. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  31159. * Returns an array with the removed particles.
  31160. * 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.
  31161. * The SPS can't be empty so at least one particle needs to remain in place.
  31162. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  31163. * @param start index of the first particle to remove
  31164. * @param end index of the last particle to remove (included)
  31165. * @returns an array populated with the removed particles
  31166. */
  31167. removeParticles(start: number, end: number): SolidParticle[];
  31168. /**
  31169. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  31170. * @param solidParticleArray an array populated with Solid Particles objects
  31171. * @returns the SPS
  31172. */
  31173. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  31174. /**
  31175. * Creates a new particle and modifies the SPS mesh geometry :
  31176. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  31177. * - calls _addParticle() to populate the particle array
  31178. * factorized code from addShape() and insertParticlesFromArray()
  31179. * @param idx particle index in the particles array
  31180. * @param i particle index in its shape
  31181. * @param modelShape particle ModelShape object
  31182. * @param shape shape vertex array
  31183. * @param meshInd shape indices array
  31184. * @param meshUV shape uv array
  31185. * @param meshCol shape color array
  31186. * @param meshNor shape normals array
  31187. * @param bbInfo shape bounding info
  31188. * @param storage target particle storage
  31189. * @options addShape() passed options
  31190. * @hidden
  31191. */
  31192. private _insertNewParticle;
  31193. /**
  31194. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  31195. * This method calls `updateParticle()` for each particle of the SPS.
  31196. * For an animated SPS, it is usually called within the render loop.
  31197. * 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.
  31198. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  31199. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  31200. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  31201. * @returns the SPS.
  31202. */
  31203. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  31204. /**
  31205. * Disposes the SPS.
  31206. */
  31207. dispose(): void;
  31208. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  31209. * idx is the particle index in the SPS
  31210. * faceId is the picked face index counted within this particle.
  31211. * Returns null if the pickInfo can't identify a picked particle.
  31212. * @param pickingInfo (PickingInfo object)
  31213. * @returns {idx: number, faceId: number} or null
  31214. */
  31215. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  31216. idx: number;
  31217. faceId: number;
  31218. }>;
  31219. /**
  31220. * Returns a SolidParticle object from its identifier : particle.id
  31221. * @param id (integer) the particle Id
  31222. * @returns the searched particle or null if not found in the SPS.
  31223. */
  31224. getParticleById(id: number): Nullable<SolidParticle>;
  31225. /**
  31226. * Returns a new array populated with the particles having the passed shapeId.
  31227. * @param shapeId (integer) the shape identifier
  31228. * @returns a new solid particle array
  31229. */
  31230. getParticlesByShapeId(shapeId: number): SolidParticle[];
  31231. /**
  31232. * Populates the passed array "ref" with the particles having the passed shapeId.
  31233. * @param shapeId the shape identifier
  31234. * @returns the SPS
  31235. * @param ref
  31236. */
  31237. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  31238. /**
  31239. * Computes the required SubMeshes according the materials assigned to the particles.
  31240. * @returns the solid particle system.
  31241. * Does nothing if called before the SPS mesh is built.
  31242. */
  31243. computeSubMeshes(): SolidParticleSystem;
  31244. /**
  31245. * Sorts the solid particles by material when MultiMaterial is enabled.
  31246. * Updates the indices32 array.
  31247. * Updates the indicesByMaterial array.
  31248. * Updates the mesh indices array.
  31249. * @returns the SPS
  31250. * @hidden
  31251. */
  31252. private _sortParticlesByMaterial;
  31253. /**
  31254. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  31255. * @hidden
  31256. */
  31257. private _setMaterialIndexesById;
  31258. /**
  31259. * Returns an array with unique values of Materials from the passed array
  31260. * @param array the material array to be checked and filtered
  31261. * @hidden
  31262. */
  31263. private _filterUniqueMaterialId;
  31264. /**
  31265. * Sets a new Standard Material as _defaultMaterial if not already set.
  31266. * @hidden
  31267. */
  31268. private _setDefaultMaterial;
  31269. /**
  31270. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  31271. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31272. * @returns the SPS.
  31273. */
  31274. refreshVisibleSize(): SolidParticleSystem;
  31275. /**
  31276. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  31277. * @param size the size (float) of the visibility box
  31278. * note : this doesn't lock the SPS mesh bounding box.
  31279. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31280. */
  31281. setVisibilityBox(size: number): void;
  31282. /**
  31283. * Gets whether the SPS as always visible or not
  31284. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31285. */
  31286. get isAlwaysVisible(): boolean;
  31287. /**
  31288. * Sets the SPS as always visible or not
  31289. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31290. */
  31291. set isAlwaysVisible(val: boolean);
  31292. /**
  31293. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  31294. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31295. */
  31296. set isVisibilityBoxLocked(val: boolean);
  31297. /**
  31298. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  31299. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31300. */
  31301. get isVisibilityBoxLocked(): boolean;
  31302. /**
  31303. * Tells to `setParticles()` to compute the particle rotations or not.
  31304. * Default value : true. The SPS is faster when it's set to false.
  31305. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  31306. */
  31307. set computeParticleRotation(val: boolean);
  31308. /**
  31309. * Tells to `setParticles()` to compute the particle colors or not.
  31310. * Default value : true. The SPS is faster when it's set to false.
  31311. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  31312. */
  31313. set computeParticleColor(val: boolean);
  31314. set computeParticleTexture(val: boolean);
  31315. /**
  31316. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  31317. * Default value : false. The SPS is faster when it's set to false.
  31318. * Note : the particle custom vertex positions aren't stored values.
  31319. */
  31320. set computeParticleVertex(val: boolean);
  31321. /**
  31322. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  31323. */
  31324. set computeBoundingBox(val: boolean);
  31325. /**
  31326. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  31327. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  31328. * Default : `true`
  31329. */
  31330. set depthSortParticles(val: boolean);
  31331. /**
  31332. * Gets if `setParticles()` computes the particle rotations or not.
  31333. * Default value : true. The SPS is faster when it's set to false.
  31334. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  31335. */
  31336. get computeParticleRotation(): boolean;
  31337. /**
  31338. * Gets if `setParticles()` computes the particle colors or not.
  31339. * Default value : true. The SPS is faster when it's set to false.
  31340. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  31341. */
  31342. get computeParticleColor(): boolean;
  31343. /**
  31344. * Gets if `setParticles()` computes the particle textures or not.
  31345. * Default value : true. The SPS is faster when it's set to false.
  31346. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  31347. */
  31348. get computeParticleTexture(): boolean;
  31349. /**
  31350. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  31351. * Default value : false. The SPS is faster when it's set to false.
  31352. * Note : the particle custom vertex positions aren't stored values.
  31353. */
  31354. get computeParticleVertex(): boolean;
  31355. /**
  31356. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  31357. */
  31358. get computeBoundingBox(): boolean;
  31359. /**
  31360. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  31361. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  31362. * Default : `true`
  31363. */
  31364. get depthSortParticles(): boolean;
  31365. /**
  31366. * Gets if the SPS is created as expandable at construction time.
  31367. * Default : `false`
  31368. */
  31369. get expandable(): boolean;
  31370. /**
  31371. * Gets if the SPS supports the Multi Materials
  31372. */
  31373. get multimaterialEnabled(): boolean;
  31374. /**
  31375. * Gets if the SPS uses the model materials for its own multimaterial.
  31376. */
  31377. get useModelMaterial(): boolean;
  31378. /**
  31379. * The SPS used material array.
  31380. */
  31381. get materials(): Material[];
  31382. /**
  31383. * Sets the SPS MultiMaterial from the passed materials.
  31384. * Note : the passed array is internally copied and not used then by reference.
  31385. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  31386. */
  31387. setMultiMaterial(materials: Material[]): void;
  31388. /**
  31389. * The SPS computed multimaterial object
  31390. */
  31391. get multimaterial(): MultiMaterial;
  31392. set multimaterial(mm: MultiMaterial);
  31393. /**
  31394. * If the subMeshes must be updated on the next call to setParticles()
  31395. */
  31396. get autoUpdateSubMeshes(): boolean;
  31397. set autoUpdateSubMeshes(val: boolean);
  31398. /**
  31399. * This function does nothing. It may be overwritten to set all the particle first values.
  31400. * The SPS doesn't call this function, you may have to call it by your own.
  31401. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  31402. */
  31403. initParticles(): void;
  31404. /**
  31405. * This function does nothing. It may be overwritten to recycle a particle.
  31406. * The SPS doesn't call this function, you may have to call it by your own.
  31407. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  31408. * @param particle The particle to recycle
  31409. * @returns the recycled particle
  31410. */
  31411. recycleParticle(particle: SolidParticle): SolidParticle;
  31412. /**
  31413. * Updates a particle : this function should be overwritten by the user.
  31414. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  31415. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  31416. * @example : just set a particle position or velocity and recycle conditions
  31417. * @param particle The particle to update
  31418. * @returns the updated particle
  31419. */
  31420. updateParticle(particle: SolidParticle): SolidParticle;
  31421. /**
  31422. * Updates a vertex of a particle : it can be overwritten by the user.
  31423. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  31424. * @param particle the current particle
  31425. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  31426. * @param pt the index of the current vertex in the particle shape
  31427. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  31428. * @example : just set a vertex particle position or color
  31429. * @returns the sps
  31430. */
  31431. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  31432. /**
  31433. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  31434. * This does nothing and may be overwritten by the user.
  31435. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31436. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31437. * @param update the boolean update value actually passed to setParticles()
  31438. */
  31439. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  31440. /**
  31441. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  31442. * This will be passed three parameters.
  31443. * This does nothing and may be overwritten by the user.
  31444. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31445. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31446. * @param update the boolean update value actually passed to setParticles()
  31447. */
  31448. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  31449. }
  31450. }
  31451. declare module "babylonjs/Particles/solidParticle" {
  31452. import { Nullable } from "babylonjs/types";
  31453. import { Vector3, Matrix, Quaternion, Vector4, Vector2 } from "babylonjs/Maths/math.vector";
  31454. import { Color4 } from "babylonjs/Maths/math.color";
  31455. import { Mesh } from "babylonjs/Meshes/mesh";
  31456. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  31457. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  31458. import { Plane } from "babylonjs/Maths/math.plane";
  31459. import { Material } from "babylonjs/Materials/material";
  31460. /**
  31461. * Represents one particle of a solid particle system.
  31462. */
  31463. export class SolidParticle {
  31464. /**
  31465. * particle global index
  31466. */
  31467. idx: number;
  31468. /**
  31469. * particle identifier
  31470. */
  31471. id: number;
  31472. /**
  31473. * The color of the particle
  31474. */
  31475. color: Nullable<Color4>;
  31476. /**
  31477. * The world space position of the particle.
  31478. */
  31479. position: Vector3;
  31480. /**
  31481. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  31482. */
  31483. rotation: Vector3;
  31484. /**
  31485. * The world space rotation quaternion of the particle.
  31486. */
  31487. rotationQuaternion: Nullable<Quaternion>;
  31488. /**
  31489. * The scaling of the particle.
  31490. */
  31491. scaling: Vector3;
  31492. /**
  31493. * The uvs of the particle.
  31494. */
  31495. uvs: Vector4;
  31496. /**
  31497. * The current speed of the particle.
  31498. */
  31499. velocity: Vector3;
  31500. /**
  31501. * The pivot point in the particle local space.
  31502. */
  31503. pivot: Vector3;
  31504. /**
  31505. * Must the particle be translated from its pivot point in its local space ?
  31506. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  31507. * Default : false
  31508. */
  31509. translateFromPivot: boolean;
  31510. /**
  31511. * Is the particle active or not ?
  31512. */
  31513. alive: boolean;
  31514. /**
  31515. * Is the particle visible or not ?
  31516. */
  31517. isVisible: boolean;
  31518. /**
  31519. * Index of this particle in the global "positions" array (Internal use)
  31520. * @hidden
  31521. */
  31522. _pos: number;
  31523. /**
  31524. * @hidden Index of this particle in the global "indices" array (Internal use)
  31525. */
  31526. _ind: number;
  31527. /**
  31528. * @hidden ModelShape of this particle (Internal use)
  31529. */
  31530. _model: ModelShape;
  31531. /**
  31532. * ModelShape id of this particle
  31533. */
  31534. shapeId: number;
  31535. /**
  31536. * Index of the particle in its shape id
  31537. */
  31538. idxInShape: number;
  31539. /**
  31540. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  31541. */
  31542. _modelBoundingInfo: BoundingInfo;
  31543. /**
  31544. * @hidden Particle BoundingInfo object (Internal use)
  31545. */
  31546. _boundingInfo: BoundingInfo;
  31547. /**
  31548. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  31549. */
  31550. _sps: SolidParticleSystem;
  31551. /**
  31552. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  31553. */
  31554. _stillInvisible: boolean;
  31555. /**
  31556. * @hidden Last computed particle rotation matrix
  31557. */
  31558. _rotationMatrix: number[];
  31559. /**
  31560. * Parent particle Id, if any.
  31561. * Default null.
  31562. */
  31563. parentId: Nullable<number>;
  31564. /**
  31565. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  31566. */
  31567. materialIndex: Nullable<number>;
  31568. /**
  31569. * Custom object or properties.
  31570. */
  31571. props: Nullable<any>;
  31572. /**
  31573. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  31574. * The possible values are :
  31575. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  31576. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  31577. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  31578. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  31579. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  31580. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  31581. * */
  31582. cullingStrategy: number;
  31583. /**
  31584. * @hidden Internal global position in the SPS.
  31585. */
  31586. _globalPosition: Vector3;
  31587. /**
  31588. * Creates a Solid Particle object.
  31589. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  31590. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  31591. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  31592. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  31593. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  31594. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  31595. * @param shapeId (integer) is the model shape identifier in the SPS.
  31596. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  31597. * @param sps defines the sps it is associated to
  31598. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  31599. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  31600. */
  31601. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  31602. /**
  31603. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  31604. * @param target the particle target
  31605. * @returns the current particle
  31606. */
  31607. copyToRef(target: SolidParticle): SolidParticle;
  31608. /**
  31609. * Legacy support, changed scale to scaling
  31610. */
  31611. get scale(): Vector3;
  31612. /**
  31613. * Legacy support, changed scale to scaling
  31614. */
  31615. set scale(scale: Vector3);
  31616. /**
  31617. * Legacy support, changed quaternion to rotationQuaternion
  31618. */
  31619. get quaternion(): Nullable<Quaternion>;
  31620. /**
  31621. * Legacy support, changed quaternion to rotationQuaternion
  31622. */
  31623. set quaternion(q: Nullable<Quaternion>);
  31624. /**
  31625. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  31626. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  31627. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  31628. * @returns true if it intersects
  31629. */
  31630. intersectsMesh(target: Mesh | SolidParticle): boolean;
  31631. /**
  31632. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  31633. * A particle is in the frustum if its bounding box intersects the frustum
  31634. * @param frustumPlanes defines the frustum to test
  31635. * @returns true if the particle is in the frustum planes
  31636. */
  31637. isInFrustum(frustumPlanes: Plane[]): boolean;
  31638. /**
  31639. * get the rotation matrix of the particle
  31640. * @hidden
  31641. */
  31642. getRotationMatrix(m: Matrix): void;
  31643. }
  31644. /**
  31645. * Represents the shape of the model used by one particle of a solid particle system.
  31646. * SPS internal tool, don't use it manually.
  31647. */
  31648. export class ModelShape {
  31649. /**
  31650. * The shape id
  31651. * @hidden
  31652. */
  31653. shapeID: number;
  31654. /**
  31655. * flat array of model positions (internal use)
  31656. * @hidden
  31657. */
  31658. _shape: Vector3[];
  31659. /**
  31660. * flat array of model UVs (internal use)
  31661. * @hidden
  31662. */
  31663. _shapeUV: number[];
  31664. /**
  31665. * color array of the model
  31666. * @hidden
  31667. */
  31668. _shapeColors: number[];
  31669. /**
  31670. * indices array of the model
  31671. * @hidden
  31672. */
  31673. _indices: number[];
  31674. /**
  31675. * normals array of the model
  31676. * @hidden
  31677. */
  31678. _normals: number[];
  31679. /**
  31680. * length of the shape in the model indices array (internal use)
  31681. * @hidden
  31682. */
  31683. _indicesLength: number;
  31684. /**
  31685. * Custom position function (internal use)
  31686. * @hidden
  31687. */
  31688. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  31689. /**
  31690. * Custom vertex function (internal use)
  31691. * @hidden
  31692. */
  31693. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  31694. /**
  31695. * Model material (internal use)
  31696. * @hidden
  31697. */
  31698. _material: Nullable<Material>;
  31699. /**
  31700. * 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.
  31701. * SPS internal tool, don't use it manually.
  31702. * @hidden
  31703. */
  31704. 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>);
  31705. }
  31706. /**
  31707. * Represents a Depth Sorted Particle in the solid particle system.
  31708. * @hidden
  31709. */
  31710. export class DepthSortedParticle {
  31711. /**
  31712. * Particle index
  31713. */
  31714. idx: number;
  31715. /**
  31716. * Index of the particle in the "indices" array
  31717. */
  31718. ind: number;
  31719. /**
  31720. * Length of the particle shape in the "indices" array
  31721. */
  31722. indicesLength: number;
  31723. /**
  31724. * Squared distance from the particle to the camera
  31725. */
  31726. sqDistance: number;
  31727. /**
  31728. * Material index when used with MultiMaterials
  31729. */
  31730. materialIndex: number;
  31731. /**
  31732. * Creates a new sorted particle
  31733. * @param materialIndex
  31734. */
  31735. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  31736. }
  31737. /**
  31738. * Represents a solid particle vertex
  31739. */
  31740. export class SolidParticleVertex {
  31741. /**
  31742. * Vertex position
  31743. */
  31744. position: Vector3;
  31745. /**
  31746. * Vertex color
  31747. */
  31748. color: Color4;
  31749. /**
  31750. * Vertex UV
  31751. */
  31752. uv: Vector2;
  31753. /**
  31754. * Creates a new solid particle vertex
  31755. */
  31756. constructor();
  31757. /** Vertex x coordinate */
  31758. get x(): number;
  31759. set x(val: number);
  31760. /** Vertex y coordinate */
  31761. get y(): number;
  31762. set y(val: number);
  31763. /** Vertex z coordinate */
  31764. get z(): number;
  31765. set z(val: number);
  31766. }
  31767. }
  31768. declare module "babylonjs/Collisions/meshCollisionData" {
  31769. import { Collider } from "babylonjs/Collisions/collider";
  31770. import { Vector3 } from "babylonjs/Maths/math.vector";
  31771. import { Nullable } from "babylonjs/types";
  31772. import { Observer } from "babylonjs/Misc/observable";
  31773. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31774. /**
  31775. * @hidden
  31776. */
  31777. export class _MeshCollisionData {
  31778. _checkCollisions: boolean;
  31779. _collisionMask: number;
  31780. _collisionGroup: number;
  31781. _surroundingMeshes: Nullable<AbstractMesh[]>;
  31782. _collider: Nullable<Collider>;
  31783. _oldPositionForCollisions: Vector3;
  31784. _diffPositionForCollisions: Vector3;
  31785. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  31786. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  31787. }
  31788. }
  31789. declare module "babylonjs/Meshes/abstractMesh" {
  31790. import { Observable } from "babylonjs/Misc/observable";
  31791. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  31792. import { Camera } from "babylonjs/Cameras/camera";
  31793. import { Scene, IDisposable } from "babylonjs/scene";
  31794. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  31795. import { Node } from "babylonjs/node";
  31796. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  31797. import { TransformNode } from "babylonjs/Meshes/transformNode";
  31798. import { SubMesh } from "babylonjs/Meshes/subMesh";
  31799. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  31800. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  31801. import { Material } from "babylonjs/Materials/material";
  31802. import { Light } from "babylonjs/Lights/light";
  31803. import { Skeleton } from "babylonjs/Bones/skeleton";
  31804. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  31805. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  31806. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  31807. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  31808. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  31809. import { Plane } from "babylonjs/Maths/math.plane";
  31810. import { Ray } from "babylonjs/Culling/ray";
  31811. import { Collider } from "babylonjs/Collisions/collider";
  31812. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  31813. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  31814. /** @hidden */
  31815. class _FacetDataStorage {
  31816. facetPositions: Vector3[];
  31817. facetNormals: Vector3[];
  31818. facetPartitioning: number[][];
  31819. facetNb: number;
  31820. partitioningSubdivisions: number;
  31821. partitioningBBoxRatio: number;
  31822. facetDataEnabled: boolean;
  31823. facetParameters: any;
  31824. bbSize: Vector3;
  31825. subDiv: {
  31826. max: number;
  31827. X: number;
  31828. Y: number;
  31829. Z: number;
  31830. };
  31831. facetDepthSort: boolean;
  31832. facetDepthSortEnabled: boolean;
  31833. depthSortedIndices: IndicesArray;
  31834. depthSortedFacets: {
  31835. ind: number;
  31836. sqDistance: number;
  31837. }[];
  31838. facetDepthSortFunction: (f1: {
  31839. ind: number;
  31840. sqDistance: number;
  31841. }, f2: {
  31842. ind: number;
  31843. sqDistance: number;
  31844. }) => number;
  31845. facetDepthSortFrom: Vector3;
  31846. facetDepthSortOrigin: Vector3;
  31847. invertedMatrix: Matrix;
  31848. }
  31849. /**
  31850. * @hidden
  31851. **/
  31852. class _InternalAbstractMeshDataInfo {
  31853. _hasVertexAlpha: boolean;
  31854. _useVertexColors: boolean;
  31855. _numBoneInfluencers: number;
  31856. _applyFog: boolean;
  31857. _receiveShadows: boolean;
  31858. _facetData: _FacetDataStorage;
  31859. _visibility: number;
  31860. _skeleton: Nullable<Skeleton>;
  31861. _layerMask: number;
  31862. _computeBonesUsingShaders: boolean;
  31863. _isActive: boolean;
  31864. _onlyForInstances: boolean;
  31865. _isActiveIntermediate: boolean;
  31866. _onlyForInstancesIntermediate: boolean;
  31867. _actAsRegularMesh: boolean;
  31868. }
  31869. /**
  31870. * Class used to store all common mesh properties
  31871. */
  31872. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  31873. /** No occlusion */
  31874. static OCCLUSION_TYPE_NONE: number;
  31875. /** Occlusion set to optimisitic */
  31876. static OCCLUSION_TYPE_OPTIMISTIC: number;
  31877. /** Occlusion set to strict */
  31878. static OCCLUSION_TYPE_STRICT: number;
  31879. /** Use an accurante occlusion algorithm */
  31880. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  31881. /** Use a conservative occlusion algorithm */
  31882. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  31883. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  31884. * Test order :
  31885. * Is the bounding sphere outside the frustum ?
  31886. * If not, are the bounding box vertices outside the frustum ?
  31887. * It not, then the cullable object is in the frustum.
  31888. */
  31889. static readonly CULLINGSTRATEGY_STANDARD: number;
  31890. /** Culling strategy : Bounding Sphere Only.
  31891. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  31892. * It's also less accurate than the standard because some not visible objects can still be selected.
  31893. * Test : is the bounding sphere outside the frustum ?
  31894. * If not, then the cullable object is in the frustum.
  31895. */
  31896. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  31897. /** Culling strategy : Optimistic Inclusion.
  31898. * This in an inclusion test first, then the standard exclusion test.
  31899. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  31900. * 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.
  31901. * Anyway, it's as accurate as the standard strategy.
  31902. * Test :
  31903. * Is the cullable object bounding sphere center in the frustum ?
  31904. * If not, apply the default culling strategy.
  31905. */
  31906. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  31907. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  31908. * This in an inclusion test first, then the bounding sphere only exclusion test.
  31909. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  31910. * 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.
  31911. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  31912. * Test :
  31913. * Is the cullable object bounding sphere center in the frustum ?
  31914. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  31915. */
  31916. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  31917. /**
  31918. * No billboard
  31919. */
  31920. static get BILLBOARDMODE_NONE(): number;
  31921. /** Billboard on X axis */
  31922. static get BILLBOARDMODE_X(): number;
  31923. /** Billboard on Y axis */
  31924. static get BILLBOARDMODE_Y(): number;
  31925. /** Billboard on Z axis */
  31926. static get BILLBOARDMODE_Z(): number;
  31927. /** Billboard on all axes */
  31928. static get BILLBOARDMODE_ALL(): number;
  31929. /** Billboard on using position instead of orientation */
  31930. static get BILLBOARDMODE_USE_POSITION(): number;
  31931. /** @hidden */
  31932. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  31933. /**
  31934. * The culling strategy to use to check whether the mesh must be rendered or not.
  31935. * This value can be changed at any time and will be used on the next render mesh selection.
  31936. * The possible values are :
  31937. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  31938. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  31939. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  31940. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  31941. * Please read each static variable documentation to get details about the culling process.
  31942. * */
  31943. cullingStrategy: number;
  31944. /**
  31945. * Gets the number of facets in the mesh
  31946. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  31947. */
  31948. get facetNb(): number;
  31949. /**
  31950. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  31951. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  31952. */
  31953. get partitioningSubdivisions(): number;
  31954. set partitioningSubdivisions(nb: number);
  31955. /**
  31956. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  31957. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  31958. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  31959. */
  31960. get partitioningBBoxRatio(): number;
  31961. set partitioningBBoxRatio(ratio: number);
  31962. /**
  31963. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  31964. * Works only for updatable meshes.
  31965. * Doesn't work with multi-materials
  31966. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  31967. */
  31968. get mustDepthSortFacets(): boolean;
  31969. set mustDepthSortFacets(sort: boolean);
  31970. /**
  31971. * The location (Vector3) where the facet depth sort must be computed from.
  31972. * By default, the active camera position.
  31973. * Used only when facet depth sort is enabled
  31974. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  31975. */
  31976. get facetDepthSortFrom(): Vector3;
  31977. set facetDepthSortFrom(location: Vector3);
  31978. /**
  31979. * gets a boolean indicating if facetData is enabled
  31980. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  31981. */
  31982. get isFacetDataEnabled(): boolean;
  31983. /** @hidden */
  31984. _updateNonUniformScalingState(value: boolean): boolean;
  31985. /**
  31986. * An event triggered when this mesh collides with another one
  31987. */
  31988. onCollideObservable: Observable<AbstractMesh>;
  31989. /** Set a function to call when this mesh collides with another one */
  31990. set onCollide(callback: () => void);
  31991. /**
  31992. * An event triggered when the collision's position changes
  31993. */
  31994. onCollisionPositionChangeObservable: Observable<Vector3>;
  31995. /** Set a function to call when the collision's position changes */
  31996. set onCollisionPositionChange(callback: () => void);
  31997. /**
  31998. * An event triggered when material is changed
  31999. */
  32000. onMaterialChangedObservable: Observable<AbstractMesh>;
  32001. /**
  32002. * Gets or sets the orientation for POV movement & rotation
  32003. */
  32004. definedFacingForward: boolean;
  32005. /** @hidden */
  32006. _occlusionQuery: Nullable<WebGLQuery>;
  32007. /** @hidden */
  32008. _renderingGroup: Nullable<RenderingGroup>;
  32009. /**
  32010. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  32011. */
  32012. get visibility(): number;
  32013. /**
  32014. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  32015. */
  32016. set visibility(value: number);
  32017. /** Gets or sets the alpha index used to sort transparent meshes
  32018. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  32019. */
  32020. alphaIndex: number;
  32021. /**
  32022. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  32023. */
  32024. isVisible: boolean;
  32025. /**
  32026. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  32027. */
  32028. isPickable: boolean;
  32029. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  32030. showSubMeshesBoundingBox: boolean;
  32031. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  32032. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  32033. */
  32034. isBlocker: boolean;
  32035. /**
  32036. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  32037. */
  32038. enablePointerMoveEvents: boolean;
  32039. /**
  32040. * Specifies the rendering group id for this mesh (0 by default)
  32041. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  32042. */
  32043. renderingGroupId: number;
  32044. private _material;
  32045. /** Gets or sets current material */
  32046. get material(): Nullable<Material>;
  32047. set material(value: Nullable<Material>);
  32048. /**
  32049. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  32050. * @see http://doc.babylonjs.com/babylon101/shadows
  32051. */
  32052. get receiveShadows(): boolean;
  32053. set receiveShadows(value: boolean);
  32054. /** Defines color to use when rendering outline */
  32055. outlineColor: Color3;
  32056. /** Define width to use when rendering outline */
  32057. outlineWidth: number;
  32058. /** Defines color to use when rendering overlay */
  32059. overlayColor: Color3;
  32060. /** Defines alpha to use when rendering overlay */
  32061. overlayAlpha: number;
  32062. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  32063. get hasVertexAlpha(): boolean;
  32064. set hasVertexAlpha(value: boolean);
  32065. /** 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) */
  32066. get useVertexColors(): boolean;
  32067. set useVertexColors(value: boolean);
  32068. /**
  32069. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  32070. */
  32071. get computeBonesUsingShaders(): boolean;
  32072. set computeBonesUsingShaders(value: boolean);
  32073. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  32074. get numBoneInfluencers(): number;
  32075. set numBoneInfluencers(value: number);
  32076. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  32077. get applyFog(): boolean;
  32078. set applyFog(value: boolean);
  32079. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  32080. useOctreeForRenderingSelection: boolean;
  32081. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  32082. useOctreeForPicking: boolean;
  32083. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  32084. useOctreeForCollisions: boolean;
  32085. /**
  32086. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  32087. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  32088. */
  32089. get layerMask(): number;
  32090. set layerMask(value: number);
  32091. /**
  32092. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  32093. */
  32094. alwaysSelectAsActiveMesh: boolean;
  32095. /**
  32096. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  32097. */
  32098. doNotSyncBoundingInfo: boolean;
  32099. /**
  32100. * Gets or sets the current action manager
  32101. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  32102. */
  32103. actionManager: Nullable<AbstractActionManager>;
  32104. private _meshCollisionData;
  32105. /**
  32106. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  32107. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32108. */
  32109. ellipsoid: Vector3;
  32110. /**
  32111. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  32112. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32113. */
  32114. ellipsoidOffset: Vector3;
  32115. /**
  32116. * Gets or sets a collision mask used to mask collisions (default is -1).
  32117. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  32118. */
  32119. get collisionMask(): number;
  32120. set collisionMask(mask: number);
  32121. /**
  32122. * Gets or sets the current collision group mask (-1 by default).
  32123. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  32124. */
  32125. get collisionGroup(): number;
  32126. set collisionGroup(mask: number);
  32127. /**
  32128. * Gets or sets current surrounding meshes (null by default).
  32129. *
  32130. * By default collision detection is tested against every mesh in the scene.
  32131. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  32132. * meshes will be tested for the collision.
  32133. *
  32134. * Note: if set to an empty array no collision will happen when this mesh is moved.
  32135. */
  32136. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  32137. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  32138. /**
  32139. * Defines edge width used when edgesRenderer is enabled
  32140. * @see https://www.babylonjs-playground.com/#10OJSG#13
  32141. */
  32142. edgesWidth: number;
  32143. /**
  32144. * Defines edge color used when edgesRenderer is enabled
  32145. * @see https://www.babylonjs-playground.com/#10OJSG#13
  32146. */
  32147. edgesColor: Color4;
  32148. /** @hidden */
  32149. _edgesRenderer: Nullable<IEdgesRenderer>;
  32150. /** @hidden */
  32151. _masterMesh: Nullable<AbstractMesh>;
  32152. /** @hidden */
  32153. _boundingInfo: Nullable<BoundingInfo>;
  32154. /** @hidden */
  32155. _renderId: number;
  32156. /**
  32157. * Gets or sets the list of subMeshes
  32158. * @see http://doc.babylonjs.com/how_to/multi_materials
  32159. */
  32160. subMeshes: SubMesh[];
  32161. /** @hidden */
  32162. _intersectionsInProgress: AbstractMesh[];
  32163. /** @hidden */
  32164. _unIndexed: boolean;
  32165. /** @hidden */
  32166. _lightSources: Light[];
  32167. /** Gets the list of lights affecting that mesh */
  32168. get lightSources(): Light[];
  32169. /** @hidden */
  32170. get _positions(): Nullable<Vector3[]>;
  32171. /** @hidden */
  32172. _waitingData: {
  32173. lods: Nullable<any>;
  32174. actions: Nullable<any>;
  32175. freezeWorldMatrix: Nullable<boolean>;
  32176. };
  32177. /** @hidden */
  32178. _bonesTransformMatrices: Nullable<Float32Array>;
  32179. /** @hidden */
  32180. _transformMatrixTexture: Nullable<RawTexture>;
  32181. /**
  32182. * Gets or sets a skeleton to apply skining transformations
  32183. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  32184. */
  32185. set skeleton(value: Nullable<Skeleton>);
  32186. get skeleton(): Nullable<Skeleton>;
  32187. /**
  32188. * An event triggered when the mesh is rebuilt.
  32189. */
  32190. onRebuildObservable: Observable<AbstractMesh>;
  32191. /**
  32192. * Creates a new AbstractMesh
  32193. * @param name defines the name of the mesh
  32194. * @param scene defines the hosting scene
  32195. */
  32196. constructor(name: string, scene?: Nullable<Scene>);
  32197. /**
  32198. * Returns the string "AbstractMesh"
  32199. * @returns "AbstractMesh"
  32200. */
  32201. getClassName(): string;
  32202. /**
  32203. * Gets a string representation of the current mesh
  32204. * @param fullDetails defines a boolean indicating if full details must be included
  32205. * @returns a string representation of the current mesh
  32206. */
  32207. toString(fullDetails?: boolean): string;
  32208. /**
  32209. * @hidden
  32210. */
  32211. protected _getEffectiveParent(): Nullable<Node>;
  32212. /** @hidden */
  32213. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  32214. /** @hidden */
  32215. _rebuild(): void;
  32216. /** @hidden */
  32217. _resyncLightSources(): void;
  32218. /** @hidden */
  32219. _resyncLightSource(light: Light): void;
  32220. /** @hidden */
  32221. _unBindEffect(): void;
  32222. /** @hidden */
  32223. _removeLightSource(light: Light, dispose: boolean): void;
  32224. private _markSubMeshesAsDirty;
  32225. /** @hidden */
  32226. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  32227. /** @hidden */
  32228. _markSubMeshesAsAttributesDirty(): void;
  32229. /** @hidden */
  32230. _markSubMeshesAsMiscDirty(): void;
  32231. /**
  32232. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  32233. */
  32234. get scaling(): Vector3;
  32235. set scaling(newScaling: Vector3);
  32236. /**
  32237. * Returns true if the mesh is blocked. Implemented by child classes
  32238. */
  32239. get isBlocked(): boolean;
  32240. /**
  32241. * Returns the mesh itself by default. Implemented by child classes
  32242. * @param camera defines the camera to use to pick the right LOD level
  32243. * @returns the currentAbstractMesh
  32244. */
  32245. getLOD(camera: Camera): Nullable<AbstractMesh>;
  32246. /**
  32247. * Returns 0 by default. Implemented by child classes
  32248. * @returns an integer
  32249. */
  32250. getTotalVertices(): number;
  32251. /**
  32252. * Returns a positive integer : the total number of indices in this mesh geometry.
  32253. * @returns the numner of indices or zero if the mesh has no geometry.
  32254. */
  32255. getTotalIndices(): number;
  32256. /**
  32257. * Returns null by default. Implemented by child classes
  32258. * @returns null
  32259. */
  32260. getIndices(): Nullable<IndicesArray>;
  32261. /**
  32262. * Returns the array of the requested vertex data kind. Implemented by child classes
  32263. * @param kind defines the vertex data kind to use
  32264. * @returns null
  32265. */
  32266. getVerticesData(kind: string): Nullable<FloatArray>;
  32267. /**
  32268. * Sets the vertex data of the mesh geometry for the requested `kind`.
  32269. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  32270. * Note that a new underlying VertexBuffer object is created each call.
  32271. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  32272. * @param kind defines vertex data kind:
  32273. * * VertexBuffer.PositionKind
  32274. * * VertexBuffer.UVKind
  32275. * * VertexBuffer.UV2Kind
  32276. * * VertexBuffer.UV3Kind
  32277. * * VertexBuffer.UV4Kind
  32278. * * VertexBuffer.UV5Kind
  32279. * * VertexBuffer.UV6Kind
  32280. * * VertexBuffer.ColorKind
  32281. * * VertexBuffer.MatricesIndicesKind
  32282. * * VertexBuffer.MatricesIndicesExtraKind
  32283. * * VertexBuffer.MatricesWeightsKind
  32284. * * VertexBuffer.MatricesWeightsExtraKind
  32285. * @param data defines the data source
  32286. * @param updatable defines if the data must be flagged as updatable (or static)
  32287. * @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
  32288. * @returns the current mesh
  32289. */
  32290. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  32291. /**
  32292. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  32293. * If the mesh has no geometry, it is simply returned as it is.
  32294. * @param kind defines vertex data kind:
  32295. * * VertexBuffer.PositionKind
  32296. * * VertexBuffer.UVKind
  32297. * * VertexBuffer.UV2Kind
  32298. * * VertexBuffer.UV3Kind
  32299. * * VertexBuffer.UV4Kind
  32300. * * VertexBuffer.UV5Kind
  32301. * * VertexBuffer.UV6Kind
  32302. * * VertexBuffer.ColorKind
  32303. * * VertexBuffer.MatricesIndicesKind
  32304. * * VertexBuffer.MatricesIndicesExtraKind
  32305. * * VertexBuffer.MatricesWeightsKind
  32306. * * VertexBuffer.MatricesWeightsExtraKind
  32307. * @param data defines the data source
  32308. * @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
  32309. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  32310. * @returns the current mesh
  32311. */
  32312. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  32313. /**
  32314. * Sets the mesh indices,
  32315. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  32316. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  32317. * @param totalVertices Defines the total number of vertices
  32318. * @returns the current mesh
  32319. */
  32320. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  32321. /**
  32322. * Gets a boolean indicating if specific vertex data is present
  32323. * @param kind defines the vertex data kind to use
  32324. * @returns true is data kind is present
  32325. */
  32326. isVerticesDataPresent(kind: string): boolean;
  32327. /**
  32328. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  32329. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  32330. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  32331. * @returns a BoundingInfo
  32332. */
  32333. getBoundingInfo(): BoundingInfo;
  32334. /**
  32335. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  32336. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  32337. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  32338. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  32339. * @returns the current mesh
  32340. */
  32341. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  32342. /**
  32343. * Overwrite the current bounding info
  32344. * @param boundingInfo defines the new bounding info
  32345. * @returns the current mesh
  32346. */
  32347. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  32348. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  32349. get useBones(): boolean;
  32350. /** @hidden */
  32351. _preActivate(): void;
  32352. /** @hidden */
  32353. _preActivateForIntermediateRendering(renderId: number): void;
  32354. /** @hidden */
  32355. _activate(renderId: number, intermediateRendering: boolean): boolean;
  32356. /** @hidden */
  32357. _postActivate(): void;
  32358. /** @hidden */
  32359. _freeze(): void;
  32360. /** @hidden */
  32361. _unFreeze(): void;
  32362. /**
  32363. * Gets the current world matrix
  32364. * @returns a Matrix
  32365. */
  32366. getWorldMatrix(): Matrix;
  32367. /** @hidden */
  32368. _getWorldMatrixDeterminant(): number;
  32369. /**
  32370. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  32371. */
  32372. get isAnInstance(): boolean;
  32373. /**
  32374. * Gets a boolean indicating if this mesh has instances
  32375. */
  32376. get hasInstances(): boolean;
  32377. /**
  32378. * Perform relative position change from the point of view of behind the front of the mesh.
  32379. * This is performed taking into account the meshes current rotation, so you do not have to care.
  32380. * Supports definition of mesh facing forward or backward
  32381. * @param amountRight defines the distance on the right axis
  32382. * @param amountUp defines the distance on the up axis
  32383. * @param amountForward defines the distance on the forward axis
  32384. * @returns the current mesh
  32385. */
  32386. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  32387. /**
  32388. * Calculate relative position change from the point of view of behind the front of the mesh.
  32389. * This is performed taking into account the meshes current rotation, so you do not have to care.
  32390. * Supports definition of mesh facing forward or backward
  32391. * @param amountRight defines the distance on the right axis
  32392. * @param amountUp defines the distance on the up axis
  32393. * @param amountForward defines the distance on the forward axis
  32394. * @returns the new displacement vector
  32395. */
  32396. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  32397. /**
  32398. * Perform relative rotation change from the point of view of behind the front of the mesh.
  32399. * Supports definition of mesh facing forward or backward
  32400. * @param flipBack defines the flip
  32401. * @param twirlClockwise defines the twirl
  32402. * @param tiltRight defines the tilt
  32403. * @returns the current mesh
  32404. */
  32405. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  32406. /**
  32407. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  32408. * Supports definition of mesh facing forward or backward.
  32409. * @param flipBack defines the flip
  32410. * @param twirlClockwise defines the twirl
  32411. * @param tiltRight defines the tilt
  32412. * @returns the new rotation vector
  32413. */
  32414. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  32415. /**
  32416. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  32417. * This means the mesh underlying bounding box and sphere are recomputed.
  32418. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  32419. * @returns the current mesh
  32420. */
  32421. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  32422. /** @hidden */
  32423. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  32424. /** @hidden */
  32425. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  32426. /** @hidden */
  32427. _updateBoundingInfo(): AbstractMesh;
  32428. /** @hidden */
  32429. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  32430. /** @hidden */
  32431. protected _afterComputeWorldMatrix(): void;
  32432. /** @hidden */
  32433. get _effectiveMesh(): AbstractMesh;
  32434. /**
  32435. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  32436. * A mesh is in the frustum if its bounding box intersects the frustum
  32437. * @param frustumPlanes defines the frustum to test
  32438. * @returns true if the mesh is in the frustum planes
  32439. */
  32440. isInFrustum(frustumPlanes: Plane[]): boolean;
  32441. /**
  32442. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  32443. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  32444. * @param frustumPlanes defines the frustum to test
  32445. * @returns true if the mesh is completely in the frustum planes
  32446. */
  32447. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  32448. /**
  32449. * True if the mesh intersects another mesh or a SolidParticle object
  32450. * @param mesh defines a target mesh or SolidParticle to test
  32451. * @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)
  32452. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  32453. * @returns true if there is an intersection
  32454. */
  32455. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  32456. /**
  32457. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  32458. * @param point defines the point to test
  32459. * @returns true if there is an intersection
  32460. */
  32461. intersectsPoint(point: Vector3): boolean;
  32462. /**
  32463. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  32464. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32465. */
  32466. get checkCollisions(): boolean;
  32467. set checkCollisions(collisionEnabled: boolean);
  32468. /**
  32469. * Gets Collider object used to compute collisions (not physics)
  32470. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32471. */
  32472. get collider(): Nullable<Collider>;
  32473. /**
  32474. * Move the mesh using collision engine
  32475. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32476. * @param displacement defines the requested displacement vector
  32477. * @returns the current mesh
  32478. */
  32479. moveWithCollisions(displacement: Vector3): AbstractMesh;
  32480. private _onCollisionPositionChange;
  32481. /** @hidden */
  32482. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  32483. /** @hidden */
  32484. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  32485. /** @hidden */
  32486. _checkCollision(collider: Collider): AbstractMesh;
  32487. /** @hidden */
  32488. _generatePointsArray(): boolean;
  32489. /**
  32490. * Checks if the passed Ray intersects with the mesh
  32491. * @param ray defines the ray to use
  32492. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  32493. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  32494. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  32495. * @returns the picking info
  32496. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  32497. */
  32498. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean): PickingInfo;
  32499. /**
  32500. * Clones the current mesh
  32501. * @param name defines the mesh name
  32502. * @param newParent defines the new mesh parent
  32503. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  32504. * @returns the new mesh
  32505. */
  32506. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  32507. /**
  32508. * Disposes all the submeshes of the current meshnp
  32509. * @returns the current mesh
  32510. */
  32511. releaseSubMeshes(): AbstractMesh;
  32512. /**
  32513. * Releases resources associated with this abstract mesh.
  32514. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  32515. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  32516. */
  32517. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  32518. /**
  32519. * Adds the passed mesh as a child to the current mesh
  32520. * @param mesh defines the child mesh
  32521. * @returns the current mesh
  32522. */
  32523. addChild(mesh: AbstractMesh): AbstractMesh;
  32524. /**
  32525. * Removes the passed mesh from the current mesh children list
  32526. * @param mesh defines the child mesh
  32527. * @returns the current mesh
  32528. */
  32529. removeChild(mesh: AbstractMesh): AbstractMesh;
  32530. /** @hidden */
  32531. private _initFacetData;
  32532. /**
  32533. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  32534. * This method can be called within the render loop.
  32535. * 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
  32536. * @returns the current mesh
  32537. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32538. */
  32539. updateFacetData(): AbstractMesh;
  32540. /**
  32541. * Returns the facetLocalNormals array.
  32542. * The normals are expressed in the mesh local spac
  32543. * @returns an array of Vector3
  32544. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32545. */
  32546. getFacetLocalNormals(): Vector3[];
  32547. /**
  32548. * Returns the facetLocalPositions array.
  32549. * The facet positions are expressed in the mesh local space
  32550. * @returns an array of Vector3
  32551. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32552. */
  32553. getFacetLocalPositions(): Vector3[];
  32554. /**
  32555. * Returns the facetLocalPartioning array
  32556. * @returns an array of array of numbers
  32557. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32558. */
  32559. getFacetLocalPartitioning(): number[][];
  32560. /**
  32561. * Returns the i-th facet position in the world system.
  32562. * This method allocates a new Vector3 per call
  32563. * @param i defines the facet index
  32564. * @returns a new Vector3
  32565. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32566. */
  32567. getFacetPosition(i: number): Vector3;
  32568. /**
  32569. * Sets the reference Vector3 with the i-th facet position in the world system
  32570. * @param i defines the facet index
  32571. * @param ref defines the target vector
  32572. * @returns the current mesh
  32573. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32574. */
  32575. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  32576. /**
  32577. * Returns the i-th facet normal in the world system.
  32578. * This method allocates a new Vector3 per call
  32579. * @param i defines the facet index
  32580. * @returns a new Vector3
  32581. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32582. */
  32583. getFacetNormal(i: number): Vector3;
  32584. /**
  32585. * Sets the reference Vector3 with the i-th facet normal in the world system
  32586. * @param i defines the facet index
  32587. * @param ref defines the target vector
  32588. * @returns the current mesh
  32589. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32590. */
  32591. getFacetNormalToRef(i: number, ref: Vector3): this;
  32592. /**
  32593. * 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)
  32594. * @param x defines x coordinate
  32595. * @param y defines y coordinate
  32596. * @param z defines z coordinate
  32597. * @returns the array of facet indexes
  32598. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32599. */
  32600. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  32601. /**
  32602. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  32603. * @param projected sets as the (x,y,z) world projection on the facet
  32604. * @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
  32605. * @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
  32606. * @param x defines x coordinate
  32607. * @param y defines y coordinate
  32608. * @param z defines z coordinate
  32609. * @returns the face index if found (or null instead)
  32610. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32611. */
  32612. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  32613. /**
  32614. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  32615. * @param projected sets as the (x,y,z) local projection on the facet
  32616. * @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
  32617. * @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
  32618. * @param x defines x coordinate
  32619. * @param y defines y coordinate
  32620. * @param z defines z coordinate
  32621. * @returns the face index if found (or null instead)
  32622. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32623. */
  32624. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  32625. /**
  32626. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  32627. * @returns the parameters
  32628. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32629. */
  32630. getFacetDataParameters(): any;
  32631. /**
  32632. * Disables the feature FacetData and frees the related memory
  32633. * @returns the current mesh
  32634. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32635. */
  32636. disableFacetData(): AbstractMesh;
  32637. /**
  32638. * Updates the AbstractMesh indices array
  32639. * @param indices defines the data source
  32640. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  32641. * @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)
  32642. * @returns the current mesh
  32643. */
  32644. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  32645. /**
  32646. * Creates new normals data for the mesh
  32647. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  32648. * @returns the current mesh
  32649. */
  32650. createNormals(updatable: boolean): AbstractMesh;
  32651. /**
  32652. * Align the mesh with a normal
  32653. * @param normal defines the normal to use
  32654. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  32655. * @returns the current mesh
  32656. */
  32657. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  32658. /** @hidden */
  32659. _checkOcclusionQuery(): boolean;
  32660. /**
  32661. * Disables the mesh edge rendering mode
  32662. * @returns the currentAbstractMesh
  32663. */
  32664. disableEdgesRendering(): AbstractMesh;
  32665. /**
  32666. * Enables the edge rendering mode on the mesh.
  32667. * This mode makes the mesh edges visible
  32668. * @param epsilon defines the maximal distance between two angles to detect a face
  32669. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  32670. * @returns the currentAbstractMesh
  32671. * @see https://www.babylonjs-playground.com/#19O9TU#0
  32672. */
  32673. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  32674. }
  32675. }
  32676. declare module "babylonjs/Actions/actionEvent" {
  32677. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32678. import { Nullable } from "babylonjs/types";
  32679. import { Sprite } from "babylonjs/Sprites/sprite";
  32680. import { Scene } from "babylonjs/scene";
  32681. import { Vector2 } from "babylonjs/Maths/math.vector";
  32682. /**
  32683. * Interface used to define ActionEvent
  32684. */
  32685. export interface IActionEvent {
  32686. /** The mesh or sprite that triggered the action */
  32687. source: any;
  32688. /** The X mouse cursor position at the time of the event */
  32689. pointerX: number;
  32690. /** The Y mouse cursor position at the time of the event */
  32691. pointerY: number;
  32692. /** The mesh that is currently pointed at (can be null) */
  32693. meshUnderPointer: Nullable<AbstractMesh>;
  32694. /** the original (browser) event that triggered the ActionEvent */
  32695. sourceEvent?: any;
  32696. /** additional data for the event */
  32697. additionalData?: any;
  32698. }
  32699. /**
  32700. * ActionEvent is the event being sent when an action is triggered.
  32701. */
  32702. export class ActionEvent implements IActionEvent {
  32703. /** The mesh or sprite that triggered the action */
  32704. source: any;
  32705. /** The X mouse cursor position at the time of the event */
  32706. pointerX: number;
  32707. /** The Y mouse cursor position at the time of the event */
  32708. pointerY: number;
  32709. /** The mesh that is currently pointed at (can be null) */
  32710. meshUnderPointer: Nullable<AbstractMesh>;
  32711. /** the original (browser) event that triggered the ActionEvent */
  32712. sourceEvent?: any;
  32713. /** additional data for the event */
  32714. additionalData?: any;
  32715. /**
  32716. * Creates a new ActionEvent
  32717. * @param source The mesh or sprite that triggered the action
  32718. * @param pointerX The X mouse cursor position at the time of the event
  32719. * @param pointerY The Y mouse cursor position at the time of the event
  32720. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  32721. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  32722. * @param additionalData additional data for the event
  32723. */
  32724. constructor(
  32725. /** The mesh or sprite that triggered the action */
  32726. source: any,
  32727. /** The X mouse cursor position at the time of the event */
  32728. pointerX: number,
  32729. /** The Y mouse cursor position at the time of the event */
  32730. pointerY: number,
  32731. /** The mesh that is currently pointed at (can be null) */
  32732. meshUnderPointer: Nullable<AbstractMesh>,
  32733. /** the original (browser) event that triggered the ActionEvent */
  32734. sourceEvent?: any,
  32735. /** additional data for the event */
  32736. additionalData?: any);
  32737. /**
  32738. * Helper function to auto-create an ActionEvent from a source mesh.
  32739. * @param source The source mesh that triggered the event
  32740. * @param evt The original (browser) event
  32741. * @param additionalData additional data for the event
  32742. * @returns the new ActionEvent
  32743. */
  32744. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  32745. /**
  32746. * Helper function to auto-create an ActionEvent from a source sprite
  32747. * @param source The source sprite that triggered the event
  32748. * @param scene Scene associated with the sprite
  32749. * @param evt The original (browser) event
  32750. * @param additionalData additional data for the event
  32751. * @returns the new ActionEvent
  32752. */
  32753. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  32754. /**
  32755. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  32756. * @param scene the scene where the event occurred
  32757. * @param evt The original (browser) event
  32758. * @returns the new ActionEvent
  32759. */
  32760. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  32761. /**
  32762. * Helper function to auto-create an ActionEvent from a primitive
  32763. * @param prim defines the target primitive
  32764. * @param pointerPos defines the pointer position
  32765. * @param evt The original (browser) event
  32766. * @param additionalData additional data for the event
  32767. * @returns the new ActionEvent
  32768. */
  32769. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  32770. }
  32771. }
  32772. declare module "babylonjs/Actions/abstractActionManager" {
  32773. import { IDisposable } from "babylonjs/scene";
  32774. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  32775. import { IAction } from "babylonjs/Actions/action";
  32776. import { Nullable } from "babylonjs/types";
  32777. /**
  32778. * Abstract class used to decouple action Manager from scene and meshes.
  32779. * Do not instantiate.
  32780. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  32781. */
  32782. export abstract class AbstractActionManager implements IDisposable {
  32783. /** Gets the list of active triggers */
  32784. static Triggers: {
  32785. [key: string]: number;
  32786. };
  32787. /** Gets the cursor to use when hovering items */
  32788. hoverCursor: string;
  32789. /** Gets the list of actions */
  32790. actions: IAction[];
  32791. /**
  32792. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  32793. */
  32794. isRecursive: boolean;
  32795. /**
  32796. * Releases all associated resources
  32797. */
  32798. abstract dispose(): void;
  32799. /**
  32800. * Does this action manager has pointer triggers
  32801. */
  32802. abstract get hasPointerTriggers(): boolean;
  32803. /**
  32804. * Does this action manager has pick triggers
  32805. */
  32806. abstract get hasPickTriggers(): boolean;
  32807. /**
  32808. * Process a specific trigger
  32809. * @param trigger defines the trigger to process
  32810. * @param evt defines the event details to be processed
  32811. */
  32812. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  32813. /**
  32814. * Does this action manager handles actions of any of the given triggers
  32815. * @param triggers defines the triggers to be tested
  32816. * @return a boolean indicating whether one (or more) of the triggers is handled
  32817. */
  32818. abstract hasSpecificTriggers(triggers: number[]): boolean;
  32819. /**
  32820. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  32821. * speed.
  32822. * @param triggerA defines the trigger to be tested
  32823. * @param triggerB defines the trigger to be tested
  32824. * @return a boolean indicating whether one (or more) of the triggers is handled
  32825. */
  32826. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  32827. /**
  32828. * Does this action manager handles actions of a given trigger
  32829. * @param trigger defines the trigger to be tested
  32830. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  32831. * @return whether the trigger is handled
  32832. */
  32833. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  32834. /**
  32835. * Serialize this manager to a JSON object
  32836. * @param name defines the property name to store this manager
  32837. * @returns a JSON representation of this manager
  32838. */
  32839. abstract serialize(name: string): any;
  32840. /**
  32841. * Registers an action to this action manager
  32842. * @param action defines the action to be registered
  32843. * @return the action amended (prepared) after registration
  32844. */
  32845. abstract registerAction(action: IAction): Nullable<IAction>;
  32846. /**
  32847. * Unregisters an action to this action manager
  32848. * @param action defines the action to be unregistered
  32849. * @return a boolean indicating whether the action has been unregistered
  32850. */
  32851. abstract unregisterAction(action: IAction): Boolean;
  32852. /**
  32853. * Does exist one action manager with at least one trigger
  32854. **/
  32855. static get HasTriggers(): boolean;
  32856. /**
  32857. * Does exist one action manager with at least one pick trigger
  32858. **/
  32859. static get HasPickTriggers(): boolean;
  32860. /**
  32861. * Does exist one action manager that handles actions of a given trigger
  32862. * @param trigger defines the trigger to be tested
  32863. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  32864. **/
  32865. static HasSpecificTrigger(trigger: number): boolean;
  32866. }
  32867. }
  32868. declare module "babylonjs/node" {
  32869. import { Scene } from "babylonjs/scene";
  32870. import { Nullable } from "babylonjs/types";
  32871. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  32872. import { Engine } from "babylonjs/Engines/engine";
  32873. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  32874. import { Observable } from "babylonjs/Misc/observable";
  32875. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  32876. import { IInspectable } from "babylonjs/Misc/iInspectable";
  32877. import { Animatable } from "babylonjs/Animations/animatable";
  32878. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  32879. import { Animation } from "babylonjs/Animations/animation";
  32880. import { AnimationRange } from "babylonjs/Animations/animationRange";
  32881. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32882. /**
  32883. * Defines how a node can be built from a string name.
  32884. */
  32885. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  32886. /**
  32887. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  32888. */
  32889. export class Node implements IBehaviorAware<Node> {
  32890. /** @hidden */
  32891. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  32892. private static _NodeConstructors;
  32893. /**
  32894. * Add a new node constructor
  32895. * @param type defines the type name of the node to construct
  32896. * @param constructorFunc defines the constructor function
  32897. */
  32898. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  32899. /**
  32900. * Returns a node constructor based on type name
  32901. * @param type defines the type name
  32902. * @param name defines the new node name
  32903. * @param scene defines the hosting scene
  32904. * @param options defines optional options to transmit to constructors
  32905. * @returns the new constructor or null
  32906. */
  32907. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  32908. /**
  32909. * Gets or sets the name of the node
  32910. */
  32911. name: string;
  32912. /**
  32913. * Gets or sets the id of the node
  32914. */
  32915. id: string;
  32916. /**
  32917. * Gets or sets the unique id of the node
  32918. */
  32919. uniqueId: number;
  32920. /**
  32921. * Gets or sets a string used to store user defined state for the node
  32922. */
  32923. state: string;
  32924. /**
  32925. * Gets or sets an object used to store user defined information for the node
  32926. */
  32927. metadata: any;
  32928. /**
  32929. * For internal use only. Please do not use.
  32930. */
  32931. reservedDataStore: any;
  32932. /**
  32933. * List of inspectable custom properties (used by the Inspector)
  32934. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  32935. */
  32936. inspectableCustomProperties: IInspectable[];
  32937. private _doNotSerialize;
  32938. /**
  32939. * Gets or sets a boolean used to define if the node must be serialized
  32940. */
  32941. get doNotSerialize(): boolean;
  32942. set doNotSerialize(value: boolean);
  32943. /** @hidden */
  32944. _isDisposed: boolean;
  32945. /**
  32946. * Gets a list of Animations associated with the node
  32947. */
  32948. animations: import("babylonjs/Animations/animation").Animation[];
  32949. protected _ranges: {
  32950. [name: string]: Nullable<AnimationRange>;
  32951. };
  32952. /**
  32953. * Callback raised when the node is ready to be used
  32954. */
  32955. onReady: Nullable<(node: Node) => void>;
  32956. private _isEnabled;
  32957. private _isParentEnabled;
  32958. private _isReady;
  32959. /** @hidden */
  32960. _currentRenderId: number;
  32961. private _parentUpdateId;
  32962. /** @hidden */
  32963. _childUpdateId: number;
  32964. /** @hidden */
  32965. _waitingParentId: Nullable<string>;
  32966. /** @hidden */
  32967. _scene: Scene;
  32968. /** @hidden */
  32969. _cache: any;
  32970. private _parentNode;
  32971. private _children;
  32972. /** @hidden */
  32973. _worldMatrix: Matrix;
  32974. /** @hidden */
  32975. _worldMatrixDeterminant: number;
  32976. /** @hidden */
  32977. _worldMatrixDeterminantIsDirty: boolean;
  32978. /** @hidden */
  32979. private _sceneRootNodesIndex;
  32980. /**
  32981. * Gets a boolean indicating if the node has been disposed
  32982. * @returns true if the node was disposed
  32983. */
  32984. isDisposed(): boolean;
  32985. /**
  32986. * Gets or sets the parent of the node (without keeping the current position in the scene)
  32987. * @see https://doc.babylonjs.com/how_to/parenting
  32988. */
  32989. set parent(parent: Nullable<Node>);
  32990. get parent(): Nullable<Node>;
  32991. /** @hidden */
  32992. _addToSceneRootNodes(): void;
  32993. /** @hidden */
  32994. _removeFromSceneRootNodes(): void;
  32995. private _animationPropertiesOverride;
  32996. /**
  32997. * Gets or sets the animation properties override
  32998. */
  32999. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  33000. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  33001. /**
  33002. * Gets a string idenfifying the name of the class
  33003. * @returns "Node" string
  33004. */
  33005. getClassName(): string;
  33006. /** @hidden */
  33007. readonly _isNode: boolean;
  33008. /**
  33009. * An event triggered when the mesh is disposed
  33010. */
  33011. onDisposeObservable: Observable<Node>;
  33012. private _onDisposeObserver;
  33013. /**
  33014. * Sets a callback that will be raised when the node will be disposed
  33015. */
  33016. set onDispose(callback: () => void);
  33017. /**
  33018. * Creates a new Node
  33019. * @param name the name and id to be given to this node
  33020. * @param scene the scene this node will be added to
  33021. */
  33022. constructor(name: string, scene?: Nullable<Scene>);
  33023. /**
  33024. * Gets the scene of the node
  33025. * @returns a scene
  33026. */
  33027. getScene(): Scene;
  33028. /**
  33029. * Gets the engine of the node
  33030. * @returns a Engine
  33031. */
  33032. getEngine(): Engine;
  33033. private _behaviors;
  33034. /**
  33035. * Attach a behavior to the node
  33036. * @see http://doc.babylonjs.com/features/behaviour
  33037. * @param behavior defines the behavior to attach
  33038. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  33039. * @returns the current Node
  33040. */
  33041. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  33042. /**
  33043. * Remove an attached behavior
  33044. * @see http://doc.babylonjs.com/features/behaviour
  33045. * @param behavior defines the behavior to attach
  33046. * @returns the current Node
  33047. */
  33048. removeBehavior(behavior: Behavior<Node>): Node;
  33049. /**
  33050. * Gets the list of attached behaviors
  33051. * @see http://doc.babylonjs.com/features/behaviour
  33052. */
  33053. get behaviors(): Behavior<Node>[];
  33054. /**
  33055. * Gets an attached behavior by name
  33056. * @param name defines the name of the behavior to look for
  33057. * @see http://doc.babylonjs.com/features/behaviour
  33058. * @returns null if behavior was not found else the requested behavior
  33059. */
  33060. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  33061. /**
  33062. * Returns the latest update of the World matrix
  33063. * @returns a Matrix
  33064. */
  33065. getWorldMatrix(): Matrix;
  33066. /** @hidden */
  33067. _getWorldMatrixDeterminant(): number;
  33068. /**
  33069. * Returns directly the latest state of the mesh World matrix.
  33070. * A Matrix is returned.
  33071. */
  33072. get worldMatrixFromCache(): Matrix;
  33073. /** @hidden */
  33074. _initCache(): void;
  33075. /** @hidden */
  33076. updateCache(force?: boolean): void;
  33077. /** @hidden */
  33078. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  33079. /** @hidden */
  33080. _updateCache(ignoreParentClass?: boolean): void;
  33081. /** @hidden */
  33082. _isSynchronized(): boolean;
  33083. /** @hidden */
  33084. _markSyncedWithParent(): void;
  33085. /** @hidden */
  33086. isSynchronizedWithParent(): boolean;
  33087. /** @hidden */
  33088. isSynchronized(): boolean;
  33089. /**
  33090. * Is this node ready to be used/rendered
  33091. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  33092. * @return true if the node is ready
  33093. */
  33094. isReady(completeCheck?: boolean): boolean;
  33095. /**
  33096. * Is this node enabled?
  33097. * 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
  33098. * @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
  33099. * @return whether this node (and its parent) is enabled
  33100. */
  33101. isEnabled(checkAncestors?: boolean): boolean;
  33102. /** @hidden */
  33103. protected _syncParentEnabledState(): void;
  33104. /**
  33105. * Set the enabled state of this node
  33106. * @param value defines the new enabled state
  33107. */
  33108. setEnabled(value: boolean): void;
  33109. /**
  33110. * Is this node a descendant of the given node?
  33111. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  33112. * @param ancestor defines the parent node to inspect
  33113. * @returns a boolean indicating if this node is a descendant of the given node
  33114. */
  33115. isDescendantOf(ancestor: Node): boolean;
  33116. /** @hidden */
  33117. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  33118. /**
  33119. * Will return all nodes that have this node as ascendant
  33120. * @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
  33121. * @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
  33122. * @return all children nodes of all types
  33123. */
  33124. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  33125. /**
  33126. * Get all child-meshes of this node
  33127. * @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)
  33128. * @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
  33129. * @returns an array of AbstractMesh
  33130. */
  33131. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  33132. /**
  33133. * Get all direct children of this node
  33134. * @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
  33135. * @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)
  33136. * @returns an array of Node
  33137. */
  33138. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  33139. /** @hidden */
  33140. _setReady(state: boolean): void;
  33141. /**
  33142. * Get an animation by name
  33143. * @param name defines the name of the animation to look for
  33144. * @returns null if not found else the requested animation
  33145. */
  33146. getAnimationByName(name: string): Nullable<Animation>;
  33147. /**
  33148. * Creates an animation range for this node
  33149. * @param name defines the name of the range
  33150. * @param from defines the starting key
  33151. * @param to defines the end key
  33152. */
  33153. createAnimationRange(name: string, from: number, to: number): void;
  33154. /**
  33155. * Delete a specific animation range
  33156. * @param name defines the name of the range to delete
  33157. * @param deleteFrames defines if animation frames from the range must be deleted as well
  33158. */
  33159. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  33160. /**
  33161. * Get an animation range by name
  33162. * @param name defines the name of the animation range to look for
  33163. * @returns null if not found else the requested animation range
  33164. */
  33165. getAnimationRange(name: string): Nullable<AnimationRange>;
  33166. /**
  33167. * Gets the list of all animation ranges defined on this node
  33168. * @returns an array
  33169. */
  33170. getAnimationRanges(): Nullable<AnimationRange>[];
  33171. /**
  33172. * Will start the animation sequence
  33173. * @param name defines the range frames for animation sequence
  33174. * @param loop defines if the animation should loop (false by default)
  33175. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  33176. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  33177. * @returns the object created for this animation. If range does not exist, it will return null
  33178. */
  33179. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  33180. /**
  33181. * Serialize animation ranges into a JSON compatible object
  33182. * @returns serialization object
  33183. */
  33184. serializeAnimationRanges(): any;
  33185. /**
  33186. * Computes the world matrix of the node
  33187. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  33188. * @returns the world matrix
  33189. */
  33190. computeWorldMatrix(force?: boolean): Matrix;
  33191. /**
  33192. * Releases resources associated with this node.
  33193. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  33194. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  33195. */
  33196. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  33197. /**
  33198. * Parse animation range data from a serialization object and store them into a given node
  33199. * @param node defines where to store the animation ranges
  33200. * @param parsedNode defines the serialization object to read data from
  33201. * @param scene defines the hosting scene
  33202. */
  33203. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  33204. /**
  33205. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  33206. * @param includeDescendants Include bounding info from descendants as well (true by default)
  33207. * @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
  33208. * @returns the new bounding vectors
  33209. */
  33210. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  33211. min: Vector3;
  33212. max: Vector3;
  33213. };
  33214. }
  33215. }
  33216. declare module "babylonjs/Animations/animation" {
  33217. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  33218. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  33219. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  33220. import { Nullable } from "babylonjs/types";
  33221. import { Scene } from "babylonjs/scene";
  33222. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  33223. import { AnimationRange } from "babylonjs/Animations/animationRange";
  33224. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  33225. import { Node } from "babylonjs/node";
  33226. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  33227. import { Size } from "babylonjs/Maths/math.size";
  33228. import { Animatable } from "babylonjs/Animations/animatable";
  33229. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  33230. /**
  33231. * @hidden
  33232. */
  33233. export class _IAnimationState {
  33234. key: number;
  33235. repeatCount: number;
  33236. workValue?: any;
  33237. loopMode?: number;
  33238. offsetValue?: any;
  33239. highLimitValue?: any;
  33240. }
  33241. /**
  33242. * Class used to store any kind of animation
  33243. */
  33244. export class Animation {
  33245. /**Name of the animation */
  33246. name: string;
  33247. /**Property to animate */
  33248. targetProperty: string;
  33249. /**The frames per second of the animation */
  33250. framePerSecond: number;
  33251. /**The data type of the animation */
  33252. dataType: number;
  33253. /**The loop mode of the animation */
  33254. loopMode?: number | undefined;
  33255. /**Specifies if blending should be enabled */
  33256. enableBlending?: boolean | undefined;
  33257. /**
  33258. * Use matrix interpolation instead of using direct key value when animating matrices
  33259. */
  33260. static AllowMatricesInterpolation: boolean;
  33261. /**
  33262. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  33263. */
  33264. static AllowMatrixDecomposeForInterpolation: boolean;
  33265. /**
  33266. * Stores the key frames of the animation
  33267. */
  33268. private _keys;
  33269. /**
  33270. * Stores the easing function of the animation
  33271. */
  33272. private _easingFunction;
  33273. /**
  33274. * @hidden Internal use only
  33275. */
  33276. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  33277. /**
  33278. * The set of event that will be linked to this animation
  33279. */
  33280. private _events;
  33281. /**
  33282. * Stores an array of target property paths
  33283. */
  33284. targetPropertyPath: string[];
  33285. /**
  33286. * Stores the blending speed of the animation
  33287. */
  33288. blendingSpeed: number;
  33289. /**
  33290. * Stores the animation ranges for the animation
  33291. */
  33292. private _ranges;
  33293. /**
  33294. * @hidden Internal use
  33295. */
  33296. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  33297. /**
  33298. * Sets up an animation
  33299. * @param property The property to animate
  33300. * @param animationType The animation type to apply
  33301. * @param framePerSecond The frames per second of the animation
  33302. * @param easingFunction The easing function used in the animation
  33303. * @returns The created animation
  33304. */
  33305. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  33306. /**
  33307. * Create and start an animation on a node
  33308. * @param name defines the name of the global animation that will be run on all nodes
  33309. * @param node defines the root node where the animation will take place
  33310. * @param targetProperty defines property to animate
  33311. * @param framePerSecond defines the number of frame per second yo use
  33312. * @param totalFrame defines the number of frames in total
  33313. * @param from defines the initial value
  33314. * @param to defines the final value
  33315. * @param loopMode defines which loop mode you want to use (off by default)
  33316. * @param easingFunction defines the easing function to use (linear by default)
  33317. * @param onAnimationEnd defines the callback to call when animation end
  33318. * @returns the animatable created for this animation
  33319. */
  33320. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  33321. /**
  33322. * Create and start an animation on a node and its descendants
  33323. * @param name defines the name of the global animation that will be run on all nodes
  33324. * @param node defines the root node where the animation will take place
  33325. * @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
  33326. * @param targetProperty defines property to animate
  33327. * @param framePerSecond defines the number of frame per second to use
  33328. * @param totalFrame defines the number of frames in total
  33329. * @param from defines the initial value
  33330. * @param to defines the final value
  33331. * @param loopMode defines which loop mode you want to use (off by default)
  33332. * @param easingFunction defines the easing function to use (linear by default)
  33333. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  33334. * @returns the list of animatables created for all nodes
  33335. * @example https://www.babylonjs-playground.com/#MH0VLI
  33336. */
  33337. 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[]>;
  33338. /**
  33339. * Creates a new animation, merges it with the existing animations and starts it
  33340. * @param name Name of the animation
  33341. * @param node Node which contains the scene that begins the animations
  33342. * @param targetProperty Specifies which property to animate
  33343. * @param framePerSecond The frames per second of the animation
  33344. * @param totalFrame The total number of frames
  33345. * @param from The frame at the beginning of the animation
  33346. * @param to The frame at the end of the animation
  33347. * @param loopMode Specifies the loop mode of the animation
  33348. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  33349. * @param onAnimationEnd Callback to run once the animation is complete
  33350. * @returns Nullable animation
  33351. */
  33352. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  33353. /**
  33354. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  33355. * @param sourceAnimation defines the Animation containing keyframes to convert
  33356. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  33357. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  33358. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  33359. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  33360. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  33361. */
  33362. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  33363. /**
  33364. * Transition property of an host to the target Value
  33365. * @param property The property to transition
  33366. * @param targetValue The target Value of the property
  33367. * @param host The object where the property to animate belongs
  33368. * @param scene Scene used to run the animation
  33369. * @param frameRate Framerate (in frame/s) to use
  33370. * @param transition The transition type we want to use
  33371. * @param duration The duration of the animation, in milliseconds
  33372. * @param onAnimationEnd Callback trigger at the end of the animation
  33373. * @returns Nullable animation
  33374. */
  33375. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  33376. /**
  33377. * Return the array of runtime animations currently using this animation
  33378. */
  33379. get runtimeAnimations(): RuntimeAnimation[];
  33380. /**
  33381. * Specifies if any of the runtime animations are currently running
  33382. */
  33383. get hasRunningRuntimeAnimations(): boolean;
  33384. /**
  33385. * Initializes the animation
  33386. * @param name Name of the animation
  33387. * @param targetProperty Property to animate
  33388. * @param framePerSecond The frames per second of the animation
  33389. * @param dataType The data type of the animation
  33390. * @param loopMode The loop mode of the animation
  33391. * @param enableBlending Specifies if blending should be enabled
  33392. */
  33393. constructor(
  33394. /**Name of the animation */
  33395. name: string,
  33396. /**Property to animate */
  33397. targetProperty: string,
  33398. /**The frames per second of the animation */
  33399. framePerSecond: number,
  33400. /**The data type of the animation */
  33401. dataType: number,
  33402. /**The loop mode of the animation */
  33403. loopMode?: number | undefined,
  33404. /**Specifies if blending should be enabled */
  33405. enableBlending?: boolean | undefined);
  33406. /**
  33407. * Converts the animation to a string
  33408. * @param fullDetails support for multiple levels of logging within scene loading
  33409. * @returns String form of the animation
  33410. */
  33411. toString(fullDetails?: boolean): string;
  33412. /**
  33413. * Add an event to this animation
  33414. * @param event Event to add
  33415. */
  33416. addEvent(event: AnimationEvent): void;
  33417. /**
  33418. * Remove all events found at the given frame
  33419. * @param frame The frame to remove events from
  33420. */
  33421. removeEvents(frame: number): void;
  33422. /**
  33423. * Retrieves all the events from the animation
  33424. * @returns Events from the animation
  33425. */
  33426. getEvents(): AnimationEvent[];
  33427. /**
  33428. * Creates an animation range
  33429. * @param name Name of the animation range
  33430. * @param from Starting frame of the animation range
  33431. * @param to Ending frame of the animation
  33432. */
  33433. createRange(name: string, from: number, to: number): void;
  33434. /**
  33435. * Deletes an animation range by name
  33436. * @param name Name of the animation range to delete
  33437. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  33438. */
  33439. deleteRange(name: string, deleteFrames?: boolean): void;
  33440. /**
  33441. * Gets the animation range by name, or null if not defined
  33442. * @param name Name of the animation range
  33443. * @returns Nullable animation range
  33444. */
  33445. getRange(name: string): Nullable<AnimationRange>;
  33446. /**
  33447. * Gets the key frames from the animation
  33448. * @returns The key frames of the animation
  33449. */
  33450. getKeys(): Array<IAnimationKey>;
  33451. /**
  33452. * Gets the highest frame rate of the animation
  33453. * @returns Highest frame rate of the animation
  33454. */
  33455. getHighestFrame(): number;
  33456. /**
  33457. * Gets the easing function of the animation
  33458. * @returns Easing function of the animation
  33459. */
  33460. getEasingFunction(): IEasingFunction;
  33461. /**
  33462. * Sets the easing function of the animation
  33463. * @param easingFunction A custom mathematical formula for animation
  33464. */
  33465. setEasingFunction(easingFunction: EasingFunction): void;
  33466. /**
  33467. * Interpolates a scalar linearly
  33468. * @param startValue Start value of the animation curve
  33469. * @param endValue End value of the animation curve
  33470. * @param gradient Scalar amount to interpolate
  33471. * @returns Interpolated scalar value
  33472. */
  33473. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  33474. /**
  33475. * Interpolates a scalar cubically
  33476. * @param startValue Start value of the animation curve
  33477. * @param outTangent End tangent of the animation
  33478. * @param endValue End value of the animation curve
  33479. * @param inTangent Start tangent of the animation curve
  33480. * @param gradient Scalar amount to interpolate
  33481. * @returns Interpolated scalar value
  33482. */
  33483. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  33484. /**
  33485. * Interpolates a quaternion using a spherical linear interpolation
  33486. * @param startValue Start value of the animation curve
  33487. * @param endValue End value of the animation curve
  33488. * @param gradient Scalar amount to interpolate
  33489. * @returns Interpolated quaternion value
  33490. */
  33491. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  33492. /**
  33493. * Interpolates a quaternion cubically
  33494. * @param startValue Start value of the animation curve
  33495. * @param outTangent End tangent of the animation curve
  33496. * @param endValue End value of the animation curve
  33497. * @param inTangent Start tangent of the animation curve
  33498. * @param gradient Scalar amount to interpolate
  33499. * @returns Interpolated quaternion value
  33500. */
  33501. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  33502. /**
  33503. * Interpolates a Vector3 linearl
  33504. * @param startValue Start value of the animation curve
  33505. * @param endValue End value of the animation curve
  33506. * @param gradient Scalar amount to interpolate
  33507. * @returns Interpolated scalar value
  33508. */
  33509. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  33510. /**
  33511. * Interpolates a Vector3 cubically
  33512. * @param startValue Start value of the animation curve
  33513. * @param outTangent End tangent of the animation
  33514. * @param endValue End value of the animation curve
  33515. * @param inTangent Start tangent of the animation curve
  33516. * @param gradient Scalar amount to interpolate
  33517. * @returns InterpolatedVector3 value
  33518. */
  33519. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  33520. /**
  33521. * Interpolates a Vector2 linearly
  33522. * @param startValue Start value of the animation curve
  33523. * @param endValue End value of the animation curve
  33524. * @param gradient Scalar amount to interpolate
  33525. * @returns Interpolated Vector2 value
  33526. */
  33527. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  33528. /**
  33529. * Interpolates a Vector2 cubically
  33530. * @param startValue Start value of the animation curve
  33531. * @param outTangent End tangent of the animation
  33532. * @param endValue End value of the animation curve
  33533. * @param inTangent Start tangent of the animation curve
  33534. * @param gradient Scalar amount to interpolate
  33535. * @returns Interpolated Vector2 value
  33536. */
  33537. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  33538. /**
  33539. * Interpolates a size linearly
  33540. * @param startValue Start value of the animation curve
  33541. * @param endValue End value of the animation curve
  33542. * @param gradient Scalar amount to interpolate
  33543. * @returns Interpolated Size value
  33544. */
  33545. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  33546. /**
  33547. * Interpolates a Color3 linearly
  33548. * @param startValue Start value of the animation curve
  33549. * @param endValue End value of the animation curve
  33550. * @param gradient Scalar amount to interpolate
  33551. * @returns Interpolated Color3 value
  33552. */
  33553. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  33554. /**
  33555. * Interpolates a Color4 linearly
  33556. * @param startValue Start value of the animation curve
  33557. * @param endValue End value of the animation curve
  33558. * @param gradient Scalar amount to interpolate
  33559. * @returns Interpolated Color3 value
  33560. */
  33561. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  33562. /**
  33563. * @hidden Internal use only
  33564. */
  33565. _getKeyValue(value: any): any;
  33566. /**
  33567. * @hidden Internal use only
  33568. */
  33569. _interpolate(currentFrame: number, state: _IAnimationState): any;
  33570. /**
  33571. * Defines the function to use to interpolate matrices
  33572. * @param startValue defines the start matrix
  33573. * @param endValue defines the end matrix
  33574. * @param gradient defines the gradient between both matrices
  33575. * @param result defines an optional target matrix where to store the interpolation
  33576. * @returns the interpolated matrix
  33577. */
  33578. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  33579. /**
  33580. * Makes a copy of the animation
  33581. * @returns Cloned animation
  33582. */
  33583. clone(): Animation;
  33584. /**
  33585. * Sets the key frames of the animation
  33586. * @param values The animation key frames to set
  33587. */
  33588. setKeys(values: Array<IAnimationKey>): void;
  33589. /**
  33590. * Serializes the animation to an object
  33591. * @returns Serialized object
  33592. */
  33593. serialize(): any;
  33594. /**
  33595. * Float animation type
  33596. */
  33597. static readonly ANIMATIONTYPE_FLOAT: number;
  33598. /**
  33599. * Vector3 animation type
  33600. */
  33601. static readonly ANIMATIONTYPE_VECTOR3: number;
  33602. /**
  33603. * Quaternion animation type
  33604. */
  33605. static readonly ANIMATIONTYPE_QUATERNION: number;
  33606. /**
  33607. * Matrix animation type
  33608. */
  33609. static readonly ANIMATIONTYPE_MATRIX: number;
  33610. /**
  33611. * Color3 animation type
  33612. */
  33613. static readonly ANIMATIONTYPE_COLOR3: number;
  33614. /**
  33615. * Color3 animation type
  33616. */
  33617. static readonly ANIMATIONTYPE_COLOR4: number;
  33618. /**
  33619. * Vector2 animation type
  33620. */
  33621. static readonly ANIMATIONTYPE_VECTOR2: number;
  33622. /**
  33623. * Size animation type
  33624. */
  33625. static readonly ANIMATIONTYPE_SIZE: number;
  33626. /**
  33627. * Relative Loop Mode
  33628. */
  33629. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  33630. /**
  33631. * Cycle Loop Mode
  33632. */
  33633. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  33634. /**
  33635. * Constant Loop Mode
  33636. */
  33637. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  33638. /** @hidden */
  33639. static _UniversalLerp(left: any, right: any, amount: number): any;
  33640. /**
  33641. * Parses an animation object and creates an animation
  33642. * @param parsedAnimation Parsed animation object
  33643. * @returns Animation object
  33644. */
  33645. static Parse(parsedAnimation: any): Animation;
  33646. /**
  33647. * Appends the serialized animations from the source animations
  33648. * @param source Source containing the animations
  33649. * @param destination Target to store the animations
  33650. */
  33651. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  33652. }
  33653. }
  33654. declare module "babylonjs/Animations/animatable.interface" {
  33655. import { Nullable } from "babylonjs/types";
  33656. import { Animation } from "babylonjs/Animations/animation";
  33657. /**
  33658. * Interface containing an array of animations
  33659. */
  33660. export interface IAnimatable {
  33661. /**
  33662. * Array of animations
  33663. */
  33664. animations: Nullable<Array<Animation>>;
  33665. }
  33666. }
  33667. declare module "babylonjs/Misc/decorators" {
  33668. import { Nullable } from "babylonjs/types";
  33669. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  33670. import { Scene } from "babylonjs/scene";
  33671. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  33672. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33673. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33674. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33675. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33676. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33677. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33678. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33679. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33680. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33681. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33682. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33683. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33684. /**
  33685. * Decorator used to define property that can be serialized as reference to a camera
  33686. * @param sourceName defines the name of the property to decorate
  33687. */
  33688. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33689. /**
  33690. * Class used to help serialization objects
  33691. */
  33692. export class SerializationHelper {
  33693. /** @hidden */
  33694. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  33695. /** @hidden */
  33696. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  33697. /** @hidden */
  33698. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  33699. /** @hidden */
  33700. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  33701. /**
  33702. * Appends the serialized animations from the source animations
  33703. * @param source Source containing the animations
  33704. * @param destination Target to store the animations
  33705. */
  33706. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  33707. /**
  33708. * Static function used to serialized a specific entity
  33709. * @param entity defines the entity to serialize
  33710. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  33711. * @returns a JSON compatible object representing the serialization of the entity
  33712. */
  33713. static Serialize<T>(entity: T, serializationObject?: any): any;
  33714. /**
  33715. * Creates a new entity from a serialization data object
  33716. * @param creationFunction defines a function used to instanciated the new entity
  33717. * @param source defines the source serialization data
  33718. * @param scene defines the hosting scene
  33719. * @param rootUrl defines the root url for resources
  33720. * @returns a new entity
  33721. */
  33722. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  33723. /**
  33724. * Clones an object
  33725. * @param creationFunction defines the function used to instanciate the new object
  33726. * @param source defines the source object
  33727. * @returns the cloned object
  33728. */
  33729. static Clone<T>(creationFunction: () => T, source: T): T;
  33730. /**
  33731. * Instanciates a new object based on a source one (some data will be shared between both object)
  33732. * @param creationFunction defines the function used to instanciate the new object
  33733. * @param source defines the source object
  33734. * @returns the new object
  33735. */
  33736. static Instanciate<T>(creationFunction: () => T, source: T): T;
  33737. }
  33738. }
  33739. declare module "babylonjs/Materials/Textures/baseTexture" {
  33740. import { Observable } from "babylonjs/Misc/observable";
  33741. import { Nullable } from "babylonjs/types";
  33742. import { Scene } from "babylonjs/scene";
  33743. import { Matrix } from "babylonjs/Maths/math.vector";
  33744. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  33745. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  33746. import { ISize } from "babylonjs/Maths/math.size";
  33747. import "babylonjs/Misc/fileTools";
  33748. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  33749. /**
  33750. * Base class of all the textures in babylon.
  33751. * It groups all the common properties the materials, post process, lights... might need
  33752. * in order to make a correct use of the texture.
  33753. */
  33754. export class BaseTexture implements IAnimatable {
  33755. /**
  33756. * Default anisotropic filtering level for the application.
  33757. * It is set to 4 as a good tradeoff between perf and quality.
  33758. */
  33759. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  33760. /**
  33761. * Gets or sets the unique id of the texture
  33762. */
  33763. uniqueId: number;
  33764. /**
  33765. * Define the name of the texture.
  33766. */
  33767. name: string;
  33768. /**
  33769. * Gets or sets an object used to store user defined information.
  33770. */
  33771. metadata: any;
  33772. /**
  33773. * For internal use only. Please do not use.
  33774. */
  33775. reservedDataStore: any;
  33776. private _hasAlpha;
  33777. /**
  33778. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  33779. */
  33780. set hasAlpha(value: boolean);
  33781. get hasAlpha(): boolean;
  33782. /**
  33783. * Defines if the alpha value should be determined via the rgb values.
  33784. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  33785. */
  33786. getAlphaFromRGB: boolean;
  33787. /**
  33788. * Intensity or strength of the texture.
  33789. * It is commonly used by materials to fine tune the intensity of the texture
  33790. */
  33791. level: number;
  33792. /**
  33793. * Define the UV chanel to use starting from 0 and defaulting to 0.
  33794. * This is part of the texture as textures usually maps to one uv set.
  33795. */
  33796. coordinatesIndex: number;
  33797. private _coordinatesMode;
  33798. /**
  33799. * How a texture is mapped.
  33800. *
  33801. * | Value | Type | Description |
  33802. * | ----- | ----------------------------------- | ----------- |
  33803. * | 0 | EXPLICIT_MODE | |
  33804. * | 1 | SPHERICAL_MODE | |
  33805. * | 2 | PLANAR_MODE | |
  33806. * | 3 | CUBIC_MODE | |
  33807. * | 4 | PROJECTION_MODE | |
  33808. * | 5 | SKYBOX_MODE | |
  33809. * | 6 | INVCUBIC_MODE | |
  33810. * | 7 | EQUIRECTANGULAR_MODE | |
  33811. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  33812. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  33813. */
  33814. set coordinatesMode(value: number);
  33815. get coordinatesMode(): number;
  33816. /**
  33817. * | Value | Type | Description |
  33818. * | ----- | ------------------ | ----------- |
  33819. * | 0 | CLAMP_ADDRESSMODE | |
  33820. * | 1 | WRAP_ADDRESSMODE | |
  33821. * | 2 | MIRROR_ADDRESSMODE | |
  33822. */
  33823. wrapU: number;
  33824. /**
  33825. * | Value | Type | Description |
  33826. * | ----- | ------------------ | ----------- |
  33827. * | 0 | CLAMP_ADDRESSMODE | |
  33828. * | 1 | WRAP_ADDRESSMODE | |
  33829. * | 2 | MIRROR_ADDRESSMODE | |
  33830. */
  33831. wrapV: number;
  33832. /**
  33833. * | Value | Type | Description |
  33834. * | ----- | ------------------ | ----------- |
  33835. * | 0 | CLAMP_ADDRESSMODE | |
  33836. * | 1 | WRAP_ADDRESSMODE | |
  33837. * | 2 | MIRROR_ADDRESSMODE | |
  33838. */
  33839. wrapR: number;
  33840. /**
  33841. * With compliant hardware and browser (supporting anisotropic filtering)
  33842. * this defines the level of anisotropic filtering in the texture.
  33843. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  33844. */
  33845. anisotropicFilteringLevel: number;
  33846. /**
  33847. * Define if the texture is a cube texture or if false a 2d texture.
  33848. */
  33849. get isCube(): boolean;
  33850. set isCube(value: boolean);
  33851. /**
  33852. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  33853. */
  33854. get is3D(): boolean;
  33855. set is3D(value: boolean);
  33856. /**
  33857. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  33858. */
  33859. get is2DArray(): boolean;
  33860. set is2DArray(value: boolean);
  33861. /**
  33862. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  33863. * HDR texture are usually stored in linear space.
  33864. * This only impacts the PBR and Background materials
  33865. */
  33866. gammaSpace: boolean;
  33867. /**
  33868. * Gets or sets whether or not the texture contains RGBD data.
  33869. */
  33870. get isRGBD(): boolean;
  33871. set isRGBD(value: boolean);
  33872. /**
  33873. * Is Z inverted in the texture (useful in a cube texture).
  33874. */
  33875. invertZ: boolean;
  33876. /**
  33877. * Are mip maps generated for this texture or not.
  33878. */
  33879. get noMipmap(): boolean;
  33880. /**
  33881. * @hidden
  33882. */
  33883. lodLevelInAlpha: boolean;
  33884. /**
  33885. * With prefiltered texture, defined the offset used during the prefiltering steps.
  33886. */
  33887. get lodGenerationOffset(): number;
  33888. set lodGenerationOffset(value: number);
  33889. /**
  33890. * With prefiltered texture, defined the scale used during the prefiltering steps.
  33891. */
  33892. get lodGenerationScale(): number;
  33893. set lodGenerationScale(value: number);
  33894. /**
  33895. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  33896. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  33897. * average roughness values.
  33898. */
  33899. get linearSpecularLOD(): boolean;
  33900. set linearSpecularLOD(value: boolean);
  33901. /**
  33902. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  33903. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  33904. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  33905. */
  33906. get irradianceTexture(): Nullable<BaseTexture>;
  33907. set irradianceTexture(value: Nullable<BaseTexture>);
  33908. /**
  33909. * Define if the texture is a render target.
  33910. */
  33911. isRenderTarget: boolean;
  33912. /**
  33913. * Define the unique id of the texture in the scene.
  33914. */
  33915. get uid(): string;
  33916. /** @hidden */
  33917. _prefiltered: boolean;
  33918. /**
  33919. * Return a string representation of the texture.
  33920. * @returns the texture as a string
  33921. */
  33922. toString(): string;
  33923. /**
  33924. * Get the class name of the texture.
  33925. * @returns "BaseTexture"
  33926. */
  33927. getClassName(): string;
  33928. /**
  33929. * Define the list of animation attached to the texture.
  33930. */
  33931. animations: import("babylonjs/Animations/animation").Animation[];
  33932. /**
  33933. * An event triggered when the texture is disposed.
  33934. */
  33935. onDisposeObservable: Observable<BaseTexture>;
  33936. private _onDisposeObserver;
  33937. /**
  33938. * Callback triggered when the texture has been disposed.
  33939. * Kept for back compatibility, you can use the onDisposeObservable instead.
  33940. */
  33941. set onDispose(callback: () => void);
  33942. /**
  33943. * Define the current state of the loading sequence when in delayed load mode.
  33944. */
  33945. delayLoadState: number;
  33946. private _scene;
  33947. private _engine;
  33948. /** @hidden */
  33949. _texture: Nullable<InternalTexture>;
  33950. private _uid;
  33951. /**
  33952. * Define if the texture is preventinga material to render or not.
  33953. * If not and the texture is not ready, the engine will use a default black texture instead.
  33954. */
  33955. get isBlocking(): boolean;
  33956. /**
  33957. * Instantiates a new BaseTexture.
  33958. * Base class of all the textures in babylon.
  33959. * It groups all the common properties the materials, post process, lights... might need
  33960. * in order to make a correct use of the texture.
  33961. * @param sceneOrEngine Define the scene or engine the texture blongs to
  33962. */
  33963. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  33964. /**
  33965. * Get the scene the texture belongs to.
  33966. * @returns the scene or null if undefined
  33967. */
  33968. getScene(): Nullable<Scene>;
  33969. /** @hidden */
  33970. protected _getEngine(): Nullable<ThinEngine>;
  33971. /**
  33972. * Get the texture transform matrix used to offset tile the texture for istance.
  33973. * @returns the transformation matrix
  33974. */
  33975. getTextureMatrix(): Matrix;
  33976. /**
  33977. * Get the texture reflection matrix used to rotate/transform the reflection.
  33978. * @returns the reflection matrix
  33979. */
  33980. getReflectionTextureMatrix(): Matrix;
  33981. /**
  33982. * Get the underlying lower level texture from Babylon.
  33983. * @returns the insternal texture
  33984. */
  33985. getInternalTexture(): Nullable<InternalTexture>;
  33986. /**
  33987. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  33988. * @returns true if ready or not blocking
  33989. */
  33990. isReadyOrNotBlocking(): boolean;
  33991. /**
  33992. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  33993. * @returns true if fully ready
  33994. */
  33995. isReady(): boolean;
  33996. private _cachedSize;
  33997. /**
  33998. * Get the size of the texture.
  33999. * @returns the texture size.
  34000. */
  34001. getSize(): ISize;
  34002. /**
  34003. * Get the base size of the texture.
  34004. * It can be different from the size if the texture has been resized for POT for instance
  34005. * @returns the base size
  34006. */
  34007. getBaseSize(): ISize;
  34008. /**
  34009. * Update the sampling mode of the texture.
  34010. * Default is Trilinear mode.
  34011. *
  34012. * | Value | Type | Description |
  34013. * | ----- | ------------------ | ----------- |
  34014. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  34015. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  34016. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  34017. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  34018. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  34019. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  34020. * | 7 | NEAREST_LINEAR | |
  34021. * | 8 | NEAREST_NEAREST | |
  34022. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  34023. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  34024. * | 11 | LINEAR_LINEAR | |
  34025. * | 12 | LINEAR_NEAREST | |
  34026. *
  34027. * > _mag_: magnification filter (close to the viewer)
  34028. * > _min_: minification filter (far from the viewer)
  34029. * > _mip_: filter used between mip map levels
  34030. *@param samplingMode Define the new sampling mode of the texture
  34031. */
  34032. updateSamplingMode(samplingMode: number): void;
  34033. /**
  34034. * Scales the texture if is `canRescale()`
  34035. * @param ratio the resize factor we want to use to rescale
  34036. */
  34037. scale(ratio: number): void;
  34038. /**
  34039. * Get if the texture can rescale.
  34040. */
  34041. get canRescale(): boolean;
  34042. /** @hidden */
  34043. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  34044. /** @hidden */
  34045. _rebuild(): void;
  34046. /**
  34047. * Triggers the load sequence in delayed load mode.
  34048. */
  34049. delayLoad(): void;
  34050. /**
  34051. * Clones the texture.
  34052. * @returns the cloned texture
  34053. */
  34054. clone(): Nullable<BaseTexture>;
  34055. /**
  34056. * Get the texture underlying type (INT, FLOAT...)
  34057. */
  34058. get textureType(): number;
  34059. /**
  34060. * Get the texture underlying format (RGB, RGBA...)
  34061. */
  34062. get textureFormat(): number;
  34063. /**
  34064. * Indicates that textures need to be re-calculated for all materials
  34065. */
  34066. protected _markAllSubMeshesAsTexturesDirty(): void;
  34067. /**
  34068. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  34069. * This will returns an RGBA array buffer containing either in values (0-255) or
  34070. * float values (0-1) depending of the underlying buffer type.
  34071. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  34072. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  34073. * @param buffer defines a user defined buffer to fill with data (can be null)
  34074. * @returns The Array buffer containing the pixels data.
  34075. */
  34076. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  34077. /**
  34078. * Release and destroy the underlying lower level texture aka internalTexture.
  34079. */
  34080. releaseInternalTexture(): void;
  34081. /** @hidden */
  34082. get _lodTextureHigh(): Nullable<BaseTexture>;
  34083. /** @hidden */
  34084. get _lodTextureMid(): Nullable<BaseTexture>;
  34085. /** @hidden */
  34086. get _lodTextureLow(): Nullable<BaseTexture>;
  34087. /**
  34088. * Dispose the texture and release its associated resources.
  34089. */
  34090. dispose(): void;
  34091. /**
  34092. * Serialize the texture into a JSON representation that can be parsed later on.
  34093. * @returns the JSON representation of the texture
  34094. */
  34095. serialize(): any;
  34096. /**
  34097. * Helper function to be called back once a list of texture contains only ready textures.
  34098. * @param textures Define the list of textures to wait for
  34099. * @param callback Define the callback triggered once the entire list will be ready
  34100. */
  34101. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  34102. private static _isScene;
  34103. }
  34104. }
  34105. declare module "babylonjs/Materials/effect" {
  34106. import { Observable } from "babylonjs/Misc/observable";
  34107. import { Nullable } from "babylonjs/types";
  34108. import { IDisposable } from "babylonjs/scene";
  34109. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  34110. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  34111. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  34112. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  34113. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  34114. import { Engine } from "babylonjs/Engines/engine";
  34115. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  34116. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  34117. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  34118. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  34119. /**
  34120. * Options to be used when creating an effect.
  34121. */
  34122. export interface IEffectCreationOptions {
  34123. /**
  34124. * Atrributes that will be used in the shader.
  34125. */
  34126. attributes: string[];
  34127. /**
  34128. * Uniform varible names that will be set in the shader.
  34129. */
  34130. uniformsNames: string[];
  34131. /**
  34132. * Uniform buffer variable names that will be set in the shader.
  34133. */
  34134. uniformBuffersNames: string[];
  34135. /**
  34136. * Sampler texture variable names that will be set in the shader.
  34137. */
  34138. samplers: string[];
  34139. /**
  34140. * Define statements that will be set in the shader.
  34141. */
  34142. defines: any;
  34143. /**
  34144. * Possible fallbacks for this effect to improve performance when needed.
  34145. */
  34146. fallbacks: Nullable<IEffectFallbacks>;
  34147. /**
  34148. * Callback that will be called when the shader is compiled.
  34149. */
  34150. onCompiled: Nullable<(effect: Effect) => void>;
  34151. /**
  34152. * Callback that will be called if an error occurs during shader compilation.
  34153. */
  34154. onError: Nullable<(effect: Effect, errors: string) => void>;
  34155. /**
  34156. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  34157. */
  34158. indexParameters?: any;
  34159. /**
  34160. * Max number of lights that can be used in the shader.
  34161. */
  34162. maxSimultaneousLights?: number;
  34163. /**
  34164. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  34165. */
  34166. transformFeedbackVaryings?: Nullable<string[]>;
  34167. }
  34168. /**
  34169. * Effect containing vertex and fragment shader that can be executed on an object.
  34170. */
  34171. export class Effect implements IDisposable {
  34172. /**
  34173. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  34174. */
  34175. static ShadersRepository: string;
  34176. /**
  34177. * Enable logging of the shader code when a compilation error occurs
  34178. */
  34179. static LogShaderCodeOnCompilationError: boolean;
  34180. /**
  34181. * Name of the effect.
  34182. */
  34183. name: any;
  34184. /**
  34185. * String container all the define statements that should be set on the shader.
  34186. */
  34187. defines: string;
  34188. /**
  34189. * Callback that will be called when the shader is compiled.
  34190. */
  34191. onCompiled: Nullable<(effect: Effect) => void>;
  34192. /**
  34193. * Callback that will be called if an error occurs during shader compilation.
  34194. */
  34195. onError: Nullable<(effect: Effect, errors: string) => void>;
  34196. /**
  34197. * Callback that will be called when effect is bound.
  34198. */
  34199. onBind: Nullable<(effect: Effect) => void>;
  34200. /**
  34201. * Unique ID of the effect.
  34202. */
  34203. uniqueId: number;
  34204. /**
  34205. * Observable that will be called when the shader is compiled.
  34206. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  34207. */
  34208. onCompileObservable: Observable<Effect>;
  34209. /**
  34210. * Observable that will be called if an error occurs during shader compilation.
  34211. */
  34212. onErrorObservable: Observable<Effect>;
  34213. /** @hidden */
  34214. _onBindObservable: Nullable<Observable<Effect>>;
  34215. /**
  34216. * @hidden
  34217. * Specifies if the effect was previously ready
  34218. */
  34219. _wasPreviouslyReady: boolean;
  34220. /**
  34221. * Observable that will be called when effect is bound.
  34222. */
  34223. get onBindObservable(): Observable<Effect>;
  34224. /** @hidden */
  34225. _bonesComputationForcedToCPU: boolean;
  34226. private static _uniqueIdSeed;
  34227. private _engine;
  34228. private _uniformBuffersNames;
  34229. private _uniformBuffersNamesList;
  34230. private _uniformsNames;
  34231. private _samplerList;
  34232. private _samplers;
  34233. private _isReady;
  34234. private _compilationError;
  34235. private _allFallbacksProcessed;
  34236. private _attributesNames;
  34237. private _attributes;
  34238. private _attributeLocationByName;
  34239. private _uniforms;
  34240. /**
  34241. * Key for the effect.
  34242. * @hidden
  34243. */
  34244. _key: string;
  34245. private _indexParameters;
  34246. private _fallbacks;
  34247. private _vertexSourceCode;
  34248. private _fragmentSourceCode;
  34249. private _vertexSourceCodeOverride;
  34250. private _fragmentSourceCodeOverride;
  34251. private _transformFeedbackVaryings;
  34252. /**
  34253. * Compiled shader to webGL program.
  34254. * @hidden
  34255. */
  34256. _pipelineContext: Nullable<IPipelineContext>;
  34257. private _valueCache;
  34258. private static _baseCache;
  34259. /**
  34260. * Instantiates an effect.
  34261. * An effect can be used to create/manage/execute vertex and fragment shaders.
  34262. * @param baseName Name of the effect.
  34263. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  34264. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  34265. * @param samplers List of sampler variables that will be passed to the shader.
  34266. * @param engine Engine to be used to render the effect
  34267. * @param defines Define statements to be added to the shader.
  34268. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  34269. * @param onCompiled Callback that will be called when the shader is compiled.
  34270. * @param onError Callback that will be called if an error occurs during shader compilation.
  34271. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  34272. */
  34273. 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);
  34274. private _useFinalCode;
  34275. /**
  34276. * Unique key for this effect
  34277. */
  34278. get key(): string;
  34279. /**
  34280. * If the effect has been compiled and prepared.
  34281. * @returns if the effect is compiled and prepared.
  34282. */
  34283. isReady(): boolean;
  34284. private _isReadyInternal;
  34285. /**
  34286. * The engine the effect was initialized with.
  34287. * @returns the engine.
  34288. */
  34289. getEngine(): Engine;
  34290. /**
  34291. * The pipeline context for this effect
  34292. * @returns the associated pipeline context
  34293. */
  34294. getPipelineContext(): Nullable<IPipelineContext>;
  34295. /**
  34296. * The set of names of attribute variables for the shader.
  34297. * @returns An array of attribute names.
  34298. */
  34299. getAttributesNames(): string[];
  34300. /**
  34301. * Returns the attribute at the given index.
  34302. * @param index The index of the attribute.
  34303. * @returns The location of the attribute.
  34304. */
  34305. getAttributeLocation(index: number): number;
  34306. /**
  34307. * Returns the attribute based on the name of the variable.
  34308. * @param name of the attribute to look up.
  34309. * @returns the attribute location.
  34310. */
  34311. getAttributeLocationByName(name: string): number;
  34312. /**
  34313. * The number of attributes.
  34314. * @returns the numnber of attributes.
  34315. */
  34316. getAttributesCount(): number;
  34317. /**
  34318. * Gets the index of a uniform variable.
  34319. * @param uniformName of the uniform to look up.
  34320. * @returns the index.
  34321. */
  34322. getUniformIndex(uniformName: string): number;
  34323. /**
  34324. * Returns the attribute based on the name of the variable.
  34325. * @param uniformName of the uniform to look up.
  34326. * @returns the location of the uniform.
  34327. */
  34328. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  34329. /**
  34330. * Returns an array of sampler variable names
  34331. * @returns The array of sampler variable names.
  34332. */
  34333. getSamplers(): string[];
  34334. /**
  34335. * Returns an array of uniform variable names
  34336. * @returns The array of uniform variable names.
  34337. */
  34338. getUniformNames(): string[];
  34339. /**
  34340. * Returns an array of uniform buffer variable names
  34341. * @returns The array of uniform buffer variable names.
  34342. */
  34343. getUniformBuffersNames(): string[];
  34344. /**
  34345. * Returns the index parameters used to create the effect
  34346. * @returns The index parameters object
  34347. */
  34348. getIndexParameters(): any;
  34349. /**
  34350. * The error from the last compilation.
  34351. * @returns the error string.
  34352. */
  34353. getCompilationError(): string;
  34354. /**
  34355. * Gets a boolean indicating that all fallbacks were used during compilation
  34356. * @returns true if all fallbacks were used
  34357. */
  34358. allFallbacksProcessed(): boolean;
  34359. /**
  34360. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  34361. * @param func The callback to be used.
  34362. */
  34363. executeWhenCompiled(func: (effect: Effect) => void): void;
  34364. private _checkIsReady;
  34365. private _loadShader;
  34366. /**
  34367. * Gets the vertex shader source code of this effect
  34368. */
  34369. get vertexSourceCode(): string;
  34370. /**
  34371. * Gets the fragment shader source code of this effect
  34372. */
  34373. get fragmentSourceCode(): string;
  34374. /**
  34375. * Recompiles the webGL program
  34376. * @param vertexSourceCode The source code for the vertex shader.
  34377. * @param fragmentSourceCode The source code for the fragment shader.
  34378. * @param onCompiled Callback called when completed.
  34379. * @param onError Callback called on error.
  34380. * @hidden
  34381. */
  34382. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  34383. /**
  34384. * Prepares the effect
  34385. * @hidden
  34386. */
  34387. _prepareEffect(): void;
  34388. private _getShaderCodeAndErrorLine;
  34389. private _processCompilationErrors;
  34390. /**
  34391. * Checks if the effect is supported. (Must be called after compilation)
  34392. */
  34393. get isSupported(): boolean;
  34394. /**
  34395. * Binds a texture to the engine to be used as output of the shader.
  34396. * @param channel Name of the output variable.
  34397. * @param texture Texture to bind.
  34398. * @hidden
  34399. */
  34400. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  34401. /**
  34402. * Sets a texture on the engine to be used in the shader.
  34403. * @param channel Name of the sampler variable.
  34404. * @param texture Texture to set.
  34405. */
  34406. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  34407. /**
  34408. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  34409. * @param channel Name of the sampler variable.
  34410. * @param texture Texture to set.
  34411. */
  34412. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  34413. /**
  34414. * Sets an array of textures on the engine to be used in the shader.
  34415. * @param channel Name of the variable.
  34416. * @param textures Textures to set.
  34417. */
  34418. setTextureArray(channel: string, textures: BaseTexture[]): void;
  34419. /**
  34420. * 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)
  34421. * @param channel Name of the sampler variable.
  34422. * @param postProcess Post process to get the input texture from.
  34423. */
  34424. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  34425. /**
  34426. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  34427. * 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)
  34428. * @param channel Name of the sampler variable.
  34429. * @param postProcess Post process to get the output texture from.
  34430. */
  34431. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  34432. /** @hidden */
  34433. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  34434. /** @hidden */
  34435. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  34436. /** @hidden */
  34437. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  34438. /** @hidden */
  34439. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  34440. /**
  34441. * Binds a buffer to a uniform.
  34442. * @param buffer Buffer to bind.
  34443. * @param name Name of the uniform variable to bind to.
  34444. */
  34445. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  34446. /**
  34447. * Binds block to a uniform.
  34448. * @param blockName Name of the block to bind.
  34449. * @param index Index to bind.
  34450. */
  34451. bindUniformBlock(blockName: string, index: number): void;
  34452. /**
  34453. * Sets an interger value on a uniform variable.
  34454. * @param uniformName Name of the variable.
  34455. * @param value Value to be set.
  34456. * @returns this effect.
  34457. */
  34458. setInt(uniformName: string, value: number): Effect;
  34459. /**
  34460. * Sets an int array on a uniform variable.
  34461. * @param uniformName Name of the variable.
  34462. * @param array array to be set.
  34463. * @returns this effect.
  34464. */
  34465. setIntArray(uniformName: string, array: Int32Array): Effect;
  34466. /**
  34467. * 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)
  34468. * @param uniformName Name of the variable.
  34469. * @param array array to be set.
  34470. * @returns this effect.
  34471. */
  34472. setIntArray2(uniformName: string, array: Int32Array): Effect;
  34473. /**
  34474. * 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)
  34475. * @param uniformName Name of the variable.
  34476. * @param array array to be set.
  34477. * @returns this effect.
  34478. */
  34479. setIntArray3(uniformName: string, array: Int32Array): Effect;
  34480. /**
  34481. * 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)
  34482. * @param uniformName Name of the variable.
  34483. * @param array array to be set.
  34484. * @returns this effect.
  34485. */
  34486. setIntArray4(uniformName: string, array: Int32Array): Effect;
  34487. /**
  34488. * Sets an float array on a uniform variable.
  34489. * @param uniformName Name of the variable.
  34490. * @param array array to be set.
  34491. * @returns this effect.
  34492. */
  34493. setFloatArray(uniformName: string, array: Float32Array): Effect;
  34494. /**
  34495. * 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)
  34496. * @param uniformName Name of the variable.
  34497. * @param array array to be set.
  34498. * @returns this effect.
  34499. */
  34500. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  34501. /**
  34502. * 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)
  34503. * @param uniformName Name of the variable.
  34504. * @param array array to be set.
  34505. * @returns this effect.
  34506. */
  34507. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  34508. /**
  34509. * 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)
  34510. * @param uniformName Name of the variable.
  34511. * @param array array to be set.
  34512. * @returns this effect.
  34513. */
  34514. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  34515. /**
  34516. * Sets an array on a uniform variable.
  34517. * @param uniformName Name of the variable.
  34518. * @param array array to be set.
  34519. * @returns this effect.
  34520. */
  34521. setArray(uniformName: string, array: number[]): Effect;
  34522. /**
  34523. * 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)
  34524. * @param uniformName Name of the variable.
  34525. * @param array array to be set.
  34526. * @returns this effect.
  34527. */
  34528. setArray2(uniformName: string, array: number[]): Effect;
  34529. /**
  34530. * 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)
  34531. * @param uniformName Name of the variable.
  34532. * @param array array to be set.
  34533. * @returns this effect.
  34534. */
  34535. setArray3(uniformName: string, array: number[]): Effect;
  34536. /**
  34537. * 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)
  34538. * @param uniformName Name of the variable.
  34539. * @param array array to be set.
  34540. * @returns this effect.
  34541. */
  34542. setArray4(uniformName: string, array: number[]): Effect;
  34543. /**
  34544. * Sets matrices on a uniform variable.
  34545. * @param uniformName Name of the variable.
  34546. * @param matrices matrices to be set.
  34547. * @returns this effect.
  34548. */
  34549. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  34550. /**
  34551. * Sets matrix on a uniform variable.
  34552. * @param uniformName Name of the variable.
  34553. * @param matrix matrix to be set.
  34554. * @returns this effect.
  34555. */
  34556. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  34557. /**
  34558. * 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)
  34559. * @param uniformName Name of the variable.
  34560. * @param matrix matrix to be set.
  34561. * @returns this effect.
  34562. */
  34563. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  34564. /**
  34565. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  34566. * @param uniformName Name of the variable.
  34567. * @param matrix matrix to be set.
  34568. * @returns this effect.
  34569. */
  34570. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  34571. /**
  34572. * Sets a float on a uniform variable.
  34573. * @param uniformName Name of the variable.
  34574. * @param value value to be set.
  34575. * @returns this effect.
  34576. */
  34577. setFloat(uniformName: string, value: number): Effect;
  34578. /**
  34579. * Sets a boolean on a uniform variable.
  34580. * @param uniformName Name of the variable.
  34581. * @param bool value to be set.
  34582. * @returns this effect.
  34583. */
  34584. setBool(uniformName: string, bool: boolean): Effect;
  34585. /**
  34586. * Sets a Vector2 on a uniform variable.
  34587. * @param uniformName Name of the variable.
  34588. * @param vector2 vector2 to be set.
  34589. * @returns this effect.
  34590. */
  34591. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  34592. /**
  34593. * Sets a float2 on a uniform variable.
  34594. * @param uniformName Name of the variable.
  34595. * @param x First float in float2.
  34596. * @param y Second float in float2.
  34597. * @returns this effect.
  34598. */
  34599. setFloat2(uniformName: string, x: number, y: number): Effect;
  34600. /**
  34601. * Sets a Vector3 on a uniform variable.
  34602. * @param uniformName Name of the variable.
  34603. * @param vector3 Value to be set.
  34604. * @returns this effect.
  34605. */
  34606. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  34607. /**
  34608. * Sets a float3 on a uniform variable.
  34609. * @param uniformName Name of the variable.
  34610. * @param x First float in float3.
  34611. * @param y Second float in float3.
  34612. * @param z Third float in float3.
  34613. * @returns this effect.
  34614. */
  34615. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  34616. /**
  34617. * Sets a Vector4 on a uniform variable.
  34618. * @param uniformName Name of the variable.
  34619. * @param vector4 Value to be set.
  34620. * @returns this effect.
  34621. */
  34622. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  34623. /**
  34624. * Sets a float4 on a uniform variable.
  34625. * @param uniformName Name of the variable.
  34626. * @param x First float in float4.
  34627. * @param y Second float in float4.
  34628. * @param z Third float in float4.
  34629. * @param w Fourth float in float4.
  34630. * @returns this effect.
  34631. */
  34632. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  34633. /**
  34634. * Sets a Color3 on a uniform variable.
  34635. * @param uniformName Name of the variable.
  34636. * @param color3 Value to be set.
  34637. * @returns this effect.
  34638. */
  34639. setColor3(uniformName: string, color3: IColor3Like): Effect;
  34640. /**
  34641. * Sets a Color4 on a uniform variable.
  34642. * @param uniformName Name of the variable.
  34643. * @param color3 Value to be set.
  34644. * @param alpha Alpha value to be set.
  34645. * @returns this effect.
  34646. */
  34647. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  34648. /**
  34649. * Sets a Color4 on a uniform variable
  34650. * @param uniformName defines the name of the variable
  34651. * @param color4 defines the value to be set
  34652. * @returns this effect.
  34653. */
  34654. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  34655. /** Release all associated resources */
  34656. dispose(): void;
  34657. /**
  34658. * This function will add a new shader to the shader store
  34659. * @param name the name of the shader
  34660. * @param pixelShader optional pixel shader content
  34661. * @param vertexShader optional vertex shader content
  34662. */
  34663. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  34664. /**
  34665. * Store of each shader (The can be looked up using effect.key)
  34666. */
  34667. static ShadersStore: {
  34668. [key: string]: string;
  34669. };
  34670. /**
  34671. * Store of each included file for a shader (The can be looked up using effect.key)
  34672. */
  34673. static IncludesShadersStore: {
  34674. [key: string]: string;
  34675. };
  34676. /**
  34677. * Resets the cache of effects.
  34678. */
  34679. static ResetCache(): void;
  34680. }
  34681. }
  34682. declare module "babylonjs/Engines/engineCapabilities" {
  34683. /**
  34684. * Interface used to describe the capabilities of the engine relatively to the current browser
  34685. */
  34686. export interface EngineCapabilities {
  34687. /** Maximum textures units per fragment shader */
  34688. maxTexturesImageUnits: number;
  34689. /** Maximum texture units per vertex shader */
  34690. maxVertexTextureImageUnits: number;
  34691. /** Maximum textures units in the entire pipeline */
  34692. maxCombinedTexturesImageUnits: number;
  34693. /** Maximum texture size */
  34694. maxTextureSize: number;
  34695. /** Maximum texture samples */
  34696. maxSamples?: number;
  34697. /** Maximum cube texture size */
  34698. maxCubemapTextureSize: number;
  34699. /** Maximum render texture size */
  34700. maxRenderTextureSize: number;
  34701. /** Maximum number of vertex attributes */
  34702. maxVertexAttribs: number;
  34703. /** Maximum number of varyings */
  34704. maxVaryingVectors: number;
  34705. /** Maximum number of uniforms per vertex shader */
  34706. maxVertexUniformVectors: number;
  34707. /** Maximum number of uniforms per fragment shader */
  34708. maxFragmentUniformVectors: number;
  34709. /** Defines if standard derivates (dx/dy) are supported */
  34710. standardDerivatives: boolean;
  34711. /** Defines if s3tc texture compression is supported */
  34712. s3tc?: WEBGL_compressed_texture_s3tc;
  34713. /** Defines if pvrtc texture compression is supported */
  34714. pvrtc: any;
  34715. /** Defines if etc1 texture compression is supported */
  34716. etc1: any;
  34717. /** Defines if etc2 texture compression is supported */
  34718. etc2: any;
  34719. /** Defines if astc texture compression is supported */
  34720. astc: any;
  34721. /** Defines if float textures are supported */
  34722. textureFloat: boolean;
  34723. /** Defines if vertex array objects are supported */
  34724. vertexArrayObject: boolean;
  34725. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  34726. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  34727. /** Gets the maximum level of anisotropy supported */
  34728. maxAnisotropy: number;
  34729. /** Defines if instancing is supported */
  34730. instancedArrays: boolean;
  34731. /** Defines if 32 bits indices are supported */
  34732. uintIndices: boolean;
  34733. /** Defines if high precision shaders are supported */
  34734. highPrecisionShaderSupported: boolean;
  34735. /** Defines if depth reading in the fragment shader is supported */
  34736. fragmentDepthSupported: boolean;
  34737. /** Defines if float texture linear filtering is supported*/
  34738. textureFloatLinearFiltering: boolean;
  34739. /** Defines if rendering to float textures is supported */
  34740. textureFloatRender: boolean;
  34741. /** Defines if half float textures are supported*/
  34742. textureHalfFloat: boolean;
  34743. /** Defines if half float texture linear filtering is supported*/
  34744. textureHalfFloatLinearFiltering: boolean;
  34745. /** Defines if rendering to half float textures is supported */
  34746. textureHalfFloatRender: boolean;
  34747. /** Defines if textureLOD shader command is supported */
  34748. textureLOD: boolean;
  34749. /** Defines if draw buffers extension is supported */
  34750. drawBuffersExtension: boolean;
  34751. /** Defines if depth textures are supported */
  34752. depthTextureExtension: boolean;
  34753. /** Defines if float color buffer are supported */
  34754. colorBufferFloat: boolean;
  34755. /** Gets disjoint timer query extension (null if not supported) */
  34756. timerQuery?: EXT_disjoint_timer_query;
  34757. /** Defines if timestamp can be used with timer query */
  34758. canUseTimestampForTimerQuery: boolean;
  34759. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  34760. multiview?: any;
  34761. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  34762. oculusMultiview?: any;
  34763. /** Function used to let the system compiles shaders in background */
  34764. parallelShaderCompile?: {
  34765. COMPLETION_STATUS_KHR: number;
  34766. };
  34767. /** Max number of texture samples for MSAA */
  34768. maxMSAASamples: number;
  34769. /** Defines if the blend min max extension is supported */
  34770. blendMinMax: boolean;
  34771. }
  34772. }
  34773. declare module "babylonjs/States/depthCullingState" {
  34774. import { Nullable } from "babylonjs/types";
  34775. /**
  34776. * @hidden
  34777. **/
  34778. export class DepthCullingState {
  34779. private _isDepthTestDirty;
  34780. private _isDepthMaskDirty;
  34781. private _isDepthFuncDirty;
  34782. private _isCullFaceDirty;
  34783. private _isCullDirty;
  34784. private _isZOffsetDirty;
  34785. private _isFrontFaceDirty;
  34786. private _depthTest;
  34787. private _depthMask;
  34788. private _depthFunc;
  34789. private _cull;
  34790. private _cullFace;
  34791. private _zOffset;
  34792. private _frontFace;
  34793. /**
  34794. * Initializes the state.
  34795. */
  34796. constructor();
  34797. get isDirty(): boolean;
  34798. get zOffset(): number;
  34799. set zOffset(value: number);
  34800. get cullFace(): Nullable<number>;
  34801. set cullFace(value: Nullable<number>);
  34802. get cull(): Nullable<boolean>;
  34803. set cull(value: Nullable<boolean>);
  34804. get depthFunc(): Nullable<number>;
  34805. set depthFunc(value: Nullable<number>);
  34806. get depthMask(): boolean;
  34807. set depthMask(value: boolean);
  34808. get depthTest(): boolean;
  34809. set depthTest(value: boolean);
  34810. get frontFace(): Nullable<number>;
  34811. set frontFace(value: Nullable<number>);
  34812. reset(): void;
  34813. apply(gl: WebGLRenderingContext): void;
  34814. }
  34815. }
  34816. declare module "babylonjs/States/stencilState" {
  34817. /**
  34818. * @hidden
  34819. **/
  34820. export class StencilState {
  34821. /** 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 */
  34822. static readonly ALWAYS: number;
  34823. /** Passed to stencilOperation to specify that stencil value must be kept */
  34824. static readonly KEEP: number;
  34825. /** Passed to stencilOperation to specify that stencil value must be replaced */
  34826. static readonly REPLACE: number;
  34827. private _isStencilTestDirty;
  34828. private _isStencilMaskDirty;
  34829. private _isStencilFuncDirty;
  34830. private _isStencilOpDirty;
  34831. private _stencilTest;
  34832. private _stencilMask;
  34833. private _stencilFunc;
  34834. private _stencilFuncRef;
  34835. private _stencilFuncMask;
  34836. private _stencilOpStencilFail;
  34837. private _stencilOpDepthFail;
  34838. private _stencilOpStencilDepthPass;
  34839. get isDirty(): boolean;
  34840. get stencilFunc(): number;
  34841. set stencilFunc(value: number);
  34842. get stencilFuncRef(): number;
  34843. set stencilFuncRef(value: number);
  34844. get stencilFuncMask(): number;
  34845. set stencilFuncMask(value: number);
  34846. get stencilOpStencilFail(): number;
  34847. set stencilOpStencilFail(value: number);
  34848. get stencilOpDepthFail(): number;
  34849. set stencilOpDepthFail(value: number);
  34850. get stencilOpStencilDepthPass(): number;
  34851. set stencilOpStencilDepthPass(value: number);
  34852. get stencilMask(): number;
  34853. set stencilMask(value: number);
  34854. get stencilTest(): boolean;
  34855. set stencilTest(value: boolean);
  34856. constructor();
  34857. reset(): void;
  34858. apply(gl: WebGLRenderingContext): void;
  34859. }
  34860. }
  34861. declare module "babylonjs/States/alphaCullingState" {
  34862. /**
  34863. * @hidden
  34864. **/
  34865. export class AlphaState {
  34866. private _isAlphaBlendDirty;
  34867. private _isBlendFunctionParametersDirty;
  34868. private _isBlendEquationParametersDirty;
  34869. private _isBlendConstantsDirty;
  34870. private _alphaBlend;
  34871. private _blendFunctionParameters;
  34872. private _blendEquationParameters;
  34873. private _blendConstants;
  34874. /**
  34875. * Initializes the state.
  34876. */
  34877. constructor();
  34878. get isDirty(): boolean;
  34879. get alphaBlend(): boolean;
  34880. set alphaBlend(value: boolean);
  34881. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  34882. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  34883. setAlphaEquationParameters(rgb: number, alpha: number): void;
  34884. reset(): void;
  34885. apply(gl: WebGLRenderingContext): void;
  34886. }
  34887. }
  34888. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  34889. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  34890. /** @hidden */
  34891. export class WebGL2ShaderProcessor implements IShaderProcessor {
  34892. attributeProcessor(attribute: string): string;
  34893. varyingProcessor(varying: string, isFragment: boolean): string;
  34894. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  34895. }
  34896. }
  34897. declare module "babylonjs/Engines/instancingAttributeInfo" {
  34898. /**
  34899. * Interface for attribute information associated with buffer instanciation
  34900. */
  34901. export interface InstancingAttributeInfo {
  34902. /**
  34903. * Name of the GLSL attribute
  34904. * if attribute index is not specified, this is used to retrieve the index from the effect
  34905. */
  34906. attributeName: string;
  34907. /**
  34908. * Index/offset of the attribute in the vertex shader
  34909. * if not specified, this will be computes from the name.
  34910. */
  34911. index?: number;
  34912. /**
  34913. * size of the attribute, 1, 2, 3 or 4
  34914. */
  34915. attributeSize: number;
  34916. /**
  34917. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  34918. */
  34919. offset: number;
  34920. /**
  34921. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  34922. * default to 1
  34923. */
  34924. divisor?: number;
  34925. /**
  34926. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  34927. * default is FLOAT
  34928. */
  34929. attributeType?: number;
  34930. /**
  34931. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  34932. */
  34933. normalized?: boolean;
  34934. }
  34935. }
  34936. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  34937. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  34938. import { Nullable } from "babylonjs/types";
  34939. module "babylonjs/Engines/thinEngine" {
  34940. interface ThinEngine {
  34941. /**
  34942. * Update a video texture
  34943. * @param texture defines the texture to update
  34944. * @param video defines the video element to use
  34945. * @param invertY defines if data must be stored with Y axis inverted
  34946. */
  34947. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  34948. }
  34949. }
  34950. }
  34951. declare module "babylonjs/Materials/Textures/videoTexture" {
  34952. import { Observable } from "babylonjs/Misc/observable";
  34953. import { Nullable } from "babylonjs/types";
  34954. import { Scene } from "babylonjs/scene";
  34955. import { Texture } from "babylonjs/Materials/Textures/texture";
  34956. import "babylonjs/Engines/Extensions/engine.videoTexture";
  34957. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  34958. /**
  34959. * Settings for finer control over video usage
  34960. */
  34961. export interface VideoTextureSettings {
  34962. /**
  34963. * Applies `autoplay` to video, if specified
  34964. */
  34965. autoPlay?: boolean;
  34966. /**
  34967. * Applies `loop` to video, if specified
  34968. */
  34969. loop?: boolean;
  34970. /**
  34971. * Automatically updates internal texture from video at every frame in the render loop
  34972. */
  34973. autoUpdateTexture: boolean;
  34974. /**
  34975. * Image src displayed during the video loading or until the user interacts with the video.
  34976. */
  34977. poster?: string;
  34978. }
  34979. /**
  34980. * If you want to display a video in your scene, this is the special texture for that.
  34981. * This special texture works similar to other textures, with the exception of a few parameters.
  34982. * @see https://doc.babylonjs.com/how_to/video_texture
  34983. */
  34984. export class VideoTexture extends Texture {
  34985. /**
  34986. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  34987. */
  34988. readonly autoUpdateTexture: boolean;
  34989. /**
  34990. * The video instance used by the texture internally
  34991. */
  34992. readonly video: HTMLVideoElement;
  34993. private _onUserActionRequestedObservable;
  34994. /**
  34995. * Event triggerd when a dom action is required by the user to play the video.
  34996. * This happens due to recent changes in browser policies preventing video to auto start.
  34997. */
  34998. get onUserActionRequestedObservable(): Observable<Texture>;
  34999. private _generateMipMaps;
  35000. private _stillImageCaptured;
  35001. private _displayingPosterTexture;
  35002. private _settings;
  35003. private _createInternalTextureOnEvent;
  35004. private _frameId;
  35005. private _currentSrc;
  35006. /**
  35007. * Creates a video texture.
  35008. * If you want to display a video in your scene, this is the special texture for that.
  35009. * This special texture works similar to other textures, with the exception of a few parameters.
  35010. * @see https://doc.babylonjs.com/how_to/video_texture
  35011. * @param name optional name, will detect from video source, if not defined
  35012. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  35013. * @param scene is obviously the current scene.
  35014. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  35015. * @param invertY is false by default but can be used to invert video on Y axis
  35016. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  35017. * @param settings allows finer control over video usage
  35018. */
  35019. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  35020. private _getName;
  35021. private _getVideo;
  35022. private _createInternalTexture;
  35023. private reset;
  35024. /**
  35025. * @hidden Internal method to initiate `update`.
  35026. */
  35027. _rebuild(): void;
  35028. /**
  35029. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  35030. */
  35031. update(): void;
  35032. /**
  35033. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  35034. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  35035. */
  35036. updateTexture(isVisible: boolean): void;
  35037. protected _updateInternalTexture: () => void;
  35038. /**
  35039. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  35040. * @param url New url.
  35041. */
  35042. updateURL(url: string): void;
  35043. /**
  35044. * Clones the texture.
  35045. * @returns the cloned texture
  35046. */
  35047. clone(): VideoTexture;
  35048. /**
  35049. * Dispose the texture and release its associated resources.
  35050. */
  35051. dispose(): void;
  35052. /**
  35053. * Creates a video texture straight from a stream.
  35054. * @param scene Define the scene the texture should be created in
  35055. * @param stream Define the stream the texture should be created from
  35056. * @returns The created video texture as a promise
  35057. */
  35058. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  35059. /**
  35060. * Creates a video texture straight from your WebCam video feed.
  35061. * @param scene Define the scene the texture should be created in
  35062. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  35063. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  35064. * @returns The created video texture as a promise
  35065. */
  35066. static CreateFromWebCamAsync(scene: Scene, constraints: {
  35067. minWidth: number;
  35068. maxWidth: number;
  35069. minHeight: number;
  35070. maxHeight: number;
  35071. deviceId: string;
  35072. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  35073. /**
  35074. * Creates a video texture straight from your WebCam video feed.
  35075. * @param scene Define the scene the texture should be created in
  35076. * @param onReady Define a callback to triggered once the texture will be ready
  35077. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  35078. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  35079. */
  35080. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  35081. minWidth: number;
  35082. maxWidth: number;
  35083. minHeight: number;
  35084. maxHeight: number;
  35085. deviceId: string;
  35086. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  35087. }
  35088. }
  35089. declare module "babylonjs/Engines/thinEngine" {
  35090. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  35091. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  35092. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  35093. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  35094. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  35095. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  35096. import { Observable } from "babylonjs/Misc/observable";
  35097. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  35098. import { StencilState } from "babylonjs/States/stencilState";
  35099. import { AlphaState } from "babylonjs/States/alphaCullingState";
  35100. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  35101. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  35102. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  35103. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  35104. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  35105. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  35106. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  35107. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  35108. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35109. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  35110. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  35111. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  35112. import { WebRequest } from "babylonjs/Misc/webRequest";
  35113. import { LoadFileError } from "babylonjs/Misc/fileTools";
  35114. /**
  35115. * Defines the interface used by objects working like Scene
  35116. * @hidden
  35117. */
  35118. export interface ISceneLike {
  35119. _addPendingData(data: any): void;
  35120. _removePendingData(data: any): void;
  35121. offlineProvider: IOfflineProvider;
  35122. }
  35123. /** Interface defining initialization parameters for Engine class */
  35124. export interface EngineOptions extends WebGLContextAttributes {
  35125. /**
  35126. * Defines if the engine should no exceed a specified device ratio
  35127. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  35128. */
  35129. limitDeviceRatio?: number;
  35130. /**
  35131. * Defines if webvr should be enabled automatically
  35132. * @see http://doc.babylonjs.com/how_to/webvr_camera
  35133. */
  35134. autoEnableWebVR?: boolean;
  35135. /**
  35136. * Defines if webgl2 should be turned off even if supported
  35137. * @see http://doc.babylonjs.com/features/webgl2
  35138. */
  35139. disableWebGL2Support?: boolean;
  35140. /**
  35141. * Defines if webaudio should be initialized as well
  35142. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35143. */
  35144. audioEngine?: boolean;
  35145. /**
  35146. * Defines if animations should run using a deterministic lock step
  35147. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35148. */
  35149. deterministicLockstep?: boolean;
  35150. /** Defines the maximum steps to use with deterministic lock step mode */
  35151. lockstepMaxSteps?: number;
  35152. /** Defines the seconds between each deterministic lock step */
  35153. timeStep?: number;
  35154. /**
  35155. * Defines that engine should ignore context lost events
  35156. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  35157. */
  35158. doNotHandleContextLost?: boolean;
  35159. /**
  35160. * Defines that engine should ignore modifying touch action attribute and style
  35161. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  35162. */
  35163. doNotHandleTouchAction?: boolean;
  35164. /**
  35165. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  35166. */
  35167. useHighPrecisionFloats?: boolean;
  35168. }
  35169. /**
  35170. * The base engine class (root of all engines)
  35171. */
  35172. export class ThinEngine {
  35173. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  35174. static ExceptionList: ({
  35175. key: string;
  35176. capture: string;
  35177. captureConstraint: number;
  35178. targets: string[];
  35179. } | {
  35180. key: string;
  35181. capture: null;
  35182. captureConstraint: null;
  35183. targets: string[];
  35184. })[];
  35185. /** @hidden */
  35186. static _TextureLoaders: IInternalTextureLoader[];
  35187. /**
  35188. * Returns the current npm package of the sdk
  35189. */
  35190. static get NpmPackage(): string;
  35191. /**
  35192. * Returns the current version of the framework
  35193. */
  35194. static get Version(): string;
  35195. /**
  35196. * Returns a string describing the current engine
  35197. */
  35198. get description(): string;
  35199. /**
  35200. * Gets or sets the epsilon value used by collision engine
  35201. */
  35202. static CollisionsEpsilon: number;
  35203. /**
  35204. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  35205. */
  35206. static get ShadersRepository(): string;
  35207. static set ShadersRepository(value: string);
  35208. /** @hidden */
  35209. _shaderProcessor: IShaderProcessor;
  35210. /**
  35211. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  35212. */
  35213. forcePOTTextures: boolean;
  35214. /**
  35215. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  35216. */
  35217. isFullscreen: boolean;
  35218. /**
  35219. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  35220. */
  35221. cullBackFaces: boolean;
  35222. /**
  35223. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  35224. */
  35225. renderEvenInBackground: boolean;
  35226. /**
  35227. * Gets or sets a boolean indicating that cache can be kept between frames
  35228. */
  35229. preventCacheWipeBetweenFrames: boolean;
  35230. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  35231. validateShaderPrograms: boolean;
  35232. /**
  35233. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  35234. * This can provide greater z depth for distant objects.
  35235. */
  35236. useReverseDepthBuffer: boolean;
  35237. /**
  35238. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  35239. */
  35240. disableUniformBuffers: boolean;
  35241. /** @hidden */
  35242. _uniformBuffers: UniformBuffer[];
  35243. /**
  35244. * Gets a boolean indicating that the engine supports uniform buffers
  35245. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  35246. */
  35247. get supportsUniformBuffers(): boolean;
  35248. /** @hidden */
  35249. _gl: WebGLRenderingContext;
  35250. /** @hidden */
  35251. _webGLVersion: number;
  35252. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  35253. protected _windowIsBackground: boolean;
  35254. protected _creationOptions: EngineOptions;
  35255. protected _highPrecisionShadersAllowed: boolean;
  35256. /** @hidden */
  35257. get _shouldUseHighPrecisionShader(): boolean;
  35258. /**
  35259. * Gets a boolean indicating that only power of 2 textures are supported
  35260. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  35261. */
  35262. get needPOTTextures(): boolean;
  35263. /** @hidden */
  35264. _badOS: boolean;
  35265. /** @hidden */
  35266. _badDesktopOS: boolean;
  35267. private _hardwareScalingLevel;
  35268. /** @hidden */
  35269. _caps: EngineCapabilities;
  35270. private _isStencilEnable;
  35271. private _glVersion;
  35272. private _glRenderer;
  35273. private _glVendor;
  35274. /** @hidden */
  35275. _videoTextureSupported: boolean;
  35276. protected _renderingQueueLaunched: boolean;
  35277. protected _activeRenderLoops: (() => void)[];
  35278. /**
  35279. * Observable signaled when a context lost event is raised
  35280. */
  35281. onContextLostObservable: Observable<ThinEngine>;
  35282. /**
  35283. * Observable signaled when a context restored event is raised
  35284. */
  35285. onContextRestoredObservable: Observable<ThinEngine>;
  35286. private _onContextLost;
  35287. private _onContextRestored;
  35288. protected _contextWasLost: boolean;
  35289. /** @hidden */
  35290. _doNotHandleContextLost: boolean;
  35291. /**
  35292. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  35293. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  35294. */
  35295. get doNotHandleContextLost(): boolean;
  35296. set doNotHandleContextLost(value: boolean);
  35297. /**
  35298. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  35299. */
  35300. disableVertexArrayObjects: boolean;
  35301. /** @hidden */
  35302. protected _colorWrite: boolean;
  35303. /** @hidden */
  35304. protected _colorWriteChanged: boolean;
  35305. /** @hidden */
  35306. protected _depthCullingState: DepthCullingState;
  35307. /** @hidden */
  35308. protected _stencilState: StencilState;
  35309. /** @hidden */
  35310. _alphaState: AlphaState;
  35311. /** @hidden */
  35312. _alphaMode: number;
  35313. /** @hidden */
  35314. _alphaEquation: number;
  35315. /** @hidden */
  35316. _internalTexturesCache: InternalTexture[];
  35317. /** @hidden */
  35318. protected _activeChannel: number;
  35319. private _currentTextureChannel;
  35320. /** @hidden */
  35321. protected _boundTexturesCache: {
  35322. [key: string]: Nullable<InternalTexture>;
  35323. };
  35324. /** @hidden */
  35325. protected _currentEffect: Nullable<Effect>;
  35326. /** @hidden */
  35327. protected _currentProgram: Nullable<WebGLProgram>;
  35328. private _compiledEffects;
  35329. private _vertexAttribArraysEnabled;
  35330. /** @hidden */
  35331. protected _cachedViewport: Nullable<IViewportLike>;
  35332. private _cachedVertexArrayObject;
  35333. /** @hidden */
  35334. protected _cachedVertexBuffers: any;
  35335. /** @hidden */
  35336. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  35337. /** @hidden */
  35338. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  35339. /** @hidden */
  35340. _currentRenderTarget: Nullable<InternalTexture>;
  35341. private _uintIndicesCurrentlySet;
  35342. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  35343. /** @hidden */
  35344. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  35345. /** @hidden */
  35346. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  35347. private _currentBufferPointers;
  35348. private _currentInstanceLocations;
  35349. private _currentInstanceBuffers;
  35350. private _textureUnits;
  35351. /** @hidden */
  35352. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  35353. /** @hidden */
  35354. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  35355. /** @hidden */
  35356. _boundRenderFunction: any;
  35357. private _vaoRecordInProgress;
  35358. private _mustWipeVertexAttributes;
  35359. private _emptyTexture;
  35360. private _emptyCubeTexture;
  35361. private _emptyTexture3D;
  35362. private _emptyTexture2DArray;
  35363. /** @hidden */
  35364. _frameHandler: number;
  35365. private _nextFreeTextureSlots;
  35366. private _maxSimultaneousTextures;
  35367. private _activeRequests;
  35368. /** @hidden */
  35369. _transformTextureUrl: Nullable<(url: string) => string>;
  35370. protected get _supportsHardwareTextureRescaling(): boolean;
  35371. private _framebufferDimensionsObject;
  35372. /**
  35373. * sets the object from which width and height will be taken from when getting render width and height
  35374. * Will fallback to the gl object
  35375. * @param dimensions the framebuffer width and height that will be used.
  35376. */
  35377. set framebufferDimensionsObject(dimensions: Nullable<{
  35378. framebufferWidth: number;
  35379. framebufferHeight: number;
  35380. }>);
  35381. /**
  35382. * Gets the current viewport
  35383. */
  35384. get currentViewport(): Nullable<IViewportLike>;
  35385. /**
  35386. * Gets the default empty texture
  35387. */
  35388. get emptyTexture(): InternalTexture;
  35389. /**
  35390. * Gets the default empty 3D texture
  35391. */
  35392. get emptyTexture3D(): InternalTexture;
  35393. /**
  35394. * Gets the default empty 2D array texture
  35395. */
  35396. get emptyTexture2DArray(): InternalTexture;
  35397. /**
  35398. * Gets the default empty cube texture
  35399. */
  35400. get emptyCubeTexture(): InternalTexture;
  35401. /**
  35402. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  35403. */
  35404. readonly premultipliedAlpha: boolean;
  35405. /**
  35406. * Observable event triggered before each texture is initialized
  35407. */
  35408. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  35409. /**
  35410. * Creates a new engine
  35411. * @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
  35412. * @param antialias defines enable antialiasing (default: false)
  35413. * @param options defines further options to be sent to the getContext() function
  35414. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  35415. */
  35416. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  35417. private _rebuildInternalTextures;
  35418. private _rebuildEffects;
  35419. /**
  35420. * Gets a boolean indicating if all created effects are ready
  35421. * @returns true if all effects are ready
  35422. */
  35423. areAllEffectsReady(): boolean;
  35424. protected _rebuildBuffers(): void;
  35425. protected _initGLContext(): void;
  35426. /**
  35427. * Gets version of the current webGL context
  35428. */
  35429. get webGLVersion(): number;
  35430. /**
  35431. * Gets a string idenfifying the name of the class
  35432. * @returns "Engine" string
  35433. */
  35434. getClassName(): string;
  35435. /**
  35436. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  35437. */
  35438. get isStencilEnable(): boolean;
  35439. /** @hidden */
  35440. _prepareWorkingCanvas(): void;
  35441. /**
  35442. * Reset the texture cache to empty state
  35443. */
  35444. resetTextureCache(): void;
  35445. /**
  35446. * Gets an object containing information about the current webGL context
  35447. * @returns an object containing the vender, the renderer and the version of the current webGL context
  35448. */
  35449. getGlInfo(): {
  35450. vendor: string;
  35451. renderer: string;
  35452. version: string;
  35453. };
  35454. /**
  35455. * Defines the hardware scaling level.
  35456. * By default the hardware scaling level is computed from the window device ratio.
  35457. * 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.
  35458. * @param level defines the level to use
  35459. */
  35460. setHardwareScalingLevel(level: number): void;
  35461. /**
  35462. * Gets the current hardware scaling level.
  35463. * By default the hardware scaling level is computed from the window device ratio.
  35464. * 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.
  35465. * @returns a number indicating the current hardware scaling level
  35466. */
  35467. getHardwareScalingLevel(): number;
  35468. /**
  35469. * Gets the list of loaded textures
  35470. * @returns an array containing all loaded textures
  35471. */
  35472. getLoadedTexturesCache(): InternalTexture[];
  35473. /**
  35474. * Gets the object containing all engine capabilities
  35475. * @returns the EngineCapabilities object
  35476. */
  35477. getCaps(): EngineCapabilities;
  35478. /**
  35479. * stop executing a render loop function and remove it from the execution array
  35480. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  35481. */
  35482. stopRenderLoop(renderFunction?: () => void): void;
  35483. /** @hidden */
  35484. _renderLoop(): void;
  35485. /**
  35486. * Gets the HTML canvas attached with the current webGL context
  35487. * @returns a HTML canvas
  35488. */
  35489. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  35490. /**
  35491. * Gets host window
  35492. * @returns the host window object
  35493. */
  35494. getHostWindow(): Nullable<Window>;
  35495. /**
  35496. * Gets the current render width
  35497. * @param useScreen defines if screen size must be used (or the current render target if any)
  35498. * @returns a number defining the current render width
  35499. */
  35500. getRenderWidth(useScreen?: boolean): number;
  35501. /**
  35502. * Gets the current render height
  35503. * @param useScreen defines if screen size must be used (or the current render target if any)
  35504. * @returns a number defining the current render height
  35505. */
  35506. getRenderHeight(useScreen?: boolean): number;
  35507. /**
  35508. * Can be used to override the current requestAnimationFrame requester.
  35509. * @hidden
  35510. */
  35511. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  35512. /**
  35513. * Register and execute a render loop. The engine can have more than one render function
  35514. * @param renderFunction defines the function to continuously execute
  35515. */
  35516. runRenderLoop(renderFunction: () => void): void;
  35517. /**
  35518. * Clear the current render buffer or the current render target (if any is set up)
  35519. * @param color defines the color to use
  35520. * @param backBuffer defines if the back buffer must be cleared
  35521. * @param depth defines if the depth buffer must be cleared
  35522. * @param stencil defines if the stencil buffer must be cleared
  35523. */
  35524. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  35525. private _viewportCached;
  35526. /** @hidden */
  35527. _viewport(x: number, y: number, width: number, height: number): void;
  35528. /**
  35529. * Set the WebGL's viewport
  35530. * @param viewport defines the viewport element to be used
  35531. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  35532. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  35533. */
  35534. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  35535. /**
  35536. * Begin a new frame
  35537. */
  35538. beginFrame(): void;
  35539. /**
  35540. * Enf the current frame
  35541. */
  35542. endFrame(): void;
  35543. /**
  35544. * Resize the view according to the canvas' size
  35545. */
  35546. resize(): void;
  35547. /**
  35548. * Force a specific size of the canvas
  35549. * @param width defines the new canvas' width
  35550. * @param height defines the new canvas' height
  35551. */
  35552. setSize(width: number, height: number): void;
  35553. /**
  35554. * Binds the frame buffer to the specified texture.
  35555. * @param texture The texture to render to or null for the default canvas
  35556. * @param faceIndex The face of the texture to render to in case of cube texture
  35557. * @param requiredWidth The width of the target to render to
  35558. * @param requiredHeight The height of the target to render to
  35559. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  35560. * @param lodLevel defines the lod level to bind to the frame buffer
  35561. * @param layer defines the 2d array index to bind to frame buffer to
  35562. */
  35563. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  35564. /** @hidden */
  35565. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  35566. /**
  35567. * Unbind the current render target texture from the webGL context
  35568. * @param texture defines the render target texture to unbind
  35569. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  35570. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  35571. */
  35572. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  35573. /**
  35574. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  35575. */
  35576. flushFramebuffer(): void;
  35577. /**
  35578. * Unbind the current render target and bind the default framebuffer
  35579. */
  35580. restoreDefaultFramebuffer(): void;
  35581. /** @hidden */
  35582. protected _resetVertexBufferBinding(): void;
  35583. /**
  35584. * Creates a vertex buffer
  35585. * @param data the data for the vertex buffer
  35586. * @returns the new WebGL static buffer
  35587. */
  35588. createVertexBuffer(data: DataArray): DataBuffer;
  35589. private _createVertexBuffer;
  35590. /**
  35591. * Creates a dynamic vertex buffer
  35592. * @param data the data for the dynamic vertex buffer
  35593. * @returns the new WebGL dynamic buffer
  35594. */
  35595. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  35596. protected _resetIndexBufferBinding(): void;
  35597. /**
  35598. * Creates a new index buffer
  35599. * @param indices defines the content of the index buffer
  35600. * @param updatable defines if the index buffer must be updatable
  35601. * @returns a new webGL buffer
  35602. */
  35603. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  35604. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  35605. /**
  35606. * Bind a webGL buffer to the webGL context
  35607. * @param buffer defines the buffer to bind
  35608. */
  35609. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  35610. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  35611. private bindBuffer;
  35612. /**
  35613. * update the bound buffer with the given data
  35614. * @param data defines the data to update
  35615. */
  35616. updateArrayBuffer(data: Float32Array): void;
  35617. private _vertexAttribPointer;
  35618. /** @hidden */
  35619. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  35620. private _bindVertexBuffersAttributes;
  35621. /**
  35622. * Records a vertex array object
  35623. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  35624. * @param vertexBuffers defines the list of vertex buffers to store
  35625. * @param indexBuffer defines the index buffer to store
  35626. * @param effect defines the effect to store
  35627. * @returns the new vertex array object
  35628. */
  35629. recordVertexArrayObject(vertexBuffers: {
  35630. [key: string]: VertexBuffer;
  35631. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  35632. /**
  35633. * Bind a specific vertex array object
  35634. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  35635. * @param vertexArrayObject defines the vertex array object to bind
  35636. * @param indexBuffer defines the index buffer to bind
  35637. */
  35638. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  35639. /**
  35640. * Bind webGl buffers directly to the webGL context
  35641. * @param vertexBuffer defines the vertex buffer to bind
  35642. * @param indexBuffer defines the index buffer to bind
  35643. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  35644. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  35645. * @param effect defines the effect associated with the vertex buffer
  35646. */
  35647. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  35648. private _unbindVertexArrayObject;
  35649. /**
  35650. * Bind a list of vertex buffers to the webGL context
  35651. * @param vertexBuffers defines the list of vertex buffers to bind
  35652. * @param indexBuffer defines the index buffer to bind
  35653. * @param effect defines the effect associated with the vertex buffers
  35654. */
  35655. bindBuffers(vertexBuffers: {
  35656. [key: string]: Nullable<VertexBuffer>;
  35657. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  35658. /**
  35659. * Unbind all instance attributes
  35660. */
  35661. unbindInstanceAttributes(): void;
  35662. /**
  35663. * Release and free the memory of a vertex array object
  35664. * @param vao defines the vertex array object to delete
  35665. */
  35666. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  35667. /** @hidden */
  35668. _releaseBuffer(buffer: DataBuffer): boolean;
  35669. protected _deleteBuffer(buffer: DataBuffer): void;
  35670. /**
  35671. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  35672. * @param instancesBuffer defines the webGL buffer to update and bind
  35673. * @param data defines the data to store in the buffer
  35674. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  35675. */
  35676. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  35677. /**
  35678. * Bind the content of a webGL buffer used with instantiation
  35679. * @param instancesBuffer defines the webGL buffer to bind
  35680. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  35681. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  35682. */
  35683. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  35684. /**
  35685. * Disable the instance attribute corresponding to the name in parameter
  35686. * @param name defines the name of the attribute to disable
  35687. */
  35688. disableInstanceAttributeByName(name: string): void;
  35689. /**
  35690. * Disable the instance attribute corresponding to the location in parameter
  35691. * @param attributeLocation defines the attribute location of the attribute to disable
  35692. */
  35693. disableInstanceAttribute(attributeLocation: number): void;
  35694. /**
  35695. * Disable the attribute corresponding to the location in parameter
  35696. * @param attributeLocation defines the attribute location of the attribute to disable
  35697. */
  35698. disableAttributeByIndex(attributeLocation: number): void;
  35699. /**
  35700. * Send a draw order
  35701. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  35702. * @param indexStart defines the starting index
  35703. * @param indexCount defines the number of index to draw
  35704. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35705. */
  35706. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  35707. /**
  35708. * Draw a list of points
  35709. * @param verticesStart defines the index of first vertex to draw
  35710. * @param verticesCount defines the count of vertices to draw
  35711. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35712. */
  35713. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  35714. /**
  35715. * Draw a list of unindexed primitives
  35716. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  35717. * @param verticesStart defines the index of first vertex to draw
  35718. * @param verticesCount defines the count of vertices to draw
  35719. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35720. */
  35721. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  35722. /**
  35723. * Draw a list of indexed primitives
  35724. * @param fillMode defines the primitive to use
  35725. * @param indexStart defines the starting index
  35726. * @param indexCount defines the number of index to draw
  35727. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35728. */
  35729. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  35730. /**
  35731. * Draw a list of unindexed primitives
  35732. * @param fillMode defines the primitive to use
  35733. * @param verticesStart defines the index of first vertex to draw
  35734. * @param verticesCount defines the count of vertices to draw
  35735. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35736. */
  35737. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  35738. private _drawMode;
  35739. /** @hidden */
  35740. protected _reportDrawCall(): void;
  35741. /** @hidden */
  35742. _releaseEffect(effect: Effect): void;
  35743. /** @hidden */
  35744. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  35745. /**
  35746. * Create a new effect (used to store vertex/fragment shaders)
  35747. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  35748. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  35749. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  35750. * @param samplers defines an array of string used to represent textures
  35751. * @param defines defines the string containing the defines to use to compile the shaders
  35752. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  35753. * @param onCompiled defines a function to call when the effect creation is successful
  35754. * @param onError defines a function to call when the effect creation has failed
  35755. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  35756. * @returns the new Effect
  35757. */
  35758. 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;
  35759. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  35760. private _compileShader;
  35761. private _compileRawShader;
  35762. /** @hidden */
  35763. _getShaderSource(shader: WebGLShader): Nullable<string>;
  35764. /**
  35765. * Directly creates a webGL program
  35766. * @param pipelineContext defines the pipeline context to attach to
  35767. * @param vertexCode defines the vertex shader code to use
  35768. * @param fragmentCode defines the fragment shader code to use
  35769. * @param context defines the webGL context to use (if not set, the current one will be used)
  35770. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  35771. * @returns the new webGL program
  35772. */
  35773. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  35774. /**
  35775. * Creates a webGL program
  35776. * @param pipelineContext defines the pipeline context to attach to
  35777. * @param vertexCode defines the vertex shader code to use
  35778. * @param fragmentCode defines the fragment shader code to use
  35779. * @param defines defines the string containing the defines to use to compile the shaders
  35780. * @param context defines the webGL context to use (if not set, the current one will be used)
  35781. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  35782. * @returns the new webGL program
  35783. */
  35784. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  35785. /**
  35786. * Creates a new pipeline context
  35787. * @returns the new pipeline
  35788. */
  35789. createPipelineContext(): IPipelineContext;
  35790. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  35791. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  35792. /** @hidden */
  35793. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  35794. /** @hidden */
  35795. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  35796. /** @hidden */
  35797. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  35798. /**
  35799. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  35800. * @param pipelineContext defines the pipeline context to use
  35801. * @param uniformsNames defines the list of uniform names
  35802. * @returns an array of webGL uniform locations
  35803. */
  35804. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  35805. /**
  35806. * Gets the lsit of active attributes for a given webGL program
  35807. * @param pipelineContext defines the pipeline context to use
  35808. * @param attributesNames defines the list of attribute names to get
  35809. * @returns an array of indices indicating the offset of each attribute
  35810. */
  35811. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  35812. /**
  35813. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  35814. * @param effect defines the effect to activate
  35815. */
  35816. enableEffect(effect: Nullable<Effect>): void;
  35817. /**
  35818. * Set the value of an uniform to a number (int)
  35819. * @param uniform defines the webGL uniform location where to store the value
  35820. * @param value defines the int number to store
  35821. */
  35822. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  35823. /**
  35824. * Set the value of an uniform to an array of int32
  35825. * @param uniform defines the webGL uniform location where to store the value
  35826. * @param array defines the array of int32 to store
  35827. */
  35828. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  35829. /**
  35830. * Set the value of an uniform to an array of int32 (stored as vec2)
  35831. * @param uniform defines the webGL uniform location where to store the value
  35832. * @param array defines the array of int32 to store
  35833. */
  35834. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  35835. /**
  35836. * Set the value of an uniform to an array of int32 (stored as vec3)
  35837. * @param uniform defines the webGL uniform location where to store the value
  35838. * @param array defines the array of int32 to store
  35839. */
  35840. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  35841. /**
  35842. * Set the value of an uniform to an array of int32 (stored as vec4)
  35843. * @param uniform defines the webGL uniform location where to store the value
  35844. * @param array defines the array of int32 to store
  35845. */
  35846. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  35847. /**
  35848. * Set the value of an uniform to an array of number
  35849. * @param uniform defines the webGL uniform location where to store the value
  35850. * @param array defines the array of number to store
  35851. */
  35852. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  35853. /**
  35854. * Set the value of an uniform to an array of number (stored as vec2)
  35855. * @param uniform defines the webGL uniform location where to store the value
  35856. * @param array defines the array of number to store
  35857. */
  35858. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  35859. /**
  35860. * Set the value of an uniform to an array of number (stored as vec3)
  35861. * @param uniform defines the webGL uniform location where to store the value
  35862. * @param array defines the array of number to store
  35863. */
  35864. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  35865. /**
  35866. * Set the value of an uniform to an array of number (stored as vec4)
  35867. * @param uniform defines the webGL uniform location where to store the value
  35868. * @param array defines the array of number to store
  35869. */
  35870. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  35871. /**
  35872. * Set the value of an uniform to an array of float32 (stored as matrices)
  35873. * @param uniform defines the webGL uniform location where to store the value
  35874. * @param matrices defines the array of float32 to store
  35875. */
  35876. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  35877. /**
  35878. * Set the value of an uniform to a matrix (3x3)
  35879. * @param uniform defines the webGL uniform location where to store the value
  35880. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  35881. */
  35882. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  35883. /**
  35884. * Set the value of an uniform to a matrix (2x2)
  35885. * @param uniform defines the webGL uniform location where to store the value
  35886. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  35887. */
  35888. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  35889. /**
  35890. * Set the value of an uniform to a number (float)
  35891. * @param uniform defines the webGL uniform location where to store the value
  35892. * @param value defines the float number to store
  35893. */
  35894. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  35895. /**
  35896. * Set the value of an uniform to a vec2
  35897. * @param uniform defines the webGL uniform location where to store the value
  35898. * @param x defines the 1st component of the value
  35899. * @param y defines the 2nd component of the value
  35900. */
  35901. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  35902. /**
  35903. * Set the value of an uniform to a vec3
  35904. * @param uniform defines the webGL uniform location where to store the value
  35905. * @param x defines the 1st component of the value
  35906. * @param y defines the 2nd component of the value
  35907. * @param z defines the 3rd component of the value
  35908. */
  35909. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  35910. /**
  35911. * Set the value of an uniform to a vec4
  35912. * @param uniform defines the webGL uniform location where to store the value
  35913. * @param x defines the 1st component of the value
  35914. * @param y defines the 2nd component of the value
  35915. * @param z defines the 3rd component of the value
  35916. * @param w defines the 4th component of the value
  35917. */
  35918. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  35919. /**
  35920. * Apply all cached states (depth, culling, stencil and alpha)
  35921. */
  35922. applyStates(): void;
  35923. /**
  35924. * Enable or disable color writing
  35925. * @param enable defines the state to set
  35926. */
  35927. setColorWrite(enable: boolean): void;
  35928. /**
  35929. * Gets a boolean indicating if color writing is enabled
  35930. * @returns the current color writing state
  35931. */
  35932. getColorWrite(): boolean;
  35933. /**
  35934. * Gets the depth culling state manager
  35935. */
  35936. get depthCullingState(): DepthCullingState;
  35937. /**
  35938. * Gets the alpha state manager
  35939. */
  35940. get alphaState(): AlphaState;
  35941. /**
  35942. * Gets the stencil state manager
  35943. */
  35944. get stencilState(): StencilState;
  35945. /**
  35946. * Clears the list of texture accessible through engine.
  35947. * This can help preventing texture load conflict due to name collision.
  35948. */
  35949. clearInternalTexturesCache(): void;
  35950. /**
  35951. * Force the entire cache to be cleared
  35952. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  35953. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  35954. */
  35955. wipeCaches(bruteForce?: boolean): void;
  35956. /** @hidden */
  35957. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  35958. min: number;
  35959. mag: number;
  35960. };
  35961. /** @hidden */
  35962. _createTexture(): WebGLTexture;
  35963. /**
  35964. * Usually called from Texture.ts.
  35965. * Passed information to create a WebGLTexture
  35966. * @param url defines a value which contains one of the following:
  35967. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  35968. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  35969. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  35970. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  35971. * @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)
  35972. * @param scene needed for loading to the correct scene
  35973. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  35974. * @param onLoad optional callback to be called upon successful completion
  35975. * @param onError optional callback to be called upon failure
  35976. * @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
  35977. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  35978. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  35979. * @param forcedExtension defines the extension to use to pick the right loader
  35980. * @param mimeType defines an optional mime type
  35981. * @returns a InternalTexture for assignment back into BABYLON.Texture
  35982. */
  35983. 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;
  35984. /**
  35985. * Loads an image as an HTMLImageElement.
  35986. * @param input url string, ArrayBuffer, or Blob to load
  35987. * @param onLoad callback called when the image successfully loads
  35988. * @param onError callback called when the image fails to load
  35989. * @param offlineProvider offline provider for caching
  35990. * @param mimeType optional mime type
  35991. * @returns the HTMLImageElement of the loaded image
  35992. * @hidden
  35993. */
  35994. 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>;
  35995. /**
  35996. * @hidden
  35997. */
  35998. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  35999. private _unpackFlipYCached;
  36000. /**
  36001. * In case you are sharing the context with other applications, it might
  36002. * be interested to not cache the unpack flip y state to ensure a consistent
  36003. * value would be set.
  36004. */
  36005. enableUnpackFlipYCached: boolean;
  36006. /** @hidden */
  36007. _unpackFlipY(value: boolean): void;
  36008. /** @hidden */
  36009. _getUnpackAlignement(): number;
  36010. private _getTextureTarget;
  36011. /**
  36012. * Update the sampling mode of a given texture
  36013. * @param samplingMode defines the required sampling mode
  36014. * @param texture defines the texture to update
  36015. * @param generateMipMaps defines whether to generate mipmaps for the texture
  36016. */
  36017. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  36018. /**
  36019. * Update the sampling mode of a given texture
  36020. * @param texture defines the texture to update
  36021. * @param wrapU defines the texture wrap mode of the u coordinates
  36022. * @param wrapV defines the texture wrap mode of the v coordinates
  36023. * @param wrapR defines the texture wrap mode of the r coordinates
  36024. */
  36025. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  36026. /** @hidden */
  36027. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  36028. width: number;
  36029. height: number;
  36030. layers?: number;
  36031. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  36032. /** @hidden */
  36033. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  36034. /** @hidden */
  36035. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  36036. /**
  36037. * Update a portion of an internal texture
  36038. * @param texture defines the texture to update
  36039. * @param imageData defines the data to store into the texture
  36040. * @param xOffset defines the x coordinates of the update rectangle
  36041. * @param yOffset defines the y coordinates of the update rectangle
  36042. * @param width defines the width of the update rectangle
  36043. * @param height defines the height of the update rectangle
  36044. * @param faceIndex defines the face index if texture is a cube (0 by default)
  36045. * @param lod defines the lod level to update (0 by default)
  36046. */
  36047. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  36048. /** @hidden */
  36049. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  36050. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  36051. private _prepareWebGLTexture;
  36052. /** @hidden */
  36053. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  36054. private _getDepthStencilBuffer;
  36055. /** @hidden */
  36056. _releaseFramebufferObjects(texture: InternalTexture): void;
  36057. /** @hidden */
  36058. _releaseTexture(texture: InternalTexture): void;
  36059. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  36060. protected _setProgram(program: WebGLProgram): void;
  36061. protected _boundUniforms: {
  36062. [key: number]: WebGLUniformLocation;
  36063. };
  36064. /**
  36065. * Binds an effect to the webGL context
  36066. * @param effect defines the effect to bind
  36067. */
  36068. bindSamplers(effect: Effect): void;
  36069. private _activateCurrentTexture;
  36070. /** @hidden */
  36071. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  36072. /** @hidden */
  36073. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  36074. /**
  36075. * Unbind all textures from the webGL context
  36076. */
  36077. unbindAllTextures(): void;
  36078. /**
  36079. * Sets a texture to the according uniform.
  36080. * @param channel The texture channel
  36081. * @param uniform The uniform to set
  36082. * @param texture The texture to apply
  36083. */
  36084. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  36085. private _bindSamplerUniformToChannel;
  36086. private _getTextureWrapMode;
  36087. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  36088. /**
  36089. * Sets an array of texture to the webGL context
  36090. * @param channel defines the channel where the texture array must be set
  36091. * @param uniform defines the associated uniform location
  36092. * @param textures defines the array of textures to bind
  36093. */
  36094. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  36095. /** @hidden */
  36096. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  36097. private _setTextureParameterFloat;
  36098. private _setTextureParameterInteger;
  36099. /**
  36100. * Unbind all vertex attributes from the webGL context
  36101. */
  36102. unbindAllAttributes(): void;
  36103. /**
  36104. * 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
  36105. */
  36106. releaseEffects(): void;
  36107. /**
  36108. * Dispose and release all associated resources
  36109. */
  36110. dispose(): void;
  36111. /**
  36112. * Attach a new callback raised when context lost event is fired
  36113. * @param callback defines the callback to call
  36114. */
  36115. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  36116. /**
  36117. * Attach a new callback raised when context restored event is fired
  36118. * @param callback defines the callback to call
  36119. */
  36120. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  36121. /**
  36122. * Get the current error code of the webGL context
  36123. * @returns the error code
  36124. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  36125. */
  36126. getError(): number;
  36127. private _canRenderToFloatFramebuffer;
  36128. private _canRenderToHalfFloatFramebuffer;
  36129. private _canRenderToFramebuffer;
  36130. /** @hidden */
  36131. _getWebGLTextureType(type: number): number;
  36132. /** @hidden */
  36133. _getInternalFormat(format: number): number;
  36134. /** @hidden */
  36135. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  36136. /** @hidden */
  36137. _getRGBAMultiSampleBufferFormat(type: number): number;
  36138. /** @hidden */
  36139. _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;
  36140. /**
  36141. * Loads a file from a url
  36142. * @param url url to load
  36143. * @param onSuccess callback called when the file successfully loads
  36144. * @param onProgress callback called while file is loading (if the server supports this mode)
  36145. * @param offlineProvider defines the offline provider for caching
  36146. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  36147. * @param onError callback called when the file fails to load
  36148. * @returns a file request object
  36149. * @hidden
  36150. */
  36151. 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;
  36152. /**
  36153. * Reads pixels from the current frame buffer. Please note that this function can be slow
  36154. * @param x defines the x coordinate of the rectangle where pixels must be read
  36155. * @param y defines the y coordinate of the rectangle where pixels must be read
  36156. * @param width defines the width of the rectangle where pixels must be read
  36157. * @param height defines the height of the rectangle where pixels must be read
  36158. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  36159. * @returns a Uint8Array containing RGBA colors
  36160. */
  36161. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  36162. private static _isSupported;
  36163. /**
  36164. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  36165. * @returns true if the engine can be created
  36166. * @ignorenaming
  36167. */
  36168. static isSupported(): boolean;
  36169. /**
  36170. * Find the next highest power of two.
  36171. * @param x Number to start search from.
  36172. * @return Next highest power of two.
  36173. */
  36174. static CeilingPOT(x: number): number;
  36175. /**
  36176. * Find the next lowest power of two.
  36177. * @param x Number to start search from.
  36178. * @return Next lowest power of two.
  36179. */
  36180. static FloorPOT(x: number): number;
  36181. /**
  36182. * Find the nearest power of two.
  36183. * @param x Number to start search from.
  36184. * @return Next nearest power of two.
  36185. */
  36186. static NearestPOT(x: number): number;
  36187. /**
  36188. * Get the closest exponent of two
  36189. * @param value defines the value to approximate
  36190. * @param max defines the maximum value to return
  36191. * @param mode defines how to define the closest value
  36192. * @returns closest exponent of two of the given value
  36193. */
  36194. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  36195. /**
  36196. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  36197. * @param func - the function to be called
  36198. * @param requester - the object that will request the next frame. Falls back to window.
  36199. * @returns frame number
  36200. */
  36201. static QueueNewFrame(func: () => void, requester?: any): number;
  36202. /**
  36203. * Gets host document
  36204. * @returns the host document object
  36205. */
  36206. getHostDocument(): Nullable<Document>;
  36207. }
  36208. }
  36209. declare module "babylonjs/Maths/sphericalPolynomial" {
  36210. import { Vector3 } from "babylonjs/Maths/math.vector";
  36211. import { Color3 } from "babylonjs/Maths/math.color";
  36212. /**
  36213. * Class representing spherical harmonics coefficients to the 3rd degree
  36214. */
  36215. export class SphericalHarmonics {
  36216. /**
  36217. * Defines whether or not the harmonics have been prescaled for rendering.
  36218. */
  36219. preScaled: boolean;
  36220. /**
  36221. * The l0,0 coefficients of the spherical harmonics
  36222. */
  36223. l00: Vector3;
  36224. /**
  36225. * The l1,-1 coefficients of the spherical harmonics
  36226. */
  36227. l1_1: Vector3;
  36228. /**
  36229. * The l1,0 coefficients of the spherical harmonics
  36230. */
  36231. l10: Vector3;
  36232. /**
  36233. * The l1,1 coefficients of the spherical harmonics
  36234. */
  36235. l11: Vector3;
  36236. /**
  36237. * The l2,-2 coefficients of the spherical harmonics
  36238. */
  36239. l2_2: Vector3;
  36240. /**
  36241. * The l2,-1 coefficients of the spherical harmonics
  36242. */
  36243. l2_1: Vector3;
  36244. /**
  36245. * The l2,0 coefficients of the spherical harmonics
  36246. */
  36247. l20: Vector3;
  36248. /**
  36249. * The l2,1 coefficients of the spherical harmonics
  36250. */
  36251. l21: Vector3;
  36252. /**
  36253. * The l2,2 coefficients of the spherical harmonics
  36254. */
  36255. l22: Vector3;
  36256. /**
  36257. * Adds a light to the spherical harmonics
  36258. * @param direction the direction of the light
  36259. * @param color the color of the light
  36260. * @param deltaSolidAngle the delta solid angle of the light
  36261. */
  36262. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  36263. /**
  36264. * Scales the spherical harmonics by the given amount
  36265. * @param scale the amount to scale
  36266. */
  36267. scaleInPlace(scale: number): void;
  36268. /**
  36269. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  36270. *
  36271. * ```
  36272. * E_lm = A_l * L_lm
  36273. * ```
  36274. *
  36275. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  36276. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  36277. * the scaling factors are given in equation 9.
  36278. */
  36279. convertIncidentRadianceToIrradiance(): void;
  36280. /**
  36281. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  36282. *
  36283. * ```
  36284. * L = (1/pi) * E * rho
  36285. * ```
  36286. *
  36287. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  36288. */
  36289. convertIrradianceToLambertianRadiance(): void;
  36290. /**
  36291. * Integrates the reconstruction coefficients directly in to the SH preventing further
  36292. * required operations at run time.
  36293. *
  36294. * This is simply done by scaling back the SH with Ylm constants parameter.
  36295. * The trigonometric part being applied by the shader at run time.
  36296. */
  36297. preScaleForRendering(): void;
  36298. /**
  36299. * Constructs a spherical harmonics from an array.
  36300. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  36301. * @returns the spherical harmonics
  36302. */
  36303. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  36304. /**
  36305. * Gets the spherical harmonics from polynomial
  36306. * @param polynomial the spherical polynomial
  36307. * @returns the spherical harmonics
  36308. */
  36309. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  36310. }
  36311. /**
  36312. * Class representing spherical polynomial coefficients to the 3rd degree
  36313. */
  36314. export class SphericalPolynomial {
  36315. private _harmonics;
  36316. /**
  36317. * The spherical harmonics used to create the polynomials.
  36318. */
  36319. get preScaledHarmonics(): SphericalHarmonics;
  36320. /**
  36321. * The x coefficients of the spherical polynomial
  36322. */
  36323. x: Vector3;
  36324. /**
  36325. * The y coefficients of the spherical polynomial
  36326. */
  36327. y: Vector3;
  36328. /**
  36329. * The z coefficients of the spherical polynomial
  36330. */
  36331. z: Vector3;
  36332. /**
  36333. * The xx coefficients of the spherical polynomial
  36334. */
  36335. xx: Vector3;
  36336. /**
  36337. * The yy coefficients of the spherical polynomial
  36338. */
  36339. yy: Vector3;
  36340. /**
  36341. * The zz coefficients of the spherical polynomial
  36342. */
  36343. zz: Vector3;
  36344. /**
  36345. * The xy coefficients of the spherical polynomial
  36346. */
  36347. xy: Vector3;
  36348. /**
  36349. * The yz coefficients of the spherical polynomial
  36350. */
  36351. yz: Vector3;
  36352. /**
  36353. * The zx coefficients of the spherical polynomial
  36354. */
  36355. zx: Vector3;
  36356. /**
  36357. * Adds an ambient color to the spherical polynomial
  36358. * @param color the color to add
  36359. */
  36360. addAmbient(color: Color3): void;
  36361. /**
  36362. * Scales the spherical polynomial by the given amount
  36363. * @param scale the amount to scale
  36364. */
  36365. scaleInPlace(scale: number): void;
  36366. /**
  36367. * Gets the spherical polynomial from harmonics
  36368. * @param harmonics the spherical harmonics
  36369. * @returns the spherical polynomial
  36370. */
  36371. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  36372. /**
  36373. * Constructs a spherical polynomial from an array.
  36374. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  36375. * @returns the spherical polynomial
  36376. */
  36377. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  36378. }
  36379. }
  36380. declare module "babylonjs/Materials/Textures/internalTexture" {
  36381. import { Observable } from "babylonjs/Misc/observable";
  36382. import { Nullable, int } from "babylonjs/types";
  36383. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  36384. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  36385. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  36386. /**
  36387. * Defines the source of the internal texture
  36388. */
  36389. export enum InternalTextureSource {
  36390. /**
  36391. * The source of the texture data is unknown
  36392. */
  36393. Unknown = 0,
  36394. /**
  36395. * Texture data comes from an URL
  36396. */
  36397. Url = 1,
  36398. /**
  36399. * Texture data is only used for temporary storage
  36400. */
  36401. Temp = 2,
  36402. /**
  36403. * Texture data comes from raw data (ArrayBuffer)
  36404. */
  36405. Raw = 3,
  36406. /**
  36407. * Texture content is dynamic (video or dynamic texture)
  36408. */
  36409. Dynamic = 4,
  36410. /**
  36411. * Texture content is generated by rendering to it
  36412. */
  36413. RenderTarget = 5,
  36414. /**
  36415. * Texture content is part of a multi render target process
  36416. */
  36417. MultiRenderTarget = 6,
  36418. /**
  36419. * Texture data comes from a cube data file
  36420. */
  36421. Cube = 7,
  36422. /**
  36423. * Texture data comes from a raw cube data
  36424. */
  36425. CubeRaw = 8,
  36426. /**
  36427. * Texture data come from a prefiltered cube data file
  36428. */
  36429. CubePrefiltered = 9,
  36430. /**
  36431. * Texture content is raw 3D data
  36432. */
  36433. Raw3D = 10,
  36434. /**
  36435. * Texture content is raw 2D array data
  36436. */
  36437. Raw2DArray = 11,
  36438. /**
  36439. * Texture content is a depth texture
  36440. */
  36441. Depth = 12,
  36442. /**
  36443. * Texture data comes from a raw cube data encoded with RGBD
  36444. */
  36445. CubeRawRGBD = 13
  36446. }
  36447. /**
  36448. * Class used to store data associated with WebGL texture data for the engine
  36449. * This class should not be used directly
  36450. */
  36451. export class InternalTexture {
  36452. /** @hidden */
  36453. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<import("babylonjs/Maths/sphericalPolynomial").SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  36454. /**
  36455. * Defines if the texture is ready
  36456. */
  36457. isReady: boolean;
  36458. /**
  36459. * Defines if the texture is a cube texture
  36460. */
  36461. isCube: boolean;
  36462. /**
  36463. * Defines if the texture contains 3D data
  36464. */
  36465. is3D: boolean;
  36466. /**
  36467. * Defines if the texture contains 2D array data
  36468. */
  36469. is2DArray: boolean;
  36470. /**
  36471. * Defines if the texture contains multiview data
  36472. */
  36473. isMultiview: boolean;
  36474. /**
  36475. * Gets the URL used to load this texture
  36476. */
  36477. url: string;
  36478. /**
  36479. * Gets the sampling mode of the texture
  36480. */
  36481. samplingMode: number;
  36482. /**
  36483. * Gets a boolean indicating if the texture needs mipmaps generation
  36484. */
  36485. generateMipMaps: boolean;
  36486. /**
  36487. * Gets the number of samples used by the texture (WebGL2+ only)
  36488. */
  36489. samples: number;
  36490. /**
  36491. * Gets the type of the texture (int, float...)
  36492. */
  36493. type: number;
  36494. /**
  36495. * Gets the format of the texture (RGB, RGBA...)
  36496. */
  36497. format: number;
  36498. /**
  36499. * Observable called when the texture is loaded
  36500. */
  36501. onLoadedObservable: Observable<InternalTexture>;
  36502. /**
  36503. * Gets the width of the texture
  36504. */
  36505. width: number;
  36506. /**
  36507. * Gets the height of the texture
  36508. */
  36509. height: number;
  36510. /**
  36511. * Gets the depth of the texture
  36512. */
  36513. depth: number;
  36514. /**
  36515. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  36516. */
  36517. baseWidth: number;
  36518. /**
  36519. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  36520. */
  36521. baseHeight: number;
  36522. /**
  36523. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  36524. */
  36525. baseDepth: number;
  36526. /**
  36527. * Gets a boolean indicating if the texture is inverted on Y axis
  36528. */
  36529. invertY: boolean;
  36530. /** @hidden */
  36531. _invertVScale: boolean;
  36532. /** @hidden */
  36533. _associatedChannel: number;
  36534. /** @hidden */
  36535. _source: InternalTextureSource;
  36536. /** @hidden */
  36537. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  36538. /** @hidden */
  36539. _bufferView: Nullable<ArrayBufferView>;
  36540. /** @hidden */
  36541. _bufferViewArray: Nullable<ArrayBufferView[]>;
  36542. /** @hidden */
  36543. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  36544. /** @hidden */
  36545. _size: number;
  36546. /** @hidden */
  36547. _extension: string;
  36548. /** @hidden */
  36549. _files: Nullable<string[]>;
  36550. /** @hidden */
  36551. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  36552. /** @hidden */
  36553. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  36554. /** @hidden */
  36555. _framebuffer: Nullable<WebGLFramebuffer>;
  36556. /** @hidden */
  36557. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  36558. /** @hidden */
  36559. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  36560. /** @hidden */
  36561. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  36562. /** @hidden */
  36563. _attachments: Nullable<number[]>;
  36564. /** @hidden */
  36565. _cachedCoordinatesMode: Nullable<number>;
  36566. /** @hidden */
  36567. _cachedWrapU: Nullable<number>;
  36568. /** @hidden */
  36569. _cachedWrapV: Nullable<number>;
  36570. /** @hidden */
  36571. _cachedWrapR: Nullable<number>;
  36572. /** @hidden */
  36573. _cachedAnisotropicFilteringLevel: Nullable<number>;
  36574. /** @hidden */
  36575. _isDisabled: boolean;
  36576. /** @hidden */
  36577. _compression: Nullable<string>;
  36578. /** @hidden */
  36579. _generateStencilBuffer: boolean;
  36580. /** @hidden */
  36581. _generateDepthBuffer: boolean;
  36582. /** @hidden */
  36583. _comparisonFunction: number;
  36584. /** @hidden */
  36585. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  36586. /** @hidden */
  36587. _lodGenerationScale: number;
  36588. /** @hidden */
  36589. _lodGenerationOffset: number;
  36590. /** @hidden */
  36591. _depthStencilTexture: Nullable<InternalTexture>;
  36592. /** @hidden */
  36593. _colorTextureArray: Nullable<WebGLTexture>;
  36594. /** @hidden */
  36595. _depthStencilTextureArray: Nullable<WebGLTexture>;
  36596. /** @hidden */
  36597. _lodTextureHigh: Nullable<BaseTexture>;
  36598. /** @hidden */
  36599. _lodTextureMid: Nullable<BaseTexture>;
  36600. /** @hidden */
  36601. _lodTextureLow: Nullable<BaseTexture>;
  36602. /** @hidden */
  36603. _isRGBD: boolean;
  36604. /** @hidden */
  36605. _linearSpecularLOD: boolean;
  36606. /** @hidden */
  36607. _irradianceTexture: Nullable<BaseTexture>;
  36608. /** @hidden */
  36609. _webGLTexture: Nullable<WebGLTexture>;
  36610. /** @hidden */
  36611. _references: number;
  36612. private _engine;
  36613. /**
  36614. * Gets the Engine the texture belongs to.
  36615. * @returns The babylon engine
  36616. */
  36617. getEngine(): ThinEngine;
  36618. /**
  36619. * Gets the data source type of the texture
  36620. */
  36621. get source(): InternalTextureSource;
  36622. /**
  36623. * Creates a new InternalTexture
  36624. * @param engine defines the engine to use
  36625. * @param source defines the type of data that will be used
  36626. * @param delayAllocation if the texture allocation should be delayed (default: false)
  36627. */
  36628. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  36629. /**
  36630. * Increments the number of references (ie. the number of Texture that point to it)
  36631. */
  36632. incrementReferences(): void;
  36633. /**
  36634. * Change the size of the texture (not the size of the content)
  36635. * @param width defines the new width
  36636. * @param height defines the new height
  36637. * @param depth defines the new depth (1 by default)
  36638. */
  36639. updateSize(width: int, height: int, depth?: int): void;
  36640. /** @hidden */
  36641. _rebuild(): void;
  36642. /** @hidden */
  36643. _swapAndDie(target: InternalTexture): void;
  36644. /**
  36645. * Dispose the current allocated resources
  36646. */
  36647. dispose(): void;
  36648. }
  36649. }
  36650. declare module "babylonjs/Audio/analyser" {
  36651. import { Scene } from "babylonjs/scene";
  36652. /**
  36653. * Class used to work with sound analyzer using fast fourier transform (FFT)
  36654. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36655. */
  36656. export class Analyser {
  36657. /**
  36658. * Gets or sets the smoothing
  36659. * @ignorenaming
  36660. */
  36661. SMOOTHING: number;
  36662. /**
  36663. * Gets or sets the FFT table size
  36664. * @ignorenaming
  36665. */
  36666. FFT_SIZE: number;
  36667. /**
  36668. * Gets or sets the bar graph amplitude
  36669. * @ignorenaming
  36670. */
  36671. BARGRAPHAMPLITUDE: number;
  36672. /**
  36673. * Gets or sets the position of the debug canvas
  36674. * @ignorenaming
  36675. */
  36676. DEBUGCANVASPOS: {
  36677. x: number;
  36678. y: number;
  36679. };
  36680. /**
  36681. * Gets or sets the debug canvas size
  36682. * @ignorenaming
  36683. */
  36684. DEBUGCANVASSIZE: {
  36685. width: number;
  36686. height: number;
  36687. };
  36688. private _byteFreqs;
  36689. private _byteTime;
  36690. private _floatFreqs;
  36691. private _webAudioAnalyser;
  36692. private _debugCanvas;
  36693. private _debugCanvasContext;
  36694. private _scene;
  36695. private _registerFunc;
  36696. private _audioEngine;
  36697. /**
  36698. * Creates a new analyser
  36699. * @param scene defines hosting scene
  36700. */
  36701. constructor(scene: Scene);
  36702. /**
  36703. * Get the number of data values you will have to play with for the visualization
  36704. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  36705. * @returns a number
  36706. */
  36707. getFrequencyBinCount(): number;
  36708. /**
  36709. * Gets the current frequency data as a byte array
  36710. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  36711. * @returns a Uint8Array
  36712. */
  36713. getByteFrequencyData(): Uint8Array;
  36714. /**
  36715. * Gets the current waveform as a byte array
  36716. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  36717. * @returns a Uint8Array
  36718. */
  36719. getByteTimeDomainData(): Uint8Array;
  36720. /**
  36721. * Gets the current frequency data as a float array
  36722. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  36723. * @returns a Float32Array
  36724. */
  36725. getFloatFrequencyData(): Float32Array;
  36726. /**
  36727. * Renders the debug canvas
  36728. */
  36729. drawDebugCanvas(): void;
  36730. /**
  36731. * Stops rendering the debug canvas and removes it
  36732. */
  36733. stopDebugCanvas(): void;
  36734. /**
  36735. * Connects two audio nodes
  36736. * @param inputAudioNode defines first node to connect
  36737. * @param outputAudioNode defines second node to connect
  36738. */
  36739. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  36740. /**
  36741. * Releases all associated resources
  36742. */
  36743. dispose(): void;
  36744. }
  36745. }
  36746. declare module "babylonjs/Audio/audioEngine" {
  36747. import { IDisposable } from "babylonjs/scene";
  36748. import { Analyser } from "babylonjs/Audio/analyser";
  36749. import { Nullable } from "babylonjs/types";
  36750. import { Observable } from "babylonjs/Misc/observable";
  36751. /**
  36752. * This represents an audio engine and it is responsible
  36753. * to play, synchronize and analyse sounds throughout the application.
  36754. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36755. */
  36756. export interface IAudioEngine extends IDisposable {
  36757. /**
  36758. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  36759. */
  36760. readonly canUseWebAudio: boolean;
  36761. /**
  36762. * Gets the current AudioContext if available.
  36763. */
  36764. readonly audioContext: Nullable<AudioContext>;
  36765. /**
  36766. * The master gain node defines the global audio volume of your audio engine.
  36767. */
  36768. readonly masterGain: GainNode;
  36769. /**
  36770. * Gets whether or not mp3 are supported by your browser.
  36771. */
  36772. readonly isMP3supported: boolean;
  36773. /**
  36774. * Gets whether or not ogg are supported by your browser.
  36775. */
  36776. readonly isOGGsupported: boolean;
  36777. /**
  36778. * Defines if Babylon should emit a warning if WebAudio is not supported.
  36779. * @ignoreNaming
  36780. */
  36781. WarnedWebAudioUnsupported: boolean;
  36782. /**
  36783. * Defines if the audio engine relies on a custom unlocked button.
  36784. * In this case, the embedded button will not be displayed.
  36785. */
  36786. useCustomUnlockedButton: boolean;
  36787. /**
  36788. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  36789. */
  36790. readonly unlocked: boolean;
  36791. /**
  36792. * Event raised when audio has been unlocked on the browser.
  36793. */
  36794. onAudioUnlockedObservable: Observable<AudioEngine>;
  36795. /**
  36796. * Event raised when audio has been locked on the browser.
  36797. */
  36798. onAudioLockedObservable: Observable<AudioEngine>;
  36799. /**
  36800. * Flags the audio engine in Locked state.
  36801. * This happens due to new browser policies preventing audio to autoplay.
  36802. */
  36803. lock(): void;
  36804. /**
  36805. * Unlocks the audio engine once a user action has been done on the dom.
  36806. * This is helpful to resume play once browser policies have been satisfied.
  36807. */
  36808. unlock(): void;
  36809. /**
  36810. * Gets the global volume sets on the master gain.
  36811. * @returns the global volume if set or -1 otherwise
  36812. */
  36813. getGlobalVolume(): number;
  36814. /**
  36815. * Sets the global volume of your experience (sets on the master gain).
  36816. * @param newVolume Defines the new global volume of the application
  36817. */
  36818. setGlobalVolume(newVolume: number): void;
  36819. /**
  36820. * Connect the audio engine to an audio analyser allowing some amazing
  36821. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  36822. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  36823. * @param analyser The analyser to connect to the engine
  36824. */
  36825. connectToAnalyser(analyser: Analyser): void;
  36826. }
  36827. /**
  36828. * This represents the default audio engine used in babylon.
  36829. * It is responsible to play, synchronize and analyse sounds throughout the application.
  36830. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36831. */
  36832. export class AudioEngine implements IAudioEngine {
  36833. private _audioContext;
  36834. private _audioContextInitialized;
  36835. private _muteButton;
  36836. private _hostElement;
  36837. /**
  36838. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  36839. */
  36840. canUseWebAudio: boolean;
  36841. /**
  36842. * The master gain node defines the global audio volume of your audio engine.
  36843. */
  36844. masterGain: GainNode;
  36845. /**
  36846. * Defines if Babylon should emit a warning if WebAudio is not supported.
  36847. * @ignoreNaming
  36848. */
  36849. WarnedWebAudioUnsupported: boolean;
  36850. /**
  36851. * Gets whether or not mp3 are supported by your browser.
  36852. */
  36853. isMP3supported: boolean;
  36854. /**
  36855. * Gets whether or not ogg are supported by your browser.
  36856. */
  36857. isOGGsupported: boolean;
  36858. /**
  36859. * Gets whether audio has been unlocked on the device.
  36860. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  36861. * a user interaction has happened.
  36862. */
  36863. unlocked: boolean;
  36864. /**
  36865. * Defines if the audio engine relies on a custom unlocked button.
  36866. * In this case, the embedded button will not be displayed.
  36867. */
  36868. useCustomUnlockedButton: boolean;
  36869. /**
  36870. * Event raised when audio has been unlocked on the browser.
  36871. */
  36872. onAudioUnlockedObservable: Observable<AudioEngine>;
  36873. /**
  36874. * Event raised when audio has been locked on the browser.
  36875. */
  36876. onAudioLockedObservable: Observable<AudioEngine>;
  36877. /**
  36878. * Gets the current AudioContext if available.
  36879. */
  36880. get audioContext(): Nullable<AudioContext>;
  36881. private _connectedAnalyser;
  36882. /**
  36883. * Instantiates a new audio engine.
  36884. *
  36885. * There should be only one per page as some browsers restrict the number
  36886. * of audio contexts you can create.
  36887. * @param hostElement defines the host element where to display the mute icon if necessary
  36888. */
  36889. constructor(hostElement?: Nullable<HTMLElement>);
  36890. /**
  36891. * Flags the audio engine in Locked state.
  36892. * This happens due to new browser policies preventing audio to autoplay.
  36893. */
  36894. lock(): void;
  36895. /**
  36896. * Unlocks the audio engine once a user action has been done on the dom.
  36897. * This is helpful to resume play once browser policies have been satisfied.
  36898. */
  36899. unlock(): void;
  36900. private _resumeAudioContext;
  36901. private _initializeAudioContext;
  36902. private _tryToRun;
  36903. private _triggerRunningState;
  36904. private _triggerSuspendedState;
  36905. private _displayMuteButton;
  36906. private _moveButtonToTopLeft;
  36907. private _onResize;
  36908. private _hideMuteButton;
  36909. /**
  36910. * Destroy and release the resources associated with the audio ccontext.
  36911. */
  36912. dispose(): void;
  36913. /**
  36914. * Gets the global volume sets on the master gain.
  36915. * @returns the global volume if set or -1 otherwise
  36916. */
  36917. getGlobalVolume(): number;
  36918. /**
  36919. * Sets the global volume of your experience (sets on the master gain).
  36920. * @param newVolume Defines the new global volume of the application
  36921. */
  36922. setGlobalVolume(newVolume: number): void;
  36923. /**
  36924. * Connect the audio engine to an audio analyser allowing some amazing
  36925. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  36926. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  36927. * @param analyser The analyser to connect to the engine
  36928. */
  36929. connectToAnalyser(analyser: Analyser): void;
  36930. }
  36931. }
  36932. declare module "babylonjs/Loading/loadingScreen" {
  36933. /**
  36934. * Interface used to present a loading screen while loading a scene
  36935. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  36936. */
  36937. export interface ILoadingScreen {
  36938. /**
  36939. * Function called to display the loading screen
  36940. */
  36941. displayLoadingUI: () => void;
  36942. /**
  36943. * Function called to hide the loading screen
  36944. */
  36945. hideLoadingUI: () => void;
  36946. /**
  36947. * Gets or sets the color to use for the background
  36948. */
  36949. loadingUIBackgroundColor: string;
  36950. /**
  36951. * Gets or sets the text to display while loading
  36952. */
  36953. loadingUIText: string;
  36954. }
  36955. /**
  36956. * Class used for the default loading screen
  36957. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  36958. */
  36959. export class DefaultLoadingScreen implements ILoadingScreen {
  36960. private _renderingCanvas;
  36961. private _loadingText;
  36962. private _loadingDivBackgroundColor;
  36963. private _loadingDiv;
  36964. private _loadingTextDiv;
  36965. /** Gets or sets the logo url to use for the default loading screen */
  36966. static DefaultLogoUrl: string;
  36967. /** Gets or sets the spinner url to use for the default loading screen */
  36968. static DefaultSpinnerUrl: string;
  36969. /**
  36970. * Creates a new default loading screen
  36971. * @param _renderingCanvas defines the canvas used to render the scene
  36972. * @param _loadingText defines the default text to display
  36973. * @param _loadingDivBackgroundColor defines the default background color
  36974. */
  36975. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  36976. /**
  36977. * Function called to display the loading screen
  36978. */
  36979. displayLoadingUI(): void;
  36980. /**
  36981. * Function called to hide the loading screen
  36982. */
  36983. hideLoadingUI(): void;
  36984. /**
  36985. * Gets or sets the text to display while loading
  36986. */
  36987. set loadingUIText(text: string);
  36988. get loadingUIText(): string;
  36989. /**
  36990. * Gets or sets the color to use for the background
  36991. */
  36992. get loadingUIBackgroundColor(): string;
  36993. set loadingUIBackgroundColor(color: string);
  36994. private _resizeLoadingUI;
  36995. }
  36996. }
  36997. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  36998. /**
  36999. * Interface for any object that can request an animation frame
  37000. */
  37001. export interface ICustomAnimationFrameRequester {
  37002. /**
  37003. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  37004. */
  37005. renderFunction?: Function;
  37006. /**
  37007. * Called to request the next frame to render to
  37008. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  37009. */
  37010. requestAnimationFrame: Function;
  37011. /**
  37012. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  37013. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  37014. */
  37015. requestID?: number;
  37016. }
  37017. }
  37018. declare module "babylonjs/Misc/performanceMonitor" {
  37019. /**
  37020. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  37021. */
  37022. export class PerformanceMonitor {
  37023. private _enabled;
  37024. private _rollingFrameTime;
  37025. private _lastFrameTimeMs;
  37026. /**
  37027. * constructor
  37028. * @param frameSampleSize The number of samples required to saturate the sliding window
  37029. */
  37030. constructor(frameSampleSize?: number);
  37031. /**
  37032. * Samples current frame
  37033. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  37034. */
  37035. sampleFrame(timeMs?: number): void;
  37036. /**
  37037. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  37038. */
  37039. get averageFrameTime(): number;
  37040. /**
  37041. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  37042. */
  37043. get averageFrameTimeVariance(): number;
  37044. /**
  37045. * Returns the frame time of the most recent frame
  37046. */
  37047. get instantaneousFrameTime(): number;
  37048. /**
  37049. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  37050. */
  37051. get averageFPS(): number;
  37052. /**
  37053. * Returns the average framerate in frames per second using the most recent frame time
  37054. */
  37055. get instantaneousFPS(): number;
  37056. /**
  37057. * Returns true if enough samples have been taken to completely fill the sliding window
  37058. */
  37059. get isSaturated(): boolean;
  37060. /**
  37061. * Enables contributions to the sliding window sample set
  37062. */
  37063. enable(): void;
  37064. /**
  37065. * Disables contributions to the sliding window sample set
  37066. * Samples will not be interpolated over the disabled period
  37067. */
  37068. disable(): void;
  37069. /**
  37070. * Returns true if sampling is enabled
  37071. */
  37072. get isEnabled(): boolean;
  37073. /**
  37074. * Resets performance monitor
  37075. */
  37076. reset(): void;
  37077. }
  37078. /**
  37079. * RollingAverage
  37080. *
  37081. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  37082. */
  37083. export class RollingAverage {
  37084. /**
  37085. * Current average
  37086. */
  37087. average: number;
  37088. /**
  37089. * Current variance
  37090. */
  37091. variance: number;
  37092. protected _samples: Array<number>;
  37093. protected _sampleCount: number;
  37094. protected _pos: number;
  37095. protected _m2: number;
  37096. /**
  37097. * constructor
  37098. * @param length The number of samples required to saturate the sliding window
  37099. */
  37100. constructor(length: number);
  37101. /**
  37102. * Adds a sample to the sample set
  37103. * @param v The sample value
  37104. */
  37105. add(v: number): void;
  37106. /**
  37107. * Returns previously added values or null if outside of history or outside the sliding window domain
  37108. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  37109. * @return Value previously recorded with add() or null if outside of range
  37110. */
  37111. history(i: number): number;
  37112. /**
  37113. * Returns true if enough samples have been taken to completely fill the sliding window
  37114. * @return true if sample-set saturated
  37115. */
  37116. isSaturated(): boolean;
  37117. /**
  37118. * Resets the rolling average (equivalent to 0 samples taken so far)
  37119. */
  37120. reset(): void;
  37121. /**
  37122. * Wraps a value around the sample range boundaries
  37123. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  37124. * @return Wrapped position in sample range
  37125. */
  37126. protected _wrapPosition(i: number): number;
  37127. }
  37128. }
  37129. declare module "babylonjs/Misc/perfCounter" {
  37130. /**
  37131. * This class is used to track a performance counter which is number based.
  37132. * The user has access to many properties which give statistics of different nature.
  37133. *
  37134. * The implementer can track two kinds of Performance Counter: time and count.
  37135. * 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.
  37136. * 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.
  37137. */
  37138. export class PerfCounter {
  37139. /**
  37140. * Gets or sets a global boolean to turn on and off all the counters
  37141. */
  37142. static Enabled: boolean;
  37143. /**
  37144. * Returns the smallest value ever
  37145. */
  37146. get min(): number;
  37147. /**
  37148. * Returns the biggest value ever
  37149. */
  37150. get max(): number;
  37151. /**
  37152. * Returns the average value since the performance counter is running
  37153. */
  37154. get average(): number;
  37155. /**
  37156. * Returns the average value of the last second the counter was monitored
  37157. */
  37158. get lastSecAverage(): number;
  37159. /**
  37160. * Returns the current value
  37161. */
  37162. get current(): number;
  37163. /**
  37164. * Gets the accumulated total
  37165. */
  37166. get total(): number;
  37167. /**
  37168. * Gets the total value count
  37169. */
  37170. get count(): number;
  37171. /**
  37172. * Creates a new counter
  37173. */
  37174. constructor();
  37175. /**
  37176. * Call this method to start monitoring a new frame.
  37177. * 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.
  37178. */
  37179. fetchNewFrame(): void;
  37180. /**
  37181. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  37182. * @param newCount the count value to add to the monitored count
  37183. * @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.
  37184. */
  37185. addCount(newCount: number, fetchResult: boolean): void;
  37186. /**
  37187. * Start monitoring this performance counter
  37188. */
  37189. beginMonitoring(): void;
  37190. /**
  37191. * Compute the time lapsed since the previous beginMonitoring() call.
  37192. * @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
  37193. */
  37194. endMonitoring(newFrame?: boolean): void;
  37195. private _fetchResult;
  37196. private _startMonitoringTime;
  37197. private _min;
  37198. private _max;
  37199. private _average;
  37200. private _current;
  37201. private _totalValueCount;
  37202. private _totalAccumulated;
  37203. private _lastSecAverage;
  37204. private _lastSecAccumulated;
  37205. private _lastSecTime;
  37206. private _lastSecValueCount;
  37207. }
  37208. }
  37209. declare module "babylonjs/Engines/Extensions/engine.alpha" {
  37210. module "babylonjs/Engines/thinEngine" {
  37211. interface ThinEngine {
  37212. /**
  37213. * Sets alpha constants used by some alpha blending modes
  37214. * @param r defines the red component
  37215. * @param g defines the green component
  37216. * @param b defines the blue component
  37217. * @param a defines the alpha component
  37218. */
  37219. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  37220. /**
  37221. * Sets the current alpha mode
  37222. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  37223. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  37224. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  37225. */
  37226. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  37227. /**
  37228. * Gets the current alpha mode
  37229. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  37230. * @returns the current alpha mode
  37231. */
  37232. getAlphaMode(): number;
  37233. /**
  37234. * Sets the current alpha equation
  37235. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  37236. */
  37237. setAlphaEquation(equation: number): void;
  37238. /**
  37239. * Gets the current alpha equation.
  37240. * @returns the current alpha equation
  37241. */
  37242. getAlphaEquation(): number;
  37243. }
  37244. }
  37245. }
  37246. declare module "babylonjs/Engines/Extensions/engine.readTexture" {
  37247. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  37248. import { Nullable } from "babylonjs/types";
  37249. module "babylonjs/Engines/thinEngine" {
  37250. interface ThinEngine {
  37251. /** @hidden */
  37252. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  37253. }
  37254. }
  37255. }
  37256. declare module "babylonjs/Engines/engine" {
  37257. import { Observable } from "babylonjs/Misc/observable";
  37258. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  37259. import { Scene } from "babylonjs/scene";
  37260. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  37261. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  37262. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  37263. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  37264. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  37265. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  37266. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  37267. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  37268. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  37269. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  37270. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  37271. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  37272. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  37273. import "babylonjs/Engines/Extensions/engine.alpha";
  37274. import "babylonjs/Engines/Extensions/engine.readTexture";
  37275. import { Material } from "babylonjs/Materials/material";
  37276. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  37277. /**
  37278. * Defines the interface used by display changed events
  37279. */
  37280. export interface IDisplayChangedEventArgs {
  37281. /** Gets the vrDisplay object (if any) */
  37282. vrDisplay: Nullable<any>;
  37283. /** Gets a boolean indicating if webVR is supported */
  37284. vrSupported: boolean;
  37285. }
  37286. /**
  37287. * Defines the interface used by objects containing a viewport (like a camera)
  37288. */
  37289. interface IViewportOwnerLike {
  37290. /**
  37291. * Gets or sets the viewport
  37292. */
  37293. viewport: IViewportLike;
  37294. }
  37295. /**
  37296. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  37297. */
  37298. export class Engine extends ThinEngine {
  37299. /** Defines that alpha blending is disabled */
  37300. static readonly ALPHA_DISABLE: number;
  37301. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  37302. static readonly ALPHA_ADD: number;
  37303. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  37304. static readonly ALPHA_COMBINE: number;
  37305. /** Defines that alpha blending to DEST - SRC * DEST */
  37306. static readonly ALPHA_SUBTRACT: number;
  37307. /** Defines that alpha blending to SRC * DEST */
  37308. static readonly ALPHA_MULTIPLY: number;
  37309. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  37310. static readonly ALPHA_MAXIMIZED: number;
  37311. /** Defines that alpha blending to SRC + DEST */
  37312. static readonly ALPHA_ONEONE: number;
  37313. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  37314. static readonly ALPHA_PREMULTIPLIED: number;
  37315. /**
  37316. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  37317. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  37318. */
  37319. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  37320. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  37321. static readonly ALPHA_INTERPOLATE: number;
  37322. /**
  37323. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  37324. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  37325. */
  37326. static readonly ALPHA_SCREENMODE: number;
  37327. /** Defines that the ressource is not delayed*/
  37328. static readonly DELAYLOADSTATE_NONE: number;
  37329. /** Defines that the ressource was successfully delay loaded */
  37330. static readonly DELAYLOADSTATE_LOADED: number;
  37331. /** Defines that the ressource is currently delay loading */
  37332. static readonly DELAYLOADSTATE_LOADING: number;
  37333. /** Defines that the ressource is delayed and has not started loading */
  37334. static readonly DELAYLOADSTATE_NOTLOADED: number;
  37335. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  37336. static readonly NEVER: number;
  37337. /** 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 */
  37338. static readonly ALWAYS: number;
  37339. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  37340. static readonly LESS: number;
  37341. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  37342. static readonly EQUAL: number;
  37343. /** 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 */
  37344. static readonly LEQUAL: number;
  37345. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  37346. static readonly GREATER: number;
  37347. /** 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 */
  37348. static readonly GEQUAL: number;
  37349. /** 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 */
  37350. static readonly NOTEQUAL: number;
  37351. /** Passed to stencilOperation to specify that stencil value must be kept */
  37352. static readonly KEEP: number;
  37353. /** Passed to stencilOperation to specify that stencil value must be replaced */
  37354. static readonly REPLACE: number;
  37355. /** Passed to stencilOperation to specify that stencil value must be incremented */
  37356. static readonly INCR: number;
  37357. /** Passed to stencilOperation to specify that stencil value must be decremented */
  37358. static readonly DECR: number;
  37359. /** Passed to stencilOperation to specify that stencil value must be inverted */
  37360. static readonly INVERT: number;
  37361. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  37362. static readonly INCR_WRAP: number;
  37363. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  37364. static readonly DECR_WRAP: number;
  37365. /** Texture is not repeating outside of 0..1 UVs */
  37366. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  37367. /** Texture is repeating outside of 0..1 UVs */
  37368. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  37369. /** Texture is repeating and mirrored */
  37370. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  37371. /** ALPHA */
  37372. static readonly TEXTUREFORMAT_ALPHA: number;
  37373. /** LUMINANCE */
  37374. static readonly TEXTUREFORMAT_LUMINANCE: number;
  37375. /** LUMINANCE_ALPHA */
  37376. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  37377. /** RGB */
  37378. static readonly TEXTUREFORMAT_RGB: number;
  37379. /** RGBA */
  37380. static readonly TEXTUREFORMAT_RGBA: number;
  37381. /** RED */
  37382. static readonly TEXTUREFORMAT_RED: number;
  37383. /** RED (2nd reference) */
  37384. static readonly TEXTUREFORMAT_R: number;
  37385. /** RG */
  37386. static readonly TEXTUREFORMAT_RG: number;
  37387. /** RED_INTEGER */
  37388. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  37389. /** RED_INTEGER (2nd reference) */
  37390. static readonly TEXTUREFORMAT_R_INTEGER: number;
  37391. /** RG_INTEGER */
  37392. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  37393. /** RGB_INTEGER */
  37394. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  37395. /** RGBA_INTEGER */
  37396. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  37397. /** UNSIGNED_BYTE */
  37398. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  37399. /** UNSIGNED_BYTE (2nd reference) */
  37400. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  37401. /** FLOAT */
  37402. static readonly TEXTURETYPE_FLOAT: number;
  37403. /** HALF_FLOAT */
  37404. static readonly TEXTURETYPE_HALF_FLOAT: number;
  37405. /** BYTE */
  37406. static readonly TEXTURETYPE_BYTE: number;
  37407. /** SHORT */
  37408. static readonly TEXTURETYPE_SHORT: number;
  37409. /** UNSIGNED_SHORT */
  37410. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  37411. /** INT */
  37412. static readonly TEXTURETYPE_INT: number;
  37413. /** UNSIGNED_INT */
  37414. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  37415. /** UNSIGNED_SHORT_4_4_4_4 */
  37416. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  37417. /** UNSIGNED_SHORT_5_5_5_1 */
  37418. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  37419. /** UNSIGNED_SHORT_5_6_5 */
  37420. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  37421. /** UNSIGNED_INT_2_10_10_10_REV */
  37422. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  37423. /** UNSIGNED_INT_24_8 */
  37424. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  37425. /** UNSIGNED_INT_10F_11F_11F_REV */
  37426. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  37427. /** UNSIGNED_INT_5_9_9_9_REV */
  37428. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  37429. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  37430. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  37431. /** nearest is mag = nearest and min = nearest and mip = linear */
  37432. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  37433. /** Bilinear is mag = linear and min = linear and mip = nearest */
  37434. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  37435. /** Trilinear is mag = linear and min = linear and mip = linear */
  37436. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  37437. /** nearest is mag = nearest and min = nearest and mip = linear */
  37438. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  37439. /** Bilinear is mag = linear and min = linear and mip = nearest */
  37440. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  37441. /** Trilinear is mag = linear and min = linear and mip = linear */
  37442. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  37443. /** mag = nearest and min = nearest and mip = nearest */
  37444. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  37445. /** mag = nearest and min = linear and mip = nearest */
  37446. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  37447. /** mag = nearest and min = linear and mip = linear */
  37448. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  37449. /** mag = nearest and min = linear and mip = none */
  37450. static readonly TEXTURE_NEAREST_LINEAR: number;
  37451. /** mag = nearest and min = nearest and mip = none */
  37452. static readonly TEXTURE_NEAREST_NEAREST: number;
  37453. /** mag = linear and min = nearest and mip = nearest */
  37454. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  37455. /** mag = linear and min = nearest and mip = linear */
  37456. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  37457. /** mag = linear and min = linear and mip = none */
  37458. static readonly TEXTURE_LINEAR_LINEAR: number;
  37459. /** mag = linear and min = nearest and mip = none */
  37460. static readonly TEXTURE_LINEAR_NEAREST: number;
  37461. /** Explicit coordinates mode */
  37462. static readonly TEXTURE_EXPLICIT_MODE: number;
  37463. /** Spherical coordinates mode */
  37464. static readonly TEXTURE_SPHERICAL_MODE: number;
  37465. /** Planar coordinates mode */
  37466. static readonly TEXTURE_PLANAR_MODE: number;
  37467. /** Cubic coordinates mode */
  37468. static readonly TEXTURE_CUBIC_MODE: number;
  37469. /** Projection coordinates mode */
  37470. static readonly TEXTURE_PROJECTION_MODE: number;
  37471. /** Skybox coordinates mode */
  37472. static readonly TEXTURE_SKYBOX_MODE: number;
  37473. /** Inverse Cubic coordinates mode */
  37474. static readonly TEXTURE_INVCUBIC_MODE: number;
  37475. /** Equirectangular coordinates mode */
  37476. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  37477. /** Equirectangular Fixed coordinates mode */
  37478. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  37479. /** Equirectangular Fixed Mirrored coordinates mode */
  37480. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  37481. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  37482. static readonly SCALEMODE_FLOOR: number;
  37483. /** Defines that texture rescaling will look for the nearest power of 2 size */
  37484. static readonly SCALEMODE_NEAREST: number;
  37485. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  37486. static readonly SCALEMODE_CEILING: number;
  37487. /**
  37488. * Returns the current npm package of the sdk
  37489. */
  37490. static get NpmPackage(): string;
  37491. /**
  37492. * Returns the current version of the framework
  37493. */
  37494. static get Version(): string;
  37495. /** Gets the list of created engines */
  37496. static get Instances(): Engine[];
  37497. /**
  37498. * Gets the latest created engine
  37499. */
  37500. static get LastCreatedEngine(): Nullable<Engine>;
  37501. /**
  37502. * Gets the latest created scene
  37503. */
  37504. static get LastCreatedScene(): Nullable<Scene>;
  37505. /**
  37506. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  37507. * @param flag defines which part of the materials must be marked as dirty
  37508. * @param predicate defines a predicate used to filter which materials should be affected
  37509. */
  37510. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  37511. /**
  37512. * Method called to create the default loading screen.
  37513. * This can be overriden in your own app.
  37514. * @param canvas The rendering canvas element
  37515. * @returns The loading screen
  37516. */
  37517. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  37518. /**
  37519. * Method called to create the default rescale post process on each engine.
  37520. */
  37521. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  37522. /**
  37523. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  37524. **/
  37525. enableOfflineSupport: boolean;
  37526. /**
  37527. * 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)
  37528. **/
  37529. disableManifestCheck: boolean;
  37530. /**
  37531. * Gets the list of created scenes
  37532. */
  37533. scenes: Scene[];
  37534. /**
  37535. * Event raised when a new scene is created
  37536. */
  37537. onNewSceneAddedObservable: Observable<Scene>;
  37538. /**
  37539. * Gets the list of created postprocesses
  37540. */
  37541. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  37542. /**
  37543. * Gets a boolean indicating if the pointer is currently locked
  37544. */
  37545. isPointerLock: boolean;
  37546. /**
  37547. * Observable event triggered each time the rendering canvas is resized
  37548. */
  37549. onResizeObservable: Observable<Engine>;
  37550. /**
  37551. * Observable event triggered each time the canvas loses focus
  37552. */
  37553. onCanvasBlurObservable: Observable<Engine>;
  37554. /**
  37555. * Observable event triggered each time the canvas gains focus
  37556. */
  37557. onCanvasFocusObservable: Observable<Engine>;
  37558. /**
  37559. * Observable event triggered each time the canvas receives pointerout event
  37560. */
  37561. onCanvasPointerOutObservable: Observable<PointerEvent>;
  37562. /**
  37563. * Observable raised when the engine begins a new frame
  37564. */
  37565. onBeginFrameObservable: Observable<Engine>;
  37566. /**
  37567. * If set, will be used to request the next animation frame for the render loop
  37568. */
  37569. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  37570. /**
  37571. * Observable raised when the engine ends the current frame
  37572. */
  37573. onEndFrameObservable: Observable<Engine>;
  37574. /**
  37575. * Observable raised when the engine is about to compile a shader
  37576. */
  37577. onBeforeShaderCompilationObservable: Observable<Engine>;
  37578. /**
  37579. * Observable raised when the engine has jsut compiled a shader
  37580. */
  37581. onAfterShaderCompilationObservable: Observable<Engine>;
  37582. /**
  37583. * Gets the audio engine
  37584. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37585. * @ignorenaming
  37586. */
  37587. static audioEngine: IAudioEngine;
  37588. /**
  37589. * Default AudioEngine factory responsible of creating the Audio Engine.
  37590. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  37591. */
  37592. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  37593. /**
  37594. * Default offline support factory responsible of creating a tool used to store data locally.
  37595. * By default, this will create a Database object if the workload has been embedded.
  37596. */
  37597. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  37598. private _loadingScreen;
  37599. private _pointerLockRequested;
  37600. private _rescalePostProcess;
  37601. private _deterministicLockstep;
  37602. private _lockstepMaxSteps;
  37603. private _timeStep;
  37604. protected get _supportsHardwareTextureRescaling(): boolean;
  37605. private _fps;
  37606. private _deltaTime;
  37607. /** @hidden */
  37608. _drawCalls: PerfCounter;
  37609. /** 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 */
  37610. canvasTabIndex: number;
  37611. /**
  37612. * Turn this value on if you want to pause FPS computation when in background
  37613. */
  37614. disablePerformanceMonitorInBackground: boolean;
  37615. private _performanceMonitor;
  37616. /**
  37617. * Gets the performance monitor attached to this engine
  37618. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  37619. */
  37620. get performanceMonitor(): PerformanceMonitor;
  37621. private _onFocus;
  37622. private _onBlur;
  37623. private _onCanvasPointerOut;
  37624. private _onCanvasBlur;
  37625. private _onCanvasFocus;
  37626. private _onFullscreenChange;
  37627. private _onPointerLockChange;
  37628. /**
  37629. * Gets the HTML element used to attach event listeners
  37630. * @returns a HTML element
  37631. */
  37632. getInputElement(): Nullable<HTMLElement>;
  37633. /**
  37634. * Creates a new engine
  37635. * @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
  37636. * @param antialias defines enable antialiasing (default: false)
  37637. * @param options defines further options to be sent to the getContext() function
  37638. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  37639. */
  37640. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  37641. /**
  37642. * Gets current aspect ratio
  37643. * @param viewportOwner defines the camera to use to get the aspect ratio
  37644. * @param useScreen defines if screen size must be used (or the current render target if any)
  37645. * @returns a number defining the aspect ratio
  37646. */
  37647. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  37648. /**
  37649. * Gets current screen aspect ratio
  37650. * @returns a number defining the aspect ratio
  37651. */
  37652. getScreenAspectRatio(): number;
  37653. /**
  37654. * Gets the client rect of the HTML canvas attached with the current webGL context
  37655. * @returns a client rectanglee
  37656. */
  37657. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  37658. /**
  37659. * Gets the client rect of the HTML element used for events
  37660. * @returns a client rectanglee
  37661. */
  37662. getInputElementClientRect(): Nullable<ClientRect>;
  37663. /**
  37664. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  37665. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  37666. * @returns true if engine is in deterministic lock step mode
  37667. */
  37668. isDeterministicLockStep(): boolean;
  37669. /**
  37670. * Gets the max steps when engine is running in deterministic lock step
  37671. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  37672. * @returns the max steps
  37673. */
  37674. getLockstepMaxSteps(): number;
  37675. /**
  37676. * Returns the time in ms between steps when using deterministic lock step.
  37677. * @returns time step in (ms)
  37678. */
  37679. getTimeStep(): number;
  37680. /**
  37681. * Force the mipmap generation for the given render target texture
  37682. * @param texture defines the render target texture to use
  37683. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  37684. */
  37685. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  37686. /** States */
  37687. /**
  37688. * Set various states to the webGL context
  37689. * @param culling defines backface culling state
  37690. * @param zOffset defines the value to apply to zOffset (0 by default)
  37691. * @param force defines if states must be applied even if cache is up to date
  37692. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  37693. */
  37694. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  37695. /**
  37696. * Set the z offset to apply to current rendering
  37697. * @param value defines the offset to apply
  37698. */
  37699. setZOffset(value: number): void;
  37700. /**
  37701. * Gets the current value of the zOffset
  37702. * @returns the current zOffset state
  37703. */
  37704. getZOffset(): number;
  37705. /**
  37706. * Enable or disable depth buffering
  37707. * @param enable defines the state to set
  37708. */
  37709. setDepthBuffer(enable: boolean): void;
  37710. /**
  37711. * Gets a boolean indicating if depth writing is enabled
  37712. * @returns the current depth writing state
  37713. */
  37714. getDepthWrite(): boolean;
  37715. /**
  37716. * Enable or disable depth writing
  37717. * @param enable defines the state to set
  37718. */
  37719. setDepthWrite(enable: boolean): void;
  37720. /**
  37721. * Gets a boolean indicating if stencil buffer is enabled
  37722. * @returns the current stencil buffer state
  37723. */
  37724. getStencilBuffer(): boolean;
  37725. /**
  37726. * Enable or disable the stencil buffer
  37727. * @param enable defines if the stencil buffer must be enabled or disabled
  37728. */
  37729. setStencilBuffer(enable: boolean): void;
  37730. /**
  37731. * Gets the current stencil mask
  37732. * @returns a number defining the new stencil mask to use
  37733. */
  37734. getStencilMask(): number;
  37735. /**
  37736. * Sets the current stencil mask
  37737. * @param mask defines the new stencil mask to use
  37738. */
  37739. setStencilMask(mask: number): void;
  37740. /**
  37741. * Gets the current stencil function
  37742. * @returns a number defining the stencil function to use
  37743. */
  37744. getStencilFunction(): number;
  37745. /**
  37746. * Gets the current stencil reference value
  37747. * @returns a number defining the stencil reference value to use
  37748. */
  37749. getStencilFunctionReference(): number;
  37750. /**
  37751. * Gets the current stencil mask
  37752. * @returns a number defining the stencil mask to use
  37753. */
  37754. getStencilFunctionMask(): number;
  37755. /**
  37756. * Sets the current stencil function
  37757. * @param stencilFunc defines the new stencil function to use
  37758. */
  37759. setStencilFunction(stencilFunc: number): void;
  37760. /**
  37761. * Sets the current stencil reference
  37762. * @param reference defines the new stencil reference to use
  37763. */
  37764. setStencilFunctionReference(reference: number): void;
  37765. /**
  37766. * Sets the current stencil mask
  37767. * @param mask defines the new stencil mask to use
  37768. */
  37769. setStencilFunctionMask(mask: number): void;
  37770. /**
  37771. * Gets the current stencil operation when stencil fails
  37772. * @returns a number defining stencil operation to use when stencil fails
  37773. */
  37774. getStencilOperationFail(): number;
  37775. /**
  37776. * Gets the current stencil operation when depth fails
  37777. * @returns a number defining stencil operation to use when depth fails
  37778. */
  37779. getStencilOperationDepthFail(): number;
  37780. /**
  37781. * Gets the current stencil operation when stencil passes
  37782. * @returns a number defining stencil operation to use when stencil passes
  37783. */
  37784. getStencilOperationPass(): number;
  37785. /**
  37786. * Sets the stencil operation to use when stencil fails
  37787. * @param operation defines the stencil operation to use when stencil fails
  37788. */
  37789. setStencilOperationFail(operation: number): void;
  37790. /**
  37791. * Sets the stencil operation to use when depth fails
  37792. * @param operation defines the stencil operation to use when depth fails
  37793. */
  37794. setStencilOperationDepthFail(operation: number): void;
  37795. /**
  37796. * Sets the stencil operation to use when stencil passes
  37797. * @param operation defines the stencil operation to use when stencil passes
  37798. */
  37799. setStencilOperationPass(operation: number): void;
  37800. /**
  37801. * Sets a boolean indicating if the dithering state is enabled or disabled
  37802. * @param value defines the dithering state
  37803. */
  37804. setDitheringState(value: boolean): void;
  37805. /**
  37806. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  37807. * @param value defines the rasterizer state
  37808. */
  37809. setRasterizerState(value: boolean): void;
  37810. /**
  37811. * Gets the current depth function
  37812. * @returns a number defining the depth function
  37813. */
  37814. getDepthFunction(): Nullable<number>;
  37815. /**
  37816. * Sets the current depth function
  37817. * @param depthFunc defines the function to use
  37818. */
  37819. setDepthFunction(depthFunc: number): void;
  37820. /**
  37821. * Sets the current depth function to GREATER
  37822. */
  37823. setDepthFunctionToGreater(): void;
  37824. /**
  37825. * Sets the current depth function to GEQUAL
  37826. */
  37827. setDepthFunctionToGreaterOrEqual(): void;
  37828. /**
  37829. * Sets the current depth function to LESS
  37830. */
  37831. setDepthFunctionToLess(): void;
  37832. /**
  37833. * Sets the current depth function to LEQUAL
  37834. */
  37835. setDepthFunctionToLessOrEqual(): void;
  37836. private _cachedStencilBuffer;
  37837. private _cachedStencilFunction;
  37838. private _cachedStencilMask;
  37839. private _cachedStencilOperationPass;
  37840. private _cachedStencilOperationFail;
  37841. private _cachedStencilOperationDepthFail;
  37842. private _cachedStencilReference;
  37843. /**
  37844. * Caches the the state of the stencil buffer
  37845. */
  37846. cacheStencilState(): void;
  37847. /**
  37848. * Restores the state of the stencil buffer
  37849. */
  37850. restoreStencilState(): void;
  37851. /**
  37852. * Directly set the WebGL Viewport
  37853. * @param x defines the x coordinate of the viewport (in screen space)
  37854. * @param y defines the y coordinate of the viewport (in screen space)
  37855. * @param width defines the width of the viewport (in screen space)
  37856. * @param height defines the height of the viewport (in screen space)
  37857. * @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
  37858. */
  37859. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  37860. /**
  37861. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  37862. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  37863. * @param y defines the y-coordinate of the corner of the clear rectangle
  37864. * @param width defines the width of the clear rectangle
  37865. * @param height defines the height of the clear rectangle
  37866. * @param clearColor defines the clear color
  37867. */
  37868. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  37869. /**
  37870. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  37871. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  37872. * @param y defines the y-coordinate of the corner of the clear rectangle
  37873. * @param width defines the width of the clear rectangle
  37874. * @param height defines the height of the clear rectangle
  37875. */
  37876. enableScissor(x: number, y: number, width: number, height: number): void;
  37877. /**
  37878. * Disable previously set scissor test rectangle
  37879. */
  37880. disableScissor(): void;
  37881. protected _reportDrawCall(): void;
  37882. /**
  37883. * Initializes a webVR display and starts listening to display change events
  37884. * The onVRDisplayChangedObservable will be notified upon these changes
  37885. * @returns The onVRDisplayChangedObservable
  37886. */
  37887. initWebVR(): Observable<IDisplayChangedEventArgs>;
  37888. /** @hidden */
  37889. _prepareVRComponent(): void;
  37890. /** @hidden */
  37891. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  37892. /** @hidden */
  37893. _submitVRFrame(): void;
  37894. /**
  37895. * Call this function to leave webVR mode
  37896. * Will do nothing if webVR is not supported or if there is no webVR device
  37897. * @see http://doc.babylonjs.com/how_to/webvr_camera
  37898. */
  37899. disableVR(): void;
  37900. /**
  37901. * Gets a boolean indicating that the system is in VR mode and is presenting
  37902. * @returns true if VR mode is engaged
  37903. */
  37904. isVRPresenting(): boolean;
  37905. /** @hidden */
  37906. _requestVRFrame(): void;
  37907. /** @hidden */
  37908. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  37909. /**
  37910. * Gets the source code of the vertex shader associated with a specific webGL program
  37911. * @param program defines the program to use
  37912. * @returns a string containing the source code of the vertex shader associated with the program
  37913. */
  37914. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  37915. /**
  37916. * Gets the source code of the fragment shader associated with a specific webGL program
  37917. * @param program defines the program to use
  37918. * @returns a string containing the source code of the fragment shader associated with the program
  37919. */
  37920. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  37921. /**
  37922. * Sets a depth stencil texture from a render target to the according uniform.
  37923. * @param channel The texture channel
  37924. * @param uniform The uniform to set
  37925. * @param texture The render target texture containing the depth stencil texture to apply
  37926. */
  37927. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  37928. /**
  37929. * Sets a texture to the webGL context from a postprocess
  37930. * @param channel defines the channel to use
  37931. * @param postProcess defines the source postprocess
  37932. */
  37933. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  37934. /**
  37935. * Binds the output of the passed in post process to the texture channel specified
  37936. * @param channel The channel the texture should be bound to
  37937. * @param postProcess The post process which's output should be bound
  37938. */
  37939. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  37940. protected _rebuildBuffers(): void;
  37941. /** @hidden */
  37942. _renderFrame(): void;
  37943. _renderLoop(): void;
  37944. /** @hidden */
  37945. _renderViews(): boolean;
  37946. /**
  37947. * Toggle full screen mode
  37948. * @param requestPointerLock defines if a pointer lock should be requested from the user
  37949. */
  37950. switchFullscreen(requestPointerLock: boolean): void;
  37951. /**
  37952. * Enters full screen mode
  37953. * @param requestPointerLock defines if a pointer lock should be requested from the user
  37954. */
  37955. enterFullscreen(requestPointerLock: boolean): void;
  37956. /**
  37957. * Exits full screen mode
  37958. */
  37959. exitFullscreen(): void;
  37960. /**
  37961. * Enters Pointerlock mode
  37962. */
  37963. enterPointerlock(): void;
  37964. /**
  37965. * Exits Pointerlock mode
  37966. */
  37967. exitPointerlock(): void;
  37968. /**
  37969. * Begin a new frame
  37970. */
  37971. beginFrame(): void;
  37972. /**
  37973. * Enf the current frame
  37974. */
  37975. endFrame(): void;
  37976. resize(): void;
  37977. /**
  37978. * Force a specific size of the canvas
  37979. * @param width defines the new canvas' width
  37980. * @param height defines the new canvas' height
  37981. */
  37982. setSize(width: number, height: number): void;
  37983. /**
  37984. * Updates a dynamic vertex buffer.
  37985. * @param vertexBuffer the vertex buffer to update
  37986. * @param data the data used to update the vertex buffer
  37987. * @param byteOffset the byte offset of the data
  37988. * @param byteLength the byte length of the data
  37989. */
  37990. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  37991. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  37992. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  37993. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  37994. _releaseTexture(texture: InternalTexture): void;
  37995. /**
  37996. * @hidden
  37997. * Rescales a texture
  37998. * @param source input texutre
  37999. * @param destination destination texture
  38000. * @param scene scene to use to render the resize
  38001. * @param internalFormat format to use when resizing
  38002. * @param onComplete callback to be called when resize has completed
  38003. */
  38004. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  38005. /**
  38006. * Gets the current framerate
  38007. * @returns a number representing the framerate
  38008. */
  38009. getFps(): number;
  38010. /**
  38011. * Gets the time spent between current and previous frame
  38012. * @returns a number representing the delta time in ms
  38013. */
  38014. getDeltaTime(): number;
  38015. private _measureFps;
  38016. /** @hidden */
  38017. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  38018. /**
  38019. * Update a dynamic index buffer
  38020. * @param indexBuffer defines the target index buffer
  38021. * @param indices defines the data to update
  38022. * @param offset defines the offset in the target index buffer where update should start
  38023. */
  38024. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  38025. /**
  38026. * Updates the sample count of a render target texture
  38027. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  38028. * @param texture defines the texture to update
  38029. * @param samples defines the sample count to set
  38030. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  38031. */
  38032. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  38033. /**
  38034. * Updates a depth texture Comparison Mode and Function.
  38035. * If the comparison Function is equal to 0, the mode will be set to none.
  38036. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  38037. * @param texture The texture to set the comparison function for
  38038. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  38039. */
  38040. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  38041. /**
  38042. * Creates a webGL buffer to use with instanciation
  38043. * @param capacity defines the size of the buffer
  38044. * @returns the webGL buffer
  38045. */
  38046. createInstancesBuffer(capacity: number): DataBuffer;
  38047. /**
  38048. * Delete a webGL buffer used with instanciation
  38049. * @param buffer defines the webGL buffer to delete
  38050. */
  38051. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  38052. private _clientWaitAsync;
  38053. /** @hidden */
  38054. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  38055. dispose(): void;
  38056. private _disableTouchAction;
  38057. /**
  38058. * Display the loading screen
  38059. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38060. */
  38061. displayLoadingUI(): void;
  38062. /**
  38063. * Hide the loading screen
  38064. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38065. */
  38066. hideLoadingUI(): void;
  38067. /**
  38068. * Gets the current loading screen object
  38069. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38070. */
  38071. get loadingScreen(): ILoadingScreen;
  38072. /**
  38073. * Sets the current loading screen object
  38074. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38075. */
  38076. set loadingScreen(loadingScreen: ILoadingScreen);
  38077. /**
  38078. * Sets the current loading screen text
  38079. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38080. */
  38081. set loadingUIText(text: string);
  38082. /**
  38083. * Sets the current loading screen background color
  38084. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38085. */
  38086. set loadingUIBackgroundColor(color: string);
  38087. /** Pointerlock and fullscreen */
  38088. /**
  38089. * Ask the browser to promote the current element to pointerlock mode
  38090. * @param element defines the DOM element to promote
  38091. */
  38092. static _RequestPointerlock(element: HTMLElement): void;
  38093. /**
  38094. * Asks the browser to exit pointerlock mode
  38095. */
  38096. static _ExitPointerlock(): void;
  38097. /**
  38098. * Ask the browser to promote the current element to fullscreen rendering mode
  38099. * @param element defines the DOM element to promote
  38100. */
  38101. static _RequestFullscreen(element: HTMLElement): void;
  38102. /**
  38103. * Asks the browser to exit fullscreen mode
  38104. */
  38105. static _ExitFullscreen(): void;
  38106. }
  38107. }
  38108. declare module "babylonjs/Engines/engineStore" {
  38109. import { Nullable } from "babylonjs/types";
  38110. import { Engine } from "babylonjs/Engines/engine";
  38111. import { Scene } from "babylonjs/scene";
  38112. /**
  38113. * The engine store class is responsible to hold all the instances of Engine and Scene created
  38114. * during the life time of the application.
  38115. */
  38116. export class EngineStore {
  38117. /** Gets the list of created engines */
  38118. static Instances: import("babylonjs/Engines/engine").Engine[];
  38119. /** @hidden */
  38120. static _LastCreatedScene: Nullable<Scene>;
  38121. /**
  38122. * Gets the latest created engine
  38123. */
  38124. static get LastCreatedEngine(): Nullable<Engine>;
  38125. /**
  38126. * Gets the latest created scene
  38127. */
  38128. static get LastCreatedScene(): Nullable<Scene>;
  38129. /**
  38130. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  38131. * @ignorenaming
  38132. */
  38133. static UseFallbackTexture: boolean;
  38134. /**
  38135. * Texture content used if a texture cannot loaded
  38136. * @ignorenaming
  38137. */
  38138. static FallbackTexture: string;
  38139. }
  38140. }
  38141. declare module "babylonjs/Misc/promise" {
  38142. /**
  38143. * Helper class that provides a small promise polyfill
  38144. */
  38145. export class PromisePolyfill {
  38146. /**
  38147. * Static function used to check if the polyfill is required
  38148. * If this is the case then the function will inject the polyfill to window.Promise
  38149. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  38150. */
  38151. static Apply(force?: boolean): void;
  38152. }
  38153. }
  38154. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  38155. /**
  38156. * Interface for screenshot methods with describe argument called `size` as object with options
  38157. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  38158. */
  38159. export interface IScreenshotSize {
  38160. /**
  38161. * number in pixels for canvas height
  38162. */
  38163. height?: number;
  38164. /**
  38165. * multiplier allowing render at a higher or lower resolution
  38166. * If value is defined then height and width will be ignored and taken from camera
  38167. */
  38168. precision?: number;
  38169. /**
  38170. * number in pixels for canvas width
  38171. */
  38172. width?: number;
  38173. }
  38174. }
  38175. declare module "babylonjs/Misc/tools" {
  38176. import { Nullable, float } from "babylonjs/types";
  38177. import { DomManagement } from "babylonjs/Misc/domManagement";
  38178. import { WebRequest } from "babylonjs/Misc/webRequest";
  38179. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  38180. import { ReadFileError } from "babylonjs/Misc/fileTools";
  38181. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  38182. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  38183. import { Camera } from "babylonjs/Cameras/camera";
  38184. import { Engine } from "babylonjs/Engines/engine";
  38185. interface IColor4Like {
  38186. r: float;
  38187. g: float;
  38188. b: float;
  38189. a: float;
  38190. }
  38191. /**
  38192. * Class containing a set of static utilities functions
  38193. */
  38194. export class Tools {
  38195. /**
  38196. * Gets or sets the base URL to use to load assets
  38197. */
  38198. static get BaseUrl(): string;
  38199. static set BaseUrl(value: string);
  38200. /**
  38201. * Enable/Disable Custom HTTP Request Headers globally.
  38202. * default = false
  38203. * @see CustomRequestHeaders
  38204. */
  38205. static UseCustomRequestHeaders: boolean;
  38206. /**
  38207. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  38208. * i.e. when loading files, where the server/service expects an Authorization header
  38209. */
  38210. static CustomRequestHeaders: {
  38211. [key: string]: string;
  38212. };
  38213. /**
  38214. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  38215. */
  38216. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  38217. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  38218. /**
  38219. * Default behaviour for cors in the application.
  38220. * It can be a string if the expected behavior is identical in the entire app.
  38221. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  38222. */
  38223. static get CorsBehavior(): string | ((url: string | string[]) => string);
  38224. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  38225. /**
  38226. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  38227. * @ignorenaming
  38228. */
  38229. static get UseFallbackTexture(): boolean;
  38230. static set UseFallbackTexture(value: boolean);
  38231. /**
  38232. * Use this object to register external classes like custom textures or material
  38233. * to allow the laoders to instantiate them
  38234. */
  38235. static get RegisteredExternalClasses(): {
  38236. [key: string]: Object;
  38237. };
  38238. static set RegisteredExternalClasses(classes: {
  38239. [key: string]: Object;
  38240. });
  38241. /**
  38242. * Texture content used if a texture cannot loaded
  38243. * @ignorenaming
  38244. */
  38245. static get fallbackTexture(): string;
  38246. static set fallbackTexture(value: string);
  38247. /**
  38248. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  38249. * @param u defines the coordinate on X axis
  38250. * @param v defines the coordinate on Y axis
  38251. * @param width defines the width of the source data
  38252. * @param height defines the height of the source data
  38253. * @param pixels defines the source byte array
  38254. * @param color defines the output color
  38255. */
  38256. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  38257. /**
  38258. * Interpolates between a and b via alpha
  38259. * @param a The lower value (returned when alpha = 0)
  38260. * @param b The upper value (returned when alpha = 1)
  38261. * @param alpha The interpolation-factor
  38262. * @return The mixed value
  38263. */
  38264. static Mix(a: number, b: number, alpha: number): number;
  38265. /**
  38266. * Tries to instantiate a new object from a given class name
  38267. * @param className defines the class name to instantiate
  38268. * @returns the new object or null if the system was not able to do the instantiation
  38269. */
  38270. static Instantiate(className: string): any;
  38271. /**
  38272. * Provides a slice function that will work even on IE
  38273. * @param data defines the array to slice
  38274. * @param start defines the start of the data (optional)
  38275. * @param end defines the end of the data (optional)
  38276. * @returns the new sliced array
  38277. */
  38278. static Slice<T>(data: T, start?: number, end?: number): T;
  38279. /**
  38280. * Polyfill for setImmediate
  38281. * @param action defines the action to execute after the current execution block
  38282. */
  38283. static SetImmediate(action: () => void): void;
  38284. /**
  38285. * Function indicating if a number is an exponent of 2
  38286. * @param value defines the value to test
  38287. * @returns true if the value is an exponent of 2
  38288. */
  38289. static IsExponentOfTwo(value: number): boolean;
  38290. private static _tmpFloatArray;
  38291. /**
  38292. * Returns the nearest 32-bit single precision float representation of a Number
  38293. * @param value A Number. If the parameter is of a different type, it will get converted
  38294. * to a number or to NaN if it cannot be converted
  38295. * @returns number
  38296. */
  38297. static FloatRound(value: number): number;
  38298. /**
  38299. * Extracts the filename from a path
  38300. * @param path defines the path to use
  38301. * @returns the filename
  38302. */
  38303. static GetFilename(path: string): string;
  38304. /**
  38305. * Extracts the "folder" part of a path (everything before the filename).
  38306. * @param uri The URI to extract the info from
  38307. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  38308. * @returns The "folder" part of the path
  38309. */
  38310. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  38311. /**
  38312. * Extracts text content from a DOM element hierarchy
  38313. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  38314. */
  38315. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  38316. /**
  38317. * Convert an angle in radians to degrees
  38318. * @param angle defines the angle to convert
  38319. * @returns the angle in degrees
  38320. */
  38321. static ToDegrees(angle: number): number;
  38322. /**
  38323. * Convert an angle in degrees to radians
  38324. * @param angle defines the angle to convert
  38325. * @returns the angle in radians
  38326. */
  38327. static ToRadians(angle: number): number;
  38328. /**
  38329. * Returns an array if obj is not an array
  38330. * @param obj defines the object to evaluate as an array
  38331. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  38332. * @returns either obj directly if obj is an array or a new array containing obj
  38333. */
  38334. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  38335. /**
  38336. * Gets the pointer prefix to use
  38337. * @param engine defines the engine we are finding the prefix for
  38338. * @returns "pointer" if touch is enabled. Else returns "mouse"
  38339. */
  38340. static GetPointerPrefix(engine: Engine): string;
  38341. /**
  38342. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  38343. * @param url define the url we are trying
  38344. * @param element define the dom element where to configure the cors policy
  38345. */
  38346. static SetCorsBehavior(url: string | string[], element: {
  38347. crossOrigin: string | null;
  38348. }): void;
  38349. /**
  38350. * Removes unwanted characters from an url
  38351. * @param url defines the url to clean
  38352. * @returns the cleaned url
  38353. */
  38354. static CleanUrl(url: string): string;
  38355. /**
  38356. * Gets or sets a function used to pre-process url before using them to load assets
  38357. */
  38358. static get PreprocessUrl(): (url: string) => string;
  38359. static set PreprocessUrl(processor: (url: string) => string);
  38360. /**
  38361. * Loads an image as an HTMLImageElement.
  38362. * @param input url string, ArrayBuffer, or Blob to load
  38363. * @param onLoad callback called when the image successfully loads
  38364. * @param onError callback called when the image fails to load
  38365. * @param offlineProvider offline provider for caching
  38366. * @param mimeType optional mime type
  38367. * @returns the HTMLImageElement of the loaded image
  38368. */
  38369. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  38370. /**
  38371. * Loads a file from a url
  38372. * @param url url string, ArrayBuffer, or Blob to load
  38373. * @param onSuccess callback called when the file successfully loads
  38374. * @param onProgress callback called while file is loading (if the server supports this mode)
  38375. * @param offlineProvider defines the offline provider for caching
  38376. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  38377. * @param onError callback called when the file fails to load
  38378. * @returns a file request object
  38379. */
  38380. 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;
  38381. /**
  38382. * Loads a file from a url
  38383. * @param url the file url to load
  38384. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  38385. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  38386. */
  38387. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  38388. /**
  38389. * Load a script (identified by an url). When the url returns, the
  38390. * content of this file is added into a new script element, attached to the DOM (body element)
  38391. * @param scriptUrl defines the url of the script to laod
  38392. * @param onSuccess defines the callback called when the script is loaded
  38393. * @param onError defines the callback to call if an error occurs
  38394. * @param scriptId defines the id of the script element
  38395. */
  38396. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  38397. /**
  38398. * Load an asynchronous script (identified by an url). When the url returns, the
  38399. * content of this file is added into a new script element, attached to the DOM (body element)
  38400. * @param scriptUrl defines the url of the script to laod
  38401. * @param scriptId defines the id of the script element
  38402. * @returns a promise request object
  38403. */
  38404. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  38405. /**
  38406. * Loads a file from a blob
  38407. * @param fileToLoad defines the blob to use
  38408. * @param callback defines the callback to call when data is loaded
  38409. * @param progressCallback defines the callback to call during loading process
  38410. * @returns a file request object
  38411. */
  38412. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  38413. /**
  38414. * Reads a file from a File object
  38415. * @param file defines the file to load
  38416. * @param onSuccess defines the callback to call when data is loaded
  38417. * @param onProgress defines the callback to call during loading process
  38418. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  38419. * @param onError defines the callback to call when an error occurs
  38420. * @returns a file request object
  38421. */
  38422. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  38423. /**
  38424. * Creates a data url from a given string content
  38425. * @param content defines the content to convert
  38426. * @returns the new data url link
  38427. */
  38428. static FileAsURL(content: string): string;
  38429. /**
  38430. * Format the given number to a specific decimal format
  38431. * @param value defines the number to format
  38432. * @param decimals defines the number of decimals to use
  38433. * @returns the formatted string
  38434. */
  38435. static Format(value: number, decimals?: number): string;
  38436. /**
  38437. * Tries to copy an object by duplicating every property
  38438. * @param source defines the source object
  38439. * @param destination defines the target object
  38440. * @param doNotCopyList defines a list of properties to avoid
  38441. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  38442. */
  38443. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  38444. /**
  38445. * Gets a boolean indicating if the given object has no own property
  38446. * @param obj defines the object to test
  38447. * @returns true if object has no own property
  38448. */
  38449. static IsEmpty(obj: any): boolean;
  38450. /**
  38451. * Function used to register events at window level
  38452. * @param windowElement defines the Window object to use
  38453. * @param events defines the events to register
  38454. */
  38455. static RegisterTopRootEvents(windowElement: Window, events: {
  38456. name: string;
  38457. handler: Nullable<(e: FocusEvent) => any>;
  38458. }[]): void;
  38459. /**
  38460. * Function used to unregister events from window level
  38461. * @param windowElement defines the Window object to use
  38462. * @param events defines the events to unregister
  38463. */
  38464. static UnregisterTopRootEvents(windowElement: Window, events: {
  38465. name: string;
  38466. handler: Nullable<(e: FocusEvent) => any>;
  38467. }[]): void;
  38468. /**
  38469. * @ignore
  38470. */
  38471. static _ScreenshotCanvas: HTMLCanvasElement;
  38472. /**
  38473. * Dumps the current bound framebuffer
  38474. * @param width defines the rendering width
  38475. * @param height defines the rendering height
  38476. * @param engine defines the hosting engine
  38477. * @param successCallback defines the callback triggered once the data are available
  38478. * @param mimeType defines the mime type of the result
  38479. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  38480. */
  38481. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  38482. /**
  38483. * Converts the canvas data to blob.
  38484. * This acts as a polyfill for browsers not supporting the to blob function.
  38485. * @param canvas Defines the canvas to extract the data from
  38486. * @param successCallback Defines the callback triggered once the data are available
  38487. * @param mimeType Defines the mime type of the result
  38488. */
  38489. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  38490. /**
  38491. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  38492. * @param successCallback defines the callback triggered once the data are available
  38493. * @param mimeType defines the mime type of the result
  38494. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  38495. */
  38496. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  38497. /**
  38498. * Downloads a blob in the browser
  38499. * @param blob defines the blob to download
  38500. * @param fileName defines the name of the downloaded file
  38501. */
  38502. static Download(blob: Blob, fileName: string): void;
  38503. /**
  38504. * Captures a screenshot of the current rendering
  38505. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  38506. * @param engine defines the rendering engine
  38507. * @param camera defines the source camera
  38508. * @param size This parameter can be set to a single number or to an object with the
  38509. * following (optional) properties: precision, width, height. If a single number is passed,
  38510. * it will be used for both width and height. If an object is passed, the screenshot size
  38511. * will be derived from the parameters. The precision property is a multiplier allowing
  38512. * rendering at a higher or lower resolution
  38513. * @param successCallback defines the callback receives a single parameter which contains the
  38514. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  38515. * src parameter of an <img> to display it
  38516. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  38517. * Check your browser for supported MIME types
  38518. */
  38519. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  38520. /**
  38521. * Captures a screenshot of the current rendering
  38522. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  38523. * @param engine defines the rendering engine
  38524. * @param camera defines the source camera
  38525. * @param size This parameter can be set to a single number or to an object with the
  38526. * following (optional) properties: precision, width, height. If a single number is passed,
  38527. * it will be used for both width and height. If an object is passed, the screenshot size
  38528. * will be derived from the parameters. The precision property is a multiplier allowing
  38529. * rendering at a higher or lower resolution
  38530. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  38531. * Check your browser for supported MIME types
  38532. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  38533. * to the src parameter of an <img> to display it
  38534. */
  38535. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  38536. /**
  38537. * Generates an image screenshot from the specified camera.
  38538. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  38539. * @param engine The engine to use for rendering
  38540. * @param camera The camera to use for rendering
  38541. * @param size This parameter can be set to a single number or to an object with the
  38542. * following (optional) properties: precision, width, height. If a single number is passed,
  38543. * it will be used for both width and height. If an object is passed, the screenshot size
  38544. * will be derived from the parameters. The precision property is a multiplier allowing
  38545. * rendering at a higher or lower resolution
  38546. * @param successCallback The callback receives a single parameter which contains the
  38547. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  38548. * src parameter of an <img> to display it
  38549. * @param mimeType The MIME type of the screenshot image (default: image/png).
  38550. * Check your browser for supported MIME types
  38551. * @param samples Texture samples (default: 1)
  38552. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  38553. * @param fileName A name for for the downloaded file.
  38554. */
  38555. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  38556. /**
  38557. * Generates an image screenshot from the specified camera.
  38558. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  38559. * @param engine The engine to use for rendering
  38560. * @param camera The camera to use for rendering
  38561. * @param size This parameter can be set to a single number or to an object with the
  38562. * following (optional) properties: precision, width, height. If a single number is passed,
  38563. * it will be used for both width and height. If an object is passed, the screenshot size
  38564. * will be derived from the parameters. The precision property is a multiplier allowing
  38565. * rendering at a higher or lower resolution
  38566. * @param mimeType The MIME type of the screenshot image (default: image/png).
  38567. * Check your browser for supported MIME types
  38568. * @param samples Texture samples (default: 1)
  38569. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  38570. * @param fileName A name for for the downloaded file.
  38571. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  38572. * to the src parameter of an <img> to display it
  38573. */
  38574. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  38575. /**
  38576. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  38577. * Be aware Math.random() could cause collisions, but:
  38578. * "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"
  38579. * @returns a pseudo random id
  38580. */
  38581. static RandomId(): string;
  38582. /**
  38583. * Test if the given uri is a base64 string
  38584. * @param uri The uri to test
  38585. * @return True if the uri is a base64 string or false otherwise
  38586. */
  38587. static IsBase64(uri: string): boolean;
  38588. /**
  38589. * Decode the given base64 uri.
  38590. * @param uri The uri to decode
  38591. * @return The decoded base64 data.
  38592. */
  38593. static DecodeBase64(uri: string): ArrayBuffer;
  38594. /**
  38595. * Gets the absolute url.
  38596. * @param url the input url
  38597. * @return the absolute url
  38598. */
  38599. static GetAbsoluteUrl(url: string): string;
  38600. /**
  38601. * No log
  38602. */
  38603. static readonly NoneLogLevel: number;
  38604. /**
  38605. * Only message logs
  38606. */
  38607. static readonly MessageLogLevel: number;
  38608. /**
  38609. * Only warning logs
  38610. */
  38611. static readonly WarningLogLevel: number;
  38612. /**
  38613. * Only error logs
  38614. */
  38615. static readonly ErrorLogLevel: number;
  38616. /**
  38617. * All logs
  38618. */
  38619. static readonly AllLogLevel: number;
  38620. /**
  38621. * Gets a value indicating the number of loading errors
  38622. * @ignorenaming
  38623. */
  38624. static get errorsCount(): number;
  38625. /**
  38626. * Callback called when a new log is added
  38627. */
  38628. static OnNewCacheEntry: (entry: string) => void;
  38629. /**
  38630. * Log a message to the console
  38631. * @param message defines the message to log
  38632. */
  38633. static Log(message: string): void;
  38634. /**
  38635. * Write a warning message to the console
  38636. * @param message defines the message to log
  38637. */
  38638. static Warn(message: string): void;
  38639. /**
  38640. * Write an error message to the console
  38641. * @param message defines the message to log
  38642. */
  38643. static Error(message: string): void;
  38644. /**
  38645. * Gets current log cache (list of logs)
  38646. */
  38647. static get LogCache(): string;
  38648. /**
  38649. * Clears the log cache
  38650. */
  38651. static ClearLogCache(): void;
  38652. /**
  38653. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  38654. */
  38655. static set LogLevels(level: number);
  38656. /**
  38657. * Checks if the window object exists
  38658. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  38659. */
  38660. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  38661. /**
  38662. * No performance log
  38663. */
  38664. static readonly PerformanceNoneLogLevel: number;
  38665. /**
  38666. * Use user marks to log performance
  38667. */
  38668. static readonly PerformanceUserMarkLogLevel: number;
  38669. /**
  38670. * Log performance to the console
  38671. */
  38672. static readonly PerformanceConsoleLogLevel: number;
  38673. private static _performance;
  38674. /**
  38675. * Sets the current performance log level
  38676. */
  38677. static set PerformanceLogLevel(level: number);
  38678. private static _StartPerformanceCounterDisabled;
  38679. private static _EndPerformanceCounterDisabled;
  38680. private static _StartUserMark;
  38681. private static _EndUserMark;
  38682. private static _StartPerformanceConsole;
  38683. private static _EndPerformanceConsole;
  38684. /**
  38685. * Starts a performance counter
  38686. */
  38687. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  38688. /**
  38689. * Ends a specific performance coutner
  38690. */
  38691. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  38692. /**
  38693. * Gets either window.performance.now() if supported or Date.now() else
  38694. */
  38695. static get Now(): number;
  38696. /**
  38697. * This method will return the name of the class used to create the instance of the given object.
  38698. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  38699. * @param object the object to get the class name from
  38700. * @param isType defines if the object is actually a type
  38701. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  38702. */
  38703. static GetClassName(object: any, isType?: boolean): string;
  38704. /**
  38705. * Gets the first element of an array satisfying a given predicate
  38706. * @param array defines the array to browse
  38707. * @param predicate defines the predicate to use
  38708. * @returns null if not found or the element
  38709. */
  38710. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  38711. /**
  38712. * This method will return the name of the full name of the class, including its owning module (if any).
  38713. * 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).
  38714. * @param object the object to get the class name from
  38715. * @param isType defines if the object is actually a type
  38716. * @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.
  38717. * @ignorenaming
  38718. */
  38719. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  38720. /**
  38721. * Returns a promise that resolves after the given amount of time.
  38722. * @param delay Number of milliseconds to delay
  38723. * @returns Promise that resolves after the given amount of time
  38724. */
  38725. static DelayAsync(delay: number): Promise<void>;
  38726. /**
  38727. * Utility function to detect if the current user agent is Safari
  38728. * @returns whether or not the current user agent is safari
  38729. */
  38730. static IsSafari(): boolean;
  38731. }
  38732. /**
  38733. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  38734. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  38735. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  38736. * @param name The name of the class, case should be preserved
  38737. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  38738. */
  38739. export function className(name: string, module?: string): (target: Object) => void;
  38740. /**
  38741. * An implementation of a loop for asynchronous functions.
  38742. */
  38743. export class AsyncLoop {
  38744. /**
  38745. * Defines the number of iterations for the loop
  38746. */
  38747. iterations: number;
  38748. /**
  38749. * Defines the current index of the loop.
  38750. */
  38751. index: number;
  38752. private _done;
  38753. private _fn;
  38754. private _successCallback;
  38755. /**
  38756. * Constructor.
  38757. * @param iterations the number of iterations.
  38758. * @param func the function to run each iteration
  38759. * @param successCallback the callback that will be called upon succesful execution
  38760. * @param offset starting offset.
  38761. */
  38762. constructor(
  38763. /**
  38764. * Defines the number of iterations for the loop
  38765. */
  38766. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  38767. /**
  38768. * Execute the next iteration. Must be called after the last iteration was finished.
  38769. */
  38770. executeNext(): void;
  38771. /**
  38772. * Break the loop and run the success callback.
  38773. */
  38774. breakLoop(): void;
  38775. /**
  38776. * Create and run an async loop.
  38777. * @param iterations the number of iterations.
  38778. * @param fn the function to run each iteration
  38779. * @param successCallback the callback that will be called upon succesful execution
  38780. * @param offset starting offset.
  38781. * @returns the created async loop object
  38782. */
  38783. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  38784. /**
  38785. * A for-loop that will run a given number of iterations synchronous and the rest async.
  38786. * @param iterations total number of iterations
  38787. * @param syncedIterations number of synchronous iterations in each async iteration.
  38788. * @param fn the function to call each iteration.
  38789. * @param callback a success call back that will be called when iterating stops.
  38790. * @param breakFunction a break condition (optional)
  38791. * @param timeout timeout settings for the setTimeout function. default - 0.
  38792. * @returns the created async loop object
  38793. */
  38794. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  38795. }
  38796. }
  38797. declare module "babylonjs/Misc/stringDictionary" {
  38798. import { Nullable } from "babylonjs/types";
  38799. /**
  38800. * This class implement a typical dictionary using a string as key and the generic type T as value.
  38801. * The underlying implementation relies on an associative array to ensure the best performances.
  38802. * The value can be anything including 'null' but except 'undefined'
  38803. */
  38804. export class StringDictionary<T> {
  38805. /**
  38806. * This will clear this dictionary and copy the content from the 'source' one.
  38807. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  38808. * @param source the dictionary to take the content from and copy to this dictionary
  38809. */
  38810. copyFrom(source: StringDictionary<T>): void;
  38811. /**
  38812. * Get a value based from its key
  38813. * @param key the given key to get the matching value from
  38814. * @return the value if found, otherwise undefined is returned
  38815. */
  38816. get(key: string): T | undefined;
  38817. /**
  38818. * Get a value from its key or add it if it doesn't exist.
  38819. * This method will ensure you that a given key/data will be present in the dictionary.
  38820. * @param key the given key to get the matching value from
  38821. * @param factory the factory that will create the value if the key is not present in the dictionary.
  38822. * The factory will only be invoked if there's no data for the given key.
  38823. * @return the value corresponding to the key.
  38824. */
  38825. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  38826. /**
  38827. * Get a value from its key if present in the dictionary otherwise add it
  38828. * @param key the key to get the value from
  38829. * @param val if there's no such key/value pair in the dictionary add it with this value
  38830. * @return the value corresponding to the key
  38831. */
  38832. getOrAdd(key: string, val: T): T;
  38833. /**
  38834. * Check if there's a given key in the dictionary
  38835. * @param key the key to check for
  38836. * @return true if the key is present, false otherwise
  38837. */
  38838. contains(key: string): boolean;
  38839. /**
  38840. * Add a new key and its corresponding value
  38841. * @param key the key to add
  38842. * @param value the value corresponding to the key
  38843. * @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
  38844. */
  38845. add(key: string, value: T): boolean;
  38846. /**
  38847. * Update a specific value associated to a key
  38848. * @param key defines the key to use
  38849. * @param value defines the value to store
  38850. * @returns true if the value was updated (or false if the key was not found)
  38851. */
  38852. set(key: string, value: T): boolean;
  38853. /**
  38854. * Get the element of the given key and remove it from the dictionary
  38855. * @param key defines the key to search
  38856. * @returns the value associated with the key or null if not found
  38857. */
  38858. getAndRemove(key: string): Nullable<T>;
  38859. /**
  38860. * Remove a key/value from the dictionary.
  38861. * @param key the key to remove
  38862. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  38863. */
  38864. remove(key: string): boolean;
  38865. /**
  38866. * Clear the whole content of the dictionary
  38867. */
  38868. clear(): void;
  38869. /**
  38870. * Gets the current count
  38871. */
  38872. get count(): number;
  38873. /**
  38874. * Execute a callback on each key/val of the dictionary.
  38875. * Note that you can remove any element in this dictionary in the callback implementation
  38876. * @param callback the callback to execute on a given key/value pair
  38877. */
  38878. forEach(callback: (key: string, val: T) => void): void;
  38879. /**
  38880. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  38881. * If the callback returns null or undefined the method will iterate to the next key/value pair
  38882. * Note that you can remove any element in this dictionary in the callback implementation
  38883. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  38884. * @returns the first item
  38885. */
  38886. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  38887. private _count;
  38888. private _data;
  38889. }
  38890. }
  38891. declare module "babylonjs/Collisions/collisionCoordinator" {
  38892. import { Nullable } from "babylonjs/types";
  38893. import { Scene } from "babylonjs/scene";
  38894. import { Vector3 } from "babylonjs/Maths/math.vector";
  38895. import { Collider } from "babylonjs/Collisions/collider";
  38896. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38897. /** @hidden */
  38898. export interface ICollisionCoordinator {
  38899. createCollider(): Collider;
  38900. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  38901. init(scene: Scene): void;
  38902. }
  38903. /** @hidden */
  38904. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  38905. private _scene;
  38906. private _scaledPosition;
  38907. private _scaledVelocity;
  38908. private _finalPosition;
  38909. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  38910. createCollider(): Collider;
  38911. init(scene: Scene): void;
  38912. private _collideWithWorld;
  38913. }
  38914. }
  38915. declare module "babylonjs/Inputs/scene.inputManager" {
  38916. import { Nullable } from "babylonjs/types";
  38917. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  38918. import { Vector2 } from "babylonjs/Maths/math.vector";
  38919. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38920. import { Scene } from "babylonjs/scene";
  38921. /**
  38922. * Class used to manage all inputs for the scene.
  38923. */
  38924. export class InputManager {
  38925. /** The distance in pixel that you have to move to prevent some events */
  38926. static DragMovementThreshold: number;
  38927. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  38928. static LongPressDelay: number;
  38929. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  38930. static DoubleClickDelay: number;
  38931. /** If you need to check double click without raising a single click at first click, enable this flag */
  38932. static ExclusiveDoubleClickMode: boolean;
  38933. private _wheelEventName;
  38934. private _onPointerMove;
  38935. private _onPointerDown;
  38936. private _onPointerUp;
  38937. private _initClickEvent;
  38938. private _initActionManager;
  38939. private _delayedSimpleClick;
  38940. private _delayedSimpleClickTimeout;
  38941. private _previousDelayedSimpleClickTimeout;
  38942. private _meshPickProceed;
  38943. private _previousButtonPressed;
  38944. private _currentPickResult;
  38945. private _previousPickResult;
  38946. private _totalPointersPressed;
  38947. private _doubleClickOccured;
  38948. private _pointerOverMesh;
  38949. private _pickedDownMesh;
  38950. private _pickedUpMesh;
  38951. private _pointerX;
  38952. private _pointerY;
  38953. private _unTranslatedPointerX;
  38954. private _unTranslatedPointerY;
  38955. private _startingPointerPosition;
  38956. private _previousStartingPointerPosition;
  38957. private _startingPointerTime;
  38958. private _previousStartingPointerTime;
  38959. private _pointerCaptures;
  38960. private _onKeyDown;
  38961. private _onKeyUp;
  38962. private _onCanvasFocusObserver;
  38963. private _onCanvasBlurObserver;
  38964. private _scene;
  38965. /**
  38966. * Creates a new InputManager
  38967. * @param scene defines the hosting scene
  38968. */
  38969. constructor(scene: Scene);
  38970. /**
  38971. * Gets the mesh that is currently under the pointer
  38972. */
  38973. get meshUnderPointer(): Nullable<AbstractMesh>;
  38974. /**
  38975. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  38976. */
  38977. get unTranslatedPointer(): Vector2;
  38978. /**
  38979. * Gets or sets the current on-screen X position of the pointer
  38980. */
  38981. get pointerX(): number;
  38982. set pointerX(value: number);
  38983. /**
  38984. * Gets or sets the current on-screen Y position of the pointer
  38985. */
  38986. get pointerY(): number;
  38987. set pointerY(value: number);
  38988. private _updatePointerPosition;
  38989. private _processPointerMove;
  38990. private _setRayOnPointerInfo;
  38991. private _checkPrePointerObservable;
  38992. /**
  38993. * Use this method to simulate a pointer move on a mesh
  38994. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  38995. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  38996. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  38997. */
  38998. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  38999. /**
  39000. * Use this method to simulate a pointer down on a mesh
  39001. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39002. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39003. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39004. */
  39005. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  39006. private _processPointerDown;
  39007. /** @hidden */
  39008. _isPointerSwiping(): boolean;
  39009. /**
  39010. * Use this method to simulate a pointer up on a mesh
  39011. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39012. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39013. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39014. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  39015. */
  39016. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  39017. private _processPointerUp;
  39018. /**
  39019. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  39020. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  39021. * @returns true if the pointer was captured
  39022. */
  39023. isPointerCaptured(pointerId?: number): boolean;
  39024. /**
  39025. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  39026. * @param attachUp defines if you want to attach events to pointerup
  39027. * @param attachDown defines if you want to attach events to pointerdown
  39028. * @param attachMove defines if you want to attach events to pointermove
  39029. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  39030. */
  39031. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  39032. /**
  39033. * Detaches all event handlers
  39034. */
  39035. detachControl(): void;
  39036. /**
  39037. * Force the value of meshUnderPointer
  39038. * @param mesh defines the mesh to use
  39039. */
  39040. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  39041. /**
  39042. * Gets the mesh under the pointer
  39043. * @returns a Mesh or null if no mesh is under the pointer
  39044. */
  39045. getPointerOverMesh(): Nullable<AbstractMesh>;
  39046. }
  39047. }
  39048. declare module "babylonjs/Animations/animationGroup" {
  39049. import { Animatable } from "babylonjs/Animations/animatable";
  39050. import { Animation } from "babylonjs/Animations/animation";
  39051. import { Scene, IDisposable } from "babylonjs/scene";
  39052. import { Observable } from "babylonjs/Misc/observable";
  39053. import { Nullable } from "babylonjs/types";
  39054. import "babylonjs/Animations/animatable";
  39055. /**
  39056. * This class defines the direct association between an animation and a target
  39057. */
  39058. export class TargetedAnimation {
  39059. /**
  39060. * Animation to perform
  39061. */
  39062. animation: Animation;
  39063. /**
  39064. * Target to animate
  39065. */
  39066. target: any;
  39067. /**
  39068. * Serialize the object
  39069. * @returns the JSON object representing the current entity
  39070. */
  39071. serialize(): any;
  39072. }
  39073. /**
  39074. * Use this class to create coordinated animations on multiple targets
  39075. */
  39076. export class AnimationGroup implements IDisposable {
  39077. /** The name of the animation group */
  39078. name: string;
  39079. private _scene;
  39080. private _targetedAnimations;
  39081. private _animatables;
  39082. private _from;
  39083. private _to;
  39084. private _isStarted;
  39085. private _isPaused;
  39086. private _speedRatio;
  39087. private _loopAnimation;
  39088. private _isAdditive;
  39089. /**
  39090. * Gets or sets the unique id of the node
  39091. */
  39092. uniqueId: number;
  39093. /**
  39094. * This observable will notify when one animation have ended
  39095. */
  39096. onAnimationEndObservable: Observable<TargetedAnimation>;
  39097. /**
  39098. * Observer raised when one animation loops
  39099. */
  39100. onAnimationLoopObservable: Observable<TargetedAnimation>;
  39101. /**
  39102. * Observer raised when all animations have looped
  39103. */
  39104. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  39105. /**
  39106. * This observable will notify when all animations have ended.
  39107. */
  39108. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  39109. /**
  39110. * This observable will notify when all animations have paused.
  39111. */
  39112. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  39113. /**
  39114. * This observable will notify when all animations are playing.
  39115. */
  39116. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  39117. /**
  39118. * Gets the first frame
  39119. */
  39120. get from(): number;
  39121. /**
  39122. * Gets the last frame
  39123. */
  39124. get to(): number;
  39125. /**
  39126. * Define if the animations are started
  39127. */
  39128. get isStarted(): boolean;
  39129. /**
  39130. * Gets a value indicating that the current group is playing
  39131. */
  39132. get isPlaying(): boolean;
  39133. /**
  39134. * Gets or sets the speed ratio to use for all animations
  39135. */
  39136. get speedRatio(): number;
  39137. /**
  39138. * Gets or sets the speed ratio to use for all animations
  39139. */
  39140. set speedRatio(value: number);
  39141. /**
  39142. * Gets or sets if all animations should loop or not
  39143. */
  39144. get loopAnimation(): boolean;
  39145. set loopAnimation(value: boolean);
  39146. /**
  39147. * Gets or sets if all animations should be evaluated additively
  39148. */
  39149. get isAdditive(): boolean;
  39150. set isAdditive(value: boolean);
  39151. /**
  39152. * Gets the targeted animations for this animation group
  39153. */
  39154. get targetedAnimations(): Array<TargetedAnimation>;
  39155. /**
  39156. * returning the list of animatables controlled by this animation group.
  39157. */
  39158. get animatables(): Array<Animatable>;
  39159. /**
  39160. * Instantiates a new Animation Group.
  39161. * This helps managing several animations at once.
  39162. * @see http://doc.babylonjs.com/how_to/group
  39163. * @param name Defines the name of the group
  39164. * @param scene Defines the scene the group belongs to
  39165. */
  39166. constructor(
  39167. /** The name of the animation group */
  39168. name: string, scene?: Nullable<Scene>);
  39169. /**
  39170. * Add an animation (with its target) in the group
  39171. * @param animation defines the animation we want to add
  39172. * @param target defines the target of the animation
  39173. * @returns the TargetedAnimation object
  39174. */
  39175. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  39176. /**
  39177. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  39178. * It can add constant keys at begin or end
  39179. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  39180. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  39181. * @returns the animation group
  39182. */
  39183. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  39184. private _animationLoopCount;
  39185. private _animationLoopFlags;
  39186. private _processLoop;
  39187. /**
  39188. * Start all animations on given targets
  39189. * @param loop defines if animations must loop
  39190. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  39191. * @param from defines the from key (optional)
  39192. * @param to defines the to key (optional)
  39193. * @param isAdditive defines the additive state for the resulting animatables (optional)
  39194. * @returns the current animation group
  39195. */
  39196. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  39197. /**
  39198. * Pause all animations
  39199. * @returns the animation group
  39200. */
  39201. pause(): AnimationGroup;
  39202. /**
  39203. * Play all animations to initial state
  39204. * This function will start() the animations if they were not started or will restart() them if they were paused
  39205. * @param loop defines if animations must loop
  39206. * @returns the animation group
  39207. */
  39208. play(loop?: boolean): AnimationGroup;
  39209. /**
  39210. * Reset all animations to initial state
  39211. * @returns the animation group
  39212. */
  39213. reset(): AnimationGroup;
  39214. /**
  39215. * Restart animations from key 0
  39216. * @returns the animation group
  39217. */
  39218. restart(): AnimationGroup;
  39219. /**
  39220. * Stop all animations
  39221. * @returns the animation group
  39222. */
  39223. stop(): AnimationGroup;
  39224. /**
  39225. * Set animation weight for all animatables
  39226. * @param weight defines the weight to use
  39227. * @return the animationGroup
  39228. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  39229. */
  39230. setWeightForAllAnimatables(weight: number): AnimationGroup;
  39231. /**
  39232. * Synchronize and normalize all animatables with a source animatable
  39233. * @param root defines the root animatable to synchronize with
  39234. * @return the animationGroup
  39235. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  39236. */
  39237. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  39238. /**
  39239. * Goes to a specific frame in this animation group
  39240. * @param frame the frame number to go to
  39241. * @return the animationGroup
  39242. */
  39243. goToFrame(frame: number): AnimationGroup;
  39244. /**
  39245. * Dispose all associated resources
  39246. */
  39247. dispose(): void;
  39248. private _checkAnimationGroupEnded;
  39249. /**
  39250. * Clone the current animation group and returns a copy
  39251. * @param newName defines the name of the new group
  39252. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  39253. * @returns the new aniamtion group
  39254. */
  39255. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  39256. /**
  39257. * Serializes the animationGroup to an object
  39258. * @returns Serialized object
  39259. */
  39260. serialize(): any;
  39261. /**
  39262. * Returns a new AnimationGroup object parsed from the source provided.
  39263. * @param parsedAnimationGroup defines the source
  39264. * @param scene defines the scene that will receive the animationGroup
  39265. * @returns a new AnimationGroup
  39266. */
  39267. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  39268. /**
  39269. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  39270. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  39271. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  39272. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  39273. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  39274. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  39275. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  39276. */
  39277. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  39278. /**
  39279. * Returns the string "AnimationGroup"
  39280. * @returns "AnimationGroup"
  39281. */
  39282. getClassName(): string;
  39283. /**
  39284. * Creates a detailled string about the object
  39285. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  39286. * @returns a string representing the object
  39287. */
  39288. toString(fullDetails?: boolean): string;
  39289. }
  39290. }
  39291. declare module "babylonjs/scene" {
  39292. import { Nullable } from "babylonjs/types";
  39293. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  39294. import { Observable } from "babylonjs/Misc/observable";
  39295. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  39296. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  39297. import { Geometry } from "babylonjs/Meshes/geometry";
  39298. import { TransformNode } from "babylonjs/Meshes/transformNode";
  39299. import { SubMesh } from "babylonjs/Meshes/subMesh";
  39300. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39301. import { Mesh } from "babylonjs/Meshes/mesh";
  39302. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  39303. import { Bone } from "babylonjs/Bones/bone";
  39304. import { Skeleton } from "babylonjs/Bones/skeleton";
  39305. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  39306. import { Camera } from "babylonjs/Cameras/camera";
  39307. import { AbstractScene } from "babylonjs/abstractScene";
  39308. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  39309. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  39310. import { Material } from "babylonjs/Materials/material";
  39311. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  39312. import { Effect } from "babylonjs/Materials/effect";
  39313. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  39314. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  39315. import { Light } from "babylonjs/Lights/light";
  39316. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  39317. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  39318. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  39319. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  39320. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  39321. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  39322. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  39323. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  39324. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  39325. import { Engine } from "babylonjs/Engines/engine";
  39326. import { Node } from "babylonjs/node";
  39327. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  39328. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  39329. import { WebRequest } from "babylonjs/Misc/webRequest";
  39330. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  39331. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  39332. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  39333. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  39334. import { Plane } from "babylonjs/Maths/math.plane";
  39335. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  39336. import { Ray } from "babylonjs/Culling/ray";
  39337. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  39338. import { Animation } from "babylonjs/Animations/animation";
  39339. import { Animatable } from "babylonjs/Animations/animatable";
  39340. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  39341. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  39342. import { Collider } from "babylonjs/Collisions/collider";
  39343. /**
  39344. * Define an interface for all classes that will hold resources
  39345. */
  39346. export interface IDisposable {
  39347. /**
  39348. * Releases all held resources
  39349. */
  39350. dispose(): void;
  39351. }
  39352. /** Interface defining initialization parameters for Scene class */
  39353. export interface SceneOptions {
  39354. /**
  39355. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  39356. * It will improve performance when the number of geometries becomes important.
  39357. */
  39358. useGeometryUniqueIdsMap?: boolean;
  39359. /**
  39360. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  39361. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  39362. */
  39363. useMaterialMeshMap?: boolean;
  39364. /**
  39365. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  39366. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  39367. */
  39368. useClonedMeshMap?: boolean;
  39369. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  39370. virtual?: boolean;
  39371. }
  39372. /**
  39373. * Represents a scene to be rendered by the engine.
  39374. * @see http://doc.babylonjs.com/features/scene
  39375. */
  39376. export class Scene extends AbstractScene implements IAnimatable {
  39377. /** The fog is deactivated */
  39378. static readonly FOGMODE_NONE: number;
  39379. /** The fog density is following an exponential function */
  39380. static readonly FOGMODE_EXP: number;
  39381. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  39382. static readonly FOGMODE_EXP2: number;
  39383. /** The fog density is following a linear function. */
  39384. static readonly FOGMODE_LINEAR: number;
  39385. /**
  39386. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  39387. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39388. */
  39389. static MinDeltaTime: number;
  39390. /**
  39391. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  39392. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39393. */
  39394. static MaxDeltaTime: number;
  39395. /**
  39396. * Factory used to create the default material.
  39397. * @param name The name of the material to create
  39398. * @param scene The scene to create the material for
  39399. * @returns The default material
  39400. */
  39401. static DefaultMaterialFactory(scene: Scene): Material;
  39402. /**
  39403. * Factory used to create the a collision coordinator.
  39404. * @returns The collision coordinator
  39405. */
  39406. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  39407. /** @hidden */
  39408. _inputManager: InputManager;
  39409. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  39410. cameraToUseForPointers: Nullable<Camera>;
  39411. /** @hidden */
  39412. readonly _isScene: boolean;
  39413. /** @hidden */
  39414. _blockEntityCollection: boolean;
  39415. /**
  39416. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  39417. */
  39418. autoClear: boolean;
  39419. /**
  39420. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  39421. */
  39422. autoClearDepthAndStencil: boolean;
  39423. /**
  39424. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  39425. */
  39426. clearColor: Color4;
  39427. /**
  39428. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  39429. */
  39430. ambientColor: Color3;
  39431. /**
  39432. * This is use to store the default BRDF lookup for PBR materials in your scene.
  39433. * It should only be one of the following (if not the default embedded one):
  39434. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  39435. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  39436. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  39437. * The material properties need to be setup according to the type of texture in use.
  39438. */
  39439. environmentBRDFTexture: BaseTexture;
  39440. /** @hidden */
  39441. protected _environmentTexture: Nullable<BaseTexture>;
  39442. /**
  39443. * Texture used in all pbr material as the reflection texture.
  39444. * As in the majority of the scene they are the same (exception for multi room and so on),
  39445. * this is easier to reference from here than from all the materials.
  39446. */
  39447. get environmentTexture(): Nullable<BaseTexture>;
  39448. /**
  39449. * Texture used in all pbr material as the reflection texture.
  39450. * As in the majority of the scene they are the same (exception for multi room and so on),
  39451. * this is easier to set here than in all the materials.
  39452. */
  39453. set environmentTexture(value: Nullable<BaseTexture>);
  39454. /** @hidden */
  39455. protected _environmentIntensity: number;
  39456. /**
  39457. * Intensity of the environment in all pbr material.
  39458. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  39459. * As in the majority of the scene they are the same (exception for multi room and so on),
  39460. * this is easier to reference from here than from all the materials.
  39461. */
  39462. get environmentIntensity(): number;
  39463. /**
  39464. * Intensity of the environment in all pbr material.
  39465. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  39466. * As in the majority of the scene they are the same (exception for multi room and so on),
  39467. * this is easier to set here than in all the materials.
  39468. */
  39469. set environmentIntensity(value: number);
  39470. /** @hidden */
  39471. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39472. /**
  39473. * Default image processing configuration used either in the rendering
  39474. * Forward main pass or through the imageProcessingPostProcess if present.
  39475. * As in the majority of the scene they are the same (exception for multi camera),
  39476. * this is easier to reference from here than from all the materials and post process.
  39477. *
  39478. * No setter as we it is a shared configuration, you can set the values instead.
  39479. */
  39480. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  39481. private _forceWireframe;
  39482. /**
  39483. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  39484. */
  39485. set forceWireframe(value: boolean);
  39486. get forceWireframe(): boolean;
  39487. private _skipFrustumClipping;
  39488. /**
  39489. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  39490. */
  39491. set skipFrustumClipping(value: boolean);
  39492. get skipFrustumClipping(): boolean;
  39493. private _forcePointsCloud;
  39494. /**
  39495. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  39496. */
  39497. set forcePointsCloud(value: boolean);
  39498. get forcePointsCloud(): boolean;
  39499. /**
  39500. * Gets or sets the active clipplane 1
  39501. */
  39502. clipPlane: Nullable<Plane>;
  39503. /**
  39504. * Gets or sets the active clipplane 2
  39505. */
  39506. clipPlane2: Nullable<Plane>;
  39507. /**
  39508. * Gets or sets the active clipplane 3
  39509. */
  39510. clipPlane3: Nullable<Plane>;
  39511. /**
  39512. * Gets or sets the active clipplane 4
  39513. */
  39514. clipPlane4: Nullable<Plane>;
  39515. /**
  39516. * Gets or sets the active clipplane 5
  39517. */
  39518. clipPlane5: Nullable<Plane>;
  39519. /**
  39520. * Gets or sets the active clipplane 6
  39521. */
  39522. clipPlane6: Nullable<Plane>;
  39523. /**
  39524. * Gets or sets a boolean indicating if animations are enabled
  39525. */
  39526. animationsEnabled: boolean;
  39527. private _animationPropertiesOverride;
  39528. /**
  39529. * Gets or sets the animation properties override
  39530. */
  39531. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  39532. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  39533. /**
  39534. * Gets or sets a boolean indicating if a constant deltatime has to be used
  39535. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  39536. */
  39537. useConstantAnimationDeltaTime: boolean;
  39538. /**
  39539. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  39540. * Please note that it requires to run a ray cast through the scene on every frame
  39541. */
  39542. constantlyUpdateMeshUnderPointer: boolean;
  39543. /**
  39544. * Defines the HTML cursor to use when hovering over interactive elements
  39545. */
  39546. hoverCursor: string;
  39547. /**
  39548. * Defines the HTML default cursor to use (empty by default)
  39549. */
  39550. defaultCursor: string;
  39551. /**
  39552. * Defines whether cursors are handled by the scene.
  39553. */
  39554. doNotHandleCursors: boolean;
  39555. /**
  39556. * This is used to call preventDefault() on pointer down
  39557. * in order to block unwanted artifacts like system double clicks
  39558. */
  39559. preventDefaultOnPointerDown: boolean;
  39560. /**
  39561. * This is used to call preventDefault() on pointer up
  39562. * in order to block unwanted artifacts like system double clicks
  39563. */
  39564. preventDefaultOnPointerUp: boolean;
  39565. /**
  39566. * Gets or sets user defined metadata
  39567. */
  39568. metadata: any;
  39569. /**
  39570. * For internal use only. Please do not use.
  39571. */
  39572. reservedDataStore: any;
  39573. /**
  39574. * Gets the name of the plugin used to load this scene (null by default)
  39575. */
  39576. loadingPluginName: string;
  39577. /**
  39578. * Use this array to add regular expressions used to disable offline support for specific urls
  39579. */
  39580. disableOfflineSupportExceptionRules: RegExp[];
  39581. /**
  39582. * An event triggered when the scene is disposed.
  39583. */
  39584. onDisposeObservable: Observable<Scene>;
  39585. private _onDisposeObserver;
  39586. /** Sets a function to be executed when this scene is disposed. */
  39587. set onDispose(callback: () => void);
  39588. /**
  39589. * An event triggered before rendering the scene (right after animations and physics)
  39590. */
  39591. onBeforeRenderObservable: Observable<Scene>;
  39592. private _onBeforeRenderObserver;
  39593. /** Sets a function to be executed before rendering this scene */
  39594. set beforeRender(callback: Nullable<() => void>);
  39595. /**
  39596. * An event triggered after rendering the scene
  39597. */
  39598. onAfterRenderObservable: Observable<Scene>;
  39599. /**
  39600. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  39601. */
  39602. onAfterRenderCameraObservable: Observable<Camera>;
  39603. private _onAfterRenderObserver;
  39604. /** Sets a function to be executed after rendering this scene */
  39605. set afterRender(callback: Nullable<() => void>);
  39606. /**
  39607. * An event triggered before animating the scene
  39608. */
  39609. onBeforeAnimationsObservable: Observable<Scene>;
  39610. /**
  39611. * An event triggered after animations processing
  39612. */
  39613. onAfterAnimationsObservable: Observable<Scene>;
  39614. /**
  39615. * An event triggered before draw calls are ready to be sent
  39616. */
  39617. onBeforeDrawPhaseObservable: Observable<Scene>;
  39618. /**
  39619. * An event triggered after draw calls have been sent
  39620. */
  39621. onAfterDrawPhaseObservable: Observable<Scene>;
  39622. /**
  39623. * An event triggered when the scene is ready
  39624. */
  39625. onReadyObservable: Observable<Scene>;
  39626. /**
  39627. * An event triggered before rendering a camera
  39628. */
  39629. onBeforeCameraRenderObservable: Observable<Camera>;
  39630. private _onBeforeCameraRenderObserver;
  39631. /** Sets a function to be executed before rendering a camera*/
  39632. set beforeCameraRender(callback: () => void);
  39633. /**
  39634. * An event triggered after rendering a camera
  39635. */
  39636. onAfterCameraRenderObservable: Observable<Camera>;
  39637. private _onAfterCameraRenderObserver;
  39638. /** Sets a function to be executed after rendering a camera*/
  39639. set afterCameraRender(callback: () => void);
  39640. /**
  39641. * An event triggered when active meshes evaluation is about to start
  39642. */
  39643. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  39644. /**
  39645. * An event triggered when active meshes evaluation is done
  39646. */
  39647. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  39648. /**
  39649. * An event triggered when particles rendering is about to start
  39650. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  39651. */
  39652. onBeforeParticlesRenderingObservable: Observable<Scene>;
  39653. /**
  39654. * An event triggered when particles rendering is done
  39655. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  39656. */
  39657. onAfterParticlesRenderingObservable: Observable<Scene>;
  39658. /**
  39659. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  39660. */
  39661. onDataLoadedObservable: Observable<Scene>;
  39662. /**
  39663. * An event triggered when a camera is created
  39664. */
  39665. onNewCameraAddedObservable: Observable<Camera>;
  39666. /**
  39667. * An event triggered when a camera is removed
  39668. */
  39669. onCameraRemovedObservable: Observable<Camera>;
  39670. /**
  39671. * An event triggered when a light is created
  39672. */
  39673. onNewLightAddedObservable: Observable<Light>;
  39674. /**
  39675. * An event triggered when a light is removed
  39676. */
  39677. onLightRemovedObservable: Observable<Light>;
  39678. /**
  39679. * An event triggered when a geometry is created
  39680. */
  39681. onNewGeometryAddedObservable: Observable<Geometry>;
  39682. /**
  39683. * An event triggered when a geometry is removed
  39684. */
  39685. onGeometryRemovedObservable: Observable<Geometry>;
  39686. /**
  39687. * An event triggered when a transform node is created
  39688. */
  39689. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  39690. /**
  39691. * An event triggered when a transform node is removed
  39692. */
  39693. onTransformNodeRemovedObservable: Observable<TransformNode>;
  39694. /**
  39695. * An event triggered when a mesh is created
  39696. */
  39697. onNewMeshAddedObservable: Observable<AbstractMesh>;
  39698. /**
  39699. * An event triggered when a mesh is removed
  39700. */
  39701. onMeshRemovedObservable: Observable<AbstractMesh>;
  39702. /**
  39703. * An event triggered when a skeleton is created
  39704. */
  39705. onNewSkeletonAddedObservable: Observable<Skeleton>;
  39706. /**
  39707. * An event triggered when a skeleton is removed
  39708. */
  39709. onSkeletonRemovedObservable: Observable<Skeleton>;
  39710. /**
  39711. * An event triggered when a material is created
  39712. */
  39713. onNewMaterialAddedObservable: Observable<Material>;
  39714. /**
  39715. * An event triggered when a material is removed
  39716. */
  39717. onMaterialRemovedObservable: Observable<Material>;
  39718. /**
  39719. * An event triggered when a texture is created
  39720. */
  39721. onNewTextureAddedObservable: Observable<BaseTexture>;
  39722. /**
  39723. * An event triggered when a texture is removed
  39724. */
  39725. onTextureRemovedObservable: Observable<BaseTexture>;
  39726. /**
  39727. * An event triggered when render targets are about to be rendered
  39728. * Can happen multiple times per frame.
  39729. */
  39730. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  39731. /**
  39732. * An event triggered when render targets were rendered.
  39733. * Can happen multiple times per frame.
  39734. */
  39735. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  39736. /**
  39737. * An event triggered before calculating deterministic simulation step
  39738. */
  39739. onBeforeStepObservable: Observable<Scene>;
  39740. /**
  39741. * An event triggered after calculating deterministic simulation step
  39742. */
  39743. onAfterStepObservable: Observable<Scene>;
  39744. /**
  39745. * An event triggered when the activeCamera property is updated
  39746. */
  39747. onActiveCameraChanged: Observable<Scene>;
  39748. /**
  39749. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  39750. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  39751. * 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)
  39752. */
  39753. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  39754. /**
  39755. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  39756. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  39757. * 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)
  39758. */
  39759. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  39760. /**
  39761. * This Observable will when a mesh has been imported into the scene.
  39762. */
  39763. onMeshImportedObservable: Observable<AbstractMesh>;
  39764. /**
  39765. * This Observable will when an animation file has been imported into the scene.
  39766. */
  39767. onAnimationFileImportedObservable: Observable<Scene>;
  39768. /**
  39769. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  39770. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  39771. */
  39772. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  39773. /** @hidden */
  39774. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  39775. /**
  39776. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  39777. */
  39778. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  39779. /**
  39780. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  39781. */
  39782. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  39783. /**
  39784. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  39785. */
  39786. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  39787. /** Callback called when a pointer move is detected */
  39788. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  39789. /** Callback called when a pointer down is detected */
  39790. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  39791. /** Callback called when a pointer up is detected */
  39792. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  39793. /** Callback called when a pointer pick is detected */
  39794. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  39795. /**
  39796. * 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).
  39797. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  39798. */
  39799. onPrePointerObservable: Observable<PointerInfoPre>;
  39800. /**
  39801. * Observable event triggered each time an input event is received from the rendering canvas
  39802. */
  39803. onPointerObservable: Observable<PointerInfo>;
  39804. /**
  39805. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  39806. */
  39807. get unTranslatedPointer(): Vector2;
  39808. /**
  39809. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  39810. */
  39811. static get DragMovementThreshold(): number;
  39812. static set DragMovementThreshold(value: number);
  39813. /**
  39814. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  39815. */
  39816. static get LongPressDelay(): number;
  39817. static set LongPressDelay(value: number);
  39818. /**
  39819. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  39820. */
  39821. static get DoubleClickDelay(): number;
  39822. static set DoubleClickDelay(value: number);
  39823. /** If you need to check double click without raising a single click at first click, enable this flag */
  39824. static get ExclusiveDoubleClickMode(): boolean;
  39825. static set ExclusiveDoubleClickMode(value: boolean);
  39826. /** @hidden */
  39827. _mirroredCameraPosition: Nullable<Vector3>;
  39828. /**
  39829. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  39830. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  39831. */
  39832. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  39833. /**
  39834. * Observable event triggered each time an keyboard event is received from the hosting window
  39835. */
  39836. onKeyboardObservable: Observable<KeyboardInfo>;
  39837. private _useRightHandedSystem;
  39838. /**
  39839. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  39840. */
  39841. set useRightHandedSystem(value: boolean);
  39842. get useRightHandedSystem(): boolean;
  39843. private _timeAccumulator;
  39844. private _currentStepId;
  39845. private _currentInternalStep;
  39846. /**
  39847. * Sets the step Id used by deterministic lock step
  39848. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39849. * @param newStepId defines the step Id
  39850. */
  39851. setStepId(newStepId: number): void;
  39852. /**
  39853. * Gets the step Id used by deterministic lock step
  39854. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39855. * @returns the step Id
  39856. */
  39857. getStepId(): number;
  39858. /**
  39859. * Gets the internal step used by deterministic lock step
  39860. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39861. * @returns the internal step
  39862. */
  39863. getInternalStep(): number;
  39864. private _fogEnabled;
  39865. /**
  39866. * Gets or sets a boolean indicating if fog is enabled on this scene
  39867. * @see http://doc.babylonjs.com/babylon101/environment#fog
  39868. * (Default is true)
  39869. */
  39870. set fogEnabled(value: boolean);
  39871. get fogEnabled(): boolean;
  39872. private _fogMode;
  39873. /**
  39874. * Gets or sets the fog mode to use
  39875. * @see http://doc.babylonjs.com/babylon101/environment#fog
  39876. * | mode | value |
  39877. * | --- | --- |
  39878. * | FOGMODE_NONE | 0 |
  39879. * | FOGMODE_EXP | 1 |
  39880. * | FOGMODE_EXP2 | 2 |
  39881. * | FOGMODE_LINEAR | 3 |
  39882. */
  39883. set fogMode(value: number);
  39884. get fogMode(): number;
  39885. /**
  39886. * Gets or sets the fog color to use
  39887. * @see http://doc.babylonjs.com/babylon101/environment#fog
  39888. * (Default is Color3(0.2, 0.2, 0.3))
  39889. */
  39890. fogColor: Color3;
  39891. /**
  39892. * Gets or sets the fog density to use
  39893. * @see http://doc.babylonjs.com/babylon101/environment#fog
  39894. * (Default is 0.1)
  39895. */
  39896. fogDensity: number;
  39897. /**
  39898. * Gets or sets the fog start distance to use
  39899. * @see http://doc.babylonjs.com/babylon101/environment#fog
  39900. * (Default is 0)
  39901. */
  39902. fogStart: number;
  39903. /**
  39904. * Gets or sets the fog end distance to use
  39905. * @see http://doc.babylonjs.com/babylon101/environment#fog
  39906. * (Default is 1000)
  39907. */
  39908. fogEnd: number;
  39909. private _shadowsEnabled;
  39910. /**
  39911. * Gets or sets a boolean indicating if shadows are enabled on this scene
  39912. */
  39913. set shadowsEnabled(value: boolean);
  39914. get shadowsEnabled(): boolean;
  39915. private _lightsEnabled;
  39916. /**
  39917. * Gets or sets a boolean indicating if lights are enabled on this scene
  39918. */
  39919. set lightsEnabled(value: boolean);
  39920. get lightsEnabled(): boolean;
  39921. /** All of the active cameras added to this scene. */
  39922. activeCameras: Camera[];
  39923. /** @hidden */
  39924. _activeCamera: Nullable<Camera>;
  39925. /** Gets or sets the current active camera */
  39926. get activeCamera(): Nullable<Camera>;
  39927. set activeCamera(value: Nullable<Camera>);
  39928. private _defaultMaterial;
  39929. /** The default material used on meshes when no material is affected */
  39930. get defaultMaterial(): Material;
  39931. /** The default material used on meshes when no material is affected */
  39932. set defaultMaterial(value: Material);
  39933. private _texturesEnabled;
  39934. /**
  39935. * Gets or sets a boolean indicating if textures are enabled on this scene
  39936. */
  39937. set texturesEnabled(value: boolean);
  39938. get texturesEnabled(): boolean;
  39939. /**
  39940. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  39941. */
  39942. physicsEnabled: boolean;
  39943. /**
  39944. * Gets or sets a boolean indicating if particles are enabled on this scene
  39945. */
  39946. particlesEnabled: boolean;
  39947. /**
  39948. * Gets or sets a boolean indicating if sprites are enabled on this scene
  39949. */
  39950. spritesEnabled: boolean;
  39951. private _skeletonsEnabled;
  39952. /**
  39953. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  39954. */
  39955. set skeletonsEnabled(value: boolean);
  39956. get skeletonsEnabled(): boolean;
  39957. /**
  39958. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  39959. */
  39960. lensFlaresEnabled: boolean;
  39961. /**
  39962. * Gets or sets a boolean indicating if collisions are enabled on this scene
  39963. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  39964. */
  39965. collisionsEnabled: boolean;
  39966. private _collisionCoordinator;
  39967. /** @hidden */
  39968. get collisionCoordinator(): ICollisionCoordinator;
  39969. /**
  39970. * Defines the gravity applied to this scene (used only for collisions)
  39971. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  39972. */
  39973. gravity: Vector3;
  39974. /**
  39975. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  39976. */
  39977. postProcessesEnabled: boolean;
  39978. /**
  39979. * The list of postprocesses added to the scene
  39980. */
  39981. postProcesses: PostProcess[];
  39982. /**
  39983. * Gets the current postprocess manager
  39984. */
  39985. postProcessManager: PostProcessManager;
  39986. /**
  39987. * Gets or sets a boolean indicating if render targets are enabled on this scene
  39988. */
  39989. renderTargetsEnabled: boolean;
  39990. /**
  39991. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  39992. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  39993. */
  39994. dumpNextRenderTargets: boolean;
  39995. /**
  39996. * The list of user defined render targets added to the scene
  39997. */
  39998. customRenderTargets: RenderTargetTexture[];
  39999. /**
  40000. * Defines if texture loading must be delayed
  40001. * If true, textures will only be loaded when they need to be rendered
  40002. */
  40003. useDelayedTextureLoading: boolean;
  40004. /**
  40005. * Gets the list of meshes imported to the scene through SceneLoader
  40006. */
  40007. importedMeshesFiles: String[];
  40008. /**
  40009. * Gets or sets a boolean indicating if probes are enabled on this scene
  40010. */
  40011. probesEnabled: boolean;
  40012. /**
  40013. * Gets or sets the current offline provider to use to store scene data
  40014. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  40015. */
  40016. offlineProvider: IOfflineProvider;
  40017. /**
  40018. * Gets or sets the action manager associated with the scene
  40019. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  40020. */
  40021. actionManager: AbstractActionManager;
  40022. private _meshesForIntersections;
  40023. /**
  40024. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  40025. */
  40026. proceduralTexturesEnabled: boolean;
  40027. private _engine;
  40028. private _totalVertices;
  40029. /** @hidden */
  40030. _activeIndices: PerfCounter;
  40031. /** @hidden */
  40032. _activeParticles: PerfCounter;
  40033. /** @hidden */
  40034. _activeBones: PerfCounter;
  40035. private _animationRatio;
  40036. /** @hidden */
  40037. _animationTimeLast: number;
  40038. /** @hidden */
  40039. _animationTime: number;
  40040. /**
  40041. * Gets or sets a general scale for animation speed
  40042. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  40043. */
  40044. animationTimeScale: number;
  40045. /** @hidden */
  40046. _cachedMaterial: Nullable<Material>;
  40047. /** @hidden */
  40048. _cachedEffect: Nullable<Effect>;
  40049. /** @hidden */
  40050. _cachedVisibility: Nullable<number>;
  40051. private _renderId;
  40052. private _frameId;
  40053. private _executeWhenReadyTimeoutId;
  40054. private _intermediateRendering;
  40055. private _viewUpdateFlag;
  40056. private _projectionUpdateFlag;
  40057. /** @hidden */
  40058. _toBeDisposed: Nullable<IDisposable>[];
  40059. private _activeRequests;
  40060. /** @hidden */
  40061. _pendingData: any[];
  40062. private _isDisposed;
  40063. /**
  40064. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  40065. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  40066. */
  40067. dispatchAllSubMeshesOfActiveMeshes: boolean;
  40068. private _activeMeshes;
  40069. private _processedMaterials;
  40070. private _renderTargets;
  40071. /** @hidden */
  40072. _activeParticleSystems: SmartArray<IParticleSystem>;
  40073. private _activeSkeletons;
  40074. private _softwareSkinnedMeshes;
  40075. private _renderingManager;
  40076. /** @hidden */
  40077. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  40078. private _transformMatrix;
  40079. private _sceneUbo;
  40080. /** @hidden */
  40081. _viewMatrix: Matrix;
  40082. private _projectionMatrix;
  40083. /** @hidden */
  40084. _forcedViewPosition: Nullable<Vector3>;
  40085. /** @hidden */
  40086. _frustumPlanes: Plane[];
  40087. /**
  40088. * Gets the list of frustum planes (built from the active camera)
  40089. */
  40090. get frustumPlanes(): Plane[];
  40091. /**
  40092. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  40093. * This is useful if there are more lights that the maximum simulteanous authorized
  40094. */
  40095. requireLightSorting: boolean;
  40096. /** @hidden */
  40097. readonly useMaterialMeshMap: boolean;
  40098. /** @hidden */
  40099. readonly useClonedMeshMap: boolean;
  40100. private _externalData;
  40101. private _uid;
  40102. /**
  40103. * @hidden
  40104. * Backing store of defined scene components.
  40105. */
  40106. _components: ISceneComponent[];
  40107. /**
  40108. * @hidden
  40109. * Backing store of defined scene components.
  40110. */
  40111. _serializableComponents: ISceneSerializableComponent[];
  40112. /**
  40113. * List of components to register on the next registration step.
  40114. */
  40115. private _transientComponents;
  40116. /**
  40117. * Registers the transient components if needed.
  40118. */
  40119. private _registerTransientComponents;
  40120. /**
  40121. * @hidden
  40122. * Add a component to the scene.
  40123. * Note that the ccomponent could be registered on th next frame if this is called after
  40124. * the register component stage.
  40125. * @param component Defines the component to add to the scene
  40126. */
  40127. _addComponent(component: ISceneComponent): void;
  40128. /**
  40129. * @hidden
  40130. * Gets a component from the scene.
  40131. * @param name defines the name of the component to retrieve
  40132. * @returns the component or null if not present
  40133. */
  40134. _getComponent(name: string): Nullable<ISceneComponent>;
  40135. /**
  40136. * @hidden
  40137. * Defines the actions happening before camera updates.
  40138. */
  40139. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  40140. /**
  40141. * @hidden
  40142. * Defines the actions happening before clear the canvas.
  40143. */
  40144. _beforeClearStage: Stage<SimpleStageAction>;
  40145. /**
  40146. * @hidden
  40147. * Defines the actions when collecting render targets for the frame.
  40148. */
  40149. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  40150. /**
  40151. * @hidden
  40152. * Defines the actions happening for one camera in the frame.
  40153. */
  40154. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  40155. /**
  40156. * @hidden
  40157. * Defines the actions happening during the per mesh ready checks.
  40158. */
  40159. _isReadyForMeshStage: Stage<MeshStageAction>;
  40160. /**
  40161. * @hidden
  40162. * Defines the actions happening before evaluate active mesh checks.
  40163. */
  40164. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  40165. /**
  40166. * @hidden
  40167. * Defines the actions happening during the evaluate sub mesh checks.
  40168. */
  40169. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  40170. /**
  40171. * @hidden
  40172. * Defines the actions happening during the active mesh stage.
  40173. */
  40174. _activeMeshStage: Stage<ActiveMeshStageAction>;
  40175. /**
  40176. * @hidden
  40177. * Defines the actions happening during the per camera render target step.
  40178. */
  40179. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  40180. /**
  40181. * @hidden
  40182. * Defines the actions happening just before the active camera is drawing.
  40183. */
  40184. _beforeCameraDrawStage: Stage<CameraStageAction>;
  40185. /**
  40186. * @hidden
  40187. * Defines the actions happening just before a render target is drawing.
  40188. */
  40189. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  40190. /**
  40191. * @hidden
  40192. * Defines the actions happening just before a rendering group is drawing.
  40193. */
  40194. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  40195. /**
  40196. * @hidden
  40197. * Defines the actions happening just before a mesh is drawing.
  40198. */
  40199. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  40200. /**
  40201. * @hidden
  40202. * Defines the actions happening just after a mesh has been drawn.
  40203. */
  40204. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  40205. /**
  40206. * @hidden
  40207. * Defines the actions happening just after a rendering group has been drawn.
  40208. */
  40209. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  40210. /**
  40211. * @hidden
  40212. * Defines the actions happening just after the active camera has been drawn.
  40213. */
  40214. _afterCameraDrawStage: Stage<CameraStageAction>;
  40215. /**
  40216. * @hidden
  40217. * Defines the actions happening just after a render target has been drawn.
  40218. */
  40219. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  40220. /**
  40221. * @hidden
  40222. * Defines the actions happening just after rendering all cameras and computing intersections.
  40223. */
  40224. _afterRenderStage: Stage<SimpleStageAction>;
  40225. /**
  40226. * @hidden
  40227. * Defines the actions happening when a pointer move event happens.
  40228. */
  40229. _pointerMoveStage: Stage<PointerMoveStageAction>;
  40230. /**
  40231. * @hidden
  40232. * Defines the actions happening when a pointer down event happens.
  40233. */
  40234. _pointerDownStage: Stage<PointerUpDownStageAction>;
  40235. /**
  40236. * @hidden
  40237. * Defines the actions happening when a pointer up event happens.
  40238. */
  40239. _pointerUpStage: Stage<PointerUpDownStageAction>;
  40240. /**
  40241. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  40242. */
  40243. private geometriesByUniqueId;
  40244. /**
  40245. * Creates a new Scene
  40246. * @param engine defines the engine to use to render this scene
  40247. * @param options defines the scene options
  40248. */
  40249. constructor(engine: Engine, options?: SceneOptions);
  40250. /**
  40251. * Gets a string idenfifying the name of the class
  40252. * @returns "Scene" string
  40253. */
  40254. getClassName(): string;
  40255. private _defaultMeshCandidates;
  40256. /**
  40257. * @hidden
  40258. */
  40259. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  40260. private _defaultSubMeshCandidates;
  40261. /**
  40262. * @hidden
  40263. */
  40264. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  40265. /**
  40266. * Sets the default candidate providers for the scene.
  40267. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  40268. * and getCollidingSubMeshCandidates to their default function
  40269. */
  40270. setDefaultCandidateProviders(): void;
  40271. /**
  40272. * Gets the mesh that is currently under the pointer
  40273. */
  40274. get meshUnderPointer(): Nullable<AbstractMesh>;
  40275. /**
  40276. * Gets or sets the current on-screen X position of the pointer
  40277. */
  40278. get pointerX(): number;
  40279. set pointerX(value: number);
  40280. /**
  40281. * Gets or sets the current on-screen Y position of the pointer
  40282. */
  40283. get pointerY(): number;
  40284. set pointerY(value: number);
  40285. /**
  40286. * Gets the cached material (ie. the latest rendered one)
  40287. * @returns the cached material
  40288. */
  40289. getCachedMaterial(): Nullable<Material>;
  40290. /**
  40291. * Gets the cached effect (ie. the latest rendered one)
  40292. * @returns the cached effect
  40293. */
  40294. getCachedEffect(): Nullable<Effect>;
  40295. /**
  40296. * Gets the cached visibility state (ie. the latest rendered one)
  40297. * @returns the cached visibility state
  40298. */
  40299. getCachedVisibility(): Nullable<number>;
  40300. /**
  40301. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  40302. * @param material defines the current material
  40303. * @param effect defines the current effect
  40304. * @param visibility defines the current visibility state
  40305. * @returns true if one parameter is not cached
  40306. */
  40307. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  40308. /**
  40309. * Gets the engine associated with the scene
  40310. * @returns an Engine
  40311. */
  40312. getEngine(): Engine;
  40313. /**
  40314. * Gets the total number of vertices rendered per frame
  40315. * @returns the total number of vertices rendered per frame
  40316. */
  40317. getTotalVertices(): number;
  40318. /**
  40319. * Gets the performance counter for total vertices
  40320. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40321. */
  40322. get totalVerticesPerfCounter(): PerfCounter;
  40323. /**
  40324. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  40325. * @returns the total number of active indices rendered per frame
  40326. */
  40327. getActiveIndices(): number;
  40328. /**
  40329. * Gets the performance counter for active indices
  40330. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40331. */
  40332. get totalActiveIndicesPerfCounter(): PerfCounter;
  40333. /**
  40334. * Gets the total number of active particles rendered per frame
  40335. * @returns the total number of active particles rendered per frame
  40336. */
  40337. getActiveParticles(): number;
  40338. /**
  40339. * Gets the performance counter for active particles
  40340. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40341. */
  40342. get activeParticlesPerfCounter(): PerfCounter;
  40343. /**
  40344. * Gets the total number of active bones rendered per frame
  40345. * @returns the total number of active bones rendered per frame
  40346. */
  40347. getActiveBones(): number;
  40348. /**
  40349. * Gets the performance counter for active bones
  40350. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40351. */
  40352. get activeBonesPerfCounter(): PerfCounter;
  40353. /**
  40354. * Gets the array of active meshes
  40355. * @returns an array of AbstractMesh
  40356. */
  40357. getActiveMeshes(): SmartArray<AbstractMesh>;
  40358. /**
  40359. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  40360. * @returns a number
  40361. */
  40362. getAnimationRatio(): number;
  40363. /**
  40364. * Gets an unique Id for the current render phase
  40365. * @returns a number
  40366. */
  40367. getRenderId(): number;
  40368. /**
  40369. * Gets an unique Id for the current frame
  40370. * @returns a number
  40371. */
  40372. getFrameId(): number;
  40373. /** Call this function if you want to manually increment the render Id*/
  40374. incrementRenderId(): void;
  40375. private _createUbo;
  40376. /**
  40377. * Use this method to simulate a pointer move on a mesh
  40378. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40379. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40380. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40381. * @returns the current scene
  40382. */
  40383. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  40384. /**
  40385. * Use this method to simulate a pointer down on a mesh
  40386. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40387. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40388. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40389. * @returns the current scene
  40390. */
  40391. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  40392. /**
  40393. * Use this method to simulate a pointer up on a mesh
  40394. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40395. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40396. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40397. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  40398. * @returns the current scene
  40399. */
  40400. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  40401. /**
  40402. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  40403. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  40404. * @returns true if the pointer was captured
  40405. */
  40406. isPointerCaptured(pointerId?: number): boolean;
  40407. /**
  40408. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  40409. * @param attachUp defines if you want to attach events to pointerup
  40410. * @param attachDown defines if you want to attach events to pointerdown
  40411. * @param attachMove defines if you want to attach events to pointermove
  40412. */
  40413. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  40414. /** Detaches all event handlers*/
  40415. detachControl(): void;
  40416. /**
  40417. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  40418. * Delay loaded resources are not taking in account
  40419. * @return true if all required resources are ready
  40420. */
  40421. isReady(): boolean;
  40422. /** Resets all cached information relative to material (including effect and visibility) */
  40423. resetCachedMaterial(): void;
  40424. /**
  40425. * Registers a function to be called before every frame render
  40426. * @param func defines the function to register
  40427. */
  40428. registerBeforeRender(func: () => void): void;
  40429. /**
  40430. * Unregisters a function called before every frame render
  40431. * @param func defines the function to unregister
  40432. */
  40433. unregisterBeforeRender(func: () => void): void;
  40434. /**
  40435. * Registers a function to be called after every frame render
  40436. * @param func defines the function to register
  40437. */
  40438. registerAfterRender(func: () => void): void;
  40439. /**
  40440. * Unregisters a function called after every frame render
  40441. * @param func defines the function to unregister
  40442. */
  40443. unregisterAfterRender(func: () => void): void;
  40444. private _executeOnceBeforeRender;
  40445. /**
  40446. * The provided function will run before render once and will be disposed afterwards.
  40447. * A timeout delay can be provided so that the function will be executed in N ms.
  40448. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  40449. * @param func The function to be executed.
  40450. * @param timeout optional delay in ms
  40451. */
  40452. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  40453. /** @hidden */
  40454. _addPendingData(data: any): void;
  40455. /** @hidden */
  40456. _removePendingData(data: any): void;
  40457. /**
  40458. * Returns the number of items waiting to be loaded
  40459. * @returns the number of items waiting to be loaded
  40460. */
  40461. getWaitingItemsCount(): number;
  40462. /**
  40463. * Returns a boolean indicating if the scene is still loading data
  40464. */
  40465. get isLoading(): boolean;
  40466. /**
  40467. * Registers a function to be executed when the scene is ready
  40468. * @param {Function} func - the function to be executed
  40469. */
  40470. executeWhenReady(func: () => void): void;
  40471. /**
  40472. * Returns a promise that resolves when the scene is ready
  40473. * @returns A promise that resolves when the scene is ready
  40474. */
  40475. whenReadyAsync(): Promise<void>;
  40476. /** @hidden */
  40477. _checkIsReady(): void;
  40478. /**
  40479. * Gets all animatable attached to the scene
  40480. */
  40481. get animatables(): Animatable[];
  40482. /**
  40483. * Resets the last animation time frame.
  40484. * Useful to override when animations start running when loading a scene for the first time.
  40485. */
  40486. resetLastAnimationTimeFrame(): void;
  40487. /**
  40488. * Gets the current view matrix
  40489. * @returns a Matrix
  40490. */
  40491. getViewMatrix(): Matrix;
  40492. /**
  40493. * Gets the current projection matrix
  40494. * @returns a Matrix
  40495. */
  40496. getProjectionMatrix(): Matrix;
  40497. /**
  40498. * Gets the current transform matrix
  40499. * @returns a Matrix made of View * Projection
  40500. */
  40501. getTransformMatrix(): Matrix;
  40502. /**
  40503. * Sets the current transform matrix
  40504. * @param viewL defines the View matrix to use
  40505. * @param projectionL defines the Projection matrix to use
  40506. * @param viewR defines the right View matrix to use (if provided)
  40507. * @param projectionR defines the right Projection matrix to use (if provided)
  40508. */
  40509. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  40510. /**
  40511. * Gets the uniform buffer used to store scene data
  40512. * @returns a UniformBuffer
  40513. */
  40514. getSceneUniformBuffer(): UniformBuffer;
  40515. /**
  40516. * Gets an unique (relatively to the current scene) Id
  40517. * @returns an unique number for the scene
  40518. */
  40519. getUniqueId(): number;
  40520. /**
  40521. * Add a mesh to the list of scene's meshes
  40522. * @param newMesh defines the mesh to add
  40523. * @param recursive if all child meshes should also be added to the scene
  40524. */
  40525. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  40526. /**
  40527. * Remove a mesh for the list of scene's meshes
  40528. * @param toRemove defines the mesh to remove
  40529. * @param recursive if all child meshes should also be removed from the scene
  40530. * @returns the index where the mesh was in the mesh list
  40531. */
  40532. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  40533. /**
  40534. * Add a transform node to the list of scene's transform nodes
  40535. * @param newTransformNode defines the transform node to add
  40536. */
  40537. addTransformNode(newTransformNode: TransformNode): void;
  40538. /**
  40539. * Remove a transform node for the list of scene's transform nodes
  40540. * @param toRemove defines the transform node to remove
  40541. * @returns the index where the transform node was in the transform node list
  40542. */
  40543. removeTransformNode(toRemove: TransformNode): number;
  40544. /**
  40545. * Remove a skeleton for the list of scene's skeletons
  40546. * @param toRemove defines the skeleton to remove
  40547. * @returns the index where the skeleton was in the skeleton list
  40548. */
  40549. removeSkeleton(toRemove: Skeleton): number;
  40550. /**
  40551. * Remove a morph target for the list of scene's morph targets
  40552. * @param toRemove defines the morph target to remove
  40553. * @returns the index where the morph target was in the morph target list
  40554. */
  40555. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  40556. /**
  40557. * Remove a light for the list of scene's lights
  40558. * @param toRemove defines the light to remove
  40559. * @returns the index where the light was in the light list
  40560. */
  40561. removeLight(toRemove: Light): number;
  40562. /**
  40563. * Remove a camera for the list of scene's cameras
  40564. * @param toRemove defines the camera to remove
  40565. * @returns the index where the camera was in the camera list
  40566. */
  40567. removeCamera(toRemove: Camera): number;
  40568. /**
  40569. * Remove a particle system for the list of scene's particle systems
  40570. * @param toRemove defines the particle system to remove
  40571. * @returns the index where the particle system was in the particle system list
  40572. */
  40573. removeParticleSystem(toRemove: IParticleSystem): number;
  40574. /**
  40575. * Remove a animation for the list of scene's animations
  40576. * @param toRemove defines the animation to remove
  40577. * @returns the index where the animation was in the animation list
  40578. */
  40579. removeAnimation(toRemove: Animation): number;
  40580. /**
  40581. * Will stop the animation of the given target
  40582. * @param target - the target
  40583. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  40584. * @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)
  40585. */
  40586. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  40587. /**
  40588. * Removes the given animation group from this scene.
  40589. * @param toRemove The animation group to remove
  40590. * @returns The index of the removed animation group
  40591. */
  40592. removeAnimationGroup(toRemove: AnimationGroup): number;
  40593. /**
  40594. * Removes the given multi-material from this scene.
  40595. * @param toRemove The multi-material to remove
  40596. * @returns The index of the removed multi-material
  40597. */
  40598. removeMultiMaterial(toRemove: MultiMaterial): number;
  40599. /**
  40600. * Removes the given material from this scene.
  40601. * @param toRemove The material to remove
  40602. * @returns The index of the removed material
  40603. */
  40604. removeMaterial(toRemove: Material): number;
  40605. /**
  40606. * Removes the given action manager from this scene.
  40607. * @param toRemove The action manager to remove
  40608. * @returns The index of the removed action manager
  40609. */
  40610. removeActionManager(toRemove: AbstractActionManager): number;
  40611. /**
  40612. * Removes the given texture from this scene.
  40613. * @param toRemove The texture to remove
  40614. * @returns The index of the removed texture
  40615. */
  40616. removeTexture(toRemove: BaseTexture): number;
  40617. /**
  40618. * Adds the given light to this scene
  40619. * @param newLight The light to add
  40620. */
  40621. addLight(newLight: Light): void;
  40622. /**
  40623. * Sorts the list list based on light priorities
  40624. */
  40625. sortLightsByPriority(): void;
  40626. /**
  40627. * Adds the given camera to this scene
  40628. * @param newCamera The camera to add
  40629. */
  40630. addCamera(newCamera: Camera): void;
  40631. /**
  40632. * Adds the given skeleton to this scene
  40633. * @param newSkeleton The skeleton to add
  40634. */
  40635. addSkeleton(newSkeleton: Skeleton): void;
  40636. /**
  40637. * Adds the given particle system to this scene
  40638. * @param newParticleSystem The particle system to add
  40639. */
  40640. addParticleSystem(newParticleSystem: IParticleSystem): void;
  40641. /**
  40642. * Adds the given animation to this scene
  40643. * @param newAnimation The animation to add
  40644. */
  40645. addAnimation(newAnimation: Animation): void;
  40646. /**
  40647. * Adds the given animation group to this scene.
  40648. * @param newAnimationGroup The animation group to add
  40649. */
  40650. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  40651. /**
  40652. * Adds the given multi-material to this scene
  40653. * @param newMultiMaterial The multi-material to add
  40654. */
  40655. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  40656. /**
  40657. * Adds the given material to this scene
  40658. * @param newMaterial The material to add
  40659. */
  40660. addMaterial(newMaterial: Material): void;
  40661. /**
  40662. * Adds the given morph target to this scene
  40663. * @param newMorphTargetManager The morph target to add
  40664. */
  40665. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  40666. /**
  40667. * Adds the given geometry to this scene
  40668. * @param newGeometry The geometry to add
  40669. */
  40670. addGeometry(newGeometry: Geometry): void;
  40671. /**
  40672. * Adds the given action manager to this scene
  40673. * @param newActionManager The action manager to add
  40674. */
  40675. addActionManager(newActionManager: AbstractActionManager): void;
  40676. /**
  40677. * Adds the given texture to this scene.
  40678. * @param newTexture The texture to add
  40679. */
  40680. addTexture(newTexture: BaseTexture): void;
  40681. /**
  40682. * Switch active camera
  40683. * @param newCamera defines the new active camera
  40684. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  40685. */
  40686. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  40687. /**
  40688. * sets the active camera of the scene using its ID
  40689. * @param id defines the camera's ID
  40690. * @return the new active camera or null if none found.
  40691. */
  40692. setActiveCameraByID(id: string): Nullable<Camera>;
  40693. /**
  40694. * sets the active camera of the scene using its name
  40695. * @param name defines the camera's name
  40696. * @returns the new active camera or null if none found.
  40697. */
  40698. setActiveCameraByName(name: string): Nullable<Camera>;
  40699. /**
  40700. * get an animation group using its name
  40701. * @param name defines the material's name
  40702. * @return the animation group or null if none found.
  40703. */
  40704. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  40705. /**
  40706. * Get a material using its unique id
  40707. * @param uniqueId defines the material's unique id
  40708. * @return the material or null if none found.
  40709. */
  40710. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  40711. /**
  40712. * get a material using its id
  40713. * @param id defines the material's ID
  40714. * @return the material or null if none found.
  40715. */
  40716. getMaterialByID(id: string): Nullable<Material>;
  40717. /**
  40718. * Gets a the last added material using a given id
  40719. * @param id defines the material's ID
  40720. * @return the last material with the given id or null if none found.
  40721. */
  40722. getLastMaterialByID(id: string): Nullable<Material>;
  40723. /**
  40724. * Gets a material using its name
  40725. * @param name defines the material's name
  40726. * @return the material or null if none found.
  40727. */
  40728. getMaterialByName(name: string): Nullable<Material>;
  40729. /**
  40730. * Get a texture using its unique id
  40731. * @param uniqueId defines the texture's unique id
  40732. * @return the texture or null if none found.
  40733. */
  40734. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  40735. /**
  40736. * Gets a camera using its id
  40737. * @param id defines the id to look for
  40738. * @returns the camera or null if not found
  40739. */
  40740. getCameraByID(id: string): Nullable<Camera>;
  40741. /**
  40742. * Gets a camera using its unique id
  40743. * @param uniqueId defines the unique id to look for
  40744. * @returns the camera or null if not found
  40745. */
  40746. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  40747. /**
  40748. * Gets a camera using its name
  40749. * @param name defines the camera's name
  40750. * @return the camera or null if none found.
  40751. */
  40752. getCameraByName(name: string): Nullable<Camera>;
  40753. /**
  40754. * Gets a bone using its id
  40755. * @param id defines the bone's id
  40756. * @return the bone or null if not found
  40757. */
  40758. getBoneByID(id: string): Nullable<Bone>;
  40759. /**
  40760. * Gets a bone using its id
  40761. * @param name defines the bone's name
  40762. * @return the bone or null if not found
  40763. */
  40764. getBoneByName(name: string): Nullable<Bone>;
  40765. /**
  40766. * Gets a light node using its name
  40767. * @param name defines the the light's name
  40768. * @return the light or null if none found.
  40769. */
  40770. getLightByName(name: string): Nullable<Light>;
  40771. /**
  40772. * Gets a light node using its id
  40773. * @param id defines the light's id
  40774. * @return the light or null if none found.
  40775. */
  40776. getLightByID(id: string): Nullable<Light>;
  40777. /**
  40778. * Gets a light node using its scene-generated unique ID
  40779. * @param uniqueId defines the light's unique id
  40780. * @return the light or null if none found.
  40781. */
  40782. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  40783. /**
  40784. * Gets a particle system by id
  40785. * @param id defines the particle system id
  40786. * @return the corresponding system or null if none found
  40787. */
  40788. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  40789. /**
  40790. * Gets a geometry using its ID
  40791. * @param id defines the geometry's id
  40792. * @return the geometry or null if none found.
  40793. */
  40794. getGeometryByID(id: string): Nullable<Geometry>;
  40795. private _getGeometryByUniqueID;
  40796. /**
  40797. * Add a new geometry to this scene
  40798. * @param geometry defines the geometry to be added to the scene.
  40799. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  40800. * @return a boolean defining if the geometry was added or not
  40801. */
  40802. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  40803. /**
  40804. * Removes an existing geometry
  40805. * @param geometry defines the geometry to be removed from the scene
  40806. * @return a boolean defining if the geometry was removed or not
  40807. */
  40808. removeGeometry(geometry: Geometry): boolean;
  40809. /**
  40810. * Gets the list of geometries attached to the scene
  40811. * @returns an array of Geometry
  40812. */
  40813. getGeometries(): Geometry[];
  40814. /**
  40815. * Gets the first added mesh found of a given ID
  40816. * @param id defines the id to search for
  40817. * @return the mesh found or null if not found at all
  40818. */
  40819. getMeshByID(id: string): Nullable<AbstractMesh>;
  40820. /**
  40821. * Gets a list of meshes using their id
  40822. * @param id defines the id to search for
  40823. * @returns a list of meshes
  40824. */
  40825. getMeshesByID(id: string): Array<AbstractMesh>;
  40826. /**
  40827. * Gets the first added transform node found of a given ID
  40828. * @param id defines the id to search for
  40829. * @return the found transform node or null if not found at all.
  40830. */
  40831. getTransformNodeByID(id: string): Nullable<TransformNode>;
  40832. /**
  40833. * Gets a transform node with its auto-generated unique id
  40834. * @param uniqueId efines the unique id to search for
  40835. * @return the found transform node or null if not found at all.
  40836. */
  40837. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  40838. /**
  40839. * Gets a list of transform nodes using their id
  40840. * @param id defines the id to search for
  40841. * @returns a list of transform nodes
  40842. */
  40843. getTransformNodesByID(id: string): Array<TransformNode>;
  40844. /**
  40845. * Gets a mesh with its auto-generated unique id
  40846. * @param uniqueId defines the unique id to search for
  40847. * @return the found mesh or null if not found at all.
  40848. */
  40849. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  40850. /**
  40851. * Gets a the last added mesh using a given id
  40852. * @param id defines the id to search for
  40853. * @return the found mesh or null if not found at all.
  40854. */
  40855. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  40856. /**
  40857. * Gets a the last added node (Mesh, Camera, Light) using a given id
  40858. * @param id defines the id to search for
  40859. * @return the found node or null if not found at all
  40860. */
  40861. getLastEntryByID(id: string): Nullable<Node>;
  40862. /**
  40863. * Gets a node (Mesh, Camera, Light) using a given id
  40864. * @param id defines the id to search for
  40865. * @return the found node or null if not found at all
  40866. */
  40867. getNodeByID(id: string): Nullable<Node>;
  40868. /**
  40869. * Gets a node (Mesh, Camera, Light) using a given name
  40870. * @param name defines the name to search for
  40871. * @return the found node or null if not found at all.
  40872. */
  40873. getNodeByName(name: string): Nullable<Node>;
  40874. /**
  40875. * Gets a mesh using a given name
  40876. * @param name defines the name to search for
  40877. * @return the found mesh or null if not found at all.
  40878. */
  40879. getMeshByName(name: string): Nullable<AbstractMesh>;
  40880. /**
  40881. * Gets a transform node using a given name
  40882. * @param name defines the name to search for
  40883. * @return the found transform node or null if not found at all.
  40884. */
  40885. getTransformNodeByName(name: string): Nullable<TransformNode>;
  40886. /**
  40887. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  40888. * @param id defines the id to search for
  40889. * @return the found skeleton or null if not found at all.
  40890. */
  40891. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  40892. /**
  40893. * Gets a skeleton using a given auto generated unique id
  40894. * @param uniqueId defines the unique id to search for
  40895. * @return the found skeleton or null if not found at all.
  40896. */
  40897. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  40898. /**
  40899. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  40900. * @param id defines the id to search for
  40901. * @return the found skeleton or null if not found at all.
  40902. */
  40903. getSkeletonById(id: string): Nullable<Skeleton>;
  40904. /**
  40905. * Gets a skeleton using a given name
  40906. * @param name defines the name to search for
  40907. * @return the found skeleton or null if not found at all.
  40908. */
  40909. getSkeletonByName(name: string): Nullable<Skeleton>;
  40910. /**
  40911. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  40912. * @param id defines the id to search for
  40913. * @return the found morph target manager or null if not found at all.
  40914. */
  40915. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  40916. /**
  40917. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  40918. * @param id defines the id to search for
  40919. * @return the found morph target or null if not found at all.
  40920. */
  40921. getMorphTargetById(id: string): Nullable<MorphTarget>;
  40922. /**
  40923. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  40924. * @param name defines the name to search for
  40925. * @return the found morph target or null if not found at all.
  40926. */
  40927. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  40928. /**
  40929. * Gets a boolean indicating if the given mesh is active
  40930. * @param mesh defines the mesh to look for
  40931. * @returns true if the mesh is in the active list
  40932. */
  40933. isActiveMesh(mesh: AbstractMesh): boolean;
  40934. /**
  40935. * Return a unique id as a string which can serve as an identifier for the scene
  40936. */
  40937. get uid(): string;
  40938. /**
  40939. * Add an externaly attached data from its key.
  40940. * This method call will fail and return false, if such key already exists.
  40941. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  40942. * @param key the unique key that identifies the data
  40943. * @param data the data object to associate to the key for this Engine instance
  40944. * @return true if no such key were already present and the data was added successfully, false otherwise
  40945. */
  40946. addExternalData<T>(key: string, data: T): boolean;
  40947. /**
  40948. * Get an externaly attached data from its key
  40949. * @param key the unique key that identifies the data
  40950. * @return the associated data, if present (can be null), or undefined if not present
  40951. */
  40952. getExternalData<T>(key: string): Nullable<T>;
  40953. /**
  40954. * Get an externaly attached data from its key, create it using a factory if it's not already present
  40955. * @param key the unique key that identifies the data
  40956. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  40957. * @return the associated data, can be null if the factory returned null.
  40958. */
  40959. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  40960. /**
  40961. * Remove an externaly attached data from the Engine instance
  40962. * @param key the unique key that identifies the data
  40963. * @return true if the data was successfully removed, false if it doesn't exist
  40964. */
  40965. removeExternalData(key: string): boolean;
  40966. private _evaluateSubMesh;
  40967. /**
  40968. * Clear the processed materials smart array preventing retention point in material dispose.
  40969. */
  40970. freeProcessedMaterials(): void;
  40971. private _preventFreeActiveMeshesAndRenderingGroups;
  40972. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  40973. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  40974. * when disposing several meshes in a row or a hierarchy of meshes.
  40975. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  40976. */
  40977. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  40978. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  40979. /**
  40980. * Clear the active meshes smart array preventing retention point in mesh dispose.
  40981. */
  40982. freeActiveMeshes(): void;
  40983. /**
  40984. * Clear the info related to rendering groups preventing retention points during dispose.
  40985. */
  40986. freeRenderingGroups(): void;
  40987. /** @hidden */
  40988. _isInIntermediateRendering(): boolean;
  40989. /**
  40990. * Lambda returning the list of potentially active meshes.
  40991. */
  40992. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  40993. /**
  40994. * Lambda returning the list of potentially active sub meshes.
  40995. */
  40996. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  40997. /**
  40998. * Lambda returning the list of potentially intersecting sub meshes.
  40999. */
  41000. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  41001. /**
  41002. * Lambda returning the list of potentially colliding sub meshes.
  41003. */
  41004. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  41005. private _activeMeshesFrozen;
  41006. private _skipEvaluateActiveMeshesCompletely;
  41007. /**
  41008. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  41009. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  41010. * @returns the current scene
  41011. */
  41012. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  41013. /**
  41014. * Use this function to restart evaluating active meshes on every frame
  41015. * @returns the current scene
  41016. */
  41017. unfreezeActiveMeshes(): Scene;
  41018. private _evaluateActiveMeshes;
  41019. private _activeMesh;
  41020. /**
  41021. * Update the transform matrix to update from the current active camera
  41022. * @param force defines a boolean used to force the update even if cache is up to date
  41023. */
  41024. updateTransformMatrix(force?: boolean): void;
  41025. private _bindFrameBuffer;
  41026. /** @hidden */
  41027. _allowPostProcessClearColor: boolean;
  41028. /** @hidden */
  41029. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  41030. private _processSubCameras;
  41031. private _checkIntersections;
  41032. /** @hidden */
  41033. _advancePhysicsEngineStep(step: number): void;
  41034. /**
  41035. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  41036. */
  41037. getDeterministicFrameTime: () => number;
  41038. /** @hidden */
  41039. _animate(): void;
  41040. /** Execute all animations (for a frame) */
  41041. animate(): void;
  41042. /**
  41043. * Render the scene
  41044. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  41045. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  41046. */
  41047. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  41048. /**
  41049. * Freeze all materials
  41050. * A frozen material will not be updatable but should be faster to render
  41051. */
  41052. freezeMaterials(): void;
  41053. /**
  41054. * Unfreeze all materials
  41055. * A frozen material will not be updatable but should be faster to render
  41056. */
  41057. unfreezeMaterials(): void;
  41058. /**
  41059. * Releases all held ressources
  41060. */
  41061. dispose(): void;
  41062. /**
  41063. * Gets if the scene is already disposed
  41064. */
  41065. get isDisposed(): boolean;
  41066. /**
  41067. * Call this function to reduce memory footprint of the scene.
  41068. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  41069. */
  41070. clearCachedVertexData(): void;
  41071. /**
  41072. * This function will remove the local cached buffer data from texture.
  41073. * It will save memory but will prevent the texture from being rebuilt
  41074. */
  41075. cleanCachedTextureBuffer(): void;
  41076. /**
  41077. * Get the world extend vectors with an optional filter
  41078. *
  41079. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  41080. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  41081. */
  41082. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  41083. min: Vector3;
  41084. max: Vector3;
  41085. };
  41086. /**
  41087. * Creates a ray that can be used to pick in the scene
  41088. * @param x defines the x coordinate of the origin (on-screen)
  41089. * @param y defines the y coordinate of the origin (on-screen)
  41090. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  41091. * @param camera defines the camera to use for the picking
  41092. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  41093. * @returns a Ray
  41094. */
  41095. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  41096. /**
  41097. * Creates a ray that can be used to pick in the scene
  41098. * @param x defines the x coordinate of the origin (on-screen)
  41099. * @param y defines the y coordinate of the origin (on-screen)
  41100. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  41101. * @param result defines the ray where to store the picking ray
  41102. * @param camera defines the camera to use for the picking
  41103. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  41104. * @returns the current scene
  41105. */
  41106. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  41107. /**
  41108. * Creates a ray that can be used to pick in the scene
  41109. * @param x defines the x coordinate of the origin (on-screen)
  41110. * @param y defines the y coordinate of the origin (on-screen)
  41111. * @param camera defines the camera to use for the picking
  41112. * @returns a Ray
  41113. */
  41114. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  41115. /**
  41116. * Creates a ray that can be used to pick in the scene
  41117. * @param x defines the x coordinate of the origin (on-screen)
  41118. * @param y defines the y coordinate of the origin (on-screen)
  41119. * @param result defines the ray where to store the picking ray
  41120. * @param camera defines the camera to use for the picking
  41121. * @returns the current scene
  41122. */
  41123. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  41124. /** Launch a ray to try to pick a mesh in the scene
  41125. * @param x position on screen
  41126. * @param y position on screen
  41127. * @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
  41128. * @param fastCheck defines if the first intersection will be used (and not the closest)
  41129. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  41130. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41131. * @returns a PickingInfo
  41132. */
  41133. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  41134. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  41135. * @param x position on screen
  41136. * @param y position on screen
  41137. * @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
  41138. * @param fastCheck defines if the first intersection will be used (and not the closest)
  41139. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  41140. * @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)
  41141. */
  41142. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  41143. /** Use the given ray to pick a mesh in the scene
  41144. * @param ray The ray to use to pick meshes
  41145. * @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
  41146. * @param fastCheck defines if the first intersection will be used (and not the closest)
  41147. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41148. * @returns a PickingInfo
  41149. */
  41150. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  41151. /**
  41152. * Launch a ray to try to pick a mesh in the scene
  41153. * @param x X position on screen
  41154. * @param y Y position on screen
  41155. * @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
  41156. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  41157. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41158. * @returns an array of PickingInfo
  41159. */
  41160. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  41161. /**
  41162. * Launch a ray to try to pick a mesh in the scene
  41163. * @param ray Ray to use
  41164. * @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
  41165. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41166. * @returns an array of PickingInfo
  41167. */
  41168. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  41169. /**
  41170. * Force the value of meshUnderPointer
  41171. * @param mesh defines the mesh to use
  41172. */
  41173. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  41174. /**
  41175. * Gets the mesh under the pointer
  41176. * @returns a Mesh or null if no mesh is under the pointer
  41177. */
  41178. getPointerOverMesh(): Nullable<AbstractMesh>;
  41179. /** @hidden */
  41180. _rebuildGeometries(): void;
  41181. /** @hidden */
  41182. _rebuildTextures(): void;
  41183. private _getByTags;
  41184. /**
  41185. * Get a list of meshes by tags
  41186. * @param tagsQuery defines the tags query to use
  41187. * @param forEach defines a predicate used to filter results
  41188. * @returns an array of Mesh
  41189. */
  41190. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  41191. /**
  41192. * Get a list of cameras by tags
  41193. * @param tagsQuery defines the tags query to use
  41194. * @param forEach defines a predicate used to filter results
  41195. * @returns an array of Camera
  41196. */
  41197. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  41198. /**
  41199. * Get a list of lights by tags
  41200. * @param tagsQuery defines the tags query to use
  41201. * @param forEach defines a predicate used to filter results
  41202. * @returns an array of Light
  41203. */
  41204. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  41205. /**
  41206. * Get a list of materials by tags
  41207. * @param tagsQuery defines the tags query to use
  41208. * @param forEach defines a predicate used to filter results
  41209. * @returns an array of Material
  41210. */
  41211. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  41212. /**
  41213. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  41214. * This allowed control for front to back rendering or reversly depending of the special needs.
  41215. *
  41216. * @param renderingGroupId The rendering group id corresponding to its index
  41217. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  41218. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  41219. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  41220. */
  41221. 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;
  41222. /**
  41223. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  41224. *
  41225. * @param renderingGroupId The rendering group id corresponding to its index
  41226. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  41227. * @param depth Automatically clears depth between groups if true and autoClear is true.
  41228. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  41229. */
  41230. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  41231. /**
  41232. * Gets the current auto clear configuration for one rendering group of the rendering
  41233. * manager.
  41234. * @param index the rendering group index to get the information for
  41235. * @returns The auto clear setup for the requested rendering group
  41236. */
  41237. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  41238. private _blockMaterialDirtyMechanism;
  41239. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  41240. get blockMaterialDirtyMechanism(): boolean;
  41241. set blockMaterialDirtyMechanism(value: boolean);
  41242. /**
  41243. * Will flag all materials as dirty to trigger new shader compilation
  41244. * @param flag defines the flag used to specify which material part must be marked as dirty
  41245. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  41246. */
  41247. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  41248. /** @hidden */
  41249. _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;
  41250. /** @hidden */
  41251. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  41252. /** @hidden */
  41253. _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;
  41254. /** @hidden */
  41255. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  41256. /** @hidden */
  41257. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  41258. /** @hidden */
  41259. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  41260. }
  41261. }
  41262. declare module "babylonjs/assetContainer" {
  41263. import { AbstractScene } from "babylonjs/abstractScene";
  41264. import { Scene } from "babylonjs/scene";
  41265. import { Mesh } from "babylonjs/Meshes/mesh";
  41266. import { TransformNode } from "babylonjs/Meshes/transformNode";
  41267. import { Skeleton } from "babylonjs/Bones/skeleton";
  41268. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  41269. import { Animatable } from "babylonjs/Animations/animatable";
  41270. import { Nullable } from "babylonjs/types";
  41271. import { Node } from "babylonjs/node";
  41272. /**
  41273. * Set of assets to keep when moving a scene into an asset container.
  41274. */
  41275. export class KeepAssets extends AbstractScene {
  41276. }
  41277. /**
  41278. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  41279. */
  41280. export class InstantiatedEntries {
  41281. /**
  41282. * List of new root nodes (eg. nodes with no parent)
  41283. */
  41284. rootNodes: TransformNode[];
  41285. /**
  41286. * List of new skeletons
  41287. */
  41288. skeletons: Skeleton[];
  41289. /**
  41290. * List of new animation groups
  41291. */
  41292. animationGroups: AnimationGroup[];
  41293. }
  41294. /**
  41295. * Container with a set of assets that can be added or removed from a scene.
  41296. */
  41297. export class AssetContainer extends AbstractScene {
  41298. private _wasAddedToScene;
  41299. /**
  41300. * The scene the AssetContainer belongs to.
  41301. */
  41302. scene: Scene;
  41303. /**
  41304. * Instantiates an AssetContainer.
  41305. * @param scene The scene the AssetContainer belongs to.
  41306. */
  41307. constructor(scene: Scene);
  41308. /**
  41309. * Instantiate or clone all meshes and add the new ones to the scene.
  41310. * Skeletons and animation groups will all be cloned
  41311. * @param nameFunction defines an optional function used to get new names for clones
  41312. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  41313. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  41314. */
  41315. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  41316. /**
  41317. * Adds all the assets from the container to the scene.
  41318. */
  41319. addAllToScene(): void;
  41320. /**
  41321. * Removes all the assets in the container from the scene
  41322. */
  41323. removeAllFromScene(): void;
  41324. /**
  41325. * Disposes all the assets in the container
  41326. */
  41327. dispose(): void;
  41328. private _moveAssets;
  41329. /**
  41330. * Removes all the assets contained in the scene and adds them to the container.
  41331. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  41332. */
  41333. moveAllFromScene(keepAssets?: KeepAssets): void;
  41334. /**
  41335. * 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.
  41336. * @returns the root mesh
  41337. */
  41338. createRootMesh(): Mesh;
  41339. /**
  41340. * Merge animations (direct and animation groups) from this asset container into a scene
  41341. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  41342. * @param animatables set of animatables to retarget to a node from the scene
  41343. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  41344. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  41345. */
  41346. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  41347. }
  41348. }
  41349. declare module "babylonjs/abstractScene" {
  41350. import { Scene } from "babylonjs/scene";
  41351. import { Nullable } from "babylonjs/types";
  41352. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41353. import { TransformNode } from "babylonjs/Meshes/transformNode";
  41354. import { Geometry } from "babylonjs/Meshes/geometry";
  41355. import { Skeleton } from "babylonjs/Bones/skeleton";
  41356. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  41357. import { AssetContainer } from "babylonjs/assetContainer";
  41358. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  41359. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  41360. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  41361. import { Material } from "babylonjs/Materials/material";
  41362. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  41363. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  41364. import { Camera } from "babylonjs/Cameras/camera";
  41365. import { Light } from "babylonjs/Lights/light";
  41366. import { Node } from "babylonjs/node";
  41367. import { Animation } from "babylonjs/Animations/animation";
  41368. /**
  41369. * Defines how the parser contract is defined.
  41370. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  41371. */
  41372. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  41373. /**
  41374. * Defines how the individual parser contract is defined.
  41375. * These parser can parse an individual asset
  41376. */
  41377. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  41378. /**
  41379. * Base class of the scene acting as a container for the different elements composing a scene.
  41380. * This class is dynamically extended by the different components of the scene increasing
  41381. * flexibility and reducing coupling
  41382. */
  41383. export abstract class AbstractScene {
  41384. /**
  41385. * Stores the list of available parsers in the application.
  41386. */
  41387. private static _BabylonFileParsers;
  41388. /**
  41389. * Stores the list of available individual parsers in the application.
  41390. */
  41391. private static _IndividualBabylonFileParsers;
  41392. /**
  41393. * Adds a parser in the list of available ones
  41394. * @param name Defines the name of the parser
  41395. * @param parser Defines the parser to add
  41396. */
  41397. static AddParser(name: string, parser: BabylonFileParser): void;
  41398. /**
  41399. * Gets a general parser from the list of avaialble ones
  41400. * @param name Defines the name of the parser
  41401. * @returns the requested parser or null
  41402. */
  41403. static GetParser(name: string): Nullable<BabylonFileParser>;
  41404. /**
  41405. * Adds n individual parser in the list of available ones
  41406. * @param name Defines the name of the parser
  41407. * @param parser Defines the parser to add
  41408. */
  41409. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  41410. /**
  41411. * Gets an individual parser from the list of avaialble ones
  41412. * @param name Defines the name of the parser
  41413. * @returns the requested parser or null
  41414. */
  41415. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  41416. /**
  41417. * Parser json data and populate both a scene and its associated container object
  41418. * @param jsonData Defines the data to parse
  41419. * @param scene Defines the scene to parse the data for
  41420. * @param container Defines the container attached to the parsing sequence
  41421. * @param rootUrl Defines the root url of the data
  41422. */
  41423. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  41424. /**
  41425. * Gets the list of root nodes (ie. nodes with no parent)
  41426. */
  41427. rootNodes: Node[];
  41428. /** All of the cameras added to this scene
  41429. * @see http://doc.babylonjs.com/babylon101/cameras
  41430. */
  41431. cameras: Camera[];
  41432. /**
  41433. * All of the lights added to this scene
  41434. * @see http://doc.babylonjs.com/babylon101/lights
  41435. */
  41436. lights: Light[];
  41437. /**
  41438. * All of the (abstract) meshes added to this scene
  41439. */
  41440. meshes: AbstractMesh[];
  41441. /**
  41442. * The list of skeletons added to the scene
  41443. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  41444. */
  41445. skeletons: Skeleton[];
  41446. /**
  41447. * All of the particle systems added to this scene
  41448. * @see http://doc.babylonjs.com/babylon101/particles
  41449. */
  41450. particleSystems: IParticleSystem[];
  41451. /**
  41452. * Gets a list of Animations associated with the scene
  41453. */
  41454. animations: Animation[];
  41455. /**
  41456. * All of the animation groups added to this scene
  41457. * @see http://doc.babylonjs.com/how_to/group
  41458. */
  41459. animationGroups: AnimationGroup[];
  41460. /**
  41461. * All of the multi-materials added to this scene
  41462. * @see http://doc.babylonjs.com/how_to/multi_materials
  41463. */
  41464. multiMaterials: MultiMaterial[];
  41465. /**
  41466. * All of the materials added to this scene
  41467. * In the context of a Scene, it is not supposed to be modified manually.
  41468. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  41469. * Note also that the order of the Material within the array is not significant and might change.
  41470. * @see http://doc.babylonjs.com/babylon101/materials
  41471. */
  41472. materials: Material[];
  41473. /**
  41474. * The list of morph target managers added to the scene
  41475. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  41476. */
  41477. morphTargetManagers: MorphTargetManager[];
  41478. /**
  41479. * The list of geometries used in the scene.
  41480. */
  41481. geometries: Geometry[];
  41482. /**
  41483. * All of the tranform nodes added to this scene
  41484. * In the context of a Scene, it is not supposed to be modified manually.
  41485. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  41486. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  41487. * @see http://doc.babylonjs.com/how_to/transformnode
  41488. */
  41489. transformNodes: TransformNode[];
  41490. /**
  41491. * ActionManagers available on the scene.
  41492. */
  41493. actionManagers: AbstractActionManager[];
  41494. /**
  41495. * Textures to keep.
  41496. */
  41497. textures: BaseTexture[];
  41498. /**
  41499. * Environment texture for the scene
  41500. */
  41501. environmentTexture: Nullable<BaseTexture>;
  41502. /**
  41503. * @returns all meshes, lights, cameras, transformNodes and bones
  41504. */
  41505. getNodes(): Array<Node>;
  41506. }
  41507. }
  41508. declare module "babylonjs/Audio/sound" {
  41509. import { Observable } from "babylonjs/Misc/observable";
  41510. import { Vector3 } from "babylonjs/Maths/math.vector";
  41511. import { Nullable } from "babylonjs/types";
  41512. import { Scene } from "babylonjs/scene";
  41513. import { TransformNode } from "babylonjs/Meshes/transformNode";
  41514. /**
  41515. * Interface used to define options for Sound class
  41516. */
  41517. export interface ISoundOptions {
  41518. /**
  41519. * Does the sound autoplay once loaded.
  41520. */
  41521. autoplay?: boolean;
  41522. /**
  41523. * Does the sound loop after it finishes playing once.
  41524. */
  41525. loop?: boolean;
  41526. /**
  41527. * Sound's volume
  41528. */
  41529. volume?: number;
  41530. /**
  41531. * Is it a spatial sound?
  41532. */
  41533. spatialSound?: boolean;
  41534. /**
  41535. * Maximum distance to hear that sound
  41536. */
  41537. maxDistance?: number;
  41538. /**
  41539. * Uses user defined attenuation function
  41540. */
  41541. useCustomAttenuation?: boolean;
  41542. /**
  41543. * Define the roll off factor of spatial sounds.
  41544. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41545. */
  41546. rolloffFactor?: number;
  41547. /**
  41548. * Define the reference distance the sound should be heard perfectly.
  41549. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41550. */
  41551. refDistance?: number;
  41552. /**
  41553. * Define the distance attenuation model the sound will follow.
  41554. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41555. */
  41556. distanceModel?: string;
  41557. /**
  41558. * Defines the playback speed (1 by default)
  41559. */
  41560. playbackRate?: number;
  41561. /**
  41562. * Defines if the sound is from a streaming source
  41563. */
  41564. streaming?: boolean;
  41565. /**
  41566. * Defines an optional length (in seconds) inside the sound file
  41567. */
  41568. length?: number;
  41569. /**
  41570. * Defines an optional offset (in seconds) inside the sound file
  41571. */
  41572. offset?: number;
  41573. /**
  41574. * If true, URLs will not be required to state the audio file codec to use.
  41575. */
  41576. skipCodecCheck?: boolean;
  41577. }
  41578. /**
  41579. * Defines a sound that can be played in the application.
  41580. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  41581. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  41582. */
  41583. export class Sound {
  41584. /**
  41585. * The name of the sound in the scene.
  41586. */
  41587. name: string;
  41588. /**
  41589. * Does the sound autoplay once loaded.
  41590. */
  41591. autoplay: boolean;
  41592. /**
  41593. * Does the sound loop after it finishes playing once.
  41594. */
  41595. loop: boolean;
  41596. /**
  41597. * Does the sound use a custom attenuation curve to simulate the falloff
  41598. * happening when the source gets further away from the camera.
  41599. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  41600. */
  41601. useCustomAttenuation: boolean;
  41602. /**
  41603. * The sound track id this sound belongs to.
  41604. */
  41605. soundTrackId: number;
  41606. /**
  41607. * Is this sound currently played.
  41608. */
  41609. isPlaying: boolean;
  41610. /**
  41611. * Is this sound currently paused.
  41612. */
  41613. isPaused: boolean;
  41614. /**
  41615. * Does this sound enables spatial sound.
  41616. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41617. */
  41618. spatialSound: boolean;
  41619. /**
  41620. * Define the reference distance the sound should be heard perfectly.
  41621. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41622. */
  41623. refDistance: number;
  41624. /**
  41625. * Define the roll off factor of spatial sounds.
  41626. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41627. */
  41628. rolloffFactor: number;
  41629. /**
  41630. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  41631. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41632. */
  41633. maxDistance: number;
  41634. /**
  41635. * Define the distance attenuation model the sound will follow.
  41636. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41637. */
  41638. distanceModel: string;
  41639. /**
  41640. * @hidden
  41641. * Back Compat
  41642. **/
  41643. onended: () => any;
  41644. /**
  41645. * Gets or sets an object used to store user defined information for the sound.
  41646. */
  41647. metadata: any;
  41648. /**
  41649. * Observable event when the current playing sound finishes.
  41650. */
  41651. onEndedObservable: Observable<Sound>;
  41652. private _panningModel;
  41653. private _playbackRate;
  41654. private _streaming;
  41655. private _startTime;
  41656. private _startOffset;
  41657. private _position;
  41658. /** @hidden */
  41659. _positionInEmitterSpace: boolean;
  41660. private _localDirection;
  41661. private _volume;
  41662. private _isReadyToPlay;
  41663. private _isDirectional;
  41664. private _readyToPlayCallback;
  41665. private _audioBuffer;
  41666. private _soundSource;
  41667. private _streamingSource;
  41668. private _soundPanner;
  41669. private _soundGain;
  41670. private _inputAudioNode;
  41671. private _outputAudioNode;
  41672. private _coneInnerAngle;
  41673. private _coneOuterAngle;
  41674. private _coneOuterGain;
  41675. private _scene;
  41676. private _connectedTransformNode;
  41677. private _customAttenuationFunction;
  41678. private _registerFunc;
  41679. private _isOutputConnected;
  41680. private _htmlAudioElement;
  41681. private _urlType;
  41682. private _length?;
  41683. private _offset?;
  41684. /** @hidden */
  41685. static _SceneComponentInitialization: (scene: Scene) => void;
  41686. /**
  41687. * Create a sound and attach it to a scene
  41688. * @param name Name of your sound
  41689. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  41690. * @param scene defines the scene the sound belongs to
  41691. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  41692. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  41693. */
  41694. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  41695. /**
  41696. * Release the sound and its associated resources
  41697. */
  41698. dispose(): void;
  41699. /**
  41700. * Gets if the sounds is ready to be played or not.
  41701. * @returns true if ready, otherwise false
  41702. */
  41703. isReady(): boolean;
  41704. private _soundLoaded;
  41705. /**
  41706. * Sets the data of the sound from an audiobuffer
  41707. * @param audioBuffer The audioBuffer containing the data
  41708. */
  41709. setAudioBuffer(audioBuffer: AudioBuffer): void;
  41710. /**
  41711. * Updates the current sounds options such as maxdistance, loop...
  41712. * @param options A JSON object containing values named as the object properties
  41713. */
  41714. updateOptions(options: ISoundOptions): void;
  41715. private _createSpatialParameters;
  41716. private _updateSpatialParameters;
  41717. /**
  41718. * Switch the panning model to HRTF:
  41719. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  41720. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41721. */
  41722. switchPanningModelToHRTF(): void;
  41723. /**
  41724. * Switch the panning model to Equal Power:
  41725. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  41726. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41727. */
  41728. switchPanningModelToEqualPower(): void;
  41729. private _switchPanningModel;
  41730. /**
  41731. * Connect this sound to a sound track audio node like gain...
  41732. * @param soundTrackAudioNode the sound track audio node to connect to
  41733. */
  41734. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  41735. /**
  41736. * Transform this sound into a directional source
  41737. * @param coneInnerAngle Size of the inner cone in degree
  41738. * @param coneOuterAngle Size of the outer cone in degree
  41739. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  41740. */
  41741. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  41742. /**
  41743. * Gets or sets the inner angle for the directional cone.
  41744. */
  41745. get directionalConeInnerAngle(): number;
  41746. /**
  41747. * Gets or sets the inner angle for the directional cone.
  41748. */
  41749. set directionalConeInnerAngle(value: number);
  41750. /**
  41751. * Gets or sets the outer angle for the directional cone.
  41752. */
  41753. get directionalConeOuterAngle(): number;
  41754. /**
  41755. * Gets or sets the outer angle for the directional cone.
  41756. */
  41757. set directionalConeOuterAngle(value: number);
  41758. /**
  41759. * Sets the position of the emitter if spatial sound is enabled
  41760. * @param newPosition Defines the new posisiton
  41761. */
  41762. setPosition(newPosition: Vector3): void;
  41763. /**
  41764. * Sets the local direction of the emitter if spatial sound is enabled
  41765. * @param newLocalDirection Defines the new local direction
  41766. */
  41767. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  41768. private _updateDirection;
  41769. /** @hidden */
  41770. updateDistanceFromListener(): void;
  41771. /**
  41772. * Sets a new custom attenuation function for the sound.
  41773. * @param callback Defines the function used for the attenuation
  41774. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  41775. */
  41776. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  41777. /**
  41778. * Play the sound
  41779. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  41780. * @param offset (optional) Start the sound at a specific time in seconds
  41781. * @param length (optional) Sound duration (in seconds)
  41782. */
  41783. play(time?: number, offset?: number, length?: number): void;
  41784. private _onended;
  41785. /**
  41786. * Stop the sound
  41787. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  41788. */
  41789. stop(time?: number): void;
  41790. /**
  41791. * Put the sound in pause
  41792. */
  41793. pause(): void;
  41794. /**
  41795. * Sets a dedicated volume for this sounds
  41796. * @param newVolume Define the new volume of the sound
  41797. * @param time Define time for gradual change to new volume
  41798. */
  41799. setVolume(newVolume: number, time?: number): void;
  41800. /**
  41801. * Set the sound play back rate
  41802. * @param newPlaybackRate Define the playback rate the sound should be played at
  41803. */
  41804. setPlaybackRate(newPlaybackRate: number): void;
  41805. /**
  41806. * Gets the volume of the sound.
  41807. * @returns the volume of the sound
  41808. */
  41809. getVolume(): number;
  41810. /**
  41811. * Attach the sound to a dedicated mesh
  41812. * @param transformNode The transform node to connect the sound with
  41813. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  41814. */
  41815. attachToMesh(transformNode: TransformNode): void;
  41816. /**
  41817. * Detach the sound from the previously attached mesh
  41818. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  41819. */
  41820. detachFromMesh(): void;
  41821. private _onRegisterAfterWorldMatrixUpdate;
  41822. /**
  41823. * Clone the current sound in the scene.
  41824. * @returns the new sound clone
  41825. */
  41826. clone(): Nullable<Sound>;
  41827. /**
  41828. * Gets the current underlying audio buffer containing the data
  41829. * @returns the audio buffer
  41830. */
  41831. getAudioBuffer(): Nullable<AudioBuffer>;
  41832. /**
  41833. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  41834. * @returns the source node
  41835. */
  41836. getSoundSource(): Nullable<AudioBufferSourceNode>;
  41837. /**
  41838. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  41839. * @returns the gain node
  41840. */
  41841. getSoundGain(): Nullable<GainNode>;
  41842. /**
  41843. * Serializes the Sound in a JSON representation
  41844. * @returns the JSON representation of the sound
  41845. */
  41846. serialize(): any;
  41847. /**
  41848. * Parse a JSON representation of a sound to innstantiate in a given scene
  41849. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  41850. * @param scene Define the scene the new parsed sound should be created in
  41851. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  41852. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  41853. * @returns the newly parsed sound
  41854. */
  41855. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  41856. }
  41857. }
  41858. declare module "babylonjs/Actions/directAudioActions" {
  41859. import { Action } from "babylonjs/Actions/action";
  41860. import { Condition } from "babylonjs/Actions/condition";
  41861. import { Sound } from "babylonjs/Audio/sound";
  41862. /**
  41863. * This defines an action helpful to play a defined sound on a triggered action.
  41864. */
  41865. export class PlaySoundAction extends Action {
  41866. private _sound;
  41867. /**
  41868. * Instantiate the action
  41869. * @param triggerOptions defines the trigger options
  41870. * @param sound defines the sound to play
  41871. * @param condition defines the trigger related conditions
  41872. */
  41873. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  41874. /** @hidden */
  41875. _prepare(): void;
  41876. /**
  41877. * Execute the action and play the sound.
  41878. */
  41879. execute(): void;
  41880. /**
  41881. * Serializes the actions and its related information.
  41882. * @param parent defines the object to serialize in
  41883. * @returns the serialized object
  41884. */
  41885. serialize(parent: any): any;
  41886. }
  41887. /**
  41888. * This defines an action helpful to stop a defined sound on a triggered action.
  41889. */
  41890. export class StopSoundAction extends Action {
  41891. private _sound;
  41892. /**
  41893. * Instantiate the action
  41894. * @param triggerOptions defines the trigger options
  41895. * @param sound defines the sound to stop
  41896. * @param condition defines the trigger related conditions
  41897. */
  41898. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  41899. /** @hidden */
  41900. _prepare(): void;
  41901. /**
  41902. * Execute the action and stop the sound.
  41903. */
  41904. execute(): void;
  41905. /**
  41906. * Serializes the actions and its related information.
  41907. * @param parent defines the object to serialize in
  41908. * @returns the serialized object
  41909. */
  41910. serialize(parent: any): any;
  41911. }
  41912. }
  41913. declare module "babylonjs/Actions/interpolateValueAction" {
  41914. import { Action } from "babylonjs/Actions/action";
  41915. import { Condition } from "babylonjs/Actions/condition";
  41916. import { Observable } from "babylonjs/Misc/observable";
  41917. /**
  41918. * This defines an action responsible to change the value of a property
  41919. * by interpolating between its current value and the newly set one once triggered.
  41920. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  41921. */
  41922. export class InterpolateValueAction extends Action {
  41923. /**
  41924. * Defines the path of the property where the value should be interpolated
  41925. */
  41926. propertyPath: string;
  41927. /**
  41928. * Defines the target value at the end of the interpolation.
  41929. */
  41930. value: any;
  41931. /**
  41932. * Defines the time it will take for the property to interpolate to the value.
  41933. */
  41934. duration: number;
  41935. /**
  41936. * Defines if the other scene animations should be stopped when the action has been triggered
  41937. */
  41938. stopOtherAnimations?: boolean;
  41939. /**
  41940. * Defines a callback raised once the interpolation animation has been done.
  41941. */
  41942. onInterpolationDone?: () => void;
  41943. /**
  41944. * Observable triggered once the interpolation animation has been done.
  41945. */
  41946. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  41947. private _target;
  41948. private _effectiveTarget;
  41949. private _property;
  41950. /**
  41951. * Instantiate the action
  41952. * @param triggerOptions defines the trigger options
  41953. * @param target defines the object containing the value to interpolate
  41954. * @param propertyPath defines the path to the property in the target object
  41955. * @param value defines the target value at the end of the interpolation
  41956. * @param duration deines the time it will take for the property to interpolate to the value.
  41957. * @param condition defines the trigger related conditions
  41958. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  41959. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  41960. */
  41961. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  41962. /** @hidden */
  41963. _prepare(): void;
  41964. /**
  41965. * Execute the action starts the value interpolation.
  41966. */
  41967. execute(): void;
  41968. /**
  41969. * Serializes the actions and its related information.
  41970. * @param parent defines the object to serialize in
  41971. * @returns the serialized object
  41972. */
  41973. serialize(parent: any): any;
  41974. }
  41975. }
  41976. declare module "babylonjs/Actions/index" {
  41977. export * from "babylonjs/Actions/abstractActionManager";
  41978. export * from "babylonjs/Actions/action";
  41979. export * from "babylonjs/Actions/actionEvent";
  41980. export * from "babylonjs/Actions/actionManager";
  41981. export * from "babylonjs/Actions/condition";
  41982. export * from "babylonjs/Actions/directActions";
  41983. export * from "babylonjs/Actions/directAudioActions";
  41984. export * from "babylonjs/Actions/interpolateValueAction";
  41985. }
  41986. declare module "babylonjs/Animations/index" {
  41987. export * from "babylonjs/Animations/animatable";
  41988. export * from "babylonjs/Animations/animation";
  41989. export * from "babylonjs/Animations/animationGroup";
  41990. export * from "babylonjs/Animations/animationPropertiesOverride";
  41991. export * from "babylonjs/Animations/easing";
  41992. export * from "babylonjs/Animations/runtimeAnimation";
  41993. export * from "babylonjs/Animations/animationEvent";
  41994. export * from "babylonjs/Animations/animationGroup";
  41995. export * from "babylonjs/Animations/animationKey";
  41996. export * from "babylonjs/Animations/animationRange";
  41997. export * from "babylonjs/Animations/animatable.interface";
  41998. }
  41999. declare module "babylonjs/Audio/soundTrack" {
  42000. import { Sound } from "babylonjs/Audio/sound";
  42001. import { Analyser } from "babylonjs/Audio/analyser";
  42002. import { Scene } from "babylonjs/scene";
  42003. /**
  42004. * Options allowed during the creation of a sound track.
  42005. */
  42006. export interface ISoundTrackOptions {
  42007. /**
  42008. * The volume the sound track should take during creation
  42009. */
  42010. volume?: number;
  42011. /**
  42012. * Define if the sound track is the main sound track of the scene
  42013. */
  42014. mainTrack?: boolean;
  42015. }
  42016. /**
  42017. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  42018. * It will be also used in a future release to apply effects on a specific track.
  42019. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  42020. */
  42021. export class SoundTrack {
  42022. /**
  42023. * The unique identifier of the sound track in the scene.
  42024. */
  42025. id: number;
  42026. /**
  42027. * The list of sounds included in the sound track.
  42028. */
  42029. soundCollection: Array<Sound>;
  42030. private _outputAudioNode;
  42031. private _scene;
  42032. private _connectedAnalyser;
  42033. private _options;
  42034. private _isInitialized;
  42035. /**
  42036. * Creates a new sound track.
  42037. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  42038. * @param scene Define the scene the sound track belongs to
  42039. * @param options
  42040. */
  42041. constructor(scene: Scene, options?: ISoundTrackOptions);
  42042. private _initializeSoundTrackAudioGraph;
  42043. /**
  42044. * Release the sound track and its associated resources
  42045. */
  42046. dispose(): void;
  42047. /**
  42048. * Adds a sound to this sound track
  42049. * @param sound define the cound to add
  42050. * @ignoreNaming
  42051. */
  42052. AddSound(sound: Sound): void;
  42053. /**
  42054. * Removes a sound to this sound track
  42055. * @param sound define the cound to remove
  42056. * @ignoreNaming
  42057. */
  42058. RemoveSound(sound: Sound): void;
  42059. /**
  42060. * Set a global volume for the full sound track.
  42061. * @param newVolume Define the new volume of the sound track
  42062. */
  42063. setVolume(newVolume: number): void;
  42064. /**
  42065. * Switch the panning model to HRTF:
  42066. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  42067. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42068. */
  42069. switchPanningModelToHRTF(): void;
  42070. /**
  42071. * Switch the panning model to Equal Power:
  42072. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  42073. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42074. */
  42075. switchPanningModelToEqualPower(): void;
  42076. /**
  42077. * Connect the sound track to an audio analyser allowing some amazing
  42078. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  42079. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  42080. * @param analyser The analyser to connect to the engine
  42081. */
  42082. connectToAnalyser(analyser: Analyser): void;
  42083. }
  42084. }
  42085. declare module "babylonjs/Audio/audioSceneComponent" {
  42086. import { Sound } from "babylonjs/Audio/sound";
  42087. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  42088. import { Nullable } from "babylonjs/types";
  42089. import { Vector3 } from "babylonjs/Maths/math.vector";
  42090. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  42091. import { Scene } from "babylonjs/scene";
  42092. import { AbstractScene } from "babylonjs/abstractScene";
  42093. import "babylonjs/Audio/audioEngine";
  42094. module "babylonjs/abstractScene" {
  42095. interface AbstractScene {
  42096. /**
  42097. * The list of sounds used in the scene.
  42098. */
  42099. sounds: Nullable<Array<Sound>>;
  42100. }
  42101. }
  42102. module "babylonjs/scene" {
  42103. interface Scene {
  42104. /**
  42105. * @hidden
  42106. * Backing field
  42107. */
  42108. _mainSoundTrack: SoundTrack;
  42109. /**
  42110. * The main sound track played by the scene.
  42111. * It cotains your primary collection of sounds.
  42112. */
  42113. mainSoundTrack: SoundTrack;
  42114. /**
  42115. * The list of sound tracks added to the scene
  42116. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  42117. */
  42118. soundTracks: Nullable<Array<SoundTrack>>;
  42119. /**
  42120. * Gets a sound using a given name
  42121. * @param name defines the name to search for
  42122. * @return the found sound or null if not found at all.
  42123. */
  42124. getSoundByName(name: string): Nullable<Sound>;
  42125. /**
  42126. * Gets or sets if audio support is enabled
  42127. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  42128. */
  42129. audioEnabled: boolean;
  42130. /**
  42131. * Gets or sets if audio will be output to headphones
  42132. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  42133. */
  42134. headphone: boolean;
  42135. /**
  42136. * Gets or sets custom audio listener position provider
  42137. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  42138. */
  42139. audioListenerPositionProvider: Nullable<() => Vector3>;
  42140. /**
  42141. * Gets or sets a refresh rate when using 3D audio positioning
  42142. */
  42143. audioPositioningRefreshRate: number;
  42144. }
  42145. }
  42146. /**
  42147. * Defines the sound scene component responsible to manage any sounds
  42148. * in a given scene.
  42149. */
  42150. export class AudioSceneComponent implements ISceneSerializableComponent {
  42151. /**
  42152. * The component name helpfull to identify the component in the list of scene components.
  42153. */
  42154. readonly name: string;
  42155. /**
  42156. * The scene the component belongs to.
  42157. */
  42158. scene: Scene;
  42159. private _audioEnabled;
  42160. /**
  42161. * Gets whether audio is enabled or not.
  42162. * Please use related enable/disable method to switch state.
  42163. */
  42164. get audioEnabled(): boolean;
  42165. private _headphone;
  42166. /**
  42167. * Gets whether audio is outputing to headphone or not.
  42168. * Please use the according Switch methods to change output.
  42169. */
  42170. get headphone(): boolean;
  42171. /**
  42172. * Gets or sets a refresh rate when using 3D audio positioning
  42173. */
  42174. audioPositioningRefreshRate: number;
  42175. private _audioListenerPositionProvider;
  42176. /**
  42177. * Gets the current audio listener position provider
  42178. */
  42179. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  42180. /**
  42181. * Sets a custom listener position for all sounds in the scene
  42182. * By default, this is the position of the first active camera
  42183. */
  42184. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  42185. /**
  42186. * Creates a new instance of the component for the given scene
  42187. * @param scene Defines the scene to register the component in
  42188. */
  42189. constructor(scene: Scene);
  42190. /**
  42191. * Registers the component in a given scene
  42192. */
  42193. register(): void;
  42194. /**
  42195. * Rebuilds the elements related to this component in case of
  42196. * context lost for instance.
  42197. */
  42198. rebuild(): void;
  42199. /**
  42200. * Serializes the component data to the specified json object
  42201. * @param serializationObject The object to serialize to
  42202. */
  42203. serialize(serializationObject: any): void;
  42204. /**
  42205. * Adds all the elements from the container to the scene
  42206. * @param container the container holding the elements
  42207. */
  42208. addFromContainer(container: AbstractScene): void;
  42209. /**
  42210. * Removes all the elements in the container from the scene
  42211. * @param container contains the elements to remove
  42212. * @param dispose if the removed element should be disposed (default: false)
  42213. */
  42214. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  42215. /**
  42216. * Disposes the component and the associated ressources.
  42217. */
  42218. dispose(): void;
  42219. /**
  42220. * Disables audio in the associated scene.
  42221. */
  42222. disableAudio(): void;
  42223. /**
  42224. * Enables audio in the associated scene.
  42225. */
  42226. enableAudio(): void;
  42227. /**
  42228. * Switch audio to headphone output.
  42229. */
  42230. switchAudioModeForHeadphones(): void;
  42231. /**
  42232. * Switch audio to normal speakers.
  42233. */
  42234. switchAudioModeForNormalSpeakers(): void;
  42235. private _cachedCameraDirection;
  42236. private _cachedCameraPosition;
  42237. private _lastCheck;
  42238. private _afterRender;
  42239. }
  42240. }
  42241. declare module "babylonjs/Audio/weightedsound" {
  42242. import { Sound } from "babylonjs/Audio/sound";
  42243. /**
  42244. * Wraps one or more Sound objects and selects one with random weight for playback.
  42245. */
  42246. export class WeightedSound {
  42247. /** When true a Sound will be selected and played when the current playing Sound completes. */
  42248. loop: boolean;
  42249. private _coneInnerAngle;
  42250. private _coneOuterAngle;
  42251. private _volume;
  42252. /** A Sound is currently playing. */
  42253. isPlaying: boolean;
  42254. /** A Sound is currently paused. */
  42255. isPaused: boolean;
  42256. private _sounds;
  42257. private _weights;
  42258. private _currentIndex?;
  42259. /**
  42260. * Creates a new WeightedSound from the list of sounds given.
  42261. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  42262. * @param sounds Array of Sounds that will be selected from.
  42263. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  42264. */
  42265. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  42266. /**
  42267. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  42268. */
  42269. get directionalConeInnerAngle(): number;
  42270. /**
  42271. * The size of cone in degress for a directional sound in which there will be no attenuation.
  42272. */
  42273. set directionalConeInnerAngle(value: number);
  42274. /**
  42275. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  42276. * Listener angles between innerAngle and outerAngle will falloff linearly.
  42277. */
  42278. get directionalConeOuterAngle(): number;
  42279. /**
  42280. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  42281. * Listener angles between innerAngle and outerAngle will falloff linearly.
  42282. */
  42283. set directionalConeOuterAngle(value: number);
  42284. /**
  42285. * Playback volume.
  42286. */
  42287. get volume(): number;
  42288. /**
  42289. * Playback volume.
  42290. */
  42291. set volume(value: number);
  42292. private _onended;
  42293. /**
  42294. * Suspend playback
  42295. */
  42296. pause(): void;
  42297. /**
  42298. * Stop playback
  42299. */
  42300. stop(): void;
  42301. /**
  42302. * Start playback.
  42303. * @param startOffset Position the clip head at a specific time in seconds.
  42304. */
  42305. play(startOffset?: number): void;
  42306. }
  42307. }
  42308. declare module "babylonjs/Audio/index" {
  42309. export * from "babylonjs/Audio/analyser";
  42310. export * from "babylonjs/Audio/audioEngine";
  42311. export * from "babylonjs/Audio/audioSceneComponent";
  42312. export * from "babylonjs/Audio/sound";
  42313. export * from "babylonjs/Audio/soundTrack";
  42314. export * from "babylonjs/Audio/weightedsound";
  42315. }
  42316. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  42317. import { Behavior } from "babylonjs/Behaviors/behavior";
  42318. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  42319. import { BackEase } from "babylonjs/Animations/easing";
  42320. /**
  42321. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  42322. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  42323. */
  42324. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  42325. /**
  42326. * Gets the name of the behavior.
  42327. */
  42328. get name(): string;
  42329. /**
  42330. * The easing function used by animations
  42331. */
  42332. static EasingFunction: BackEase;
  42333. /**
  42334. * The easing mode used by animations
  42335. */
  42336. static EasingMode: number;
  42337. /**
  42338. * The duration of the animation, in milliseconds
  42339. */
  42340. transitionDuration: number;
  42341. /**
  42342. * Length of the distance animated by the transition when lower radius is reached
  42343. */
  42344. lowerRadiusTransitionRange: number;
  42345. /**
  42346. * Length of the distance animated by the transition when upper radius is reached
  42347. */
  42348. upperRadiusTransitionRange: number;
  42349. private _autoTransitionRange;
  42350. /**
  42351. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  42352. */
  42353. get autoTransitionRange(): boolean;
  42354. /**
  42355. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  42356. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  42357. */
  42358. set autoTransitionRange(value: boolean);
  42359. private _attachedCamera;
  42360. private _onAfterCheckInputsObserver;
  42361. private _onMeshTargetChangedObserver;
  42362. /**
  42363. * Initializes the behavior.
  42364. */
  42365. init(): void;
  42366. /**
  42367. * Attaches the behavior to its arc rotate camera.
  42368. * @param camera Defines the camera to attach the behavior to
  42369. */
  42370. attach(camera: ArcRotateCamera): void;
  42371. /**
  42372. * Detaches the behavior from its current arc rotate camera.
  42373. */
  42374. detach(): void;
  42375. private _radiusIsAnimating;
  42376. private _radiusBounceTransition;
  42377. private _animatables;
  42378. private _cachedWheelPrecision;
  42379. /**
  42380. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  42381. * @param radiusLimit The limit to check against.
  42382. * @return Bool to indicate if at limit.
  42383. */
  42384. private _isRadiusAtLimit;
  42385. /**
  42386. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  42387. * @param radiusDelta The delta by which to animate to. Can be negative.
  42388. */
  42389. private _applyBoundRadiusAnimation;
  42390. /**
  42391. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  42392. */
  42393. protected _clearAnimationLocks(): void;
  42394. /**
  42395. * Stops and removes all animations that have been applied to the camera
  42396. */
  42397. stopAllAnimations(): void;
  42398. }
  42399. }
  42400. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  42401. import { Behavior } from "babylonjs/Behaviors/behavior";
  42402. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  42403. import { ExponentialEase } from "babylonjs/Animations/easing";
  42404. import { Nullable } from "babylonjs/types";
  42405. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42406. import { Vector3 } from "babylonjs/Maths/math.vector";
  42407. /**
  42408. * 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.
  42409. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  42410. */
  42411. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  42412. /**
  42413. * Gets the name of the behavior.
  42414. */
  42415. get name(): string;
  42416. private _mode;
  42417. private _radiusScale;
  42418. private _positionScale;
  42419. private _defaultElevation;
  42420. private _elevationReturnTime;
  42421. private _elevationReturnWaitTime;
  42422. private _zoomStopsAnimation;
  42423. private _framingTime;
  42424. /**
  42425. * The easing function used by animations
  42426. */
  42427. static EasingFunction: ExponentialEase;
  42428. /**
  42429. * The easing mode used by animations
  42430. */
  42431. static EasingMode: number;
  42432. /**
  42433. * Sets the current mode used by the behavior
  42434. */
  42435. set mode(mode: number);
  42436. /**
  42437. * Gets current mode used by the behavior.
  42438. */
  42439. get mode(): number;
  42440. /**
  42441. * Sets the scale applied to the radius (1 by default)
  42442. */
  42443. set radiusScale(radius: number);
  42444. /**
  42445. * Gets the scale applied to the radius
  42446. */
  42447. get radiusScale(): number;
  42448. /**
  42449. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  42450. */
  42451. set positionScale(scale: number);
  42452. /**
  42453. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  42454. */
  42455. get positionScale(): number;
  42456. /**
  42457. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  42458. * behaviour is triggered, in radians.
  42459. */
  42460. set defaultElevation(elevation: number);
  42461. /**
  42462. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  42463. * behaviour is triggered, in radians.
  42464. */
  42465. get defaultElevation(): number;
  42466. /**
  42467. * Sets the time (in milliseconds) taken to return to the default beta position.
  42468. * Negative value indicates camera should not return to default.
  42469. */
  42470. set elevationReturnTime(speed: number);
  42471. /**
  42472. * Gets the time (in milliseconds) taken to return to the default beta position.
  42473. * Negative value indicates camera should not return to default.
  42474. */
  42475. get elevationReturnTime(): number;
  42476. /**
  42477. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  42478. */
  42479. set elevationReturnWaitTime(time: number);
  42480. /**
  42481. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  42482. */
  42483. get elevationReturnWaitTime(): number;
  42484. /**
  42485. * Sets the flag that indicates if user zooming should stop animation.
  42486. */
  42487. set zoomStopsAnimation(flag: boolean);
  42488. /**
  42489. * Gets the flag that indicates if user zooming should stop animation.
  42490. */
  42491. get zoomStopsAnimation(): boolean;
  42492. /**
  42493. * Sets the transition time when framing the mesh, in milliseconds
  42494. */
  42495. set framingTime(time: number);
  42496. /**
  42497. * Gets the transition time when framing the mesh, in milliseconds
  42498. */
  42499. get framingTime(): number;
  42500. /**
  42501. * Define if the behavior should automatically change the configured
  42502. * camera limits and sensibilities.
  42503. */
  42504. autoCorrectCameraLimitsAndSensibility: boolean;
  42505. private _onPrePointerObservableObserver;
  42506. private _onAfterCheckInputsObserver;
  42507. private _onMeshTargetChangedObserver;
  42508. private _attachedCamera;
  42509. private _isPointerDown;
  42510. private _lastInteractionTime;
  42511. /**
  42512. * Initializes the behavior.
  42513. */
  42514. init(): void;
  42515. /**
  42516. * Attaches the behavior to its arc rotate camera.
  42517. * @param camera Defines the camera to attach the behavior to
  42518. */
  42519. attach(camera: ArcRotateCamera): void;
  42520. /**
  42521. * Detaches the behavior from its current arc rotate camera.
  42522. */
  42523. detach(): void;
  42524. private _animatables;
  42525. private _betaIsAnimating;
  42526. private _betaTransition;
  42527. private _radiusTransition;
  42528. private _vectorTransition;
  42529. /**
  42530. * Targets the given mesh and updates zoom level accordingly.
  42531. * @param mesh The mesh to target.
  42532. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42533. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42534. */
  42535. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42536. /**
  42537. * Targets the given mesh with its children and updates zoom level accordingly.
  42538. * @param mesh The mesh to target.
  42539. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42540. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42541. */
  42542. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42543. /**
  42544. * Targets the given meshes with their children and updates zoom level accordingly.
  42545. * @param meshes The mesh to target.
  42546. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42547. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42548. */
  42549. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42550. /**
  42551. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  42552. * @param minimumWorld Determines the smaller position of the bounding box extend
  42553. * @param maximumWorld Determines the bigger position of the bounding box extend
  42554. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42555. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42556. */
  42557. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42558. /**
  42559. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  42560. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  42561. * frustum width.
  42562. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  42563. * to fully enclose the mesh in the viewing frustum.
  42564. */
  42565. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  42566. /**
  42567. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  42568. * is automatically returned to its default position (expected to be above ground plane).
  42569. */
  42570. private _maintainCameraAboveGround;
  42571. /**
  42572. * Returns the frustum slope based on the canvas ratio and camera FOV
  42573. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  42574. */
  42575. private _getFrustumSlope;
  42576. /**
  42577. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  42578. */
  42579. private _clearAnimationLocks;
  42580. /**
  42581. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  42582. */
  42583. private _applyUserInteraction;
  42584. /**
  42585. * Stops and removes all animations that have been applied to the camera
  42586. */
  42587. stopAllAnimations(): void;
  42588. /**
  42589. * Gets a value indicating if the user is moving the camera
  42590. */
  42591. get isUserIsMoving(): boolean;
  42592. /**
  42593. * The camera can move all the way towards the mesh.
  42594. */
  42595. static IgnoreBoundsSizeMode: number;
  42596. /**
  42597. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  42598. */
  42599. static FitFrustumSidesMode: number;
  42600. }
  42601. }
  42602. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  42603. import { Nullable } from "babylonjs/types";
  42604. import { Camera } from "babylonjs/Cameras/camera";
  42605. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  42606. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  42607. /**
  42608. * Base class for Camera Pointer Inputs.
  42609. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  42610. * for example usage.
  42611. */
  42612. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  42613. /**
  42614. * Defines the camera the input is attached to.
  42615. */
  42616. abstract camera: Camera;
  42617. /**
  42618. * Whether keyboard modifier keys are pressed at time of last mouse event.
  42619. */
  42620. protected _altKey: boolean;
  42621. protected _ctrlKey: boolean;
  42622. protected _metaKey: boolean;
  42623. protected _shiftKey: boolean;
  42624. /**
  42625. * Which mouse buttons were pressed at time of last mouse event.
  42626. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  42627. */
  42628. protected _buttonsPressed: number;
  42629. /**
  42630. * Defines the buttons associated with the input to handle camera move.
  42631. */
  42632. buttons: number[];
  42633. /**
  42634. * Attach the input controls to a specific dom element to get the input from.
  42635. * @param element Defines the element the controls should be listened from
  42636. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42637. */
  42638. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42639. /**
  42640. * Detach the current controls from the specified dom element.
  42641. * @param element Defines the element to stop listening the inputs from
  42642. */
  42643. detachControl(element: Nullable<HTMLElement>): void;
  42644. /**
  42645. * Gets the class name of the current input.
  42646. * @returns the class name
  42647. */
  42648. getClassName(): string;
  42649. /**
  42650. * Get the friendly name associated with the input class.
  42651. * @returns the input friendly name
  42652. */
  42653. getSimpleName(): string;
  42654. /**
  42655. * Called on pointer POINTERDOUBLETAP event.
  42656. * Override this method to provide functionality on POINTERDOUBLETAP event.
  42657. */
  42658. protected onDoubleTap(type: string): void;
  42659. /**
  42660. * Called on pointer POINTERMOVE event if only a single touch is active.
  42661. * Override this method to provide functionality.
  42662. */
  42663. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  42664. /**
  42665. * Called on pointer POINTERMOVE event if multiple touches are active.
  42666. * Override this method to provide functionality.
  42667. */
  42668. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  42669. /**
  42670. * Called on JS contextmenu event.
  42671. * Override this method to provide functionality.
  42672. */
  42673. protected onContextMenu(evt: PointerEvent): void;
  42674. /**
  42675. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  42676. * press.
  42677. * Override this method to provide functionality.
  42678. */
  42679. protected onButtonDown(evt: PointerEvent): void;
  42680. /**
  42681. * Called each time a new POINTERUP event occurs. Ie, for each button
  42682. * release.
  42683. * Override this method to provide functionality.
  42684. */
  42685. protected onButtonUp(evt: PointerEvent): void;
  42686. /**
  42687. * Called when window becomes inactive.
  42688. * Override this method to provide functionality.
  42689. */
  42690. protected onLostFocus(): void;
  42691. private _pointerInput;
  42692. private _observer;
  42693. private _onLostFocus;
  42694. private pointA;
  42695. private pointB;
  42696. }
  42697. }
  42698. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  42699. import { Nullable } from "babylonjs/types";
  42700. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  42701. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  42702. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  42703. /**
  42704. * Manage the pointers inputs to control an arc rotate camera.
  42705. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42706. */
  42707. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  42708. /**
  42709. * Defines the camera the input is attached to.
  42710. */
  42711. camera: ArcRotateCamera;
  42712. /**
  42713. * Gets the class name of the current input.
  42714. * @returns the class name
  42715. */
  42716. getClassName(): string;
  42717. /**
  42718. * Defines the buttons associated with the input to handle camera move.
  42719. */
  42720. buttons: number[];
  42721. /**
  42722. * Defines the pointer angular sensibility along the X axis or how fast is
  42723. * the camera rotating.
  42724. */
  42725. angularSensibilityX: number;
  42726. /**
  42727. * Defines the pointer angular sensibility along the Y axis or how fast is
  42728. * the camera rotating.
  42729. */
  42730. angularSensibilityY: number;
  42731. /**
  42732. * Defines the pointer pinch precision or how fast is the camera zooming.
  42733. */
  42734. pinchPrecision: number;
  42735. /**
  42736. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  42737. * from 0.
  42738. * It defines the percentage of current camera.radius to use as delta when
  42739. * pinch zoom is used.
  42740. */
  42741. pinchDeltaPercentage: number;
  42742. /**
  42743. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  42744. * that any object in the plane at the camera's target point will scale
  42745. * perfectly with finger motion.
  42746. * Overrides pinchDeltaPercentage and pinchPrecision.
  42747. */
  42748. useNaturalPinchZoom: boolean;
  42749. /**
  42750. * Defines the pointer panning sensibility or how fast is the camera moving.
  42751. */
  42752. panningSensibility: number;
  42753. /**
  42754. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  42755. */
  42756. multiTouchPanning: boolean;
  42757. /**
  42758. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  42759. * zoom (pinch) through multitouch.
  42760. */
  42761. multiTouchPanAndZoom: boolean;
  42762. /**
  42763. * Revers pinch action direction.
  42764. */
  42765. pinchInwards: boolean;
  42766. private _isPanClick;
  42767. private _twoFingerActivityCount;
  42768. private _isPinching;
  42769. /**
  42770. * Called on pointer POINTERMOVE event if only a single touch is active.
  42771. */
  42772. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  42773. /**
  42774. * Called on pointer POINTERDOUBLETAP event.
  42775. */
  42776. protected onDoubleTap(type: string): void;
  42777. /**
  42778. * Called on pointer POINTERMOVE event if multiple touches are active.
  42779. */
  42780. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  42781. /**
  42782. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  42783. * press.
  42784. */
  42785. protected onButtonDown(evt: PointerEvent): void;
  42786. /**
  42787. * Called each time a new POINTERUP event occurs. Ie, for each button
  42788. * release.
  42789. */
  42790. protected onButtonUp(evt: PointerEvent): void;
  42791. /**
  42792. * Called when window becomes inactive.
  42793. */
  42794. protected onLostFocus(): void;
  42795. }
  42796. }
  42797. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  42798. import { Nullable } from "babylonjs/types";
  42799. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  42800. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  42801. /**
  42802. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  42803. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42804. */
  42805. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  42806. /**
  42807. * Defines the camera the input is attached to.
  42808. */
  42809. camera: ArcRotateCamera;
  42810. /**
  42811. * Defines the list of key codes associated with the up action (increase alpha)
  42812. */
  42813. keysUp: number[];
  42814. /**
  42815. * Defines the list of key codes associated with the down action (decrease alpha)
  42816. */
  42817. keysDown: number[];
  42818. /**
  42819. * Defines the list of key codes associated with the left action (increase beta)
  42820. */
  42821. keysLeft: number[];
  42822. /**
  42823. * Defines the list of key codes associated with the right action (decrease beta)
  42824. */
  42825. keysRight: number[];
  42826. /**
  42827. * Defines the list of key codes associated with the reset action.
  42828. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  42829. */
  42830. keysReset: number[];
  42831. /**
  42832. * Defines the panning sensibility of the inputs.
  42833. * (How fast is the camera panning)
  42834. */
  42835. panningSensibility: number;
  42836. /**
  42837. * Defines the zooming sensibility of the inputs.
  42838. * (How fast is the camera zooming)
  42839. */
  42840. zoomingSensibility: number;
  42841. /**
  42842. * Defines whether maintaining the alt key down switch the movement mode from
  42843. * orientation to zoom.
  42844. */
  42845. useAltToZoom: boolean;
  42846. /**
  42847. * Rotation speed of the camera
  42848. */
  42849. angularSpeed: number;
  42850. private _keys;
  42851. private _ctrlPressed;
  42852. private _altPressed;
  42853. private _onCanvasBlurObserver;
  42854. private _onKeyboardObserver;
  42855. private _engine;
  42856. private _scene;
  42857. /**
  42858. * Attach the input controls to a specific dom element to get the input from.
  42859. * @param element Defines the element the controls should be listened from
  42860. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42861. */
  42862. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42863. /**
  42864. * Detach the current controls from the specified dom element.
  42865. * @param element Defines the element to stop listening the inputs from
  42866. */
  42867. detachControl(element: Nullable<HTMLElement>): void;
  42868. /**
  42869. * Update the current camera state depending on the inputs that have been used this frame.
  42870. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42871. */
  42872. checkInputs(): void;
  42873. /**
  42874. * Gets the class name of the current intput.
  42875. * @returns the class name
  42876. */
  42877. getClassName(): string;
  42878. /**
  42879. * Get the friendly name associated with the input class.
  42880. * @returns the input friendly name
  42881. */
  42882. getSimpleName(): string;
  42883. }
  42884. }
  42885. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  42886. import { Nullable } from "babylonjs/types";
  42887. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  42888. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  42889. /**
  42890. * Manage the mouse wheel inputs to control an arc rotate camera.
  42891. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42892. */
  42893. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  42894. /**
  42895. * Defines the camera the input is attached to.
  42896. */
  42897. camera: ArcRotateCamera;
  42898. /**
  42899. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  42900. */
  42901. wheelPrecision: number;
  42902. /**
  42903. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  42904. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  42905. */
  42906. wheelDeltaPercentage: number;
  42907. private _wheel;
  42908. private _observer;
  42909. private computeDeltaFromMouseWheelLegacyEvent;
  42910. /**
  42911. * Attach the input controls to a specific dom element to get the input from.
  42912. * @param element Defines the element the controls should be listened from
  42913. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42914. */
  42915. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42916. /**
  42917. * Detach the current controls from the specified dom element.
  42918. * @param element Defines the element to stop listening the inputs from
  42919. */
  42920. detachControl(element: Nullable<HTMLElement>): void;
  42921. /**
  42922. * Gets the class name of the current intput.
  42923. * @returns the class name
  42924. */
  42925. getClassName(): string;
  42926. /**
  42927. * Get the friendly name associated with the input class.
  42928. * @returns the input friendly name
  42929. */
  42930. getSimpleName(): string;
  42931. }
  42932. }
  42933. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  42934. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  42935. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  42936. /**
  42937. * Default Inputs manager for the ArcRotateCamera.
  42938. * It groups all the default supported inputs for ease of use.
  42939. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42940. */
  42941. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  42942. /**
  42943. * Instantiates a new ArcRotateCameraInputsManager.
  42944. * @param camera Defines the camera the inputs belong to
  42945. */
  42946. constructor(camera: ArcRotateCamera);
  42947. /**
  42948. * Add mouse wheel input support to the input manager.
  42949. * @returns the current input manager
  42950. */
  42951. addMouseWheel(): ArcRotateCameraInputsManager;
  42952. /**
  42953. * Add pointers input support to the input manager.
  42954. * @returns the current input manager
  42955. */
  42956. addPointers(): ArcRotateCameraInputsManager;
  42957. /**
  42958. * Add keyboard input support to the input manager.
  42959. * @returns the current input manager
  42960. */
  42961. addKeyboard(): ArcRotateCameraInputsManager;
  42962. }
  42963. }
  42964. declare module "babylonjs/Cameras/arcRotateCamera" {
  42965. import { Observable } from "babylonjs/Misc/observable";
  42966. import { Nullable } from "babylonjs/types";
  42967. import { Scene } from "babylonjs/scene";
  42968. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  42969. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42970. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  42971. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  42972. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  42973. import { Camera } from "babylonjs/Cameras/camera";
  42974. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  42975. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  42976. import { Collider } from "babylonjs/Collisions/collider";
  42977. /**
  42978. * This represents an orbital type of camera.
  42979. *
  42980. * 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.
  42981. * 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.
  42982. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  42983. */
  42984. export class ArcRotateCamera extends TargetCamera {
  42985. /**
  42986. * Defines the rotation angle of the camera along the longitudinal axis.
  42987. */
  42988. alpha: number;
  42989. /**
  42990. * Defines the rotation angle of the camera along the latitudinal axis.
  42991. */
  42992. beta: number;
  42993. /**
  42994. * Defines the radius of the camera from it s target point.
  42995. */
  42996. radius: number;
  42997. protected _target: Vector3;
  42998. protected _targetHost: Nullable<AbstractMesh>;
  42999. /**
  43000. * Defines the target point of the camera.
  43001. * The camera looks towards it form the radius distance.
  43002. */
  43003. get target(): Vector3;
  43004. set target(value: Vector3);
  43005. /**
  43006. * Define the current local position of the camera in the scene
  43007. */
  43008. get position(): Vector3;
  43009. set position(newPosition: Vector3);
  43010. protected _upVector: Vector3;
  43011. protected _upToYMatrix: Matrix;
  43012. protected _YToUpMatrix: Matrix;
  43013. /**
  43014. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  43015. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  43016. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  43017. */
  43018. set upVector(vec: Vector3);
  43019. get upVector(): Vector3;
  43020. /**
  43021. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  43022. */
  43023. setMatUp(): void;
  43024. /**
  43025. * Current inertia value on the longitudinal axis.
  43026. * The bigger this number the longer it will take for the camera to stop.
  43027. */
  43028. inertialAlphaOffset: number;
  43029. /**
  43030. * Current inertia value on the latitudinal axis.
  43031. * The bigger this number the longer it will take for the camera to stop.
  43032. */
  43033. inertialBetaOffset: number;
  43034. /**
  43035. * Current inertia value on the radius axis.
  43036. * The bigger this number the longer it will take for the camera to stop.
  43037. */
  43038. inertialRadiusOffset: number;
  43039. /**
  43040. * Minimum allowed angle on the longitudinal axis.
  43041. * This can help limiting how the Camera is able to move in the scene.
  43042. */
  43043. lowerAlphaLimit: Nullable<number>;
  43044. /**
  43045. * Maximum allowed angle on the longitudinal axis.
  43046. * This can help limiting how the Camera is able to move in the scene.
  43047. */
  43048. upperAlphaLimit: Nullable<number>;
  43049. /**
  43050. * Minimum allowed angle on the latitudinal axis.
  43051. * This can help limiting how the Camera is able to move in the scene.
  43052. */
  43053. lowerBetaLimit: number;
  43054. /**
  43055. * Maximum allowed angle on the latitudinal axis.
  43056. * This can help limiting how the Camera is able to move in the scene.
  43057. */
  43058. upperBetaLimit: number;
  43059. /**
  43060. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  43061. * This can help limiting how the Camera is able to move in the scene.
  43062. */
  43063. lowerRadiusLimit: Nullable<number>;
  43064. /**
  43065. * Maximum allowed distance of the camera to the target (The camera can not get further).
  43066. * This can help limiting how the Camera is able to move in the scene.
  43067. */
  43068. upperRadiusLimit: Nullable<number>;
  43069. /**
  43070. * Defines the current inertia value used during panning of the camera along the X axis.
  43071. */
  43072. inertialPanningX: number;
  43073. /**
  43074. * Defines the current inertia value used during panning of the camera along the Y axis.
  43075. */
  43076. inertialPanningY: number;
  43077. /**
  43078. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  43079. * Basically if your fingers moves away from more than this distance you will be considered
  43080. * in pinch mode.
  43081. */
  43082. pinchToPanMaxDistance: number;
  43083. /**
  43084. * Defines the maximum distance the camera can pan.
  43085. * This could help keeping the cammera always in your scene.
  43086. */
  43087. panningDistanceLimit: Nullable<number>;
  43088. /**
  43089. * Defines the target of the camera before paning.
  43090. */
  43091. panningOriginTarget: Vector3;
  43092. /**
  43093. * Defines the value of the inertia used during panning.
  43094. * 0 would mean stop inertia and one would mean no decelleration at all.
  43095. */
  43096. panningInertia: number;
  43097. /**
  43098. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  43099. */
  43100. get angularSensibilityX(): number;
  43101. set angularSensibilityX(value: number);
  43102. /**
  43103. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  43104. */
  43105. get angularSensibilityY(): number;
  43106. set angularSensibilityY(value: number);
  43107. /**
  43108. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  43109. */
  43110. get pinchPrecision(): number;
  43111. set pinchPrecision(value: number);
  43112. /**
  43113. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  43114. * It will be used instead of pinchDeltaPrecision if different from 0.
  43115. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  43116. */
  43117. get pinchDeltaPercentage(): number;
  43118. set pinchDeltaPercentage(value: number);
  43119. /**
  43120. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  43121. * and pinch delta percentage.
  43122. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  43123. * that any object in the plane at the camera's target point will scale
  43124. * perfectly with finger motion.
  43125. */
  43126. get useNaturalPinchZoom(): boolean;
  43127. set useNaturalPinchZoom(value: boolean);
  43128. /**
  43129. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  43130. */
  43131. get panningSensibility(): number;
  43132. set panningSensibility(value: number);
  43133. /**
  43134. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  43135. */
  43136. get keysUp(): number[];
  43137. set keysUp(value: number[]);
  43138. /**
  43139. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  43140. */
  43141. get keysDown(): number[];
  43142. set keysDown(value: number[]);
  43143. /**
  43144. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  43145. */
  43146. get keysLeft(): number[];
  43147. set keysLeft(value: number[]);
  43148. /**
  43149. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  43150. */
  43151. get keysRight(): number[];
  43152. set keysRight(value: number[]);
  43153. /**
  43154. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  43155. */
  43156. get wheelPrecision(): number;
  43157. set wheelPrecision(value: number);
  43158. /**
  43159. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  43160. * It will be used instead of pinchDeltaPrecision if different from 0.
  43161. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  43162. */
  43163. get wheelDeltaPercentage(): number;
  43164. set wheelDeltaPercentage(value: number);
  43165. /**
  43166. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  43167. */
  43168. zoomOnFactor: number;
  43169. /**
  43170. * Defines a screen offset for the camera position.
  43171. */
  43172. targetScreenOffset: Vector2;
  43173. /**
  43174. * Allows the camera to be completely reversed.
  43175. * If false the camera can not arrive upside down.
  43176. */
  43177. allowUpsideDown: boolean;
  43178. /**
  43179. * Define if double tap/click is used to restore the previously saved state of the camera.
  43180. */
  43181. useInputToRestoreState: boolean;
  43182. /** @hidden */
  43183. _viewMatrix: Matrix;
  43184. /** @hidden */
  43185. _useCtrlForPanning: boolean;
  43186. /** @hidden */
  43187. _panningMouseButton: number;
  43188. /**
  43189. * Defines the input associated to the camera.
  43190. */
  43191. inputs: ArcRotateCameraInputsManager;
  43192. /** @hidden */
  43193. _reset: () => void;
  43194. /**
  43195. * Defines the allowed panning axis.
  43196. */
  43197. panningAxis: Vector3;
  43198. protected _localDirection: Vector3;
  43199. protected _transformedDirection: Vector3;
  43200. private _bouncingBehavior;
  43201. /**
  43202. * Gets the bouncing behavior of the camera if it has been enabled.
  43203. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  43204. */
  43205. get bouncingBehavior(): Nullable<BouncingBehavior>;
  43206. /**
  43207. * Defines if the bouncing behavior of the camera is enabled on the camera.
  43208. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  43209. */
  43210. get useBouncingBehavior(): boolean;
  43211. set useBouncingBehavior(value: boolean);
  43212. private _framingBehavior;
  43213. /**
  43214. * Gets the framing behavior of the camera if it has been enabled.
  43215. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  43216. */
  43217. get framingBehavior(): Nullable<FramingBehavior>;
  43218. /**
  43219. * Defines if the framing behavior of the camera is enabled on the camera.
  43220. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  43221. */
  43222. get useFramingBehavior(): boolean;
  43223. set useFramingBehavior(value: boolean);
  43224. private _autoRotationBehavior;
  43225. /**
  43226. * Gets the auto rotation behavior of the camera if it has been enabled.
  43227. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  43228. */
  43229. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  43230. /**
  43231. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  43232. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  43233. */
  43234. get useAutoRotationBehavior(): boolean;
  43235. set useAutoRotationBehavior(value: boolean);
  43236. /**
  43237. * Observable triggered when the mesh target has been changed on the camera.
  43238. */
  43239. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  43240. /**
  43241. * Event raised when the camera is colliding with a mesh.
  43242. */
  43243. onCollide: (collidedMesh: AbstractMesh) => void;
  43244. /**
  43245. * Defines whether the camera should check collision with the objects oh the scene.
  43246. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  43247. */
  43248. checkCollisions: boolean;
  43249. /**
  43250. * Defines the collision radius of the camera.
  43251. * This simulates a sphere around the camera.
  43252. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  43253. */
  43254. collisionRadius: Vector3;
  43255. protected _collider: Collider;
  43256. protected _previousPosition: Vector3;
  43257. protected _collisionVelocity: Vector3;
  43258. protected _newPosition: Vector3;
  43259. protected _previousAlpha: number;
  43260. protected _previousBeta: number;
  43261. protected _previousRadius: number;
  43262. protected _collisionTriggered: boolean;
  43263. protected _targetBoundingCenter: Nullable<Vector3>;
  43264. private _computationVector;
  43265. /**
  43266. * Instantiates a new ArcRotateCamera in a given scene
  43267. * @param name Defines the name of the camera
  43268. * @param alpha Defines the camera rotation along the logitudinal axis
  43269. * @param beta Defines the camera rotation along the latitudinal axis
  43270. * @param radius Defines the camera distance from its target
  43271. * @param target Defines the camera target
  43272. * @param scene Defines the scene the camera belongs to
  43273. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  43274. */
  43275. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  43276. /** @hidden */
  43277. _initCache(): void;
  43278. /** @hidden */
  43279. _updateCache(ignoreParentClass?: boolean): void;
  43280. protected _getTargetPosition(): Vector3;
  43281. private _storedAlpha;
  43282. private _storedBeta;
  43283. private _storedRadius;
  43284. private _storedTarget;
  43285. private _storedTargetScreenOffset;
  43286. /**
  43287. * Stores the current state of the camera (alpha, beta, radius and target)
  43288. * @returns the camera itself
  43289. */
  43290. storeState(): Camera;
  43291. /**
  43292. * @hidden
  43293. * Restored camera state. You must call storeState() first
  43294. */
  43295. _restoreStateValues(): boolean;
  43296. /** @hidden */
  43297. _isSynchronizedViewMatrix(): boolean;
  43298. /**
  43299. * Attached controls to the current camera.
  43300. * @param element Defines the element the controls should be listened from
  43301. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43302. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  43303. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  43304. */
  43305. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  43306. /**
  43307. * Detach the current controls from the camera.
  43308. * The camera will stop reacting to inputs.
  43309. * @param element Defines the element to stop listening the inputs from
  43310. */
  43311. detachControl(element: HTMLElement): void;
  43312. /** @hidden */
  43313. _checkInputs(): void;
  43314. protected _checkLimits(): void;
  43315. /**
  43316. * Rebuilds angles (alpha, beta) and radius from the give position and target
  43317. */
  43318. rebuildAnglesAndRadius(): void;
  43319. /**
  43320. * Use a position to define the current camera related information like alpha, beta and radius
  43321. * @param position Defines the position to set the camera at
  43322. */
  43323. setPosition(position: Vector3): void;
  43324. /**
  43325. * Defines the target the camera should look at.
  43326. * This will automatically adapt alpha beta and radius to fit within the new target.
  43327. * @param target Defines the new target as a Vector or a mesh
  43328. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  43329. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  43330. */
  43331. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  43332. /** @hidden */
  43333. _getViewMatrix(): Matrix;
  43334. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  43335. /**
  43336. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  43337. * @param meshes Defines the mesh to zoom on
  43338. * @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)
  43339. */
  43340. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  43341. /**
  43342. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  43343. * The target will be changed but the radius
  43344. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  43345. * @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)
  43346. */
  43347. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  43348. min: Vector3;
  43349. max: Vector3;
  43350. distance: number;
  43351. }, doNotUpdateMaxZ?: boolean): void;
  43352. /**
  43353. * @override
  43354. * Override Camera.createRigCamera
  43355. */
  43356. createRigCamera(name: string, cameraIndex: number): Camera;
  43357. /**
  43358. * @hidden
  43359. * @override
  43360. * Override Camera._updateRigCameras
  43361. */
  43362. _updateRigCameras(): void;
  43363. /**
  43364. * Destroy the camera and release the current resources hold by it.
  43365. */
  43366. dispose(): void;
  43367. /**
  43368. * Gets the current object class name.
  43369. * @return the class name
  43370. */
  43371. getClassName(): string;
  43372. }
  43373. }
  43374. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  43375. import { Behavior } from "babylonjs/Behaviors/behavior";
  43376. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43377. /**
  43378. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  43379. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  43380. */
  43381. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  43382. /**
  43383. * Gets the name of the behavior.
  43384. */
  43385. get name(): string;
  43386. private _zoomStopsAnimation;
  43387. private _idleRotationSpeed;
  43388. private _idleRotationWaitTime;
  43389. private _idleRotationSpinupTime;
  43390. /**
  43391. * Sets the flag that indicates if user zooming should stop animation.
  43392. */
  43393. set zoomStopsAnimation(flag: boolean);
  43394. /**
  43395. * Gets the flag that indicates if user zooming should stop animation.
  43396. */
  43397. get zoomStopsAnimation(): boolean;
  43398. /**
  43399. * Sets the default speed at which the camera rotates around the model.
  43400. */
  43401. set idleRotationSpeed(speed: number);
  43402. /**
  43403. * Gets the default speed at which the camera rotates around the model.
  43404. */
  43405. get idleRotationSpeed(): number;
  43406. /**
  43407. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  43408. */
  43409. set idleRotationWaitTime(time: number);
  43410. /**
  43411. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  43412. */
  43413. get idleRotationWaitTime(): number;
  43414. /**
  43415. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  43416. */
  43417. set idleRotationSpinupTime(time: number);
  43418. /**
  43419. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  43420. */
  43421. get idleRotationSpinupTime(): number;
  43422. /**
  43423. * Gets a value indicating if the camera is currently rotating because of this behavior
  43424. */
  43425. get rotationInProgress(): boolean;
  43426. private _onPrePointerObservableObserver;
  43427. private _onAfterCheckInputsObserver;
  43428. private _attachedCamera;
  43429. private _isPointerDown;
  43430. private _lastFrameTime;
  43431. private _lastInteractionTime;
  43432. private _cameraRotationSpeed;
  43433. /**
  43434. * Initializes the behavior.
  43435. */
  43436. init(): void;
  43437. /**
  43438. * Attaches the behavior to its arc rotate camera.
  43439. * @param camera Defines the camera to attach the behavior to
  43440. */
  43441. attach(camera: ArcRotateCamera): void;
  43442. /**
  43443. * Detaches the behavior from its current arc rotate camera.
  43444. */
  43445. detach(): void;
  43446. /**
  43447. * Returns true if user is scrolling.
  43448. * @return true if user is scrolling.
  43449. */
  43450. private _userIsZooming;
  43451. private _lastFrameRadius;
  43452. private _shouldAnimationStopForInteraction;
  43453. /**
  43454. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  43455. */
  43456. private _applyUserInteraction;
  43457. private _userIsMoving;
  43458. }
  43459. }
  43460. declare module "babylonjs/Behaviors/Cameras/index" {
  43461. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  43462. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  43463. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  43464. }
  43465. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  43466. import { Mesh } from "babylonjs/Meshes/mesh";
  43467. import { TransformNode } from "babylonjs/Meshes/transformNode";
  43468. import { Behavior } from "babylonjs/Behaviors/behavior";
  43469. /**
  43470. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  43471. */
  43472. export class AttachToBoxBehavior implements Behavior<Mesh> {
  43473. private ui;
  43474. /**
  43475. * The name of the behavior
  43476. */
  43477. name: string;
  43478. /**
  43479. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  43480. */
  43481. distanceAwayFromFace: number;
  43482. /**
  43483. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  43484. */
  43485. distanceAwayFromBottomOfFace: number;
  43486. private _faceVectors;
  43487. private _target;
  43488. private _scene;
  43489. private _onRenderObserver;
  43490. private _tmpMatrix;
  43491. private _tmpVector;
  43492. /**
  43493. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  43494. * @param ui The transform node that should be attched to the mesh
  43495. */
  43496. constructor(ui: TransformNode);
  43497. /**
  43498. * Initializes the behavior
  43499. */
  43500. init(): void;
  43501. private _closestFace;
  43502. private _zeroVector;
  43503. private _lookAtTmpMatrix;
  43504. private _lookAtToRef;
  43505. /**
  43506. * Attaches the AttachToBoxBehavior to the passed in mesh
  43507. * @param target The mesh that the specified node will be attached to
  43508. */
  43509. attach(target: Mesh): void;
  43510. /**
  43511. * Detaches the behavior from the mesh
  43512. */
  43513. detach(): void;
  43514. }
  43515. }
  43516. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  43517. import { Behavior } from "babylonjs/Behaviors/behavior";
  43518. import { Mesh } from "babylonjs/Meshes/mesh";
  43519. /**
  43520. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  43521. */
  43522. export class FadeInOutBehavior implements Behavior<Mesh> {
  43523. /**
  43524. * Time in milliseconds to delay before fading in (Default: 0)
  43525. */
  43526. delay: number;
  43527. /**
  43528. * Time in milliseconds for the mesh to fade in (Default: 300)
  43529. */
  43530. fadeInTime: number;
  43531. private _millisecondsPerFrame;
  43532. private _hovered;
  43533. private _hoverValue;
  43534. private _ownerNode;
  43535. /**
  43536. * Instatiates the FadeInOutBehavior
  43537. */
  43538. constructor();
  43539. /**
  43540. * The name of the behavior
  43541. */
  43542. get name(): string;
  43543. /**
  43544. * Initializes the behavior
  43545. */
  43546. init(): void;
  43547. /**
  43548. * Attaches the fade behavior on the passed in mesh
  43549. * @param ownerNode The mesh that will be faded in/out once attached
  43550. */
  43551. attach(ownerNode: Mesh): void;
  43552. /**
  43553. * Detaches the behavior from the mesh
  43554. */
  43555. detach(): void;
  43556. /**
  43557. * Triggers the mesh to begin fading in or out
  43558. * @param value if the object should fade in or out (true to fade in)
  43559. */
  43560. fadeIn(value: boolean): void;
  43561. private _update;
  43562. private _setAllVisibility;
  43563. }
  43564. }
  43565. declare module "babylonjs/Misc/pivotTools" {
  43566. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43567. /**
  43568. * Class containing a set of static utilities functions for managing Pivots
  43569. * @hidden
  43570. */
  43571. export class PivotTools {
  43572. private static _PivotCached;
  43573. private static _OldPivotPoint;
  43574. private static _PivotTranslation;
  43575. private static _PivotTmpVector;
  43576. /** @hidden */
  43577. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  43578. /** @hidden */
  43579. static _RestorePivotPoint(mesh: AbstractMesh): void;
  43580. }
  43581. }
  43582. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  43583. import { Scene } from "babylonjs/scene";
  43584. import { Vector4 } from "babylonjs/Maths/math.vector";
  43585. import { Mesh } from "babylonjs/Meshes/mesh";
  43586. import { Nullable } from "babylonjs/types";
  43587. import { Plane } from "babylonjs/Maths/math.plane";
  43588. /**
  43589. * Class containing static functions to help procedurally build meshes
  43590. */
  43591. export class PlaneBuilder {
  43592. /**
  43593. * Creates a plane mesh
  43594. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  43595. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  43596. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  43597. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43598. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43599. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43600. * @param name defines the name of the mesh
  43601. * @param options defines the options used to create the mesh
  43602. * @param scene defines the hosting scene
  43603. * @returns the plane mesh
  43604. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  43605. */
  43606. static CreatePlane(name: string, options: {
  43607. size?: number;
  43608. width?: number;
  43609. height?: number;
  43610. sideOrientation?: number;
  43611. frontUVs?: Vector4;
  43612. backUVs?: Vector4;
  43613. updatable?: boolean;
  43614. sourcePlane?: Plane;
  43615. }, scene?: Nullable<Scene>): Mesh;
  43616. }
  43617. }
  43618. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  43619. import { Behavior } from "babylonjs/Behaviors/behavior";
  43620. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43621. import { Observable } from "babylonjs/Misc/observable";
  43622. import { Vector3 } from "babylonjs/Maths/math.vector";
  43623. import { Ray } from "babylonjs/Culling/ray";
  43624. import "babylonjs/Meshes/Builders/planeBuilder";
  43625. /**
  43626. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  43627. */
  43628. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  43629. private static _AnyMouseID;
  43630. /**
  43631. * Abstract mesh the behavior is set on
  43632. */
  43633. attachedNode: AbstractMesh;
  43634. private _dragPlane;
  43635. private _scene;
  43636. private _pointerObserver;
  43637. private _beforeRenderObserver;
  43638. private static _planeScene;
  43639. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  43640. /**
  43641. * 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)
  43642. */
  43643. maxDragAngle: number;
  43644. /**
  43645. * @hidden
  43646. */
  43647. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  43648. /**
  43649. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  43650. */
  43651. currentDraggingPointerID: number;
  43652. /**
  43653. * The last position where the pointer hit the drag plane in world space
  43654. */
  43655. lastDragPosition: Vector3;
  43656. /**
  43657. * If the behavior is currently in a dragging state
  43658. */
  43659. dragging: boolean;
  43660. /**
  43661. * 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)
  43662. */
  43663. dragDeltaRatio: number;
  43664. /**
  43665. * If the drag plane orientation should be updated during the dragging (Default: true)
  43666. */
  43667. updateDragPlane: boolean;
  43668. private _debugMode;
  43669. private _moving;
  43670. /**
  43671. * Fires each time the attached mesh is dragged with the pointer
  43672. * * delta between last drag position and current drag position in world space
  43673. * * dragDistance along the drag axis
  43674. * * dragPlaneNormal normal of the current drag plane used during the drag
  43675. * * dragPlanePoint in world space where the drag intersects the drag plane
  43676. */
  43677. onDragObservable: Observable<{
  43678. delta: Vector3;
  43679. dragPlanePoint: Vector3;
  43680. dragPlaneNormal: Vector3;
  43681. dragDistance: number;
  43682. pointerId: number;
  43683. }>;
  43684. /**
  43685. * Fires each time a drag begins (eg. mouse down on mesh)
  43686. */
  43687. onDragStartObservable: Observable<{
  43688. dragPlanePoint: Vector3;
  43689. pointerId: number;
  43690. }>;
  43691. /**
  43692. * Fires each time a drag ends (eg. mouse release after drag)
  43693. */
  43694. onDragEndObservable: Observable<{
  43695. dragPlanePoint: Vector3;
  43696. pointerId: number;
  43697. }>;
  43698. /**
  43699. * If the attached mesh should be moved when dragged
  43700. */
  43701. moveAttached: boolean;
  43702. /**
  43703. * If the drag behavior will react to drag events (Default: true)
  43704. */
  43705. enabled: boolean;
  43706. /**
  43707. * If pointer events should start and release the drag (Default: true)
  43708. */
  43709. startAndReleaseDragOnPointerEvents: boolean;
  43710. /**
  43711. * If camera controls should be detached during the drag
  43712. */
  43713. detachCameraControls: boolean;
  43714. /**
  43715. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  43716. */
  43717. useObjectOrientationForDragging: boolean;
  43718. private _options;
  43719. /**
  43720. * Gets the options used by the behavior
  43721. */
  43722. get options(): {
  43723. dragAxis?: Vector3;
  43724. dragPlaneNormal?: Vector3;
  43725. };
  43726. /**
  43727. * Sets the options used by the behavior
  43728. */
  43729. set options(options: {
  43730. dragAxis?: Vector3;
  43731. dragPlaneNormal?: Vector3;
  43732. });
  43733. /**
  43734. * Creates a pointer drag behavior that can be attached to a mesh
  43735. * @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)
  43736. */
  43737. constructor(options?: {
  43738. dragAxis?: Vector3;
  43739. dragPlaneNormal?: Vector3;
  43740. });
  43741. /**
  43742. * Predicate to determine if it is valid to move the object to a new position when it is moved
  43743. */
  43744. validateDrag: (targetPosition: Vector3) => boolean;
  43745. /**
  43746. * The name of the behavior
  43747. */
  43748. get name(): string;
  43749. /**
  43750. * Initializes the behavior
  43751. */
  43752. init(): void;
  43753. private _tmpVector;
  43754. private _alternatePickedPoint;
  43755. private _worldDragAxis;
  43756. private _targetPosition;
  43757. private _attachedElement;
  43758. /**
  43759. * Attaches the drag behavior the passed in mesh
  43760. * @param ownerNode The mesh that will be dragged around once attached
  43761. * @param predicate Predicate to use for pick filtering
  43762. */
  43763. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  43764. /**
  43765. * Force relase the drag action by code.
  43766. */
  43767. releaseDrag(): void;
  43768. private _startDragRay;
  43769. private _lastPointerRay;
  43770. /**
  43771. * Simulates the start of a pointer drag event on the behavior
  43772. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  43773. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  43774. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  43775. */
  43776. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  43777. private _startDrag;
  43778. private _dragDelta;
  43779. private _moveDrag;
  43780. private _pickWithRayOnDragPlane;
  43781. private _pointA;
  43782. private _pointB;
  43783. private _pointC;
  43784. private _lineA;
  43785. private _lineB;
  43786. private _localAxis;
  43787. private _lookAt;
  43788. private _updateDragPlanePosition;
  43789. /**
  43790. * Detaches the behavior from the mesh
  43791. */
  43792. detach(): void;
  43793. }
  43794. }
  43795. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  43796. import { Mesh } from "babylonjs/Meshes/mesh";
  43797. import { Behavior } from "babylonjs/Behaviors/behavior";
  43798. /**
  43799. * A behavior that when attached to a mesh will allow the mesh to be scaled
  43800. */
  43801. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  43802. private _dragBehaviorA;
  43803. private _dragBehaviorB;
  43804. private _startDistance;
  43805. private _initialScale;
  43806. private _targetScale;
  43807. private _ownerNode;
  43808. private _sceneRenderObserver;
  43809. /**
  43810. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  43811. */
  43812. constructor();
  43813. /**
  43814. * The name of the behavior
  43815. */
  43816. get name(): string;
  43817. /**
  43818. * Initializes the behavior
  43819. */
  43820. init(): void;
  43821. private _getCurrentDistance;
  43822. /**
  43823. * Attaches the scale behavior the passed in mesh
  43824. * @param ownerNode The mesh that will be scaled around once attached
  43825. */
  43826. attach(ownerNode: Mesh): void;
  43827. /**
  43828. * Detaches the behavior from the mesh
  43829. */
  43830. detach(): void;
  43831. }
  43832. }
  43833. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  43834. import { Behavior } from "babylonjs/Behaviors/behavior";
  43835. import { Mesh } from "babylonjs/Meshes/mesh";
  43836. import { Observable } from "babylonjs/Misc/observable";
  43837. /**
  43838. * 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
  43839. */
  43840. export class SixDofDragBehavior implements Behavior<Mesh> {
  43841. private static _virtualScene;
  43842. private _ownerNode;
  43843. private _sceneRenderObserver;
  43844. private _scene;
  43845. private _targetPosition;
  43846. private _virtualOriginMesh;
  43847. private _virtualDragMesh;
  43848. private _pointerObserver;
  43849. private _moving;
  43850. private _startingOrientation;
  43851. private _attachedElement;
  43852. /**
  43853. * 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)
  43854. */
  43855. private zDragFactor;
  43856. /**
  43857. * If the object should rotate to face the drag origin
  43858. */
  43859. rotateDraggedObject: boolean;
  43860. /**
  43861. * If the behavior is currently in a dragging state
  43862. */
  43863. dragging: boolean;
  43864. /**
  43865. * 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)
  43866. */
  43867. dragDeltaRatio: number;
  43868. /**
  43869. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  43870. */
  43871. currentDraggingPointerID: number;
  43872. /**
  43873. * If camera controls should be detached during the drag
  43874. */
  43875. detachCameraControls: boolean;
  43876. /**
  43877. * Fires each time a drag starts
  43878. */
  43879. onDragStartObservable: Observable<{}>;
  43880. /**
  43881. * Fires each time a drag ends (eg. mouse release after drag)
  43882. */
  43883. onDragEndObservable: Observable<{}>;
  43884. /**
  43885. * 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
  43886. */
  43887. constructor();
  43888. /**
  43889. * The name of the behavior
  43890. */
  43891. get name(): string;
  43892. /**
  43893. * Initializes the behavior
  43894. */
  43895. init(): void;
  43896. /**
  43897. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  43898. */
  43899. private get _pointerCamera();
  43900. /**
  43901. * Attaches the scale behavior the passed in mesh
  43902. * @param ownerNode The mesh that will be scaled around once attached
  43903. */
  43904. attach(ownerNode: Mesh): void;
  43905. /**
  43906. * Detaches the behavior from the mesh
  43907. */
  43908. detach(): void;
  43909. }
  43910. }
  43911. declare module "babylonjs/Behaviors/Meshes/index" {
  43912. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  43913. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  43914. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  43915. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  43916. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  43917. }
  43918. declare module "babylonjs/Behaviors/index" {
  43919. export * from "babylonjs/Behaviors/behavior";
  43920. export * from "babylonjs/Behaviors/Cameras/index";
  43921. export * from "babylonjs/Behaviors/Meshes/index";
  43922. }
  43923. declare module "babylonjs/Bones/boneIKController" {
  43924. import { Bone } from "babylonjs/Bones/bone";
  43925. import { Vector3 } from "babylonjs/Maths/math.vector";
  43926. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43927. import { Nullable } from "babylonjs/types";
  43928. /**
  43929. * Class used to apply inverse kinematics to bones
  43930. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  43931. */
  43932. export class BoneIKController {
  43933. private static _tmpVecs;
  43934. private static _tmpQuat;
  43935. private static _tmpMats;
  43936. /**
  43937. * Gets or sets the target mesh
  43938. */
  43939. targetMesh: AbstractMesh;
  43940. /** Gets or sets the mesh used as pole */
  43941. poleTargetMesh: AbstractMesh;
  43942. /**
  43943. * Gets or sets the bone used as pole
  43944. */
  43945. poleTargetBone: Nullable<Bone>;
  43946. /**
  43947. * Gets or sets the target position
  43948. */
  43949. targetPosition: Vector3;
  43950. /**
  43951. * Gets or sets the pole target position
  43952. */
  43953. poleTargetPosition: Vector3;
  43954. /**
  43955. * Gets or sets the pole target local offset
  43956. */
  43957. poleTargetLocalOffset: Vector3;
  43958. /**
  43959. * Gets or sets the pole angle
  43960. */
  43961. poleAngle: number;
  43962. /**
  43963. * Gets or sets the mesh associated with the controller
  43964. */
  43965. mesh: AbstractMesh;
  43966. /**
  43967. * 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)
  43968. */
  43969. slerpAmount: number;
  43970. private _bone1Quat;
  43971. private _bone1Mat;
  43972. private _bone2Ang;
  43973. private _bone1;
  43974. private _bone2;
  43975. private _bone1Length;
  43976. private _bone2Length;
  43977. private _maxAngle;
  43978. private _maxReach;
  43979. private _rightHandedSystem;
  43980. private _bendAxis;
  43981. private _slerping;
  43982. private _adjustRoll;
  43983. /**
  43984. * Gets or sets maximum allowed angle
  43985. */
  43986. get maxAngle(): number;
  43987. set maxAngle(value: number);
  43988. /**
  43989. * Creates a new BoneIKController
  43990. * @param mesh defines the mesh to control
  43991. * @param bone defines the bone to control
  43992. * @param options defines options to set up the controller
  43993. */
  43994. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  43995. targetMesh?: AbstractMesh;
  43996. poleTargetMesh?: AbstractMesh;
  43997. poleTargetBone?: Bone;
  43998. poleTargetLocalOffset?: Vector3;
  43999. poleAngle?: number;
  44000. bendAxis?: Vector3;
  44001. maxAngle?: number;
  44002. slerpAmount?: number;
  44003. });
  44004. private _setMaxAngle;
  44005. /**
  44006. * Force the controller to update the bones
  44007. */
  44008. update(): void;
  44009. }
  44010. }
  44011. declare module "babylonjs/Bones/boneLookController" {
  44012. import { Vector3 } from "babylonjs/Maths/math.vector";
  44013. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44014. import { Bone } from "babylonjs/Bones/bone";
  44015. import { Space } from "babylonjs/Maths/math.axis";
  44016. /**
  44017. * Class used to make a bone look toward a point in space
  44018. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  44019. */
  44020. export class BoneLookController {
  44021. private static _tmpVecs;
  44022. private static _tmpQuat;
  44023. private static _tmpMats;
  44024. /**
  44025. * The target Vector3 that the bone will look at
  44026. */
  44027. target: Vector3;
  44028. /**
  44029. * The mesh that the bone is attached to
  44030. */
  44031. mesh: AbstractMesh;
  44032. /**
  44033. * The bone that will be looking to the target
  44034. */
  44035. bone: Bone;
  44036. /**
  44037. * The up axis of the coordinate system that is used when the bone is rotated
  44038. */
  44039. upAxis: Vector3;
  44040. /**
  44041. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  44042. */
  44043. upAxisSpace: Space;
  44044. /**
  44045. * Used to make an adjustment to the yaw of the bone
  44046. */
  44047. adjustYaw: number;
  44048. /**
  44049. * Used to make an adjustment to the pitch of the bone
  44050. */
  44051. adjustPitch: number;
  44052. /**
  44053. * Used to make an adjustment to the roll of the bone
  44054. */
  44055. adjustRoll: number;
  44056. /**
  44057. * 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)
  44058. */
  44059. slerpAmount: number;
  44060. private _minYaw;
  44061. private _maxYaw;
  44062. private _minPitch;
  44063. private _maxPitch;
  44064. private _minYawSin;
  44065. private _minYawCos;
  44066. private _maxYawSin;
  44067. private _maxYawCos;
  44068. private _midYawConstraint;
  44069. private _minPitchTan;
  44070. private _maxPitchTan;
  44071. private _boneQuat;
  44072. private _slerping;
  44073. private _transformYawPitch;
  44074. private _transformYawPitchInv;
  44075. private _firstFrameSkipped;
  44076. private _yawRange;
  44077. private _fowardAxis;
  44078. /**
  44079. * Gets or sets the minimum yaw angle that the bone can look to
  44080. */
  44081. get minYaw(): number;
  44082. set minYaw(value: number);
  44083. /**
  44084. * Gets or sets the maximum yaw angle that the bone can look to
  44085. */
  44086. get maxYaw(): number;
  44087. set maxYaw(value: number);
  44088. /**
  44089. * Gets or sets the minimum pitch angle that the bone can look to
  44090. */
  44091. get minPitch(): number;
  44092. set minPitch(value: number);
  44093. /**
  44094. * Gets or sets the maximum pitch angle that the bone can look to
  44095. */
  44096. get maxPitch(): number;
  44097. set maxPitch(value: number);
  44098. /**
  44099. * Create a BoneLookController
  44100. * @param mesh the mesh that the bone belongs to
  44101. * @param bone the bone that will be looking to the target
  44102. * @param target the target Vector3 to look at
  44103. * @param options optional settings:
  44104. * * maxYaw: the maximum angle the bone will yaw to
  44105. * * minYaw: the minimum angle the bone will yaw to
  44106. * * maxPitch: the maximum angle the bone will pitch to
  44107. * * minPitch: the minimum angle the bone will yaw to
  44108. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  44109. * * upAxis: the up axis of the coordinate system
  44110. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  44111. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  44112. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  44113. * * adjustYaw: used to make an adjustment to the yaw of the bone
  44114. * * adjustPitch: used to make an adjustment to the pitch of the bone
  44115. * * adjustRoll: used to make an adjustment to the roll of the bone
  44116. **/
  44117. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  44118. maxYaw?: number;
  44119. minYaw?: number;
  44120. maxPitch?: number;
  44121. minPitch?: number;
  44122. slerpAmount?: number;
  44123. upAxis?: Vector3;
  44124. upAxisSpace?: Space;
  44125. yawAxis?: Vector3;
  44126. pitchAxis?: Vector3;
  44127. adjustYaw?: number;
  44128. adjustPitch?: number;
  44129. adjustRoll?: number;
  44130. });
  44131. /**
  44132. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  44133. */
  44134. update(): void;
  44135. private _getAngleDiff;
  44136. private _getAngleBetween;
  44137. private _isAngleBetween;
  44138. }
  44139. }
  44140. declare module "babylonjs/Bones/index" {
  44141. export * from "babylonjs/Bones/bone";
  44142. export * from "babylonjs/Bones/boneIKController";
  44143. export * from "babylonjs/Bones/boneLookController";
  44144. export * from "babylonjs/Bones/skeleton";
  44145. }
  44146. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  44147. import { Nullable } from "babylonjs/types";
  44148. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44149. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44150. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  44151. /**
  44152. * Manage the gamepad inputs to control an arc rotate camera.
  44153. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  44154. */
  44155. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  44156. /**
  44157. * Defines the camera the input is attached to.
  44158. */
  44159. camera: ArcRotateCamera;
  44160. /**
  44161. * Defines the gamepad the input is gathering event from.
  44162. */
  44163. gamepad: Nullable<Gamepad>;
  44164. /**
  44165. * Defines the gamepad rotation sensiblity.
  44166. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  44167. */
  44168. gamepadRotationSensibility: number;
  44169. /**
  44170. * Defines the gamepad move sensiblity.
  44171. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  44172. */
  44173. gamepadMoveSensibility: number;
  44174. private _yAxisScale;
  44175. /**
  44176. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  44177. */
  44178. get invertYAxis(): boolean;
  44179. set invertYAxis(value: boolean);
  44180. private _onGamepadConnectedObserver;
  44181. private _onGamepadDisconnectedObserver;
  44182. /**
  44183. * Attach the input controls to a specific dom element to get the input from.
  44184. * @param element Defines the element the controls should be listened from
  44185. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44186. */
  44187. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44188. /**
  44189. * Detach the current controls from the specified dom element.
  44190. * @param element Defines the element to stop listening the inputs from
  44191. */
  44192. detachControl(element: Nullable<HTMLElement>): void;
  44193. /**
  44194. * Update the current camera state depending on the inputs that have been used this frame.
  44195. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44196. */
  44197. checkInputs(): void;
  44198. /**
  44199. * Gets the class name of the current intput.
  44200. * @returns the class name
  44201. */
  44202. getClassName(): string;
  44203. /**
  44204. * Get the friendly name associated with the input class.
  44205. * @returns the input friendly name
  44206. */
  44207. getSimpleName(): string;
  44208. }
  44209. }
  44210. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  44211. import { Nullable } from "babylonjs/types";
  44212. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44213. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44214. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  44215. interface ArcRotateCameraInputsManager {
  44216. /**
  44217. * Add orientation input support to the input manager.
  44218. * @returns the current input manager
  44219. */
  44220. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  44221. }
  44222. }
  44223. /**
  44224. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  44225. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  44226. */
  44227. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  44228. /**
  44229. * Defines the camera the input is attached to.
  44230. */
  44231. camera: ArcRotateCamera;
  44232. /**
  44233. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  44234. */
  44235. alphaCorrection: number;
  44236. /**
  44237. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  44238. */
  44239. gammaCorrection: number;
  44240. private _alpha;
  44241. private _gamma;
  44242. private _dirty;
  44243. private _deviceOrientationHandler;
  44244. /**
  44245. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  44246. */
  44247. constructor();
  44248. /**
  44249. * Attach the input controls to a specific dom element to get the input from.
  44250. * @param element Defines the element the controls should be listened from
  44251. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44252. */
  44253. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44254. /** @hidden */
  44255. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  44256. /**
  44257. * Update the current camera state depending on the inputs that have been used this frame.
  44258. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44259. */
  44260. checkInputs(): void;
  44261. /**
  44262. * Detach the current controls from the specified dom element.
  44263. * @param element Defines the element to stop listening the inputs from
  44264. */
  44265. detachControl(element: Nullable<HTMLElement>): void;
  44266. /**
  44267. * Gets the class name of the current intput.
  44268. * @returns the class name
  44269. */
  44270. getClassName(): string;
  44271. /**
  44272. * Get the friendly name associated with the input class.
  44273. * @returns the input friendly name
  44274. */
  44275. getSimpleName(): string;
  44276. }
  44277. }
  44278. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  44279. import { Nullable } from "babylonjs/types";
  44280. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44281. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  44282. /**
  44283. * Listen to mouse events to control the camera.
  44284. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  44285. */
  44286. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  44287. /**
  44288. * Defines the camera the input is attached to.
  44289. */
  44290. camera: FlyCamera;
  44291. /**
  44292. * Defines if touch is enabled. (Default is true.)
  44293. */
  44294. touchEnabled: boolean;
  44295. /**
  44296. * Defines the buttons associated with the input to handle camera rotation.
  44297. */
  44298. buttons: number[];
  44299. /**
  44300. * Assign buttons for Yaw control.
  44301. */
  44302. buttonsYaw: number[];
  44303. /**
  44304. * Assign buttons for Pitch control.
  44305. */
  44306. buttonsPitch: number[];
  44307. /**
  44308. * Assign buttons for Roll control.
  44309. */
  44310. buttonsRoll: number[];
  44311. /**
  44312. * Detect if any button is being pressed while mouse is moved.
  44313. * -1 = Mouse locked.
  44314. * 0 = Left button.
  44315. * 1 = Middle Button.
  44316. * 2 = Right Button.
  44317. */
  44318. activeButton: number;
  44319. /**
  44320. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  44321. * Higher values reduce its sensitivity.
  44322. */
  44323. angularSensibility: number;
  44324. private _mousemoveCallback;
  44325. private _observer;
  44326. private _rollObserver;
  44327. private previousPosition;
  44328. private noPreventDefault;
  44329. private element;
  44330. /**
  44331. * Listen to mouse events to control the camera.
  44332. * @param touchEnabled Define if touch is enabled. (Default is true.)
  44333. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  44334. */
  44335. constructor(touchEnabled?: boolean);
  44336. /**
  44337. * Attach the mouse control to the HTML DOM element.
  44338. * @param element Defines the element that listens to the input events.
  44339. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  44340. */
  44341. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44342. /**
  44343. * Detach the current controls from the specified dom element.
  44344. * @param element Defines the element to stop listening the inputs from
  44345. */
  44346. detachControl(element: Nullable<HTMLElement>): void;
  44347. /**
  44348. * Gets the class name of the current input.
  44349. * @returns the class name.
  44350. */
  44351. getClassName(): string;
  44352. /**
  44353. * Get the friendly name associated with the input class.
  44354. * @returns the input's friendly name.
  44355. */
  44356. getSimpleName(): string;
  44357. private _pointerInput;
  44358. private _onMouseMove;
  44359. /**
  44360. * Rotate camera by mouse offset.
  44361. */
  44362. private rotateCamera;
  44363. }
  44364. }
  44365. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  44366. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  44367. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  44368. /**
  44369. * Default Inputs manager for the FlyCamera.
  44370. * It groups all the default supported inputs for ease of use.
  44371. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  44372. */
  44373. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  44374. /**
  44375. * Instantiates a new FlyCameraInputsManager.
  44376. * @param camera Defines the camera the inputs belong to.
  44377. */
  44378. constructor(camera: FlyCamera);
  44379. /**
  44380. * Add keyboard input support to the input manager.
  44381. * @returns the new FlyCameraKeyboardMoveInput().
  44382. */
  44383. addKeyboard(): FlyCameraInputsManager;
  44384. /**
  44385. * Add mouse input support to the input manager.
  44386. * @param touchEnabled Enable touch screen support.
  44387. * @returns the new FlyCameraMouseInput().
  44388. */
  44389. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  44390. }
  44391. }
  44392. declare module "babylonjs/Cameras/flyCamera" {
  44393. import { Scene } from "babylonjs/scene";
  44394. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  44395. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44396. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  44397. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  44398. /**
  44399. * This is a flying camera, designed for 3D movement and rotation in all directions,
  44400. * such as in a 3D Space Shooter or a Flight Simulator.
  44401. */
  44402. export class FlyCamera extends TargetCamera {
  44403. /**
  44404. * Define the collision ellipsoid of the camera.
  44405. * This is helpful for simulating a camera body, like a player's body.
  44406. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  44407. */
  44408. ellipsoid: Vector3;
  44409. /**
  44410. * Define an offset for the position of the ellipsoid around the camera.
  44411. * This can be helpful if the camera is attached away from the player's body center,
  44412. * such as at its head.
  44413. */
  44414. ellipsoidOffset: Vector3;
  44415. /**
  44416. * Enable or disable collisions of the camera with the rest of the scene objects.
  44417. */
  44418. checkCollisions: boolean;
  44419. /**
  44420. * Enable or disable gravity on the camera.
  44421. */
  44422. applyGravity: boolean;
  44423. /**
  44424. * Define the current direction the camera is moving to.
  44425. */
  44426. cameraDirection: Vector3;
  44427. /**
  44428. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  44429. * This overrides and empties cameraRotation.
  44430. */
  44431. rotationQuaternion: Quaternion;
  44432. /**
  44433. * Track Roll to maintain the wanted Rolling when looking around.
  44434. */
  44435. _trackRoll: number;
  44436. /**
  44437. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  44438. */
  44439. rollCorrect: number;
  44440. /**
  44441. * Mimic a banked turn, Rolling the camera when Yawing.
  44442. * It's recommended to use rollCorrect = 10 for faster banking correction.
  44443. */
  44444. bankedTurn: boolean;
  44445. /**
  44446. * Limit in radians for how much Roll banking will add. (Default: 90°)
  44447. */
  44448. bankedTurnLimit: number;
  44449. /**
  44450. * Value of 0 disables the banked Roll.
  44451. * Value of 1 is equal to the Yaw angle in radians.
  44452. */
  44453. bankedTurnMultiplier: number;
  44454. /**
  44455. * The inputs manager loads all the input sources, such as keyboard and mouse.
  44456. */
  44457. inputs: FlyCameraInputsManager;
  44458. /**
  44459. * Gets the input sensibility for mouse input.
  44460. * Higher values reduce sensitivity.
  44461. */
  44462. get angularSensibility(): number;
  44463. /**
  44464. * Sets the input sensibility for a mouse input.
  44465. * Higher values reduce sensitivity.
  44466. */
  44467. set angularSensibility(value: number);
  44468. /**
  44469. * Get the keys for camera movement forward.
  44470. */
  44471. get keysForward(): number[];
  44472. /**
  44473. * Set the keys for camera movement forward.
  44474. */
  44475. set keysForward(value: number[]);
  44476. /**
  44477. * Get the keys for camera movement backward.
  44478. */
  44479. get keysBackward(): number[];
  44480. set keysBackward(value: number[]);
  44481. /**
  44482. * Get the keys for camera movement up.
  44483. */
  44484. get keysUp(): number[];
  44485. /**
  44486. * Set the keys for camera movement up.
  44487. */
  44488. set keysUp(value: number[]);
  44489. /**
  44490. * Get the keys for camera movement down.
  44491. */
  44492. get keysDown(): number[];
  44493. /**
  44494. * Set the keys for camera movement down.
  44495. */
  44496. set keysDown(value: number[]);
  44497. /**
  44498. * Get the keys for camera movement left.
  44499. */
  44500. get keysLeft(): number[];
  44501. /**
  44502. * Set the keys for camera movement left.
  44503. */
  44504. set keysLeft(value: number[]);
  44505. /**
  44506. * Set the keys for camera movement right.
  44507. */
  44508. get keysRight(): number[];
  44509. /**
  44510. * Set the keys for camera movement right.
  44511. */
  44512. set keysRight(value: number[]);
  44513. /**
  44514. * Event raised when the camera collides with a mesh in the scene.
  44515. */
  44516. onCollide: (collidedMesh: AbstractMesh) => void;
  44517. private _collider;
  44518. private _needMoveForGravity;
  44519. private _oldPosition;
  44520. private _diffPosition;
  44521. private _newPosition;
  44522. /** @hidden */
  44523. _localDirection: Vector3;
  44524. /** @hidden */
  44525. _transformedDirection: Vector3;
  44526. /**
  44527. * Instantiates a FlyCamera.
  44528. * This is a flying camera, designed for 3D movement and rotation in all directions,
  44529. * such as in a 3D Space Shooter or a Flight Simulator.
  44530. * @param name Define the name of the camera in the scene.
  44531. * @param position Define the starting position of the camera in the scene.
  44532. * @param scene Define the scene the camera belongs to.
  44533. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  44534. */
  44535. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  44536. /**
  44537. * Attach a control to the HTML DOM element.
  44538. * @param element Defines the element that listens to the input events.
  44539. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  44540. */
  44541. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44542. /**
  44543. * Detach a control from the HTML DOM element.
  44544. * The camera will stop reacting to that input.
  44545. * @param element Defines the element that listens to the input events.
  44546. */
  44547. detachControl(element: HTMLElement): void;
  44548. private _collisionMask;
  44549. /**
  44550. * Get the mask that the camera ignores in collision events.
  44551. */
  44552. get collisionMask(): number;
  44553. /**
  44554. * Set the mask that the camera ignores in collision events.
  44555. */
  44556. set collisionMask(mask: number);
  44557. /** @hidden */
  44558. _collideWithWorld(displacement: Vector3): void;
  44559. /** @hidden */
  44560. private _onCollisionPositionChange;
  44561. /** @hidden */
  44562. _checkInputs(): void;
  44563. /** @hidden */
  44564. _decideIfNeedsToMove(): boolean;
  44565. /** @hidden */
  44566. _updatePosition(): void;
  44567. /**
  44568. * Restore the Roll to its target value at the rate specified.
  44569. * @param rate - Higher means slower restoring.
  44570. * @hidden
  44571. */
  44572. restoreRoll(rate: number): void;
  44573. /**
  44574. * Destroy the camera and release the current resources held by it.
  44575. */
  44576. dispose(): void;
  44577. /**
  44578. * Get the current object class name.
  44579. * @returns the class name.
  44580. */
  44581. getClassName(): string;
  44582. }
  44583. }
  44584. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  44585. import { Nullable } from "babylonjs/types";
  44586. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44587. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  44588. /**
  44589. * Listen to keyboard events to control the camera.
  44590. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  44591. */
  44592. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  44593. /**
  44594. * Defines the camera the input is attached to.
  44595. */
  44596. camera: FlyCamera;
  44597. /**
  44598. * The list of keyboard keys used to control the forward move of the camera.
  44599. */
  44600. keysForward: number[];
  44601. /**
  44602. * The list of keyboard keys used to control the backward move of the camera.
  44603. */
  44604. keysBackward: number[];
  44605. /**
  44606. * The list of keyboard keys used to control the forward move of the camera.
  44607. */
  44608. keysUp: number[];
  44609. /**
  44610. * The list of keyboard keys used to control the backward move of the camera.
  44611. */
  44612. keysDown: number[];
  44613. /**
  44614. * The list of keyboard keys used to control the right strafe move of the camera.
  44615. */
  44616. keysRight: number[];
  44617. /**
  44618. * The list of keyboard keys used to control the left strafe move of the camera.
  44619. */
  44620. keysLeft: number[];
  44621. private _keys;
  44622. private _onCanvasBlurObserver;
  44623. private _onKeyboardObserver;
  44624. private _engine;
  44625. private _scene;
  44626. /**
  44627. * Attach the input controls to a specific dom element to get the input from.
  44628. * @param element Defines the element the controls should be listened from
  44629. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44630. */
  44631. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44632. /**
  44633. * Detach the current controls from the specified dom element.
  44634. * @param element Defines the element to stop listening the inputs from
  44635. */
  44636. detachControl(element: Nullable<HTMLElement>): void;
  44637. /**
  44638. * Gets the class name of the current intput.
  44639. * @returns the class name
  44640. */
  44641. getClassName(): string;
  44642. /** @hidden */
  44643. _onLostFocus(e: FocusEvent): void;
  44644. /**
  44645. * Get the friendly name associated with the input class.
  44646. * @returns the input friendly name
  44647. */
  44648. getSimpleName(): string;
  44649. /**
  44650. * Update the current camera state depending on the inputs that have been used this frame.
  44651. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44652. */
  44653. checkInputs(): void;
  44654. }
  44655. }
  44656. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  44657. import { Nullable } from "babylonjs/types";
  44658. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  44659. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44660. /**
  44661. * Manage the mouse wheel inputs to control a follow camera.
  44662. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  44663. */
  44664. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  44665. /**
  44666. * Defines the camera the input is attached to.
  44667. */
  44668. camera: FollowCamera;
  44669. /**
  44670. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  44671. */
  44672. axisControlRadius: boolean;
  44673. /**
  44674. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  44675. */
  44676. axisControlHeight: boolean;
  44677. /**
  44678. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  44679. */
  44680. axisControlRotation: boolean;
  44681. /**
  44682. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  44683. * relation to mouseWheel events.
  44684. */
  44685. wheelPrecision: number;
  44686. /**
  44687. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  44688. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  44689. */
  44690. wheelDeltaPercentage: number;
  44691. private _wheel;
  44692. private _observer;
  44693. /**
  44694. * Attach the input controls to a specific dom element to get the input from.
  44695. * @param element Defines the element the controls should be listened from
  44696. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44697. */
  44698. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44699. /**
  44700. * Detach the current controls from the specified dom element.
  44701. * @param element Defines the element to stop listening the inputs from
  44702. */
  44703. detachControl(element: Nullable<HTMLElement>): void;
  44704. /**
  44705. * Gets the class name of the current intput.
  44706. * @returns the class name
  44707. */
  44708. getClassName(): string;
  44709. /**
  44710. * Get the friendly name associated with the input class.
  44711. * @returns the input friendly name
  44712. */
  44713. getSimpleName(): string;
  44714. }
  44715. }
  44716. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  44717. import { Nullable } from "babylonjs/types";
  44718. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  44719. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  44720. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  44721. /**
  44722. * Manage the pointers inputs to control an follow camera.
  44723. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  44724. */
  44725. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  44726. /**
  44727. * Defines the camera the input is attached to.
  44728. */
  44729. camera: FollowCamera;
  44730. /**
  44731. * Gets the class name of the current input.
  44732. * @returns the class name
  44733. */
  44734. getClassName(): string;
  44735. /**
  44736. * Defines the pointer angular sensibility along the X axis or how fast is
  44737. * the camera rotating.
  44738. * A negative number will reverse the axis direction.
  44739. */
  44740. angularSensibilityX: number;
  44741. /**
  44742. * Defines the pointer angular sensibility along the Y axis or how fast is
  44743. * the camera rotating.
  44744. * A negative number will reverse the axis direction.
  44745. */
  44746. angularSensibilityY: number;
  44747. /**
  44748. * Defines the pointer pinch precision or how fast is the camera zooming.
  44749. * A negative number will reverse the axis direction.
  44750. */
  44751. pinchPrecision: number;
  44752. /**
  44753. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  44754. * from 0.
  44755. * It defines the percentage of current camera.radius to use as delta when
  44756. * pinch zoom is used.
  44757. */
  44758. pinchDeltaPercentage: number;
  44759. /**
  44760. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  44761. */
  44762. axisXControlRadius: boolean;
  44763. /**
  44764. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  44765. */
  44766. axisXControlHeight: boolean;
  44767. /**
  44768. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  44769. */
  44770. axisXControlRotation: boolean;
  44771. /**
  44772. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  44773. */
  44774. axisYControlRadius: boolean;
  44775. /**
  44776. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  44777. */
  44778. axisYControlHeight: boolean;
  44779. /**
  44780. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  44781. */
  44782. axisYControlRotation: boolean;
  44783. /**
  44784. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  44785. */
  44786. axisPinchControlRadius: boolean;
  44787. /**
  44788. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  44789. */
  44790. axisPinchControlHeight: boolean;
  44791. /**
  44792. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  44793. */
  44794. axisPinchControlRotation: boolean;
  44795. /**
  44796. * Log error messages if basic misconfiguration has occurred.
  44797. */
  44798. warningEnable: boolean;
  44799. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  44800. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  44801. private _warningCounter;
  44802. private _warning;
  44803. }
  44804. }
  44805. declare module "babylonjs/Cameras/followCameraInputsManager" {
  44806. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  44807. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  44808. /**
  44809. * Default Inputs manager for the FollowCamera.
  44810. * It groups all the default supported inputs for ease of use.
  44811. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  44812. */
  44813. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  44814. /**
  44815. * Instantiates a new FollowCameraInputsManager.
  44816. * @param camera Defines the camera the inputs belong to
  44817. */
  44818. constructor(camera: FollowCamera);
  44819. /**
  44820. * Add keyboard input support to the input manager.
  44821. * @returns the current input manager
  44822. */
  44823. addKeyboard(): FollowCameraInputsManager;
  44824. /**
  44825. * Add mouse wheel input support to the input manager.
  44826. * @returns the current input manager
  44827. */
  44828. addMouseWheel(): FollowCameraInputsManager;
  44829. /**
  44830. * Add pointers input support to the input manager.
  44831. * @returns the current input manager
  44832. */
  44833. addPointers(): FollowCameraInputsManager;
  44834. /**
  44835. * Add orientation input support to the input manager.
  44836. * @returns the current input manager
  44837. */
  44838. addVRDeviceOrientation(): FollowCameraInputsManager;
  44839. }
  44840. }
  44841. declare module "babylonjs/Cameras/followCamera" {
  44842. import { Nullable } from "babylonjs/types";
  44843. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  44844. import { Scene } from "babylonjs/scene";
  44845. import { Vector3 } from "babylonjs/Maths/math.vector";
  44846. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44847. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  44848. /**
  44849. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  44850. * an arc rotate version arcFollowCamera are available.
  44851. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  44852. */
  44853. export class FollowCamera extends TargetCamera {
  44854. /**
  44855. * Distance the follow camera should follow an object at
  44856. */
  44857. radius: number;
  44858. /**
  44859. * Minimum allowed distance of the camera to the axis of rotation
  44860. * (The camera can not get closer).
  44861. * This can help limiting how the Camera is able to move in the scene.
  44862. */
  44863. lowerRadiusLimit: Nullable<number>;
  44864. /**
  44865. * Maximum allowed distance of the camera to the axis of rotation
  44866. * (The camera can not get further).
  44867. * This can help limiting how the Camera is able to move in the scene.
  44868. */
  44869. upperRadiusLimit: Nullable<number>;
  44870. /**
  44871. * Define a rotation offset between the camera and the object it follows
  44872. */
  44873. rotationOffset: number;
  44874. /**
  44875. * Minimum allowed angle to camera position relative to target object.
  44876. * This can help limiting how the Camera is able to move in the scene.
  44877. */
  44878. lowerRotationOffsetLimit: Nullable<number>;
  44879. /**
  44880. * Maximum allowed angle to camera position relative to target object.
  44881. * This can help limiting how the Camera is able to move in the scene.
  44882. */
  44883. upperRotationOffsetLimit: Nullable<number>;
  44884. /**
  44885. * Define a height offset between the camera and the object it follows.
  44886. * It can help following an object from the top (like a car chaing a plane)
  44887. */
  44888. heightOffset: number;
  44889. /**
  44890. * Minimum allowed height of camera position relative to target object.
  44891. * This can help limiting how the Camera is able to move in the scene.
  44892. */
  44893. lowerHeightOffsetLimit: Nullable<number>;
  44894. /**
  44895. * Maximum allowed height of camera position relative to target object.
  44896. * This can help limiting how the Camera is able to move in the scene.
  44897. */
  44898. upperHeightOffsetLimit: Nullable<number>;
  44899. /**
  44900. * Define how fast the camera can accelerate to follow it s target.
  44901. */
  44902. cameraAcceleration: number;
  44903. /**
  44904. * Define the speed limit of the camera following an object.
  44905. */
  44906. maxCameraSpeed: number;
  44907. /**
  44908. * Define the target of the camera.
  44909. */
  44910. lockedTarget: Nullable<AbstractMesh>;
  44911. /**
  44912. * Defines the input associated with the camera.
  44913. */
  44914. inputs: FollowCameraInputsManager;
  44915. /**
  44916. * Instantiates the follow camera.
  44917. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  44918. * @param name Define the name of the camera in the scene
  44919. * @param position Define the position of the camera
  44920. * @param scene Define the scene the camera belong to
  44921. * @param lockedTarget Define the target of the camera
  44922. */
  44923. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  44924. private _follow;
  44925. /**
  44926. * Attached controls to the current camera.
  44927. * @param element Defines the element the controls should be listened from
  44928. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44929. */
  44930. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44931. /**
  44932. * Detach the current controls from the camera.
  44933. * The camera will stop reacting to inputs.
  44934. * @param element Defines the element to stop listening the inputs from
  44935. */
  44936. detachControl(element: HTMLElement): void;
  44937. /** @hidden */
  44938. _checkInputs(): void;
  44939. private _checkLimits;
  44940. /**
  44941. * Gets the camera class name.
  44942. * @returns the class name
  44943. */
  44944. getClassName(): string;
  44945. }
  44946. /**
  44947. * Arc Rotate version of the follow camera.
  44948. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  44949. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  44950. */
  44951. export class ArcFollowCamera extends TargetCamera {
  44952. /** The longitudinal angle of the camera */
  44953. alpha: number;
  44954. /** The latitudinal angle of the camera */
  44955. beta: number;
  44956. /** The radius of the camera from its target */
  44957. radius: number;
  44958. /** Define the camera target (the messh it should follow) */
  44959. target: Nullable<AbstractMesh>;
  44960. private _cartesianCoordinates;
  44961. /**
  44962. * Instantiates a new ArcFollowCamera
  44963. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  44964. * @param name Define the name of the camera
  44965. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  44966. * @param beta Define the rotation angle of the camera around the elevation axis
  44967. * @param radius Define the radius of the camera from its target point
  44968. * @param target Define the target of the camera
  44969. * @param scene Define the scene the camera belongs to
  44970. */
  44971. constructor(name: string,
  44972. /** The longitudinal angle of the camera */
  44973. alpha: number,
  44974. /** The latitudinal angle of the camera */
  44975. beta: number,
  44976. /** The radius of the camera from its target */
  44977. radius: number,
  44978. /** Define the camera target (the messh it should follow) */
  44979. target: Nullable<AbstractMesh>, scene: Scene);
  44980. private _follow;
  44981. /** @hidden */
  44982. _checkInputs(): void;
  44983. /**
  44984. * Returns the class name of the object.
  44985. * It is mostly used internally for serialization purposes.
  44986. */
  44987. getClassName(): string;
  44988. }
  44989. }
  44990. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  44991. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44992. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  44993. import { Nullable } from "babylonjs/types";
  44994. /**
  44995. * Manage the keyboard inputs to control the movement of a follow camera.
  44996. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  44997. */
  44998. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  44999. /**
  45000. * Defines the camera the input is attached to.
  45001. */
  45002. camera: FollowCamera;
  45003. /**
  45004. * Defines the list of key codes associated with the up action (increase heightOffset)
  45005. */
  45006. keysHeightOffsetIncr: number[];
  45007. /**
  45008. * Defines the list of key codes associated with the down action (decrease heightOffset)
  45009. */
  45010. keysHeightOffsetDecr: number[];
  45011. /**
  45012. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  45013. */
  45014. keysHeightOffsetModifierAlt: boolean;
  45015. /**
  45016. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  45017. */
  45018. keysHeightOffsetModifierCtrl: boolean;
  45019. /**
  45020. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  45021. */
  45022. keysHeightOffsetModifierShift: boolean;
  45023. /**
  45024. * Defines the list of key codes associated with the left action (increase rotationOffset)
  45025. */
  45026. keysRotationOffsetIncr: number[];
  45027. /**
  45028. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  45029. */
  45030. keysRotationOffsetDecr: number[];
  45031. /**
  45032. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  45033. */
  45034. keysRotationOffsetModifierAlt: boolean;
  45035. /**
  45036. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  45037. */
  45038. keysRotationOffsetModifierCtrl: boolean;
  45039. /**
  45040. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  45041. */
  45042. keysRotationOffsetModifierShift: boolean;
  45043. /**
  45044. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  45045. */
  45046. keysRadiusIncr: number[];
  45047. /**
  45048. * Defines the list of key codes associated with the zoom-out action (increase radius)
  45049. */
  45050. keysRadiusDecr: number[];
  45051. /**
  45052. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  45053. */
  45054. keysRadiusModifierAlt: boolean;
  45055. /**
  45056. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  45057. */
  45058. keysRadiusModifierCtrl: boolean;
  45059. /**
  45060. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  45061. */
  45062. keysRadiusModifierShift: boolean;
  45063. /**
  45064. * Defines the rate of change of heightOffset.
  45065. */
  45066. heightSensibility: number;
  45067. /**
  45068. * Defines the rate of change of rotationOffset.
  45069. */
  45070. rotationSensibility: number;
  45071. /**
  45072. * Defines the rate of change of radius.
  45073. */
  45074. radiusSensibility: number;
  45075. private _keys;
  45076. private _ctrlPressed;
  45077. private _altPressed;
  45078. private _shiftPressed;
  45079. private _onCanvasBlurObserver;
  45080. private _onKeyboardObserver;
  45081. private _engine;
  45082. private _scene;
  45083. /**
  45084. * Attach the input controls to a specific dom element to get the input from.
  45085. * @param element Defines the element the controls should be listened from
  45086. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45087. */
  45088. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45089. /**
  45090. * Detach the current controls from the specified dom element.
  45091. * @param element Defines the element to stop listening the inputs from
  45092. */
  45093. detachControl(element: Nullable<HTMLElement>): void;
  45094. /**
  45095. * Update the current camera state depending on the inputs that have been used this frame.
  45096. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45097. */
  45098. checkInputs(): void;
  45099. /**
  45100. * Gets the class name of the current input.
  45101. * @returns the class name
  45102. */
  45103. getClassName(): string;
  45104. /**
  45105. * Get the friendly name associated with the input class.
  45106. * @returns the input friendly name
  45107. */
  45108. getSimpleName(): string;
  45109. /**
  45110. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  45111. * allow modification of the heightOffset value.
  45112. */
  45113. private _modifierHeightOffset;
  45114. /**
  45115. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  45116. * allow modification of the rotationOffset value.
  45117. */
  45118. private _modifierRotationOffset;
  45119. /**
  45120. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  45121. * allow modification of the radius value.
  45122. */
  45123. private _modifierRadius;
  45124. }
  45125. }
  45126. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  45127. import { Nullable } from "babylonjs/types";
  45128. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45129. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  45130. import { Observable } from "babylonjs/Misc/observable";
  45131. module "babylonjs/Cameras/freeCameraInputsManager" {
  45132. interface FreeCameraInputsManager {
  45133. /**
  45134. * @hidden
  45135. */
  45136. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  45137. /**
  45138. * Add orientation input support to the input manager.
  45139. * @returns the current input manager
  45140. */
  45141. addDeviceOrientation(): FreeCameraInputsManager;
  45142. }
  45143. }
  45144. /**
  45145. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  45146. * Screen rotation is taken into account.
  45147. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  45148. */
  45149. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  45150. private _camera;
  45151. private _screenOrientationAngle;
  45152. private _constantTranform;
  45153. private _screenQuaternion;
  45154. private _alpha;
  45155. private _beta;
  45156. private _gamma;
  45157. /**
  45158. * Can be used to detect if a device orientation sensor is available on a device
  45159. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  45160. * @returns a promise that will resolve on orientation change
  45161. */
  45162. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  45163. /**
  45164. * @hidden
  45165. */
  45166. _onDeviceOrientationChangedObservable: Observable<void>;
  45167. /**
  45168. * Instantiates a new input
  45169. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  45170. */
  45171. constructor();
  45172. /**
  45173. * Define the camera controlled by the input.
  45174. */
  45175. get camera(): FreeCamera;
  45176. set camera(camera: FreeCamera);
  45177. /**
  45178. * Attach the input controls to a specific dom element to get the input from.
  45179. * @param element Defines the element the controls should be listened from
  45180. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45181. */
  45182. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45183. private _orientationChanged;
  45184. private _deviceOrientation;
  45185. /**
  45186. * Detach the current controls from the specified dom element.
  45187. * @param element Defines the element to stop listening the inputs from
  45188. */
  45189. detachControl(element: Nullable<HTMLElement>): void;
  45190. /**
  45191. * Update the current camera state depending on the inputs that have been used this frame.
  45192. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45193. */
  45194. checkInputs(): void;
  45195. /**
  45196. * Gets the class name of the current intput.
  45197. * @returns the class name
  45198. */
  45199. getClassName(): string;
  45200. /**
  45201. * Get the friendly name associated with the input class.
  45202. * @returns the input friendly name
  45203. */
  45204. getSimpleName(): string;
  45205. }
  45206. }
  45207. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  45208. import { Nullable } from "babylonjs/types";
  45209. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45210. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  45211. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  45212. /**
  45213. * Manage the gamepad inputs to control a free camera.
  45214. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  45215. */
  45216. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  45217. /**
  45218. * Define the camera the input is attached to.
  45219. */
  45220. camera: FreeCamera;
  45221. /**
  45222. * Define the Gamepad controlling the input
  45223. */
  45224. gamepad: Nullable<Gamepad>;
  45225. /**
  45226. * Defines the gamepad rotation sensiblity.
  45227. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  45228. */
  45229. gamepadAngularSensibility: number;
  45230. /**
  45231. * Defines the gamepad move sensiblity.
  45232. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  45233. */
  45234. gamepadMoveSensibility: number;
  45235. private _yAxisScale;
  45236. /**
  45237. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  45238. */
  45239. get invertYAxis(): boolean;
  45240. set invertYAxis(value: boolean);
  45241. private _onGamepadConnectedObserver;
  45242. private _onGamepadDisconnectedObserver;
  45243. private _cameraTransform;
  45244. private _deltaTransform;
  45245. private _vector3;
  45246. private _vector2;
  45247. /**
  45248. * Attach the input controls to a specific dom element to get the input from.
  45249. * @param element Defines the element the controls should be listened from
  45250. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45251. */
  45252. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45253. /**
  45254. * Detach the current controls from the specified dom element.
  45255. * @param element Defines the element to stop listening the inputs from
  45256. */
  45257. detachControl(element: Nullable<HTMLElement>): void;
  45258. /**
  45259. * Update the current camera state depending on the inputs that have been used this frame.
  45260. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45261. */
  45262. checkInputs(): void;
  45263. /**
  45264. * Gets the class name of the current intput.
  45265. * @returns the class name
  45266. */
  45267. getClassName(): string;
  45268. /**
  45269. * Get the friendly name associated with the input class.
  45270. * @returns the input friendly name
  45271. */
  45272. getSimpleName(): string;
  45273. }
  45274. }
  45275. declare module "babylonjs/Misc/virtualJoystick" {
  45276. import { Nullable } from "babylonjs/types";
  45277. import { Vector3 } from "babylonjs/Maths/math.vector";
  45278. /**
  45279. * Defines the potential axis of a Joystick
  45280. */
  45281. export enum JoystickAxis {
  45282. /** X axis */
  45283. X = 0,
  45284. /** Y axis */
  45285. Y = 1,
  45286. /** Z axis */
  45287. Z = 2
  45288. }
  45289. /**
  45290. * Class used to define virtual joystick (used in touch mode)
  45291. */
  45292. export class VirtualJoystick {
  45293. /**
  45294. * Gets or sets a boolean indicating that left and right values must be inverted
  45295. */
  45296. reverseLeftRight: boolean;
  45297. /**
  45298. * Gets or sets a boolean indicating that up and down values must be inverted
  45299. */
  45300. reverseUpDown: boolean;
  45301. /**
  45302. * Gets the offset value for the position (ie. the change of the position value)
  45303. */
  45304. deltaPosition: Vector3;
  45305. /**
  45306. * Gets a boolean indicating if the virtual joystick was pressed
  45307. */
  45308. pressed: boolean;
  45309. /**
  45310. * Canvas the virtual joystick will render onto, default z-index of this is 5
  45311. */
  45312. static Canvas: Nullable<HTMLCanvasElement>;
  45313. private static _globalJoystickIndex;
  45314. private static vjCanvasContext;
  45315. private static vjCanvasWidth;
  45316. private static vjCanvasHeight;
  45317. private static halfWidth;
  45318. private _action;
  45319. private _axisTargetedByLeftAndRight;
  45320. private _axisTargetedByUpAndDown;
  45321. private _joystickSensibility;
  45322. private _inversedSensibility;
  45323. private _joystickPointerID;
  45324. private _joystickColor;
  45325. private _joystickPointerPos;
  45326. private _joystickPreviousPointerPos;
  45327. private _joystickPointerStartPos;
  45328. private _deltaJoystickVector;
  45329. private _leftJoystick;
  45330. private _touches;
  45331. private _onPointerDownHandlerRef;
  45332. private _onPointerMoveHandlerRef;
  45333. private _onPointerUpHandlerRef;
  45334. private _onResize;
  45335. /**
  45336. * Creates a new virtual joystick
  45337. * @param leftJoystick defines that the joystick is for left hand (false by default)
  45338. */
  45339. constructor(leftJoystick?: boolean);
  45340. /**
  45341. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  45342. * @param newJoystickSensibility defines the new sensibility
  45343. */
  45344. setJoystickSensibility(newJoystickSensibility: number): void;
  45345. private _onPointerDown;
  45346. private _onPointerMove;
  45347. private _onPointerUp;
  45348. /**
  45349. * Change the color of the virtual joystick
  45350. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  45351. */
  45352. setJoystickColor(newColor: string): void;
  45353. /**
  45354. * Defines a callback to call when the joystick is touched
  45355. * @param action defines the callback
  45356. */
  45357. setActionOnTouch(action: () => any): void;
  45358. /**
  45359. * Defines which axis you'd like to control for left & right
  45360. * @param axis defines the axis to use
  45361. */
  45362. setAxisForLeftRight(axis: JoystickAxis): void;
  45363. /**
  45364. * Defines which axis you'd like to control for up & down
  45365. * @param axis defines the axis to use
  45366. */
  45367. setAxisForUpDown(axis: JoystickAxis): void;
  45368. private _drawVirtualJoystick;
  45369. /**
  45370. * Release internal HTML canvas
  45371. */
  45372. releaseCanvas(): void;
  45373. }
  45374. }
  45375. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  45376. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  45377. import { Nullable } from "babylonjs/types";
  45378. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45379. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  45380. module "babylonjs/Cameras/freeCameraInputsManager" {
  45381. interface FreeCameraInputsManager {
  45382. /**
  45383. * Add virtual joystick input support to the input manager.
  45384. * @returns the current input manager
  45385. */
  45386. addVirtualJoystick(): FreeCameraInputsManager;
  45387. }
  45388. }
  45389. /**
  45390. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  45391. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  45392. */
  45393. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  45394. /**
  45395. * Defines the camera the input is attached to.
  45396. */
  45397. camera: FreeCamera;
  45398. private _leftjoystick;
  45399. private _rightjoystick;
  45400. /**
  45401. * Gets the left stick of the virtual joystick.
  45402. * @returns The virtual Joystick
  45403. */
  45404. getLeftJoystick(): VirtualJoystick;
  45405. /**
  45406. * Gets the right stick of the virtual joystick.
  45407. * @returns The virtual Joystick
  45408. */
  45409. getRightJoystick(): VirtualJoystick;
  45410. /**
  45411. * Update the current camera state depending on the inputs that have been used this frame.
  45412. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45413. */
  45414. checkInputs(): void;
  45415. /**
  45416. * Attach the input controls to a specific dom element to get the input from.
  45417. * @param element Defines the element the controls should be listened from
  45418. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45419. */
  45420. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45421. /**
  45422. * Detach the current controls from the specified dom element.
  45423. * @param element Defines the element to stop listening the inputs from
  45424. */
  45425. detachControl(element: Nullable<HTMLElement>): void;
  45426. /**
  45427. * Gets the class name of the current intput.
  45428. * @returns the class name
  45429. */
  45430. getClassName(): string;
  45431. /**
  45432. * Get the friendly name associated with the input class.
  45433. * @returns the input friendly name
  45434. */
  45435. getSimpleName(): string;
  45436. }
  45437. }
  45438. declare module "babylonjs/Cameras/Inputs/index" {
  45439. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  45440. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  45441. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  45442. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  45443. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  45444. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  45445. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  45446. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  45447. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  45448. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  45449. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  45450. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  45451. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  45452. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  45453. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  45454. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  45455. }
  45456. declare module "babylonjs/Cameras/touchCamera" {
  45457. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  45458. import { Scene } from "babylonjs/scene";
  45459. import { Vector3 } from "babylonjs/Maths/math.vector";
  45460. /**
  45461. * This represents a FPS type of camera controlled by touch.
  45462. * This is like a universal camera minus the Gamepad controls.
  45463. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  45464. */
  45465. export class TouchCamera extends FreeCamera {
  45466. /**
  45467. * Defines the touch sensibility for rotation.
  45468. * The higher the faster.
  45469. */
  45470. get touchAngularSensibility(): number;
  45471. set touchAngularSensibility(value: number);
  45472. /**
  45473. * Defines the touch sensibility for move.
  45474. * The higher the faster.
  45475. */
  45476. get touchMoveSensibility(): number;
  45477. set touchMoveSensibility(value: number);
  45478. /**
  45479. * Instantiates a new touch camera.
  45480. * This represents a FPS type of camera controlled by touch.
  45481. * This is like a universal camera minus the Gamepad controls.
  45482. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  45483. * @param name Define the name of the camera in the scene
  45484. * @param position Define the start position of the camera in the scene
  45485. * @param scene Define the scene the camera belongs to
  45486. */
  45487. constructor(name: string, position: Vector3, scene: Scene);
  45488. /**
  45489. * Gets the current object class name.
  45490. * @return the class name
  45491. */
  45492. getClassName(): string;
  45493. /** @hidden */
  45494. _setupInputs(): void;
  45495. }
  45496. }
  45497. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  45498. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  45499. import { Scene } from "babylonjs/scene";
  45500. import { Vector3 } from "babylonjs/Maths/math.vector";
  45501. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  45502. import { Axis } from "babylonjs/Maths/math.axis";
  45503. /**
  45504. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  45505. * being tilted forward or back and left or right.
  45506. */
  45507. export class DeviceOrientationCamera extends FreeCamera {
  45508. private _initialQuaternion;
  45509. private _quaternionCache;
  45510. private _tmpDragQuaternion;
  45511. private _disablePointerInputWhenUsingDeviceOrientation;
  45512. /**
  45513. * Creates a new device orientation camera
  45514. * @param name The name of the camera
  45515. * @param position The start position camera
  45516. * @param scene The scene the camera belongs to
  45517. */
  45518. constructor(name: string, position: Vector3, scene: Scene);
  45519. /**
  45520. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  45521. */
  45522. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  45523. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  45524. private _dragFactor;
  45525. /**
  45526. * Enabled turning on the y axis when the orientation sensor is active
  45527. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  45528. */
  45529. enableHorizontalDragging(dragFactor?: number): void;
  45530. /**
  45531. * Gets the current instance class name ("DeviceOrientationCamera").
  45532. * This helps avoiding instanceof at run time.
  45533. * @returns the class name
  45534. */
  45535. getClassName(): string;
  45536. /**
  45537. * @hidden
  45538. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  45539. */
  45540. _checkInputs(): void;
  45541. /**
  45542. * Reset the camera to its default orientation on the specified axis only.
  45543. * @param axis The axis to reset
  45544. */
  45545. resetToCurrentRotation(axis?: Axis): void;
  45546. }
  45547. }
  45548. declare module "babylonjs/Gamepads/xboxGamepad" {
  45549. import { Observable } from "babylonjs/Misc/observable";
  45550. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  45551. /**
  45552. * Defines supported buttons for XBox360 compatible gamepads
  45553. */
  45554. export enum Xbox360Button {
  45555. /** A */
  45556. A = 0,
  45557. /** B */
  45558. B = 1,
  45559. /** X */
  45560. X = 2,
  45561. /** Y */
  45562. Y = 3,
  45563. /** Left button */
  45564. LB = 4,
  45565. /** Right button */
  45566. RB = 5,
  45567. /** Back */
  45568. Back = 8,
  45569. /** Start */
  45570. Start = 9,
  45571. /** Left stick */
  45572. LeftStick = 10,
  45573. /** Right stick */
  45574. RightStick = 11
  45575. }
  45576. /** Defines values for XBox360 DPad */
  45577. export enum Xbox360Dpad {
  45578. /** Up */
  45579. Up = 12,
  45580. /** Down */
  45581. Down = 13,
  45582. /** Left */
  45583. Left = 14,
  45584. /** Right */
  45585. Right = 15
  45586. }
  45587. /**
  45588. * Defines a XBox360 gamepad
  45589. */
  45590. export class Xbox360Pad extends Gamepad {
  45591. private _leftTrigger;
  45592. private _rightTrigger;
  45593. private _onlefttriggerchanged;
  45594. private _onrighttriggerchanged;
  45595. private _onbuttondown;
  45596. private _onbuttonup;
  45597. private _ondpaddown;
  45598. private _ondpadup;
  45599. /** Observable raised when a button is pressed */
  45600. onButtonDownObservable: Observable<Xbox360Button>;
  45601. /** Observable raised when a button is released */
  45602. onButtonUpObservable: Observable<Xbox360Button>;
  45603. /** Observable raised when a pad is pressed */
  45604. onPadDownObservable: Observable<Xbox360Dpad>;
  45605. /** Observable raised when a pad is released */
  45606. onPadUpObservable: Observable<Xbox360Dpad>;
  45607. private _buttonA;
  45608. private _buttonB;
  45609. private _buttonX;
  45610. private _buttonY;
  45611. private _buttonBack;
  45612. private _buttonStart;
  45613. private _buttonLB;
  45614. private _buttonRB;
  45615. private _buttonLeftStick;
  45616. private _buttonRightStick;
  45617. private _dPadUp;
  45618. private _dPadDown;
  45619. private _dPadLeft;
  45620. private _dPadRight;
  45621. private _isXboxOnePad;
  45622. /**
  45623. * Creates a new XBox360 gamepad object
  45624. * @param id defines the id of this gamepad
  45625. * @param index defines its index
  45626. * @param gamepad defines the internal HTML gamepad object
  45627. * @param xboxOne defines if it is a XBox One gamepad
  45628. */
  45629. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  45630. /**
  45631. * Defines the callback to call when left trigger is pressed
  45632. * @param callback defines the callback to use
  45633. */
  45634. onlefttriggerchanged(callback: (value: number) => void): void;
  45635. /**
  45636. * Defines the callback to call when right trigger is pressed
  45637. * @param callback defines the callback to use
  45638. */
  45639. onrighttriggerchanged(callback: (value: number) => void): void;
  45640. /**
  45641. * Gets the left trigger value
  45642. */
  45643. get leftTrigger(): number;
  45644. /**
  45645. * Sets the left trigger value
  45646. */
  45647. set leftTrigger(newValue: number);
  45648. /**
  45649. * Gets the right trigger value
  45650. */
  45651. get rightTrigger(): number;
  45652. /**
  45653. * Sets the right trigger value
  45654. */
  45655. set rightTrigger(newValue: number);
  45656. /**
  45657. * Defines the callback to call when a button is pressed
  45658. * @param callback defines the callback to use
  45659. */
  45660. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  45661. /**
  45662. * Defines the callback to call when a button is released
  45663. * @param callback defines the callback to use
  45664. */
  45665. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  45666. /**
  45667. * Defines the callback to call when a pad is pressed
  45668. * @param callback defines the callback to use
  45669. */
  45670. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  45671. /**
  45672. * Defines the callback to call when a pad is released
  45673. * @param callback defines the callback to use
  45674. */
  45675. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  45676. private _setButtonValue;
  45677. private _setDPadValue;
  45678. /**
  45679. * Gets the value of the `A` button
  45680. */
  45681. get buttonA(): number;
  45682. /**
  45683. * Sets the value of the `A` button
  45684. */
  45685. set buttonA(value: number);
  45686. /**
  45687. * Gets the value of the `B` button
  45688. */
  45689. get buttonB(): number;
  45690. /**
  45691. * Sets the value of the `B` button
  45692. */
  45693. set buttonB(value: number);
  45694. /**
  45695. * Gets the value of the `X` button
  45696. */
  45697. get buttonX(): number;
  45698. /**
  45699. * Sets the value of the `X` button
  45700. */
  45701. set buttonX(value: number);
  45702. /**
  45703. * Gets the value of the `Y` button
  45704. */
  45705. get buttonY(): number;
  45706. /**
  45707. * Sets the value of the `Y` button
  45708. */
  45709. set buttonY(value: number);
  45710. /**
  45711. * Gets the value of the `Start` button
  45712. */
  45713. get buttonStart(): number;
  45714. /**
  45715. * Sets the value of the `Start` button
  45716. */
  45717. set buttonStart(value: number);
  45718. /**
  45719. * Gets the value of the `Back` button
  45720. */
  45721. get buttonBack(): number;
  45722. /**
  45723. * Sets the value of the `Back` button
  45724. */
  45725. set buttonBack(value: number);
  45726. /**
  45727. * Gets the value of the `Left` button
  45728. */
  45729. get buttonLB(): number;
  45730. /**
  45731. * Sets the value of the `Left` button
  45732. */
  45733. set buttonLB(value: number);
  45734. /**
  45735. * Gets the value of the `Right` button
  45736. */
  45737. get buttonRB(): number;
  45738. /**
  45739. * Sets the value of the `Right` button
  45740. */
  45741. set buttonRB(value: number);
  45742. /**
  45743. * Gets the value of the Left joystick
  45744. */
  45745. get buttonLeftStick(): number;
  45746. /**
  45747. * Sets the value of the Left joystick
  45748. */
  45749. set buttonLeftStick(value: number);
  45750. /**
  45751. * Gets the value of the Right joystick
  45752. */
  45753. get buttonRightStick(): number;
  45754. /**
  45755. * Sets the value of the Right joystick
  45756. */
  45757. set buttonRightStick(value: number);
  45758. /**
  45759. * Gets the value of D-pad up
  45760. */
  45761. get dPadUp(): number;
  45762. /**
  45763. * Sets the value of D-pad up
  45764. */
  45765. set dPadUp(value: number);
  45766. /**
  45767. * Gets the value of D-pad down
  45768. */
  45769. get dPadDown(): number;
  45770. /**
  45771. * Sets the value of D-pad down
  45772. */
  45773. set dPadDown(value: number);
  45774. /**
  45775. * Gets the value of D-pad left
  45776. */
  45777. get dPadLeft(): number;
  45778. /**
  45779. * Sets the value of D-pad left
  45780. */
  45781. set dPadLeft(value: number);
  45782. /**
  45783. * Gets the value of D-pad right
  45784. */
  45785. get dPadRight(): number;
  45786. /**
  45787. * Sets the value of D-pad right
  45788. */
  45789. set dPadRight(value: number);
  45790. /**
  45791. * Force the gamepad to synchronize with device values
  45792. */
  45793. update(): void;
  45794. /**
  45795. * Disposes the gamepad
  45796. */
  45797. dispose(): void;
  45798. }
  45799. }
  45800. declare module "babylonjs/Gamepads/dualShockGamepad" {
  45801. import { Observable } from "babylonjs/Misc/observable";
  45802. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  45803. /**
  45804. * Defines supported buttons for DualShock compatible gamepads
  45805. */
  45806. export enum DualShockButton {
  45807. /** Cross */
  45808. Cross = 0,
  45809. /** Circle */
  45810. Circle = 1,
  45811. /** Square */
  45812. Square = 2,
  45813. /** Triangle */
  45814. Triangle = 3,
  45815. /** L1 */
  45816. L1 = 4,
  45817. /** R1 */
  45818. R1 = 5,
  45819. /** Share */
  45820. Share = 8,
  45821. /** Options */
  45822. Options = 9,
  45823. /** Left stick */
  45824. LeftStick = 10,
  45825. /** Right stick */
  45826. RightStick = 11
  45827. }
  45828. /** Defines values for DualShock DPad */
  45829. export enum DualShockDpad {
  45830. /** Up */
  45831. Up = 12,
  45832. /** Down */
  45833. Down = 13,
  45834. /** Left */
  45835. Left = 14,
  45836. /** Right */
  45837. Right = 15
  45838. }
  45839. /**
  45840. * Defines a DualShock gamepad
  45841. */
  45842. export class DualShockPad extends Gamepad {
  45843. private _leftTrigger;
  45844. private _rightTrigger;
  45845. private _onlefttriggerchanged;
  45846. private _onrighttriggerchanged;
  45847. private _onbuttondown;
  45848. private _onbuttonup;
  45849. private _ondpaddown;
  45850. private _ondpadup;
  45851. /** Observable raised when a button is pressed */
  45852. onButtonDownObservable: Observable<DualShockButton>;
  45853. /** Observable raised when a button is released */
  45854. onButtonUpObservable: Observable<DualShockButton>;
  45855. /** Observable raised when a pad is pressed */
  45856. onPadDownObservable: Observable<DualShockDpad>;
  45857. /** Observable raised when a pad is released */
  45858. onPadUpObservable: Observable<DualShockDpad>;
  45859. private _buttonCross;
  45860. private _buttonCircle;
  45861. private _buttonSquare;
  45862. private _buttonTriangle;
  45863. private _buttonShare;
  45864. private _buttonOptions;
  45865. private _buttonL1;
  45866. private _buttonR1;
  45867. private _buttonLeftStick;
  45868. private _buttonRightStick;
  45869. private _dPadUp;
  45870. private _dPadDown;
  45871. private _dPadLeft;
  45872. private _dPadRight;
  45873. /**
  45874. * Creates a new DualShock gamepad object
  45875. * @param id defines the id of this gamepad
  45876. * @param index defines its index
  45877. * @param gamepad defines the internal HTML gamepad object
  45878. */
  45879. constructor(id: string, index: number, gamepad: any);
  45880. /**
  45881. * Defines the callback to call when left trigger is pressed
  45882. * @param callback defines the callback to use
  45883. */
  45884. onlefttriggerchanged(callback: (value: number) => void): void;
  45885. /**
  45886. * Defines the callback to call when right trigger is pressed
  45887. * @param callback defines the callback to use
  45888. */
  45889. onrighttriggerchanged(callback: (value: number) => void): void;
  45890. /**
  45891. * Gets the left trigger value
  45892. */
  45893. get leftTrigger(): number;
  45894. /**
  45895. * Sets the left trigger value
  45896. */
  45897. set leftTrigger(newValue: number);
  45898. /**
  45899. * Gets the right trigger value
  45900. */
  45901. get rightTrigger(): number;
  45902. /**
  45903. * Sets the right trigger value
  45904. */
  45905. set rightTrigger(newValue: number);
  45906. /**
  45907. * Defines the callback to call when a button is pressed
  45908. * @param callback defines the callback to use
  45909. */
  45910. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  45911. /**
  45912. * Defines the callback to call when a button is released
  45913. * @param callback defines the callback to use
  45914. */
  45915. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  45916. /**
  45917. * Defines the callback to call when a pad is pressed
  45918. * @param callback defines the callback to use
  45919. */
  45920. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  45921. /**
  45922. * Defines the callback to call when a pad is released
  45923. * @param callback defines the callback to use
  45924. */
  45925. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  45926. private _setButtonValue;
  45927. private _setDPadValue;
  45928. /**
  45929. * Gets the value of the `Cross` button
  45930. */
  45931. get buttonCross(): number;
  45932. /**
  45933. * Sets the value of the `Cross` button
  45934. */
  45935. set buttonCross(value: number);
  45936. /**
  45937. * Gets the value of the `Circle` button
  45938. */
  45939. get buttonCircle(): number;
  45940. /**
  45941. * Sets the value of the `Circle` button
  45942. */
  45943. set buttonCircle(value: number);
  45944. /**
  45945. * Gets the value of the `Square` button
  45946. */
  45947. get buttonSquare(): number;
  45948. /**
  45949. * Sets the value of the `Square` button
  45950. */
  45951. set buttonSquare(value: number);
  45952. /**
  45953. * Gets the value of the `Triangle` button
  45954. */
  45955. get buttonTriangle(): number;
  45956. /**
  45957. * Sets the value of the `Triangle` button
  45958. */
  45959. set buttonTriangle(value: number);
  45960. /**
  45961. * Gets the value of the `Options` button
  45962. */
  45963. get buttonOptions(): number;
  45964. /**
  45965. * Sets the value of the `Options` button
  45966. */
  45967. set buttonOptions(value: number);
  45968. /**
  45969. * Gets the value of the `Share` button
  45970. */
  45971. get buttonShare(): number;
  45972. /**
  45973. * Sets the value of the `Share` button
  45974. */
  45975. set buttonShare(value: number);
  45976. /**
  45977. * Gets the value of the `L1` button
  45978. */
  45979. get buttonL1(): number;
  45980. /**
  45981. * Sets the value of the `L1` button
  45982. */
  45983. set buttonL1(value: number);
  45984. /**
  45985. * Gets the value of the `R1` button
  45986. */
  45987. get buttonR1(): number;
  45988. /**
  45989. * Sets the value of the `R1` button
  45990. */
  45991. set buttonR1(value: number);
  45992. /**
  45993. * Gets the value of the Left joystick
  45994. */
  45995. get buttonLeftStick(): number;
  45996. /**
  45997. * Sets the value of the Left joystick
  45998. */
  45999. set buttonLeftStick(value: number);
  46000. /**
  46001. * Gets the value of the Right joystick
  46002. */
  46003. get buttonRightStick(): number;
  46004. /**
  46005. * Sets the value of the Right joystick
  46006. */
  46007. set buttonRightStick(value: number);
  46008. /**
  46009. * Gets the value of D-pad up
  46010. */
  46011. get dPadUp(): number;
  46012. /**
  46013. * Sets the value of D-pad up
  46014. */
  46015. set dPadUp(value: number);
  46016. /**
  46017. * Gets the value of D-pad down
  46018. */
  46019. get dPadDown(): number;
  46020. /**
  46021. * Sets the value of D-pad down
  46022. */
  46023. set dPadDown(value: number);
  46024. /**
  46025. * Gets the value of D-pad left
  46026. */
  46027. get dPadLeft(): number;
  46028. /**
  46029. * Sets the value of D-pad left
  46030. */
  46031. set dPadLeft(value: number);
  46032. /**
  46033. * Gets the value of D-pad right
  46034. */
  46035. get dPadRight(): number;
  46036. /**
  46037. * Sets the value of D-pad right
  46038. */
  46039. set dPadRight(value: number);
  46040. /**
  46041. * Force the gamepad to synchronize with device values
  46042. */
  46043. update(): void;
  46044. /**
  46045. * Disposes the gamepad
  46046. */
  46047. dispose(): void;
  46048. }
  46049. }
  46050. declare module "babylonjs/Gamepads/gamepadManager" {
  46051. import { Observable } from "babylonjs/Misc/observable";
  46052. import { Nullable } from "babylonjs/types";
  46053. import { Scene } from "babylonjs/scene";
  46054. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  46055. /**
  46056. * Manager for handling gamepads
  46057. */
  46058. export class GamepadManager {
  46059. private _scene?;
  46060. private _babylonGamepads;
  46061. private _oneGamepadConnected;
  46062. /** @hidden */
  46063. _isMonitoring: boolean;
  46064. private _gamepadEventSupported;
  46065. private _gamepadSupport?;
  46066. /**
  46067. * observable to be triggered when the gamepad controller has been connected
  46068. */
  46069. onGamepadConnectedObservable: Observable<Gamepad>;
  46070. /**
  46071. * observable to be triggered when the gamepad controller has been disconnected
  46072. */
  46073. onGamepadDisconnectedObservable: Observable<Gamepad>;
  46074. private _onGamepadConnectedEvent;
  46075. private _onGamepadDisconnectedEvent;
  46076. /**
  46077. * Initializes the gamepad manager
  46078. * @param _scene BabylonJS scene
  46079. */
  46080. constructor(_scene?: Scene | undefined);
  46081. /**
  46082. * The gamepads in the game pad manager
  46083. */
  46084. get gamepads(): Gamepad[];
  46085. /**
  46086. * Get the gamepad controllers based on type
  46087. * @param type The type of gamepad controller
  46088. * @returns Nullable gamepad
  46089. */
  46090. getGamepadByType(type?: number): Nullable<Gamepad>;
  46091. /**
  46092. * Disposes the gamepad manager
  46093. */
  46094. dispose(): void;
  46095. private _addNewGamepad;
  46096. private _startMonitoringGamepads;
  46097. private _stopMonitoringGamepads;
  46098. /** @hidden */
  46099. _checkGamepadsStatus(): void;
  46100. private _updateGamepadObjects;
  46101. }
  46102. }
  46103. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  46104. import { Nullable } from "babylonjs/types";
  46105. import { Scene } from "babylonjs/scene";
  46106. import { ISceneComponent } from "babylonjs/sceneComponent";
  46107. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  46108. module "babylonjs/scene" {
  46109. interface Scene {
  46110. /** @hidden */
  46111. _gamepadManager: Nullable<GamepadManager>;
  46112. /**
  46113. * Gets the gamepad manager associated with the scene
  46114. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  46115. */
  46116. gamepadManager: GamepadManager;
  46117. }
  46118. }
  46119. module "babylonjs/Cameras/freeCameraInputsManager" {
  46120. /**
  46121. * Interface representing a free camera inputs manager
  46122. */
  46123. interface FreeCameraInputsManager {
  46124. /**
  46125. * Adds gamepad input support to the FreeCameraInputsManager.
  46126. * @returns the FreeCameraInputsManager
  46127. */
  46128. addGamepad(): FreeCameraInputsManager;
  46129. }
  46130. }
  46131. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  46132. /**
  46133. * Interface representing an arc rotate camera inputs manager
  46134. */
  46135. interface ArcRotateCameraInputsManager {
  46136. /**
  46137. * Adds gamepad input support to the ArcRotateCamera InputManager.
  46138. * @returns the camera inputs manager
  46139. */
  46140. addGamepad(): ArcRotateCameraInputsManager;
  46141. }
  46142. }
  46143. /**
  46144. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  46145. */
  46146. export class GamepadSystemSceneComponent implements ISceneComponent {
  46147. /**
  46148. * The component name helpfull to identify the component in the list of scene components.
  46149. */
  46150. readonly name: string;
  46151. /**
  46152. * The scene the component belongs to.
  46153. */
  46154. scene: Scene;
  46155. /**
  46156. * Creates a new instance of the component for the given scene
  46157. * @param scene Defines the scene to register the component in
  46158. */
  46159. constructor(scene: Scene);
  46160. /**
  46161. * Registers the component in a given scene
  46162. */
  46163. register(): void;
  46164. /**
  46165. * Rebuilds the elements related to this component in case of
  46166. * context lost for instance.
  46167. */
  46168. rebuild(): void;
  46169. /**
  46170. * Disposes the component and the associated ressources
  46171. */
  46172. dispose(): void;
  46173. private _beforeCameraUpdate;
  46174. }
  46175. }
  46176. declare module "babylonjs/Cameras/universalCamera" {
  46177. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  46178. import { Scene } from "babylonjs/scene";
  46179. import { Vector3 } from "babylonjs/Maths/math.vector";
  46180. import "babylonjs/Gamepads/gamepadSceneComponent";
  46181. /**
  46182. * 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,
  46183. * which still works and will still be found in many Playgrounds.
  46184. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  46185. */
  46186. export class UniversalCamera extends TouchCamera {
  46187. /**
  46188. * Defines the gamepad rotation sensiblity.
  46189. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  46190. */
  46191. get gamepadAngularSensibility(): number;
  46192. set gamepadAngularSensibility(value: number);
  46193. /**
  46194. * Defines the gamepad move sensiblity.
  46195. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  46196. */
  46197. get gamepadMoveSensibility(): number;
  46198. set gamepadMoveSensibility(value: number);
  46199. /**
  46200. * 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,
  46201. * which still works and will still be found in many Playgrounds.
  46202. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  46203. * @param name Define the name of the camera in the scene
  46204. * @param position Define the start position of the camera in the scene
  46205. * @param scene Define the scene the camera belongs to
  46206. */
  46207. constructor(name: string, position: Vector3, scene: Scene);
  46208. /**
  46209. * Gets the current object class name.
  46210. * @return the class name
  46211. */
  46212. getClassName(): string;
  46213. }
  46214. }
  46215. declare module "babylonjs/Cameras/gamepadCamera" {
  46216. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  46217. import { Scene } from "babylonjs/scene";
  46218. import { Vector3 } from "babylonjs/Maths/math.vector";
  46219. /**
  46220. * This represents a FPS type of camera. This is only here for back compat purpose.
  46221. * Please use the UniversalCamera instead as both are identical.
  46222. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  46223. */
  46224. export class GamepadCamera extends UniversalCamera {
  46225. /**
  46226. * Instantiates a new Gamepad Camera
  46227. * This represents a FPS type of camera. This is only here for back compat purpose.
  46228. * Please use the UniversalCamera instead as both are identical.
  46229. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  46230. * @param name Define the name of the camera in the scene
  46231. * @param position Define the start position of the camera in the scene
  46232. * @param scene Define the scene the camera belongs to
  46233. */
  46234. constructor(name: string, position: Vector3, scene: Scene);
  46235. /**
  46236. * Gets the current object class name.
  46237. * @return the class name
  46238. */
  46239. getClassName(): string;
  46240. }
  46241. }
  46242. declare module "babylonjs/Shaders/pass.fragment" {
  46243. /** @hidden */
  46244. export var passPixelShader: {
  46245. name: string;
  46246. shader: string;
  46247. };
  46248. }
  46249. declare module "babylonjs/Shaders/passCube.fragment" {
  46250. /** @hidden */
  46251. export var passCubePixelShader: {
  46252. name: string;
  46253. shader: string;
  46254. };
  46255. }
  46256. declare module "babylonjs/PostProcesses/passPostProcess" {
  46257. import { Nullable } from "babylonjs/types";
  46258. import { Camera } from "babylonjs/Cameras/camera";
  46259. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  46260. import { Engine } from "babylonjs/Engines/engine";
  46261. import "babylonjs/Shaders/pass.fragment";
  46262. import "babylonjs/Shaders/passCube.fragment";
  46263. /**
  46264. * PassPostProcess which produces an output the same as it's input
  46265. */
  46266. export class PassPostProcess extends PostProcess {
  46267. /**
  46268. * Creates the PassPostProcess
  46269. * @param name The name of the effect.
  46270. * @param options The required width/height ratio to downsize to before computing the render pass.
  46271. * @param camera The camera to apply the render pass to.
  46272. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  46273. * @param engine The engine which the post process will be applied. (default: current engine)
  46274. * @param reusable If the post process can be reused on the same frame. (default: false)
  46275. * @param textureType The type of texture to be used when performing the post processing.
  46276. * @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)
  46277. */
  46278. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  46279. }
  46280. /**
  46281. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  46282. */
  46283. export class PassCubePostProcess extends PostProcess {
  46284. private _face;
  46285. /**
  46286. * Gets or sets the cube face to display.
  46287. * * 0 is +X
  46288. * * 1 is -X
  46289. * * 2 is +Y
  46290. * * 3 is -Y
  46291. * * 4 is +Z
  46292. * * 5 is -Z
  46293. */
  46294. get face(): number;
  46295. set face(value: number);
  46296. /**
  46297. * Creates the PassCubePostProcess
  46298. * @param name The name of the effect.
  46299. * @param options The required width/height ratio to downsize to before computing the render pass.
  46300. * @param camera The camera to apply the render pass to.
  46301. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  46302. * @param engine The engine which the post process will be applied. (default: current engine)
  46303. * @param reusable If the post process can be reused on the same frame. (default: false)
  46304. * @param textureType The type of texture to be used when performing the post processing.
  46305. * @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)
  46306. */
  46307. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  46308. }
  46309. }
  46310. declare module "babylonjs/Shaders/anaglyph.fragment" {
  46311. /** @hidden */
  46312. export var anaglyphPixelShader: {
  46313. name: string;
  46314. shader: string;
  46315. };
  46316. }
  46317. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  46318. import { Engine } from "babylonjs/Engines/engine";
  46319. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  46320. import { Camera } from "babylonjs/Cameras/camera";
  46321. import "babylonjs/Shaders/anaglyph.fragment";
  46322. /**
  46323. * Postprocess used to generate anaglyphic rendering
  46324. */
  46325. export class AnaglyphPostProcess extends PostProcess {
  46326. private _passedProcess;
  46327. /**
  46328. * Creates a new AnaglyphPostProcess
  46329. * @param name defines postprocess name
  46330. * @param options defines creation options or target ratio scale
  46331. * @param rigCameras defines cameras using this postprocess
  46332. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  46333. * @param engine defines hosting engine
  46334. * @param reusable defines if the postprocess will be reused multiple times per frame
  46335. */
  46336. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  46337. }
  46338. }
  46339. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  46340. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  46341. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  46342. import { Scene } from "babylonjs/scene";
  46343. import { Vector3 } from "babylonjs/Maths/math.vector";
  46344. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  46345. /**
  46346. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  46347. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46348. */
  46349. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  46350. /**
  46351. * Creates a new AnaglyphArcRotateCamera
  46352. * @param name defines camera name
  46353. * @param alpha defines alpha angle (in radians)
  46354. * @param beta defines beta angle (in radians)
  46355. * @param radius defines radius
  46356. * @param target defines camera target
  46357. * @param interaxialDistance defines distance between each color axis
  46358. * @param scene defines the hosting scene
  46359. */
  46360. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  46361. /**
  46362. * Gets camera class name
  46363. * @returns AnaglyphArcRotateCamera
  46364. */
  46365. getClassName(): string;
  46366. }
  46367. }
  46368. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  46369. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46370. import { Scene } from "babylonjs/scene";
  46371. import { Vector3 } from "babylonjs/Maths/math.vector";
  46372. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  46373. /**
  46374. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  46375. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46376. */
  46377. export class AnaglyphFreeCamera extends FreeCamera {
  46378. /**
  46379. * Creates a new AnaglyphFreeCamera
  46380. * @param name defines camera name
  46381. * @param position defines initial position
  46382. * @param interaxialDistance defines distance between each color axis
  46383. * @param scene defines the hosting scene
  46384. */
  46385. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  46386. /**
  46387. * Gets camera class name
  46388. * @returns AnaglyphFreeCamera
  46389. */
  46390. getClassName(): string;
  46391. }
  46392. }
  46393. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  46394. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  46395. import { Scene } from "babylonjs/scene";
  46396. import { Vector3 } from "babylonjs/Maths/math.vector";
  46397. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  46398. /**
  46399. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  46400. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46401. */
  46402. export class AnaglyphGamepadCamera extends GamepadCamera {
  46403. /**
  46404. * Creates a new AnaglyphGamepadCamera
  46405. * @param name defines camera name
  46406. * @param position defines initial position
  46407. * @param interaxialDistance defines distance between each color axis
  46408. * @param scene defines the hosting scene
  46409. */
  46410. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  46411. /**
  46412. * Gets camera class name
  46413. * @returns AnaglyphGamepadCamera
  46414. */
  46415. getClassName(): string;
  46416. }
  46417. }
  46418. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  46419. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  46420. import { Scene } from "babylonjs/scene";
  46421. import { Vector3 } from "babylonjs/Maths/math.vector";
  46422. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  46423. /**
  46424. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  46425. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46426. */
  46427. export class AnaglyphUniversalCamera extends UniversalCamera {
  46428. /**
  46429. * Creates a new AnaglyphUniversalCamera
  46430. * @param name defines camera name
  46431. * @param position defines initial position
  46432. * @param interaxialDistance defines distance between each color axis
  46433. * @param scene defines the hosting scene
  46434. */
  46435. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  46436. /**
  46437. * Gets camera class name
  46438. * @returns AnaglyphUniversalCamera
  46439. */
  46440. getClassName(): string;
  46441. }
  46442. }
  46443. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  46444. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  46445. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  46446. import { Scene } from "babylonjs/scene";
  46447. import { Vector3 } from "babylonjs/Maths/math.vector";
  46448. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  46449. /**
  46450. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  46451. * @see http://doc.babylonjs.com/features/cameras
  46452. */
  46453. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  46454. /**
  46455. * Creates a new StereoscopicArcRotateCamera
  46456. * @param name defines camera name
  46457. * @param alpha defines alpha angle (in radians)
  46458. * @param beta defines beta angle (in radians)
  46459. * @param radius defines radius
  46460. * @param target defines camera target
  46461. * @param interaxialDistance defines distance between each color axis
  46462. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46463. * @param scene defines the hosting scene
  46464. */
  46465. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46466. /**
  46467. * Gets camera class name
  46468. * @returns StereoscopicArcRotateCamera
  46469. */
  46470. getClassName(): string;
  46471. }
  46472. }
  46473. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  46474. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46475. import { Scene } from "babylonjs/scene";
  46476. import { Vector3 } from "babylonjs/Maths/math.vector";
  46477. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  46478. /**
  46479. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  46480. * @see http://doc.babylonjs.com/features/cameras
  46481. */
  46482. export class StereoscopicFreeCamera extends FreeCamera {
  46483. /**
  46484. * Creates a new StereoscopicFreeCamera
  46485. * @param name defines camera name
  46486. * @param position defines initial position
  46487. * @param interaxialDistance defines distance between each color axis
  46488. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46489. * @param scene defines the hosting scene
  46490. */
  46491. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46492. /**
  46493. * Gets camera class name
  46494. * @returns StereoscopicFreeCamera
  46495. */
  46496. getClassName(): string;
  46497. }
  46498. }
  46499. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  46500. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  46501. import { Scene } from "babylonjs/scene";
  46502. import { Vector3 } from "babylonjs/Maths/math.vector";
  46503. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  46504. /**
  46505. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  46506. * @see http://doc.babylonjs.com/features/cameras
  46507. */
  46508. export class StereoscopicGamepadCamera extends GamepadCamera {
  46509. /**
  46510. * Creates a new StereoscopicGamepadCamera
  46511. * @param name defines camera name
  46512. * @param position defines initial position
  46513. * @param interaxialDistance defines distance between each color axis
  46514. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46515. * @param scene defines the hosting scene
  46516. */
  46517. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46518. /**
  46519. * Gets camera class name
  46520. * @returns StereoscopicGamepadCamera
  46521. */
  46522. getClassName(): string;
  46523. }
  46524. }
  46525. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  46526. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  46527. import { Scene } from "babylonjs/scene";
  46528. import { Vector3 } from "babylonjs/Maths/math.vector";
  46529. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  46530. /**
  46531. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  46532. * @see http://doc.babylonjs.com/features/cameras
  46533. */
  46534. export class StereoscopicUniversalCamera extends UniversalCamera {
  46535. /**
  46536. * Creates a new StereoscopicUniversalCamera
  46537. * @param name defines camera name
  46538. * @param position defines initial position
  46539. * @param interaxialDistance defines distance between each color axis
  46540. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46541. * @param scene defines the hosting scene
  46542. */
  46543. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46544. /**
  46545. * Gets camera class name
  46546. * @returns StereoscopicUniversalCamera
  46547. */
  46548. getClassName(): string;
  46549. }
  46550. }
  46551. declare module "babylonjs/Cameras/Stereoscopic/index" {
  46552. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  46553. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  46554. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  46555. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  46556. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  46557. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  46558. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  46559. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  46560. }
  46561. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  46562. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46563. import { Scene } from "babylonjs/scene";
  46564. import { Vector3 } from "babylonjs/Maths/math.vector";
  46565. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  46566. /**
  46567. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  46568. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  46569. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  46570. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  46571. */
  46572. export class VirtualJoysticksCamera extends FreeCamera {
  46573. /**
  46574. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  46575. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  46576. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  46577. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  46578. * @param name Define the name of the camera in the scene
  46579. * @param position Define the start position of the camera in the scene
  46580. * @param scene Define the scene the camera belongs to
  46581. */
  46582. constructor(name: string, position: Vector3, scene: Scene);
  46583. /**
  46584. * Gets the current object class name.
  46585. * @return the class name
  46586. */
  46587. getClassName(): string;
  46588. }
  46589. }
  46590. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  46591. import { Matrix } from "babylonjs/Maths/math.vector";
  46592. /**
  46593. * This represents all the required metrics to create a VR camera.
  46594. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  46595. */
  46596. export class VRCameraMetrics {
  46597. /**
  46598. * Define the horizontal resolution off the screen.
  46599. */
  46600. hResolution: number;
  46601. /**
  46602. * Define the vertical resolution off the screen.
  46603. */
  46604. vResolution: number;
  46605. /**
  46606. * Define the horizontal screen size.
  46607. */
  46608. hScreenSize: number;
  46609. /**
  46610. * Define the vertical screen size.
  46611. */
  46612. vScreenSize: number;
  46613. /**
  46614. * Define the vertical screen center position.
  46615. */
  46616. vScreenCenter: number;
  46617. /**
  46618. * Define the distance of the eyes to the screen.
  46619. */
  46620. eyeToScreenDistance: number;
  46621. /**
  46622. * Define the distance between both lenses
  46623. */
  46624. lensSeparationDistance: number;
  46625. /**
  46626. * Define the distance between both viewer's eyes.
  46627. */
  46628. interpupillaryDistance: number;
  46629. /**
  46630. * Define the distortion factor of the VR postprocess.
  46631. * Please, touch with care.
  46632. */
  46633. distortionK: number[];
  46634. /**
  46635. * Define the chromatic aberration correction factors for the VR post process.
  46636. */
  46637. chromaAbCorrection: number[];
  46638. /**
  46639. * Define the scale factor of the post process.
  46640. * The smaller the better but the slower.
  46641. */
  46642. postProcessScaleFactor: number;
  46643. /**
  46644. * Define an offset for the lens center.
  46645. */
  46646. lensCenterOffset: number;
  46647. /**
  46648. * Define if the current vr camera should compensate the distortion of the lense or not.
  46649. */
  46650. compensateDistortion: boolean;
  46651. /**
  46652. * Defines if multiview should be enabled when rendering (Default: false)
  46653. */
  46654. multiviewEnabled: boolean;
  46655. /**
  46656. * Gets the rendering aspect ratio based on the provided resolutions.
  46657. */
  46658. get aspectRatio(): number;
  46659. /**
  46660. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  46661. */
  46662. get aspectRatioFov(): number;
  46663. /**
  46664. * @hidden
  46665. */
  46666. get leftHMatrix(): Matrix;
  46667. /**
  46668. * @hidden
  46669. */
  46670. get rightHMatrix(): Matrix;
  46671. /**
  46672. * @hidden
  46673. */
  46674. get leftPreViewMatrix(): Matrix;
  46675. /**
  46676. * @hidden
  46677. */
  46678. get rightPreViewMatrix(): Matrix;
  46679. /**
  46680. * Get the default VRMetrics based on the most generic setup.
  46681. * @returns the default vr metrics
  46682. */
  46683. static GetDefault(): VRCameraMetrics;
  46684. }
  46685. }
  46686. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  46687. /** @hidden */
  46688. export var vrDistortionCorrectionPixelShader: {
  46689. name: string;
  46690. shader: string;
  46691. };
  46692. }
  46693. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  46694. import { Camera } from "babylonjs/Cameras/camera";
  46695. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  46696. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  46697. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  46698. /**
  46699. * VRDistortionCorrectionPostProcess used for mobile VR
  46700. */
  46701. export class VRDistortionCorrectionPostProcess extends PostProcess {
  46702. private _isRightEye;
  46703. private _distortionFactors;
  46704. private _postProcessScaleFactor;
  46705. private _lensCenterOffset;
  46706. private _scaleIn;
  46707. private _scaleFactor;
  46708. private _lensCenter;
  46709. /**
  46710. * Initializes the VRDistortionCorrectionPostProcess
  46711. * @param name The name of the effect.
  46712. * @param camera The camera to apply the render pass to.
  46713. * @param isRightEye If this is for the right eye distortion
  46714. * @param vrMetrics All the required metrics for the VR camera
  46715. */
  46716. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  46717. }
  46718. }
  46719. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  46720. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  46721. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  46722. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  46723. import { Scene } from "babylonjs/scene";
  46724. import { Vector3 } from "babylonjs/Maths/math.vector";
  46725. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  46726. import "babylonjs/Cameras/RigModes/vrRigMode";
  46727. /**
  46728. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  46729. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  46730. */
  46731. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  46732. /**
  46733. * Creates a new VRDeviceOrientationArcRotateCamera
  46734. * @param name defines camera name
  46735. * @param alpha defines the camera rotation along the logitudinal axis
  46736. * @param beta defines the camera rotation along the latitudinal axis
  46737. * @param radius defines the camera distance from its target
  46738. * @param target defines the camera target
  46739. * @param scene defines the scene the camera belongs to
  46740. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  46741. * @param vrCameraMetrics defines the vr metrics associated to the camera
  46742. */
  46743. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  46744. /**
  46745. * Gets camera class name
  46746. * @returns VRDeviceOrientationArcRotateCamera
  46747. */
  46748. getClassName(): string;
  46749. }
  46750. }
  46751. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  46752. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  46753. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  46754. import { Scene } from "babylonjs/scene";
  46755. import { Vector3 } from "babylonjs/Maths/math.vector";
  46756. import "babylonjs/Cameras/RigModes/vrRigMode";
  46757. /**
  46758. * Camera used to simulate VR rendering (based on FreeCamera)
  46759. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  46760. */
  46761. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  46762. /**
  46763. * Creates a new VRDeviceOrientationFreeCamera
  46764. * @param name defines camera name
  46765. * @param position defines the start position of the camera
  46766. * @param scene defines the scene the camera belongs to
  46767. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  46768. * @param vrCameraMetrics defines the vr metrics associated to the camera
  46769. */
  46770. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  46771. /**
  46772. * Gets camera class name
  46773. * @returns VRDeviceOrientationFreeCamera
  46774. */
  46775. getClassName(): string;
  46776. }
  46777. }
  46778. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  46779. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  46780. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  46781. import { Scene } from "babylonjs/scene";
  46782. import { Vector3 } from "babylonjs/Maths/math.vector";
  46783. import "babylonjs/Gamepads/gamepadSceneComponent";
  46784. /**
  46785. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  46786. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  46787. */
  46788. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  46789. /**
  46790. * Creates a new VRDeviceOrientationGamepadCamera
  46791. * @param name defines camera name
  46792. * @param position defines the start position of the camera
  46793. * @param scene defines the scene the camera belongs to
  46794. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  46795. * @param vrCameraMetrics defines the vr metrics associated to the camera
  46796. */
  46797. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  46798. /**
  46799. * Gets camera class name
  46800. * @returns VRDeviceOrientationGamepadCamera
  46801. */
  46802. getClassName(): string;
  46803. }
  46804. }
  46805. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  46806. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  46807. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46808. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  46809. /** @hidden */
  46810. export var imageProcessingPixelShader: {
  46811. name: string;
  46812. shader: string;
  46813. };
  46814. }
  46815. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  46816. import { Nullable } from "babylonjs/types";
  46817. import { Color4 } from "babylonjs/Maths/math.color";
  46818. import { Camera } from "babylonjs/Cameras/camera";
  46819. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46820. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  46821. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  46822. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  46823. import { Engine } from "babylonjs/Engines/engine";
  46824. import "babylonjs/Shaders/imageProcessing.fragment";
  46825. import "babylonjs/Shaders/postprocess.vertex";
  46826. /**
  46827. * ImageProcessingPostProcess
  46828. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  46829. */
  46830. export class ImageProcessingPostProcess extends PostProcess {
  46831. /**
  46832. * Default configuration related to image processing available in the PBR Material.
  46833. */
  46834. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  46835. /**
  46836. * Gets the image processing configuration used either in this material.
  46837. */
  46838. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  46839. /**
  46840. * Sets the Default image processing configuration used either in the this material.
  46841. *
  46842. * If sets to null, the scene one is in use.
  46843. */
  46844. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  46845. /**
  46846. * Keep track of the image processing observer to allow dispose and replace.
  46847. */
  46848. private _imageProcessingObserver;
  46849. /**
  46850. * Attaches a new image processing configuration to the PBR Material.
  46851. * @param configuration
  46852. */
  46853. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  46854. /**
  46855. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  46856. */
  46857. get colorCurves(): Nullable<ColorCurves>;
  46858. /**
  46859. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  46860. */
  46861. set colorCurves(value: Nullable<ColorCurves>);
  46862. /**
  46863. * Gets wether the color curves effect is enabled.
  46864. */
  46865. get colorCurvesEnabled(): boolean;
  46866. /**
  46867. * Sets wether the color curves effect is enabled.
  46868. */
  46869. set colorCurvesEnabled(value: boolean);
  46870. /**
  46871. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  46872. */
  46873. get colorGradingTexture(): Nullable<BaseTexture>;
  46874. /**
  46875. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  46876. */
  46877. set colorGradingTexture(value: Nullable<BaseTexture>);
  46878. /**
  46879. * Gets wether the color grading effect is enabled.
  46880. */
  46881. get colorGradingEnabled(): boolean;
  46882. /**
  46883. * Gets wether the color grading effect is enabled.
  46884. */
  46885. set colorGradingEnabled(value: boolean);
  46886. /**
  46887. * Gets exposure used in the effect.
  46888. */
  46889. get exposure(): number;
  46890. /**
  46891. * Sets exposure used in the effect.
  46892. */
  46893. set exposure(value: number);
  46894. /**
  46895. * Gets wether tonemapping is enabled or not.
  46896. */
  46897. get toneMappingEnabled(): boolean;
  46898. /**
  46899. * Sets wether tonemapping is enabled or not
  46900. */
  46901. set toneMappingEnabled(value: boolean);
  46902. /**
  46903. * Gets the type of tone mapping effect.
  46904. */
  46905. get toneMappingType(): number;
  46906. /**
  46907. * Sets the type of tone mapping effect.
  46908. */
  46909. set toneMappingType(value: number);
  46910. /**
  46911. * Gets contrast used in the effect.
  46912. */
  46913. get contrast(): number;
  46914. /**
  46915. * Sets contrast used in the effect.
  46916. */
  46917. set contrast(value: number);
  46918. /**
  46919. * Gets Vignette stretch size.
  46920. */
  46921. get vignetteStretch(): number;
  46922. /**
  46923. * Sets Vignette stretch size.
  46924. */
  46925. set vignetteStretch(value: number);
  46926. /**
  46927. * Gets Vignette centre X Offset.
  46928. */
  46929. get vignetteCentreX(): number;
  46930. /**
  46931. * Sets Vignette centre X Offset.
  46932. */
  46933. set vignetteCentreX(value: number);
  46934. /**
  46935. * Gets Vignette centre Y Offset.
  46936. */
  46937. get vignetteCentreY(): number;
  46938. /**
  46939. * Sets Vignette centre Y Offset.
  46940. */
  46941. set vignetteCentreY(value: number);
  46942. /**
  46943. * Gets Vignette weight or intensity of the vignette effect.
  46944. */
  46945. get vignetteWeight(): number;
  46946. /**
  46947. * Sets Vignette weight or intensity of the vignette effect.
  46948. */
  46949. set vignetteWeight(value: number);
  46950. /**
  46951. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  46952. * if vignetteEnabled is set to true.
  46953. */
  46954. get vignetteColor(): Color4;
  46955. /**
  46956. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  46957. * if vignetteEnabled is set to true.
  46958. */
  46959. set vignetteColor(value: Color4);
  46960. /**
  46961. * Gets Camera field of view used by the Vignette effect.
  46962. */
  46963. get vignetteCameraFov(): number;
  46964. /**
  46965. * Sets Camera field of view used by the Vignette effect.
  46966. */
  46967. set vignetteCameraFov(value: number);
  46968. /**
  46969. * Gets the vignette blend mode allowing different kind of effect.
  46970. */
  46971. get vignetteBlendMode(): number;
  46972. /**
  46973. * Sets the vignette blend mode allowing different kind of effect.
  46974. */
  46975. set vignetteBlendMode(value: number);
  46976. /**
  46977. * Gets wether the vignette effect is enabled.
  46978. */
  46979. get vignetteEnabled(): boolean;
  46980. /**
  46981. * Sets wether the vignette effect is enabled.
  46982. */
  46983. set vignetteEnabled(value: boolean);
  46984. private _fromLinearSpace;
  46985. /**
  46986. * Gets wether the input of the processing is in Gamma or Linear Space.
  46987. */
  46988. get fromLinearSpace(): boolean;
  46989. /**
  46990. * Sets wether the input of the processing is in Gamma or Linear Space.
  46991. */
  46992. set fromLinearSpace(value: boolean);
  46993. /**
  46994. * Defines cache preventing GC.
  46995. */
  46996. private _defines;
  46997. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  46998. /**
  46999. * "ImageProcessingPostProcess"
  47000. * @returns "ImageProcessingPostProcess"
  47001. */
  47002. getClassName(): string;
  47003. protected _updateParameters(): void;
  47004. dispose(camera?: Camera): void;
  47005. }
  47006. }
  47007. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  47008. import { Scene } from "babylonjs/scene";
  47009. import { Color3 } from "babylonjs/Maths/math.color";
  47010. import { Mesh } from "babylonjs/Meshes/mesh";
  47011. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  47012. import { Nullable } from "babylonjs/types";
  47013. /**
  47014. * Class containing static functions to help procedurally build meshes
  47015. */
  47016. export class GroundBuilder {
  47017. /**
  47018. * Creates a ground mesh
  47019. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  47020. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  47021. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47022. * @param name defines the name of the mesh
  47023. * @param options defines the options used to create the mesh
  47024. * @param scene defines the hosting scene
  47025. * @returns the ground mesh
  47026. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  47027. */
  47028. static CreateGround(name: string, options: {
  47029. width?: number;
  47030. height?: number;
  47031. subdivisions?: number;
  47032. subdivisionsX?: number;
  47033. subdivisionsY?: number;
  47034. updatable?: boolean;
  47035. }, scene: any): Mesh;
  47036. /**
  47037. * Creates a tiled ground mesh
  47038. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  47039. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  47040. * * 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
  47041. * * 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
  47042. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  47043. * @param name defines the name of the mesh
  47044. * @param options defines the options used to create the mesh
  47045. * @param scene defines the hosting scene
  47046. * @returns the tiled ground mesh
  47047. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  47048. */
  47049. static CreateTiledGround(name: string, options: {
  47050. xmin: number;
  47051. zmin: number;
  47052. xmax: number;
  47053. zmax: number;
  47054. subdivisions?: {
  47055. w: number;
  47056. h: number;
  47057. };
  47058. precision?: {
  47059. w: number;
  47060. h: number;
  47061. };
  47062. updatable?: boolean;
  47063. }, scene?: Nullable<Scene>): Mesh;
  47064. /**
  47065. * Creates a ground mesh from a height map
  47066. * * The parameter `url` sets the URL of the height map image resource.
  47067. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  47068. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  47069. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  47070. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  47071. * * 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.
  47072. * * 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).
  47073. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  47074. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  47075. * @param name defines the name of the mesh
  47076. * @param url defines the url to the height map
  47077. * @param options defines the options used to create the mesh
  47078. * @param scene defines the hosting scene
  47079. * @returns the ground mesh
  47080. * @see https://doc.babylonjs.com/babylon101/height_map
  47081. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  47082. */
  47083. static CreateGroundFromHeightMap(name: string, url: string, options: {
  47084. width?: number;
  47085. height?: number;
  47086. subdivisions?: number;
  47087. minHeight?: number;
  47088. maxHeight?: number;
  47089. colorFilter?: Color3;
  47090. alphaFilter?: number;
  47091. updatable?: boolean;
  47092. onReady?: (mesh: GroundMesh) => void;
  47093. }, scene?: Nullable<Scene>): GroundMesh;
  47094. }
  47095. }
  47096. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  47097. import { Vector4 } from "babylonjs/Maths/math.vector";
  47098. import { Mesh } from "babylonjs/Meshes/mesh";
  47099. /**
  47100. * Class containing static functions to help procedurally build meshes
  47101. */
  47102. export class TorusBuilder {
  47103. /**
  47104. * Creates a torus mesh
  47105. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  47106. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  47107. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  47108. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47109. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  47110. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  47111. * @param name defines the name of the mesh
  47112. * @param options defines the options used to create the mesh
  47113. * @param scene defines the hosting scene
  47114. * @returns the torus mesh
  47115. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  47116. */
  47117. static CreateTorus(name: string, options: {
  47118. diameter?: number;
  47119. thickness?: number;
  47120. tessellation?: number;
  47121. updatable?: boolean;
  47122. sideOrientation?: number;
  47123. frontUVs?: Vector4;
  47124. backUVs?: Vector4;
  47125. }, scene: any): Mesh;
  47126. }
  47127. }
  47128. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  47129. import { Vector4 } from "babylonjs/Maths/math.vector";
  47130. import { Color4 } from "babylonjs/Maths/math.color";
  47131. import { Mesh } from "babylonjs/Meshes/mesh";
  47132. /**
  47133. * Class containing static functions to help procedurally build meshes
  47134. */
  47135. export class CylinderBuilder {
  47136. /**
  47137. * Creates a cylinder or a cone mesh
  47138. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  47139. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  47140. * * 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.
  47141. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  47142. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  47143. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  47144. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  47145. * * 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).
  47146. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  47147. * * 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).
  47148. * * 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
  47149. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  47150. * * 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
  47151. * * 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.
  47152. * * If `enclose` is false, a ring surface is one element.
  47153. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  47154. * * 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
  47155. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47156. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  47157. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  47158. * @param name defines the name of the mesh
  47159. * @param options defines the options used to create the mesh
  47160. * @param scene defines the hosting scene
  47161. * @returns the cylinder mesh
  47162. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  47163. */
  47164. static CreateCylinder(name: string, options: {
  47165. height?: number;
  47166. diameterTop?: number;
  47167. diameterBottom?: number;
  47168. diameter?: number;
  47169. tessellation?: number;
  47170. subdivisions?: number;
  47171. arc?: number;
  47172. faceColors?: Color4[];
  47173. faceUV?: Vector4[];
  47174. updatable?: boolean;
  47175. hasRings?: boolean;
  47176. enclose?: boolean;
  47177. cap?: number;
  47178. sideOrientation?: number;
  47179. frontUVs?: Vector4;
  47180. backUVs?: Vector4;
  47181. }, scene: any): Mesh;
  47182. }
  47183. }
  47184. declare module "babylonjs/XR/webXRTypes" {
  47185. import { Nullable } from "babylonjs/types";
  47186. import { IDisposable } from "babylonjs/scene";
  47187. /**
  47188. * States of the webXR experience
  47189. */
  47190. export enum WebXRState {
  47191. /**
  47192. * Transitioning to being in XR mode
  47193. */
  47194. ENTERING_XR = 0,
  47195. /**
  47196. * Transitioning to non XR mode
  47197. */
  47198. EXITING_XR = 1,
  47199. /**
  47200. * In XR mode and presenting
  47201. */
  47202. IN_XR = 2,
  47203. /**
  47204. * Not entered XR mode
  47205. */
  47206. NOT_IN_XR = 3
  47207. }
  47208. /**
  47209. * Abstraction of the XR render target
  47210. */
  47211. export interface WebXRRenderTarget extends IDisposable {
  47212. /**
  47213. * xrpresent context of the canvas which can be used to display/mirror xr content
  47214. */
  47215. canvasContext: WebGLRenderingContext;
  47216. /**
  47217. * xr layer for the canvas
  47218. */
  47219. xrLayer: Nullable<XRWebGLLayer>;
  47220. /**
  47221. * Initializes the xr layer for the session
  47222. * @param xrSession xr session
  47223. * @returns a promise that will resolve once the XR Layer has been created
  47224. */
  47225. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  47226. }
  47227. }
  47228. declare module "babylonjs/XR/webXRManagedOutputCanvas" {
  47229. import { Nullable } from "babylonjs/types";
  47230. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  47231. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  47232. /**
  47233. * COnfiguration object for WebXR output canvas
  47234. */
  47235. export class WebXRManagedOutputCanvasOptions {
  47236. /**
  47237. * An optional canvas in case you wish to create it yourself and provide it here.
  47238. * If not provided, a new canvas will be created
  47239. */
  47240. canvasElement?: HTMLCanvasElement;
  47241. /**
  47242. * Options for this XR Layer output
  47243. */
  47244. canvasOptions?: XRWebGLLayerOptions;
  47245. /**
  47246. * CSS styling for a newly created canvas (if not provided)
  47247. */
  47248. newCanvasCssStyle?: string;
  47249. /**
  47250. * Get the default values of the configuration object
  47251. * @returns default values of this configuration object
  47252. */
  47253. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  47254. }
  47255. /**
  47256. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  47257. */
  47258. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  47259. private _options;
  47260. private _canvas;
  47261. private _engine;
  47262. /**
  47263. * Rendering context of the canvas which can be used to display/mirror xr content
  47264. */
  47265. canvasContext: WebGLRenderingContext;
  47266. /**
  47267. * xr layer for the canvas
  47268. */
  47269. xrLayer: Nullable<XRWebGLLayer>;
  47270. /**
  47271. * Initializes the canvas to be added/removed upon entering/exiting xr
  47272. * @param _xrSessionManager The XR Session manager
  47273. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  47274. */
  47275. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  47276. /**
  47277. * Disposes of the object
  47278. */
  47279. dispose(): void;
  47280. /**
  47281. * Initializes the xr layer for the session
  47282. * @param xrSession xr session
  47283. * @returns a promise that will resolve once the XR Layer has been created
  47284. */
  47285. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  47286. private _addCanvas;
  47287. private _removeCanvas;
  47288. private _setManagedOutputCanvas;
  47289. }
  47290. }
  47291. declare module "babylonjs/XR/webXRSessionManager" {
  47292. import { Observable } from "babylonjs/Misc/observable";
  47293. import { Nullable } from "babylonjs/types";
  47294. import { IDisposable, Scene } from "babylonjs/scene";
  47295. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  47296. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  47297. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  47298. /**
  47299. * Manages an XRSession to work with Babylon's engine
  47300. * @see https://doc.babylonjs.com/how_to/webxr
  47301. */
  47302. export class WebXRSessionManager implements IDisposable {
  47303. /** The scene which the session should be created for */
  47304. scene: Scene;
  47305. private _referenceSpace;
  47306. private _rttProvider;
  47307. private _sessionEnded;
  47308. private _xrNavigator;
  47309. private baseLayer;
  47310. /**
  47311. * The base reference space from which the session started. good if you want to reset your
  47312. * reference space
  47313. */
  47314. baseReferenceSpace: XRReferenceSpace;
  47315. /**
  47316. * Current XR frame
  47317. */
  47318. currentFrame: Nullable<XRFrame>;
  47319. /** WebXR timestamp updated every frame */
  47320. currentTimestamp: number;
  47321. /**
  47322. * Used just in case of a failure to initialize an immersive session.
  47323. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  47324. */
  47325. defaultHeightCompensation: number;
  47326. /**
  47327. * Fires every time a new xrFrame arrives which can be used to update the camera
  47328. */
  47329. onXRFrameObservable: Observable<XRFrame>;
  47330. /**
  47331. * Fires when the reference space changed
  47332. */
  47333. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  47334. /**
  47335. * Fires when the xr session is ended either by the device or manually done
  47336. */
  47337. onXRSessionEnded: Observable<any>;
  47338. /**
  47339. * Fires when the xr session is ended either by the device or manually done
  47340. */
  47341. onXRSessionInit: Observable<XRSession>;
  47342. /**
  47343. * Underlying xr session
  47344. */
  47345. session: XRSession;
  47346. /**
  47347. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  47348. * or get the offset the player is currently at.
  47349. */
  47350. viewerReferenceSpace: XRReferenceSpace;
  47351. /**
  47352. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  47353. * @param scene The scene which the session should be created for
  47354. */
  47355. constructor(
  47356. /** The scene which the session should be created for */
  47357. scene: Scene);
  47358. /**
  47359. * The current reference space used in this session. This reference space can constantly change!
  47360. * It is mainly used to offset the camera's position.
  47361. */
  47362. get referenceSpace(): XRReferenceSpace;
  47363. /**
  47364. * Set a new reference space and triggers the observable
  47365. */
  47366. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  47367. /**
  47368. * Disposes of the session manager
  47369. */
  47370. dispose(): void;
  47371. /**
  47372. * Stops the xrSession and restores the render loop
  47373. * @returns Promise which resolves after it exits XR
  47374. */
  47375. exitXRAsync(): Promise<void>;
  47376. /**
  47377. * Gets the correct render target texture to be rendered this frame for this eye
  47378. * @param eye the eye for which to get the render target
  47379. * @returns the render target for the specified eye
  47380. */
  47381. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  47382. /**
  47383. * Creates a WebXRRenderTarget object for the XR session
  47384. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  47385. * @param options optional options to provide when creating a new render target
  47386. * @returns a WebXR render target to which the session can render
  47387. */
  47388. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  47389. /**
  47390. * Initializes the manager
  47391. * After initialization enterXR can be called to start an XR session
  47392. * @returns Promise which resolves after it is initialized
  47393. */
  47394. initializeAsync(): Promise<void>;
  47395. /**
  47396. * Initializes an xr session
  47397. * @param xrSessionMode mode to initialize
  47398. * @param xrSessionInit defines optional and required values to pass to the session builder
  47399. * @returns a promise which will resolve once the session has been initialized
  47400. */
  47401. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  47402. /**
  47403. * Checks if a session would be supported for the creation options specified
  47404. * @param sessionMode session mode to check if supported eg. immersive-vr
  47405. * @returns A Promise that resolves to true if supported and false if not
  47406. */
  47407. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  47408. /**
  47409. * Resets the reference space to the one started the session
  47410. */
  47411. resetReferenceSpace(): void;
  47412. /**
  47413. * Starts rendering to the xr layer
  47414. */
  47415. runXRRenderLoop(): void;
  47416. /**
  47417. * Sets the reference space on the xr session
  47418. * @param referenceSpaceType space to set
  47419. * @returns a promise that will resolve once the reference space has been set
  47420. */
  47421. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  47422. /**
  47423. * Updates the render state of the session
  47424. * @param state state to set
  47425. * @returns a promise that resolves once the render state has been updated
  47426. */
  47427. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  47428. /**
  47429. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  47430. * @param sessionMode defines the session to test
  47431. * @returns a promise with boolean as final value
  47432. */
  47433. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  47434. private _createRenderTargetTexture;
  47435. }
  47436. }
  47437. declare module "babylonjs/XR/webXRCamera" {
  47438. import { Matrix } from "babylonjs/Maths/math.vector";
  47439. import { Scene } from "babylonjs/scene";
  47440. import { Camera } from "babylonjs/Cameras/camera";
  47441. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  47442. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  47443. /**
  47444. * WebXR Camera which holds the views for the xrSession
  47445. * @see https://doc.babylonjs.com/how_to/webxr_camera
  47446. */
  47447. export class WebXRCamera extends FreeCamera {
  47448. private _xrSessionManager;
  47449. private _firstFrame;
  47450. private _referenceQuaternion;
  47451. private _referencedPosition;
  47452. private _xrInvPositionCache;
  47453. private _xrInvQuaternionCache;
  47454. /**
  47455. * Should position compensation execute on first frame.
  47456. * This is used when copying the position from a native (non XR) camera
  47457. */
  47458. compensateOnFirstFrame: boolean;
  47459. /**
  47460. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  47461. * @param name the name of the camera
  47462. * @param scene the scene to add the camera to
  47463. * @param _xrSessionManager a constructed xr session manager
  47464. */
  47465. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  47466. /**
  47467. * Return the user's height, unrelated to the current ground.
  47468. * This will be the y position of this camera, when ground level is 0.
  47469. */
  47470. get realWorldHeight(): number;
  47471. /** @hidden */
  47472. _updateForDualEyeDebugging(): void;
  47473. /**
  47474. * Sets this camera's transformation based on a non-vr camera
  47475. * @param otherCamera the non-vr camera to copy the transformation from
  47476. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  47477. */
  47478. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  47479. /**
  47480. * Gets the current instance class name ("WebXRCamera").
  47481. * @returns the class name
  47482. */
  47483. getClassName(): string;
  47484. /**
  47485. * Overriding the _getViewMatrix function, as it is computed by WebXR
  47486. */
  47487. _getViewMatrix(): Matrix;
  47488. private _updateFromXRSession;
  47489. private _updateNumberOfRigCameras;
  47490. private _updateReferenceSpace;
  47491. private _updateReferenceSpaceOffset;
  47492. }
  47493. }
  47494. declare module "babylonjs/XR/webXRFeaturesManager" {
  47495. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  47496. import { IDisposable } from "babylonjs/scene";
  47497. /**
  47498. * Defining the interface required for a (webxr) feature
  47499. */
  47500. export interface IWebXRFeature extends IDisposable {
  47501. /**
  47502. * Is this feature attached
  47503. */
  47504. attached: boolean;
  47505. /**
  47506. * Should auto-attach be disabled?
  47507. */
  47508. disableAutoAttach: boolean;
  47509. /**
  47510. * Attach the feature to the session
  47511. * Will usually be called by the features manager
  47512. *
  47513. * @param force should attachment be forced (even when already attached)
  47514. * @returns true if successful.
  47515. */
  47516. attach(force?: boolean): boolean;
  47517. /**
  47518. * Detach the feature from the session
  47519. * Will usually be called by the features manager
  47520. *
  47521. * @returns true if successful.
  47522. */
  47523. detach(): boolean;
  47524. }
  47525. /**
  47526. * A list of the currently available features without referencing them
  47527. */
  47528. export class WebXRFeatureName {
  47529. /**
  47530. * The name of the anchor system feature
  47531. */
  47532. static ANCHOR_SYSTEM: string;
  47533. /**
  47534. * The name of the background remover feature
  47535. */
  47536. static BACKGROUND_REMOVER: string;
  47537. /**
  47538. * The name of the hit test feature
  47539. */
  47540. static HIT_TEST: string;
  47541. /**
  47542. * physics impostors for xr controllers feature
  47543. */
  47544. static PHYSICS_CONTROLLERS: string;
  47545. /**
  47546. * The name of the plane detection feature
  47547. */
  47548. static PLANE_DETECTION: string;
  47549. /**
  47550. * The name of the pointer selection feature
  47551. */
  47552. static POINTER_SELECTION: string;
  47553. /**
  47554. * The name of the teleportation feature
  47555. */
  47556. static TELEPORTATION: string;
  47557. }
  47558. /**
  47559. * Defining the constructor of a feature. Used to register the modules.
  47560. */
  47561. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  47562. /**
  47563. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  47564. * It is mainly used in AR sessions.
  47565. *
  47566. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  47567. */
  47568. export class WebXRFeaturesManager implements IDisposable {
  47569. private _xrSessionManager;
  47570. private static readonly _AvailableFeatures;
  47571. private _features;
  47572. /**
  47573. * constructs a new features manages.
  47574. *
  47575. * @param _xrSessionManager an instance of WebXRSessionManager
  47576. */
  47577. constructor(_xrSessionManager: WebXRSessionManager);
  47578. /**
  47579. * Used to register a module. After calling this function a developer can use this feature in the scene.
  47580. * Mainly used internally.
  47581. *
  47582. * @param featureName the name of the feature to register
  47583. * @param constructorFunction the function used to construct the module
  47584. * @param version the (babylon) version of the module
  47585. * @param stable is that a stable version of this module
  47586. */
  47587. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  47588. /**
  47589. * Returns a constructor of a specific feature.
  47590. *
  47591. * @param featureName the name of the feature to construct
  47592. * @param version the version of the feature to load
  47593. * @param xrSessionManager the xrSessionManager. Used to construct the module
  47594. * @param options optional options provided to the module.
  47595. * @returns a function that, when called, will return a new instance of this feature
  47596. */
  47597. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  47598. /**
  47599. * Can be used to return the list of features currently registered
  47600. *
  47601. * @returns an Array of available features
  47602. */
  47603. static GetAvailableFeatures(): string[];
  47604. /**
  47605. * Gets the versions available for a specific feature
  47606. * @param featureName the name of the feature
  47607. * @returns an array with the available versions
  47608. */
  47609. static GetAvailableVersions(featureName: string): string[];
  47610. /**
  47611. * Return the latest unstable version of this feature
  47612. * @param featureName the name of the feature to search
  47613. * @returns the version number. if not found will return -1
  47614. */
  47615. static GetLatestVersionOfFeature(featureName: string): number;
  47616. /**
  47617. * Return the latest stable version of this feature
  47618. * @param featureName the name of the feature to search
  47619. * @returns the version number. if not found will return -1
  47620. */
  47621. static GetStableVersionOfFeature(featureName: string): number;
  47622. /**
  47623. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  47624. * Can be used during a session to start a feature
  47625. * @param featureName the name of feature to attach
  47626. */
  47627. attachFeature(featureName: string): void;
  47628. /**
  47629. * Can be used inside a session or when the session ends to detach a specific feature
  47630. * @param featureName the name of the feature to detach
  47631. */
  47632. detachFeature(featureName: string): void;
  47633. /**
  47634. * Used to disable an already-enabled feature
  47635. * The feature will be disposed and will be recreated once enabled.
  47636. * @param featureName the feature to disable
  47637. * @returns true if disable was successful
  47638. */
  47639. disableFeature(featureName: string | {
  47640. Name: string;
  47641. }): boolean;
  47642. /**
  47643. * dispose this features manager
  47644. */
  47645. dispose(): void;
  47646. /**
  47647. * 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.
  47648. * 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.
  47649. *
  47650. * @param featureName the name of the feature to load or the class of the feature
  47651. * @param version optional version to load. if not provided the latest version will be enabled
  47652. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  47653. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  47654. * @returns a new constructed feature or throws an error if feature not found.
  47655. */
  47656. enableFeature(featureName: string | {
  47657. Name: string;
  47658. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  47659. /**
  47660. * get the implementation of an enabled feature.
  47661. * @param featureName the name of the feature to load
  47662. * @returns the feature class, if found
  47663. */
  47664. getEnabledFeature(featureName: string): IWebXRFeature;
  47665. /**
  47666. * Get the list of enabled features
  47667. * @returns an array of enabled features
  47668. */
  47669. getEnabledFeatures(): string[];
  47670. }
  47671. }
  47672. declare module "babylonjs/XR/webXRExperienceHelper" {
  47673. import { Observable } from "babylonjs/Misc/observable";
  47674. import { IDisposable, Scene } from "babylonjs/scene";
  47675. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  47676. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  47677. import { WebXRState, WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  47678. import { WebXRFeaturesManager } from "babylonjs/XR/webXRFeaturesManager";
  47679. /**
  47680. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  47681. * @see https://doc.babylonjs.com/how_to/webxr
  47682. */
  47683. export class WebXRExperienceHelper implements IDisposable {
  47684. private scene;
  47685. private _nonVRCamera;
  47686. private _originalSceneAutoClear;
  47687. private _supported;
  47688. /**
  47689. * Camera used to render xr content
  47690. */
  47691. camera: WebXRCamera;
  47692. /** A features manager for this xr session */
  47693. featuresManager: WebXRFeaturesManager;
  47694. /**
  47695. * Observers registered here will be triggered after the camera's initial transformation is set
  47696. * This can be used to set a different ground level or an extra rotation.
  47697. *
  47698. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  47699. * to the position set after this observable is done executing.
  47700. */
  47701. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  47702. /**
  47703. * Fires when the state of the experience helper has changed
  47704. */
  47705. onStateChangedObservable: Observable<WebXRState>;
  47706. /** Session manager used to keep track of xr session */
  47707. sessionManager: WebXRSessionManager;
  47708. /**
  47709. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  47710. */
  47711. state: WebXRState;
  47712. /**
  47713. * Creates a WebXRExperienceHelper
  47714. * @param scene The scene the helper should be created in
  47715. */
  47716. private constructor();
  47717. /**
  47718. * Creates the experience helper
  47719. * @param scene the scene to attach the experience helper to
  47720. * @returns a promise for the experience helper
  47721. */
  47722. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  47723. /**
  47724. * Disposes of the experience helper
  47725. */
  47726. dispose(): void;
  47727. /**
  47728. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  47729. * @param sessionMode options for the XR session
  47730. * @param referenceSpaceType frame of reference of the XR session
  47731. * @param renderTarget the output canvas that will be used to enter XR mode
  47732. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  47733. * @returns promise that resolves after xr mode has entered
  47734. */
  47735. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  47736. /**
  47737. * Exits XR mode and returns the scene to its original state
  47738. * @returns promise that resolves after xr mode has exited
  47739. */
  47740. exitXRAsync(): Promise<void>;
  47741. private _nonXRToXRCamera;
  47742. private _setState;
  47743. }
  47744. }
  47745. declare module "babylonjs/XR/motionController/webXRControllerComponent" {
  47746. import { IMinimalMotionControllerObject, MotionControllerComponentType } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  47747. import { Observable } from "babylonjs/Misc/observable";
  47748. import { IDisposable } from "babylonjs/scene";
  47749. /**
  47750. * X-Y values for axes in WebXR
  47751. */
  47752. export interface IWebXRMotionControllerAxesValue {
  47753. /**
  47754. * The value of the x axis
  47755. */
  47756. x: number;
  47757. /**
  47758. * The value of the y-axis
  47759. */
  47760. y: number;
  47761. }
  47762. /**
  47763. * changed / previous values for the values of this component
  47764. */
  47765. export interface IWebXRMotionControllerComponentChangesValues<T> {
  47766. /**
  47767. * current (this frame) value
  47768. */
  47769. current: T;
  47770. /**
  47771. * previous (last change) value
  47772. */
  47773. previous: T;
  47774. }
  47775. /**
  47776. * Represents changes in the component between current frame and last values recorded
  47777. */
  47778. export interface IWebXRMotionControllerComponentChanges {
  47779. /**
  47780. * will be populated with previous and current values if axes changed
  47781. */
  47782. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  47783. /**
  47784. * will be populated with previous and current values if pressed changed
  47785. */
  47786. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  47787. /**
  47788. * will be populated with previous and current values if touched changed
  47789. */
  47790. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  47791. /**
  47792. * will be populated with previous and current values if value changed
  47793. */
  47794. value?: IWebXRMotionControllerComponentChangesValues<number>;
  47795. }
  47796. /**
  47797. * This class represents a single component (for example button or thumbstick) of a motion controller
  47798. */
  47799. export class WebXRControllerComponent implements IDisposable {
  47800. /**
  47801. * the id of this component
  47802. */
  47803. id: string;
  47804. /**
  47805. * the type of the component
  47806. */
  47807. type: MotionControllerComponentType;
  47808. private _buttonIndex;
  47809. private _axesIndices;
  47810. private _axes;
  47811. private _changes;
  47812. private _currentValue;
  47813. private _hasChanges;
  47814. private _pressed;
  47815. private _touched;
  47816. /**
  47817. * button component type
  47818. */
  47819. static BUTTON_TYPE: MotionControllerComponentType;
  47820. /**
  47821. * squeeze component type
  47822. */
  47823. static SQUEEZE_TYPE: MotionControllerComponentType;
  47824. /**
  47825. * Thumbstick component type
  47826. */
  47827. static THUMBSTICK_TYPE: MotionControllerComponentType;
  47828. /**
  47829. * Touchpad component type
  47830. */
  47831. static TOUCHPAD_TYPE: MotionControllerComponentType;
  47832. /**
  47833. * trigger component type
  47834. */
  47835. static TRIGGER_TYPE: MotionControllerComponentType;
  47836. /**
  47837. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  47838. * the axes data changes
  47839. */
  47840. onAxisValueChangedObservable: Observable<{
  47841. x: number;
  47842. y: number;
  47843. }>;
  47844. /**
  47845. * Observers registered here will be triggered when the state of a button changes
  47846. * State change is either pressed / touched / value
  47847. */
  47848. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  47849. /**
  47850. * Creates a new component for a motion controller.
  47851. * It is created by the motion controller itself
  47852. *
  47853. * @param id the id of this component
  47854. * @param type the type of the component
  47855. * @param _buttonIndex index in the buttons array of the gamepad
  47856. * @param _axesIndices indices of the values in the axes array of the gamepad
  47857. */
  47858. constructor(
  47859. /**
  47860. * the id of this component
  47861. */
  47862. id: string,
  47863. /**
  47864. * the type of the component
  47865. */
  47866. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  47867. /**
  47868. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  47869. */
  47870. get axes(): IWebXRMotionControllerAxesValue;
  47871. /**
  47872. * Get the changes. Elements will be populated only if they changed with their previous and current value
  47873. */
  47874. get changes(): IWebXRMotionControllerComponentChanges;
  47875. /**
  47876. * Return whether or not the component changed the last frame
  47877. */
  47878. get hasChanges(): boolean;
  47879. /**
  47880. * is the button currently pressed
  47881. */
  47882. get pressed(): boolean;
  47883. /**
  47884. * is the button currently touched
  47885. */
  47886. get touched(): boolean;
  47887. /**
  47888. * Get the current value of this component
  47889. */
  47890. get value(): number;
  47891. /**
  47892. * Dispose this component
  47893. */
  47894. dispose(): void;
  47895. /**
  47896. * Are there axes correlating to this component
  47897. * @return true is axes data is available
  47898. */
  47899. isAxes(): boolean;
  47900. /**
  47901. * Is this component a button (hence - pressable)
  47902. * @returns true if can be pressed
  47903. */
  47904. isButton(): boolean;
  47905. /**
  47906. * update this component using the gamepad object it is in. Called on every frame
  47907. * @param nativeController the native gamepad controller object
  47908. */
  47909. update(nativeController: IMinimalMotionControllerObject): void;
  47910. }
  47911. }
  47912. declare module "babylonjs/Loading/sceneLoader" {
  47913. import { Observable } from "babylonjs/Misc/observable";
  47914. import { Nullable } from "babylonjs/types";
  47915. import { Scene } from "babylonjs/scene";
  47916. import { Engine } from "babylonjs/Engines/engine";
  47917. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47918. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  47919. import { AssetContainer } from "babylonjs/assetContainer";
  47920. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  47921. import { Skeleton } from "babylonjs/Bones/skeleton";
  47922. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  47923. import { WebRequest } from "babylonjs/Misc/webRequest";
  47924. /**
  47925. * Class used to represent data loading progression
  47926. */
  47927. export class SceneLoaderProgressEvent {
  47928. /** defines if data length to load can be evaluated */
  47929. readonly lengthComputable: boolean;
  47930. /** defines the loaded data length */
  47931. readonly loaded: number;
  47932. /** defines the data length to load */
  47933. readonly total: number;
  47934. /**
  47935. * Create a new progress event
  47936. * @param lengthComputable defines if data length to load can be evaluated
  47937. * @param loaded defines the loaded data length
  47938. * @param total defines the data length to load
  47939. */
  47940. constructor(
  47941. /** defines if data length to load can be evaluated */
  47942. lengthComputable: boolean,
  47943. /** defines the loaded data length */
  47944. loaded: number,
  47945. /** defines the data length to load */
  47946. total: number);
  47947. /**
  47948. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  47949. * @param event defines the source event
  47950. * @returns a new SceneLoaderProgressEvent
  47951. */
  47952. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  47953. }
  47954. /**
  47955. * Interface used by SceneLoader plugins to define supported file extensions
  47956. */
  47957. export interface ISceneLoaderPluginExtensions {
  47958. /**
  47959. * Defines the list of supported extensions
  47960. */
  47961. [extension: string]: {
  47962. isBinary: boolean;
  47963. };
  47964. }
  47965. /**
  47966. * Interface used by SceneLoader plugin factory
  47967. */
  47968. export interface ISceneLoaderPluginFactory {
  47969. /**
  47970. * Defines the name of the factory
  47971. */
  47972. name: string;
  47973. /**
  47974. * Function called to create a new plugin
  47975. * @return the new plugin
  47976. */
  47977. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  47978. /**
  47979. * The callback that returns true if the data can be directly loaded.
  47980. * @param data string containing the file data
  47981. * @returns if the data can be loaded directly
  47982. */
  47983. canDirectLoad?(data: string): boolean;
  47984. }
  47985. /**
  47986. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  47987. */
  47988. export interface ISceneLoaderPluginBase {
  47989. /**
  47990. * The friendly name of this plugin.
  47991. */
  47992. name: string;
  47993. /**
  47994. * The file extensions supported by this plugin.
  47995. */
  47996. extensions: string | ISceneLoaderPluginExtensions;
  47997. /**
  47998. * The callback called when loading from a url.
  47999. * @param scene scene loading this url
  48000. * @param url url to load
  48001. * @param onSuccess callback called when the file successfully loads
  48002. * @param onProgress callback called while file is loading (if the server supports this mode)
  48003. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  48004. * @param onError callback called when the file fails to load
  48005. * @returns a file request object
  48006. */
  48007. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  48008. /**
  48009. * The callback called when loading from a file object.
  48010. * @param scene scene loading this file
  48011. * @param file defines the file to load
  48012. * @param onSuccess defines the callback to call when data is loaded
  48013. * @param onProgress defines the callback to call during loading process
  48014. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  48015. * @param onError defines the callback to call when an error occurs
  48016. * @returns a file request object
  48017. */
  48018. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  48019. /**
  48020. * The callback that returns true if the data can be directly loaded.
  48021. * @param data string containing the file data
  48022. * @returns if the data can be loaded directly
  48023. */
  48024. canDirectLoad?(data: string): boolean;
  48025. /**
  48026. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  48027. * @param scene scene loading this data
  48028. * @param data string containing the data
  48029. * @returns data to pass to the plugin
  48030. */
  48031. directLoad?(scene: Scene, data: string): any;
  48032. /**
  48033. * The callback that allows custom handling of the root url based on the response url.
  48034. * @param rootUrl the original root url
  48035. * @param responseURL the response url if available
  48036. * @returns the new root url
  48037. */
  48038. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  48039. }
  48040. /**
  48041. * Interface used to define a SceneLoader plugin
  48042. */
  48043. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  48044. /**
  48045. * Import meshes into a scene.
  48046. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  48047. * @param scene The scene to import into
  48048. * @param data The data to import
  48049. * @param rootUrl The root url for scene and resources
  48050. * @param meshes The meshes array to import into
  48051. * @param particleSystems The particle systems array to import into
  48052. * @param skeletons The skeletons array to import into
  48053. * @param onError The callback when import fails
  48054. * @returns True if successful or false otherwise
  48055. */
  48056. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  48057. /**
  48058. * Load into a scene.
  48059. * @param scene The scene to load into
  48060. * @param data The data to import
  48061. * @param rootUrl The root url for scene and resources
  48062. * @param onError The callback when import fails
  48063. * @returns True if successful or false otherwise
  48064. */
  48065. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  48066. /**
  48067. * Load into an asset container.
  48068. * @param scene The scene to load into
  48069. * @param data The data to import
  48070. * @param rootUrl The root url for scene and resources
  48071. * @param onError The callback when import fails
  48072. * @returns The loaded asset container
  48073. */
  48074. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  48075. }
  48076. /**
  48077. * Interface used to define an async SceneLoader plugin
  48078. */
  48079. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  48080. /**
  48081. * Import meshes into a scene.
  48082. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  48083. * @param scene The scene to import into
  48084. * @param data The data to import
  48085. * @param rootUrl The root url for scene and resources
  48086. * @param onProgress The callback when the load progresses
  48087. * @param fileName Defines the name of the file to load
  48088. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  48089. */
  48090. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  48091. meshes: AbstractMesh[];
  48092. particleSystems: IParticleSystem[];
  48093. skeletons: Skeleton[];
  48094. animationGroups: AnimationGroup[];
  48095. }>;
  48096. /**
  48097. * Load into a scene.
  48098. * @param scene The scene to load into
  48099. * @param data The data to import
  48100. * @param rootUrl The root url for scene and resources
  48101. * @param onProgress The callback when the load progresses
  48102. * @param fileName Defines the name of the file to load
  48103. * @returns Nothing
  48104. */
  48105. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  48106. /**
  48107. * Load into an asset container.
  48108. * @param scene The scene to load into
  48109. * @param data The data to import
  48110. * @param rootUrl The root url for scene and resources
  48111. * @param onProgress The callback when the load progresses
  48112. * @param fileName Defines the name of the file to load
  48113. * @returns The loaded asset container
  48114. */
  48115. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  48116. }
  48117. /**
  48118. * Mode that determines how to handle old animation groups before loading new ones.
  48119. */
  48120. export enum SceneLoaderAnimationGroupLoadingMode {
  48121. /**
  48122. * Reset all old animations to initial state then dispose them.
  48123. */
  48124. Clean = 0,
  48125. /**
  48126. * Stop all old animations.
  48127. */
  48128. Stop = 1,
  48129. /**
  48130. * Restart old animations from first frame.
  48131. */
  48132. Sync = 2,
  48133. /**
  48134. * Old animations remains untouched.
  48135. */
  48136. NoSync = 3
  48137. }
  48138. /**
  48139. * Class used to load scene from various file formats using registered plugins
  48140. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  48141. */
  48142. export class SceneLoader {
  48143. /**
  48144. * No logging while loading
  48145. */
  48146. static readonly NO_LOGGING: number;
  48147. /**
  48148. * Minimal logging while loading
  48149. */
  48150. static readonly MINIMAL_LOGGING: number;
  48151. /**
  48152. * Summary logging while loading
  48153. */
  48154. static readonly SUMMARY_LOGGING: number;
  48155. /**
  48156. * Detailled logging while loading
  48157. */
  48158. static readonly DETAILED_LOGGING: number;
  48159. /**
  48160. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  48161. */
  48162. static get ForceFullSceneLoadingForIncremental(): boolean;
  48163. static set ForceFullSceneLoadingForIncremental(value: boolean);
  48164. /**
  48165. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  48166. */
  48167. static get ShowLoadingScreen(): boolean;
  48168. static set ShowLoadingScreen(value: boolean);
  48169. /**
  48170. * Defines the current logging level (while loading the scene)
  48171. * @ignorenaming
  48172. */
  48173. static get loggingLevel(): number;
  48174. static set loggingLevel(value: number);
  48175. /**
  48176. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  48177. */
  48178. static get CleanBoneMatrixWeights(): boolean;
  48179. static set CleanBoneMatrixWeights(value: boolean);
  48180. /**
  48181. * Event raised when a plugin is used to load a scene
  48182. */
  48183. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  48184. private static _registeredPlugins;
  48185. private static _getDefaultPlugin;
  48186. private static _getPluginForExtension;
  48187. private static _getPluginForDirectLoad;
  48188. private static _getPluginForFilename;
  48189. private static _getDirectLoad;
  48190. private static _loadData;
  48191. private static _getFileInfo;
  48192. /**
  48193. * Gets a plugin that can load the given extension
  48194. * @param extension defines the extension to load
  48195. * @returns a plugin or null if none works
  48196. */
  48197. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  48198. /**
  48199. * Gets a boolean indicating that the given extension can be loaded
  48200. * @param extension defines the extension to load
  48201. * @returns true if the extension is supported
  48202. */
  48203. static IsPluginForExtensionAvailable(extension: string): boolean;
  48204. /**
  48205. * Adds a new plugin to the list of registered plugins
  48206. * @param plugin defines the plugin to add
  48207. */
  48208. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  48209. /**
  48210. * Import meshes into a scene
  48211. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  48212. * @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)
  48213. * @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)
  48214. * @param scene the instance of BABYLON.Scene to append to
  48215. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  48216. * @param onProgress a callback with a progress event for each file being loaded
  48217. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48218. * @param pluginExtension the extension used to determine the plugin
  48219. * @returns The loaded plugin
  48220. */
  48221. 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>;
  48222. /**
  48223. * Import meshes into a scene
  48224. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  48225. * @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)
  48226. * @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)
  48227. * @param scene the instance of BABYLON.Scene to append to
  48228. * @param onProgress a callback with a progress event for each file being loaded
  48229. * @param pluginExtension the extension used to determine the plugin
  48230. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  48231. */
  48232. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  48233. meshes: AbstractMesh[];
  48234. particleSystems: IParticleSystem[];
  48235. skeletons: Skeleton[];
  48236. animationGroups: AnimationGroup[];
  48237. }>;
  48238. /**
  48239. * Load a scene
  48240. * @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)
  48241. * @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)
  48242. * @param engine is the instance of BABYLON.Engine to use to create the scene
  48243. * @param onSuccess a callback with the scene when import succeeds
  48244. * @param onProgress a callback with a progress event for each file being loaded
  48245. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48246. * @param pluginExtension the extension used to determine the plugin
  48247. * @returns The loaded plugin
  48248. */
  48249. 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>;
  48250. /**
  48251. * Load a scene
  48252. * @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)
  48253. * @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)
  48254. * @param engine is the instance of BABYLON.Engine to use to create the scene
  48255. * @param onProgress a callback with a progress event for each file being loaded
  48256. * @param pluginExtension the extension used to determine the plugin
  48257. * @returns The loaded scene
  48258. */
  48259. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  48260. /**
  48261. * Append a scene
  48262. * @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)
  48263. * @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)
  48264. * @param scene is the instance of BABYLON.Scene to append to
  48265. * @param onSuccess a callback with the scene when import succeeds
  48266. * @param onProgress a callback with a progress event for each file being loaded
  48267. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48268. * @param pluginExtension the extension used to determine the plugin
  48269. * @returns The loaded plugin
  48270. */
  48271. 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>;
  48272. /**
  48273. * Append a scene
  48274. * @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)
  48275. * @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)
  48276. * @param scene is the instance of BABYLON.Scene to append to
  48277. * @param onProgress a callback with a progress event for each file being loaded
  48278. * @param pluginExtension the extension used to determine the plugin
  48279. * @returns The given scene
  48280. */
  48281. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  48282. /**
  48283. * Load a scene into an asset container
  48284. * @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)
  48285. * @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)
  48286. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  48287. * @param onSuccess a callback with the scene when import succeeds
  48288. * @param onProgress a callback with a progress event for each file being loaded
  48289. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48290. * @param pluginExtension the extension used to determine the plugin
  48291. * @returns The loaded plugin
  48292. */
  48293. 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>;
  48294. /**
  48295. * Load a scene into an asset container
  48296. * @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)
  48297. * @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)
  48298. * @param scene is the instance of Scene to append to
  48299. * @param onProgress a callback with a progress event for each file being loaded
  48300. * @param pluginExtension the extension used to determine the plugin
  48301. * @returns The loaded asset container
  48302. */
  48303. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  48304. /**
  48305. * Import animations from a file into a scene
  48306. * @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)
  48307. * @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)
  48308. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  48309. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  48310. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  48311. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  48312. * @param onSuccess a callback with the scene when import succeeds
  48313. * @param onProgress a callback with a progress event for each file being loaded
  48314. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48315. */
  48316. 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;
  48317. /**
  48318. * Import animations from a file into a scene
  48319. * @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)
  48320. * @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)
  48321. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  48322. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  48323. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  48324. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  48325. * @param onSuccess a callback with the scene when import succeeds
  48326. * @param onProgress a callback with a progress event for each file being loaded
  48327. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48328. * @returns the updated scene with imported animations
  48329. */
  48330. 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>;
  48331. }
  48332. }
  48333. declare module "babylonjs/XR/motionController/webXRAbstractMotionController" {
  48334. import { IDisposable, Scene } from "babylonjs/scene";
  48335. import { WebXRControllerComponent } from "babylonjs/XR/motionController/webXRControllerComponent";
  48336. import { Observable } from "babylonjs/Misc/observable";
  48337. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48338. import { Nullable } from "babylonjs/types";
  48339. /**
  48340. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  48341. */
  48342. export type MotionControllerHandedness = "none" | "left" | "right";
  48343. /**
  48344. * The type of components available in motion controllers.
  48345. * This is not the name of the component.
  48346. */
  48347. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  48348. /**
  48349. * The state of a controller component
  48350. */
  48351. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  48352. /**
  48353. * The schema of motion controller layout.
  48354. * No object will be initialized using this interface
  48355. * This is used just to define the profile.
  48356. */
  48357. export interface IMotionControllerLayout {
  48358. /**
  48359. * Path to load the assets. Usually relative to the base path
  48360. */
  48361. assetPath: string;
  48362. /**
  48363. * Available components (unsorted)
  48364. */
  48365. components: {
  48366. /**
  48367. * A map of component Ids
  48368. */
  48369. [componentId: string]: {
  48370. /**
  48371. * The type of input the component outputs
  48372. */
  48373. type: MotionControllerComponentType;
  48374. /**
  48375. * The indices of this component in the gamepad object
  48376. */
  48377. gamepadIndices: {
  48378. /**
  48379. * Index of button
  48380. */
  48381. button?: number;
  48382. /**
  48383. * If available, index of x-axis
  48384. */
  48385. xAxis?: number;
  48386. /**
  48387. * If available, index of y-axis
  48388. */
  48389. yAxis?: number;
  48390. };
  48391. /**
  48392. * The mesh's root node name
  48393. */
  48394. rootNodeName: string;
  48395. /**
  48396. * Animation definitions for this model
  48397. */
  48398. visualResponses: {
  48399. [stateKey: string]: {
  48400. /**
  48401. * What property will be animated
  48402. */
  48403. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  48404. /**
  48405. * What states influence this visual response
  48406. */
  48407. states: MotionControllerComponentStateType[];
  48408. /**
  48409. * Type of animation - movement or visibility
  48410. */
  48411. valueNodeProperty: "transform" | "visibility";
  48412. /**
  48413. * Base node name to move. Its position will be calculated according to the min and max nodes
  48414. */
  48415. valueNodeName?: string;
  48416. /**
  48417. * Minimum movement node
  48418. */
  48419. minNodeName?: string;
  48420. /**
  48421. * Max movement node
  48422. */
  48423. maxNodeName?: string;
  48424. };
  48425. };
  48426. /**
  48427. * If touch enabled, what is the name of node to display user feedback
  48428. */
  48429. touchPointNodeName?: string;
  48430. };
  48431. };
  48432. /**
  48433. * Is it xr standard mapping or not
  48434. */
  48435. gamepadMapping: "" | "xr-standard";
  48436. /**
  48437. * Base root node of this entire model
  48438. */
  48439. rootNodeName: string;
  48440. /**
  48441. * Defines the main button component id
  48442. */
  48443. selectComponentId: string;
  48444. }
  48445. /**
  48446. * A definition for the layout map in the input profile
  48447. */
  48448. export interface IMotionControllerLayoutMap {
  48449. /**
  48450. * Layouts with handedness type as a key
  48451. */
  48452. [handedness: string]: IMotionControllerLayout;
  48453. }
  48454. /**
  48455. * The XR Input profile schema
  48456. * Profiles can be found here:
  48457. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  48458. */
  48459. export interface IMotionControllerProfile {
  48460. /**
  48461. * fallback profiles for this profileId
  48462. */
  48463. fallbackProfileIds: string[];
  48464. /**
  48465. * The layout map, with handedness as key
  48466. */
  48467. layouts: IMotionControllerLayoutMap;
  48468. /**
  48469. * The id of this profile
  48470. * correlates to the profile(s) in the xrInput.profiles array
  48471. */
  48472. profileId: string;
  48473. }
  48474. /**
  48475. * A helper-interface for the 3 meshes needed for controller button animation
  48476. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  48477. */
  48478. export interface IMotionControllerButtonMeshMap {
  48479. /**
  48480. * the mesh that defines the pressed value mesh position.
  48481. * This is used to find the max-position of this button
  48482. */
  48483. pressedMesh: AbstractMesh;
  48484. /**
  48485. * the mesh that defines the unpressed value mesh position.
  48486. * This is used to find the min (or initial) position of this button
  48487. */
  48488. unpressedMesh: AbstractMesh;
  48489. /**
  48490. * The mesh that will be changed when value changes
  48491. */
  48492. valueMesh: AbstractMesh;
  48493. }
  48494. /**
  48495. * A helper-interface for the 3 meshes needed for controller axis animation.
  48496. * This will be expanded when touchpad animations are fully supported
  48497. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  48498. */
  48499. export interface IMotionControllerMeshMap {
  48500. /**
  48501. * the mesh that defines the maximum value mesh position.
  48502. */
  48503. maxMesh?: AbstractMesh;
  48504. /**
  48505. * the mesh that defines the minimum value mesh position.
  48506. */
  48507. minMesh?: AbstractMesh;
  48508. /**
  48509. * The mesh that will be changed when axis value changes
  48510. */
  48511. valueMesh: AbstractMesh;
  48512. }
  48513. /**
  48514. * The elements needed for change-detection of the gamepad objects in motion controllers
  48515. */
  48516. export interface IMinimalMotionControllerObject {
  48517. /**
  48518. * Available axes of this controller
  48519. */
  48520. axes: number[];
  48521. /**
  48522. * An array of available buttons
  48523. */
  48524. buttons: Array<{
  48525. /**
  48526. * Value of the button/trigger
  48527. */
  48528. value: number;
  48529. /**
  48530. * If the button/trigger is currently touched
  48531. */
  48532. touched: boolean;
  48533. /**
  48534. * If the button/trigger is currently pressed
  48535. */
  48536. pressed: boolean;
  48537. }>;
  48538. /**
  48539. * EXPERIMENTAL haptic support.
  48540. */
  48541. hapticActuators?: Array<{
  48542. pulse: (value: number, duration: number) => Promise<boolean>;
  48543. }>;
  48544. }
  48545. /**
  48546. * An Abstract Motion controller
  48547. * This class receives an xrInput and a profile layout and uses those to initialize the components
  48548. * Each component has an observable to check for changes in value and state
  48549. */
  48550. export abstract class WebXRAbstractMotionController implements IDisposable {
  48551. protected scene: Scene;
  48552. protected layout: IMotionControllerLayout;
  48553. /**
  48554. * The gamepad object correlating to this controller
  48555. */
  48556. gamepadObject: IMinimalMotionControllerObject;
  48557. /**
  48558. * handedness (left/right/none) of this controller
  48559. */
  48560. handedness: MotionControllerHandedness;
  48561. private _initComponent;
  48562. private _modelReady;
  48563. /**
  48564. * A map of components (WebXRControllerComponent) in this motion controller
  48565. * Components have a ComponentType and can also have both button and axis definitions
  48566. */
  48567. readonly components: {
  48568. [id: string]: WebXRControllerComponent;
  48569. };
  48570. /**
  48571. * Disable the model's animation. Can be set at any time.
  48572. */
  48573. disableAnimation: boolean;
  48574. /**
  48575. * Observers registered here will be triggered when the model of this controller is done loading
  48576. */
  48577. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  48578. /**
  48579. * The profile id of this motion controller
  48580. */
  48581. abstract profileId: string;
  48582. /**
  48583. * The root mesh of the model. It is null if the model was not yet initialized
  48584. */
  48585. rootMesh: Nullable<AbstractMesh>;
  48586. /**
  48587. * constructs a new abstract motion controller
  48588. * @param scene the scene to which the model of the controller will be added
  48589. * @param layout The profile layout to load
  48590. * @param gamepadObject The gamepad object correlating to this controller
  48591. * @param handedness handedness (left/right/none) of this controller
  48592. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  48593. */
  48594. constructor(scene: Scene, layout: IMotionControllerLayout,
  48595. /**
  48596. * The gamepad object correlating to this controller
  48597. */
  48598. gamepadObject: IMinimalMotionControllerObject,
  48599. /**
  48600. * handedness (left/right/none) of this controller
  48601. */
  48602. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  48603. /**
  48604. * Dispose this controller, the model mesh and all its components
  48605. */
  48606. dispose(): void;
  48607. /**
  48608. * Returns all components of specific type
  48609. * @param type the type to search for
  48610. * @return an array of components with this type
  48611. */
  48612. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  48613. /**
  48614. * get a component based an its component id as defined in layout.components
  48615. * @param id the id of the component
  48616. * @returns the component correlates to the id or undefined if not found
  48617. */
  48618. getComponent(id: string): WebXRControllerComponent;
  48619. /**
  48620. * Get the list of components available in this motion controller
  48621. * @returns an array of strings correlating to available components
  48622. */
  48623. getComponentIds(): string[];
  48624. /**
  48625. * Get the first component of specific type
  48626. * @param type type of component to find
  48627. * @return a controller component or null if not found
  48628. */
  48629. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  48630. /**
  48631. * Get the main (Select) component of this controller as defined in the layout
  48632. * @returns the main component of this controller
  48633. */
  48634. getMainComponent(): WebXRControllerComponent;
  48635. /**
  48636. * Loads the model correlating to this controller
  48637. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  48638. * @returns A promise fulfilled with the result of the model loading
  48639. */
  48640. loadModel(): Promise<boolean>;
  48641. /**
  48642. * Update this model using the current XRFrame
  48643. * @param xrFrame the current xr frame to use and update the model
  48644. */
  48645. updateFromXRFrame(xrFrame: XRFrame): void;
  48646. /**
  48647. * Backwards compatibility due to a deeply-integrated typo
  48648. */
  48649. get handness(): XREye;
  48650. /**
  48651. * Pulse (vibrate) this controller
  48652. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  48653. * Consecutive calls to this function will cancel the last pulse call
  48654. *
  48655. * @param value the strength of the pulse in 0.0...1.0 range
  48656. * @param duration Duration of the pulse in milliseconds
  48657. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  48658. * @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
  48659. */
  48660. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  48661. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  48662. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  48663. /**
  48664. * Moves the axis on the controller mesh based on its current state
  48665. * @param axis the index of the axis
  48666. * @param axisValue the value of the axis which determines the meshes new position
  48667. * @hidden
  48668. */
  48669. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  48670. /**
  48671. * Update the model itself with the current frame data
  48672. * @param xrFrame the frame to use for updating the model mesh
  48673. */
  48674. protected updateModel(xrFrame: XRFrame): void;
  48675. /**
  48676. * Get the filename and path for this controller's model
  48677. * @returns a map of filename and path
  48678. */
  48679. protected abstract _getFilenameAndPath(): {
  48680. filename: string;
  48681. path: string;
  48682. };
  48683. /**
  48684. * This function is called before the mesh is loaded. It checks for loading constraints.
  48685. * For example, this function can check if the GLB loader is available
  48686. * If this function returns false, the generic controller will be loaded instead
  48687. * @returns Is the client ready to load the mesh
  48688. */
  48689. protected abstract _getModelLoadingConstraints(): boolean;
  48690. /**
  48691. * This function will be called after the model was successfully loaded and can be used
  48692. * for mesh transformations before it is available for the user
  48693. * @param meshes the loaded meshes
  48694. */
  48695. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  48696. /**
  48697. * Set the root mesh for this controller. Important for the WebXR controller class
  48698. * @param meshes the loaded meshes
  48699. */
  48700. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  48701. /**
  48702. * A function executed each frame that updates the mesh (if needed)
  48703. * @param xrFrame the current xrFrame
  48704. */
  48705. protected abstract _updateModel(xrFrame: XRFrame): void;
  48706. private _getGenericFilenameAndPath;
  48707. private _getGenericParentMesh;
  48708. }
  48709. }
  48710. declare module "babylonjs/XR/motionController/webXRGenericMotionController" {
  48711. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  48712. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48713. import { Scene } from "babylonjs/scene";
  48714. /**
  48715. * A generic trigger-only motion controller for WebXR
  48716. */
  48717. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  48718. /**
  48719. * Static version of the profile id of this controller
  48720. */
  48721. static ProfileId: string;
  48722. profileId: string;
  48723. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  48724. protected _getFilenameAndPath(): {
  48725. filename: string;
  48726. path: string;
  48727. };
  48728. protected _getModelLoadingConstraints(): boolean;
  48729. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  48730. protected _setRootMesh(meshes: AbstractMesh[]): void;
  48731. protected _updateModel(): void;
  48732. }
  48733. }
  48734. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  48735. import { Vector4 } from "babylonjs/Maths/math.vector";
  48736. import { Mesh } from "babylonjs/Meshes/mesh";
  48737. import { Scene } from "babylonjs/scene";
  48738. import { Nullable } from "babylonjs/types";
  48739. /**
  48740. * Class containing static functions to help procedurally build meshes
  48741. */
  48742. export class SphereBuilder {
  48743. /**
  48744. * Creates a sphere mesh
  48745. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  48746. * * 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`)
  48747. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  48748. * * 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
  48749. * * 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)
  48750. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48751. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  48752. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48753. * @param name defines the name of the mesh
  48754. * @param options defines the options used to create the mesh
  48755. * @param scene defines the hosting scene
  48756. * @returns the sphere mesh
  48757. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  48758. */
  48759. static CreateSphere(name: string, options: {
  48760. segments?: number;
  48761. diameter?: number;
  48762. diameterX?: number;
  48763. diameterY?: number;
  48764. diameterZ?: number;
  48765. arc?: number;
  48766. slice?: number;
  48767. sideOrientation?: number;
  48768. frontUVs?: Vector4;
  48769. backUVs?: Vector4;
  48770. updatable?: boolean;
  48771. }, scene?: Nullable<Scene>): Mesh;
  48772. }
  48773. }
  48774. declare module "babylonjs/XR/motionController/webXRProfiledMotionController" {
  48775. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48776. import { WebXRAbstractMotionController, IMotionControllerProfile } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  48777. import { Scene } from "babylonjs/scene";
  48778. /**
  48779. * A profiled motion controller has its profile loaded from an online repository.
  48780. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  48781. */
  48782. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  48783. private _repositoryUrl;
  48784. private _buttonMeshMapping;
  48785. private _touchDots;
  48786. /**
  48787. * The profile ID of this controller. Will be populated when the controller initializes.
  48788. */
  48789. profileId: string;
  48790. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  48791. dispose(): void;
  48792. protected _getFilenameAndPath(): {
  48793. filename: string;
  48794. path: string;
  48795. };
  48796. protected _getModelLoadingConstraints(): boolean;
  48797. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  48798. protected _setRootMesh(meshes: AbstractMesh[]): void;
  48799. protected _updateModel(_xrFrame: XRFrame): void;
  48800. }
  48801. }
  48802. declare module "babylonjs/XR/motionController/webXRMotionControllerManager" {
  48803. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  48804. import { Scene } from "babylonjs/scene";
  48805. /**
  48806. * A construction function type to create a new controller based on an xrInput object
  48807. */
  48808. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  48809. /**
  48810. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  48811. *
  48812. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  48813. * it should be replaced with auto-loaded controllers.
  48814. *
  48815. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  48816. */
  48817. export class WebXRMotionControllerManager {
  48818. private static _AvailableControllers;
  48819. private static _Fallbacks;
  48820. private static _ProfileLoadingPromises;
  48821. private static _ProfilesList;
  48822. /**
  48823. * The base URL of the online controller repository. Can be changed at any time.
  48824. */
  48825. static BaseRepositoryUrl: string;
  48826. /**
  48827. * Which repository gets priority - local or online
  48828. */
  48829. static PrioritizeOnlineRepository: boolean;
  48830. /**
  48831. * Use the online repository, or use only locally-defined controllers
  48832. */
  48833. static UseOnlineRepository: boolean;
  48834. /**
  48835. * Clear the cache used for profile loading and reload when requested again
  48836. */
  48837. static ClearProfilesCache(): void;
  48838. /**
  48839. * Register the default fallbacks.
  48840. * This function is called automatically when this file is imported.
  48841. */
  48842. static DefaultFallbacks(): void;
  48843. /**
  48844. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  48845. * @param profileId the profile to which a fallback needs to be found
  48846. * @return an array with corresponding fallback profiles
  48847. */
  48848. static FindFallbackWithProfileId(profileId: string): string[];
  48849. /**
  48850. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  48851. * The order of search:
  48852. *
  48853. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  48854. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  48855. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  48856. * 4) return the generic trigger controller if none were found
  48857. *
  48858. * @param xrInput the xrInput to which a new controller is initialized
  48859. * @param scene the scene to which the model will be added
  48860. * @param forceProfile force a certain profile for this controller
  48861. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  48862. */
  48863. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  48864. /**
  48865. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  48866. *
  48867. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  48868. *
  48869. * @param type the profile type to register
  48870. * @param constructFunction the function to be called when loading this profile
  48871. */
  48872. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  48873. /**
  48874. * Register a fallback to a specific profile.
  48875. * @param profileId the profileId that will receive the fallbacks
  48876. * @param fallbacks A list of fallback profiles
  48877. */
  48878. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  48879. /**
  48880. * Will update the list of profiles available in the repository
  48881. * @return a promise that resolves to a map of profiles available online
  48882. */
  48883. static UpdateProfilesList(): Promise<{
  48884. [profile: string]: string;
  48885. }>;
  48886. private static _LoadProfileFromRepository;
  48887. private static _LoadProfilesFromAvailableControllers;
  48888. }
  48889. }
  48890. declare module "babylonjs/XR/webXRInputSource" {
  48891. import { Observable } from "babylonjs/Misc/observable";
  48892. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48893. import { Ray } from "babylonjs/Culling/ray";
  48894. import { Scene } from "babylonjs/scene";
  48895. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  48896. /**
  48897. * Configuration options for the WebXR controller creation
  48898. */
  48899. export interface IWebXRControllerOptions {
  48900. /**
  48901. * Should the controller mesh be animated when a user interacts with it
  48902. * The pressed buttons / thumbstick and touchpad animations will be disabled
  48903. */
  48904. disableMotionControllerAnimation?: boolean;
  48905. /**
  48906. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  48907. */
  48908. doNotLoadControllerMesh?: boolean;
  48909. /**
  48910. * Force a specific controller type for this controller.
  48911. * This can be used when creating your own profile or when testing different controllers
  48912. */
  48913. forceControllerProfile?: string;
  48914. /**
  48915. * Defines a rendering group ID for meshes that will be loaded.
  48916. * This is for the default controllers only.
  48917. */
  48918. renderingGroupId?: number;
  48919. }
  48920. /**
  48921. * Represents an XR controller
  48922. */
  48923. export class WebXRInputSource {
  48924. private _scene;
  48925. /** The underlying input source for the controller */
  48926. inputSource: XRInputSource;
  48927. private _options;
  48928. private _tmpVector;
  48929. private _uniqueId;
  48930. /**
  48931. * 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
  48932. */
  48933. grip?: AbstractMesh;
  48934. /**
  48935. * If available, this is the gamepad object related to this controller.
  48936. * Using this object it is possible to get click events and trackpad changes of the
  48937. * webxr controller that is currently being used.
  48938. */
  48939. motionController?: WebXRAbstractMotionController;
  48940. /**
  48941. * Event that fires when the controller is removed/disposed.
  48942. * The object provided as event data is this controller, after associated assets were disposed.
  48943. * uniqueId is still available.
  48944. */
  48945. onDisposeObservable: Observable<WebXRInputSource>;
  48946. /**
  48947. * Will be triggered when the mesh associated with the motion controller is done loading.
  48948. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  48949. * A shortened version of controller -> motion controller -> on mesh loaded.
  48950. */
  48951. onMeshLoadedObservable: Observable<AbstractMesh>;
  48952. /**
  48953. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  48954. */
  48955. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  48956. /**
  48957. * Pointer which can be used to select objects or attach a visible laser to
  48958. */
  48959. pointer: AbstractMesh;
  48960. /**
  48961. * Creates the controller
  48962. * @see https://doc.babylonjs.com/how_to/webxr
  48963. * @param _scene the scene which the controller should be associated to
  48964. * @param inputSource the underlying input source for the controller
  48965. * @param _options options for this controller creation
  48966. */
  48967. constructor(_scene: Scene,
  48968. /** The underlying input source for the controller */
  48969. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  48970. /**
  48971. * Get this controllers unique id
  48972. */
  48973. get uniqueId(): string;
  48974. /**
  48975. * Disposes of the object
  48976. */
  48977. dispose(): void;
  48978. /**
  48979. * Gets a world space ray coming from the pointer or grip
  48980. * @param result the resulting ray
  48981. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  48982. */
  48983. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  48984. /**
  48985. * Updates the controller pose based on the given XRFrame
  48986. * @param xrFrame xr frame to update the pose with
  48987. * @param referenceSpace reference space to use
  48988. */
  48989. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  48990. }
  48991. }
  48992. declare module "babylonjs/XR/webXRInput" {
  48993. import { Observable } from "babylonjs/Misc/observable";
  48994. import { IDisposable } from "babylonjs/scene";
  48995. import { WebXRInputSource, IWebXRControllerOptions } from "babylonjs/XR/webXRInputSource";
  48996. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  48997. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  48998. /**
  48999. * The schema for initialization options of the XR Input class
  49000. */
  49001. export interface IWebXRInputOptions {
  49002. /**
  49003. * If set to true no model will be automatically loaded
  49004. */
  49005. doNotLoadControllerMeshes?: boolean;
  49006. /**
  49007. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  49008. * If not found, the xr input profile data will be used.
  49009. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  49010. */
  49011. forceInputProfile?: string;
  49012. /**
  49013. * Do not send a request to the controller repository to load the profile.
  49014. *
  49015. * Instead, use the controllers available in babylon itself.
  49016. */
  49017. disableOnlineControllerRepository?: boolean;
  49018. /**
  49019. * A custom URL for the controllers repository
  49020. */
  49021. customControllersRepositoryURL?: string;
  49022. /**
  49023. * Should the controller model's components not move according to the user input
  49024. */
  49025. disableControllerAnimation?: boolean;
  49026. /**
  49027. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  49028. */
  49029. controllerOptions?: IWebXRControllerOptions;
  49030. }
  49031. /**
  49032. * XR input used to track XR inputs such as controllers/rays
  49033. */
  49034. export class WebXRInput implements IDisposable {
  49035. /**
  49036. * the xr session manager for this session
  49037. */
  49038. xrSessionManager: WebXRSessionManager;
  49039. /**
  49040. * the WebXR camera for this session. Mainly used for teleportation
  49041. */
  49042. xrCamera: WebXRCamera;
  49043. private readonly options;
  49044. /**
  49045. * XR controllers being tracked
  49046. */
  49047. controllers: Array<WebXRInputSource>;
  49048. private _frameObserver;
  49049. private _sessionEndedObserver;
  49050. private _sessionInitObserver;
  49051. /**
  49052. * Event when a controller has been connected/added
  49053. */
  49054. onControllerAddedObservable: Observable<WebXRInputSource>;
  49055. /**
  49056. * Event when a controller has been removed/disconnected
  49057. */
  49058. onControllerRemovedObservable: Observable<WebXRInputSource>;
  49059. /**
  49060. * Initializes the WebXRInput
  49061. * @param xrSessionManager the xr session manager for this session
  49062. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  49063. * @param options = initialization options for this xr input
  49064. */
  49065. constructor(
  49066. /**
  49067. * the xr session manager for this session
  49068. */
  49069. xrSessionManager: WebXRSessionManager,
  49070. /**
  49071. * the WebXR camera for this session. Mainly used for teleportation
  49072. */
  49073. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  49074. private _onInputSourcesChange;
  49075. private _addAndRemoveControllers;
  49076. /**
  49077. * Disposes of the object
  49078. */
  49079. dispose(): void;
  49080. }
  49081. }
  49082. declare module "babylonjs/XR/features/WebXRAbstractFeature" {
  49083. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  49084. import { Observable, EventState } from "babylonjs/Misc/observable";
  49085. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  49086. /**
  49087. * This is the base class for all WebXR features.
  49088. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  49089. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  49090. */
  49091. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  49092. protected _xrSessionManager: WebXRSessionManager;
  49093. private _attached;
  49094. private _removeOnDetach;
  49095. /**
  49096. * Should auto-attach be disabled?
  49097. */
  49098. disableAutoAttach: boolean;
  49099. /**
  49100. * Construct a new (abstract) WebXR feature
  49101. * @param _xrSessionManager the xr session manager for this feature
  49102. */
  49103. constructor(_xrSessionManager: WebXRSessionManager);
  49104. /**
  49105. * Is this feature attached
  49106. */
  49107. get attached(): boolean;
  49108. /**
  49109. * attach this feature
  49110. *
  49111. * @param force should attachment be forced (even when already attached)
  49112. * @returns true if successful, false is failed or already attached
  49113. */
  49114. attach(force?: boolean): boolean;
  49115. /**
  49116. * detach this feature.
  49117. *
  49118. * @returns true if successful, false if failed or already detached
  49119. */
  49120. detach(): boolean;
  49121. /**
  49122. * Dispose this feature and all of the resources attached
  49123. */
  49124. dispose(): void;
  49125. /**
  49126. * This is used to register callbacks that will automatically be removed when detach is called.
  49127. * @param observable the observable to which the observer will be attached
  49128. * @param callback the callback to register
  49129. */
  49130. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  49131. /**
  49132. * Code in this function will be executed on each xrFrame received from the browser.
  49133. * This function will not execute after the feature is detached.
  49134. * @param _xrFrame the current frame
  49135. */
  49136. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  49137. }
  49138. }
  49139. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  49140. import { IDisposable, Scene } from "babylonjs/scene";
  49141. import { Nullable } from "babylonjs/types";
  49142. import { Observable } from "babylonjs/Misc/observable";
  49143. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49144. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  49145. import { Camera } from "babylonjs/Cameras/camera";
  49146. /**
  49147. * Renders a layer on top of an existing scene
  49148. */
  49149. export class UtilityLayerRenderer implements IDisposable {
  49150. /** the original scene that will be rendered on top of */
  49151. originalScene: Scene;
  49152. private _pointerCaptures;
  49153. private _lastPointerEvents;
  49154. private static _DefaultUtilityLayer;
  49155. private static _DefaultKeepDepthUtilityLayer;
  49156. private _sharedGizmoLight;
  49157. private _renderCamera;
  49158. /**
  49159. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  49160. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  49161. * @returns the camera that is used when rendering the utility layer
  49162. */
  49163. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  49164. /**
  49165. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  49166. * @param cam the camera that should be used when rendering the utility layer
  49167. */
  49168. setRenderCamera(cam: Nullable<Camera>): void;
  49169. /**
  49170. * @hidden
  49171. * Light which used by gizmos to get light shading
  49172. */
  49173. _getSharedGizmoLight(): HemisphericLight;
  49174. /**
  49175. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  49176. */
  49177. pickUtilitySceneFirst: boolean;
  49178. /**
  49179. * 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)
  49180. */
  49181. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  49182. /**
  49183. * 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)
  49184. */
  49185. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  49186. /**
  49187. * The scene that is rendered on top of the original scene
  49188. */
  49189. utilityLayerScene: Scene;
  49190. /**
  49191. * If the utility layer should automatically be rendered on top of existing scene
  49192. */
  49193. shouldRender: boolean;
  49194. /**
  49195. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  49196. */
  49197. onlyCheckPointerDownEvents: boolean;
  49198. /**
  49199. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  49200. */
  49201. processAllEvents: boolean;
  49202. /**
  49203. * Observable raised when the pointer move from the utility layer scene to the main scene
  49204. */
  49205. onPointerOutObservable: Observable<number>;
  49206. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  49207. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  49208. private _afterRenderObserver;
  49209. private _sceneDisposeObserver;
  49210. private _originalPointerObserver;
  49211. /**
  49212. * Instantiates a UtilityLayerRenderer
  49213. * @param originalScene the original scene that will be rendered on top of
  49214. * @param handleEvents boolean indicating if the utility layer should handle events
  49215. */
  49216. constructor(
  49217. /** the original scene that will be rendered on top of */
  49218. originalScene: Scene, handleEvents?: boolean);
  49219. private _notifyObservers;
  49220. /**
  49221. * Renders the utility layers scene on top of the original scene
  49222. */
  49223. render(): void;
  49224. /**
  49225. * Disposes of the renderer
  49226. */
  49227. dispose(): void;
  49228. private _updateCamera;
  49229. }
  49230. }
  49231. declare module "babylonjs/XR/features/WebXRControllerPointerSelection" {
  49232. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  49233. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49234. import { WebXRInput } from "babylonjs/XR/webXRInput";
  49235. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  49236. import { Scene } from "babylonjs/scene";
  49237. import { Nullable } from "babylonjs/types";
  49238. import { Color3 } from "babylonjs/Maths/math.color";
  49239. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  49240. /**
  49241. * Options interface for the pointer selection module
  49242. */
  49243. export interface IWebXRControllerPointerSelectionOptions {
  49244. /**
  49245. * if provided, this scene will be used to render meshes.
  49246. */
  49247. customUtilityLayerScene?: Scene;
  49248. /**
  49249. * 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)
  49250. * If not disabled, the last picked point will be used to execute a pointer up event
  49251. * If disabled, pointer up event will be triggered right after the pointer down event.
  49252. * Used in screen and gaze target ray mode only
  49253. */
  49254. disablePointerUpOnTouchOut: boolean;
  49255. /**
  49256. * For gaze mode (time to select instead of press)
  49257. */
  49258. forceGazeMode: boolean;
  49259. /**
  49260. * 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
  49261. * to start a new countdown to the pointer down event.
  49262. * Defaults to 1.
  49263. */
  49264. gazeModePointerMovedFactor?: number;
  49265. /**
  49266. * Different button type to use instead of the main component
  49267. */
  49268. overrideButtonId?: string;
  49269. /**
  49270. * use this rendering group id for the meshes (optional)
  49271. */
  49272. renderingGroupId?: number;
  49273. /**
  49274. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  49275. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  49276. * 3000 means 3 seconds between pointing at something and selecting it
  49277. */
  49278. timeToSelect?: number;
  49279. /**
  49280. * Should meshes created here be added to a utility layer or the main scene
  49281. */
  49282. useUtilityLayer?: boolean;
  49283. /**
  49284. * the xr input to use with this pointer selection
  49285. */
  49286. xrInput: WebXRInput;
  49287. }
  49288. /**
  49289. * A module that will enable pointer selection for motion controllers of XR Input Sources
  49290. */
  49291. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  49292. private readonly _options;
  49293. private static _idCounter;
  49294. private _attachController;
  49295. private _controllers;
  49296. private _scene;
  49297. private _tmpVectorForPickCompare;
  49298. /**
  49299. * The module's name
  49300. */
  49301. static readonly Name: string;
  49302. /**
  49303. * The (Babylon) version of this module.
  49304. * This is an integer representing the implementation version.
  49305. * This number does not correspond to the WebXR specs version
  49306. */
  49307. static readonly Version: number;
  49308. /**
  49309. * Disable lighting on the laser pointer (so it will always be visible)
  49310. */
  49311. disablePointerLighting: boolean;
  49312. /**
  49313. * Disable lighting on the selection mesh (so it will always be visible)
  49314. */
  49315. disableSelectionMeshLighting: boolean;
  49316. /**
  49317. * Should the laser pointer be displayed
  49318. */
  49319. displayLaserPointer: boolean;
  49320. /**
  49321. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  49322. */
  49323. displaySelectionMesh: boolean;
  49324. /**
  49325. * This color will be set to the laser pointer when selection is triggered
  49326. */
  49327. laserPointerPickedColor: Color3;
  49328. /**
  49329. * Default color of the laser pointer
  49330. */
  49331. lasterPointerDefaultColor: Color3;
  49332. /**
  49333. * default color of the selection ring
  49334. */
  49335. selectionMeshDefaultColor: Color3;
  49336. /**
  49337. * This color will be applied to the selection ring when selection is triggered
  49338. */
  49339. selectionMeshPickedColor: Color3;
  49340. /**
  49341. * Optional filter to be used for ray selection. This predicate shares behavior with
  49342. * scene.pointerMovePredicate which takes priority if it is also assigned.
  49343. */
  49344. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  49345. /**
  49346. * constructs a new background remover module
  49347. * @param _xrSessionManager the session manager for this module
  49348. * @param _options read-only options to be used in this module
  49349. */
  49350. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  49351. /**
  49352. * attach this feature
  49353. * Will usually be called by the features manager
  49354. *
  49355. * @returns true if successful.
  49356. */
  49357. attach(): boolean;
  49358. /**
  49359. * detach this feature.
  49360. * Will usually be called by the features manager
  49361. *
  49362. * @returns true if successful.
  49363. */
  49364. detach(): boolean;
  49365. /**
  49366. * Will get the mesh under a specific pointer.
  49367. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  49368. * @param controllerId the controllerId to check
  49369. * @returns The mesh under pointer or null if no mesh is under the pointer
  49370. */
  49371. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  49372. /**
  49373. * Get the xr controller that correlates to the pointer id in the pointer event
  49374. *
  49375. * @param id the pointer id to search for
  49376. * @returns the controller that correlates to this id or null if not found
  49377. */
  49378. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  49379. protected _onXRFrame(_xrFrame: XRFrame): void;
  49380. private _attachGazeMode;
  49381. private _attachScreenRayMode;
  49382. private _attachTrackedPointerRayMode;
  49383. private _convertNormalToDirectionOfRay;
  49384. private _detachController;
  49385. private _generateNewMeshPair;
  49386. private _pickingMoved;
  49387. private _updatePointerDistance;
  49388. }
  49389. }
  49390. declare module "babylonjs/XR/webXREnterExitUI" {
  49391. import { Nullable } from "babylonjs/types";
  49392. import { Observable } from "babylonjs/Misc/observable";
  49393. import { IDisposable, Scene } from "babylonjs/scene";
  49394. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  49395. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  49396. /**
  49397. * Button which can be used to enter a different mode of XR
  49398. */
  49399. export class WebXREnterExitUIButton {
  49400. /** button element */
  49401. element: HTMLElement;
  49402. /** XR initialization options for the button */
  49403. sessionMode: XRSessionMode;
  49404. /** Reference space type */
  49405. referenceSpaceType: XRReferenceSpaceType;
  49406. /**
  49407. * Creates a WebXREnterExitUIButton
  49408. * @param element button element
  49409. * @param sessionMode XR initialization session mode
  49410. * @param referenceSpaceType the type of reference space to be used
  49411. */
  49412. constructor(
  49413. /** button element */
  49414. element: HTMLElement,
  49415. /** XR initialization options for the button */
  49416. sessionMode: XRSessionMode,
  49417. /** Reference space type */
  49418. referenceSpaceType: XRReferenceSpaceType);
  49419. /**
  49420. * Extendable function which can be used to update the button's visuals when the state changes
  49421. * @param activeButton the current active button in the UI
  49422. */
  49423. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  49424. }
  49425. /**
  49426. * Options to create the webXR UI
  49427. */
  49428. export class WebXREnterExitUIOptions {
  49429. /**
  49430. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  49431. */
  49432. customButtons?: Array<WebXREnterExitUIButton>;
  49433. /**
  49434. * A reference space type to use when creating the default button.
  49435. * Default is local-floor
  49436. */
  49437. referenceSpaceType?: XRReferenceSpaceType;
  49438. /**
  49439. * Context to enter xr with
  49440. */
  49441. renderTarget?: Nullable<WebXRRenderTarget>;
  49442. /**
  49443. * A session mode to use when creating the default button.
  49444. * Default is immersive-vr
  49445. */
  49446. sessionMode?: XRSessionMode;
  49447. /**
  49448. * A list of optional features to init the session with
  49449. */
  49450. optionalFeatures?: string[];
  49451. }
  49452. /**
  49453. * UI to allow the user to enter/exit XR mode
  49454. */
  49455. export class WebXREnterExitUI implements IDisposable {
  49456. private scene;
  49457. /** version of the options passed to this UI */
  49458. options: WebXREnterExitUIOptions;
  49459. private _activeButton;
  49460. private _buttons;
  49461. private _overlay;
  49462. /**
  49463. * Fired every time the active button is changed.
  49464. *
  49465. * When xr is entered via a button that launches xr that button will be the callback parameter
  49466. *
  49467. * When exiting xr the callback parameter will be null)
  49468. */
  49469. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  49470. /**
  49471. *
  49472. * @param scene babylon scene object to use
  49473. * @param options (read-only) version of the options passed to this UI
  49474. */
  49475. private constructor();
  49476. /**
  49477. * Creates UI to allow the user to enter/exit XR mode
  49478. * @param scene the scene to add the ui to
  49479. * @param helper the xr experience helper to enter/exit xr with
  49480. * @param options options to configure the UI
  49481. * @returns the created ui
  49482. */
  49483. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  49484. /**
  49485. * Disposes of the XR UI component
  49486. */
  49487. dispose(): void;
  49488. private _updateButtons;
  49489. }
  49490. }
  49491. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  49492. import { Vector3 } from "babylonjs/Maths/math.vector";
  49493. import { Color4 } from "babylonjs/Maths/math.color";
  49494. import { Nullable } from "babylonjs/types";
  49495. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  49496. import { Scene } from "babylonjs/scene";
  49497. /**
  49498. * Class containing static functions to help procedurally build meshes
  49499. */
  49500. export class LinesBuilder {
  49501. /**
  49502. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  49503. * * 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
  49504. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  49505. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  49506. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  49507. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  49508. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  49509. * * 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
  49510. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  49511. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49512. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  49513. * @param name defines the name of the new line system
  49514. * @param options defines the options used to create the line system
  49515. * @param scene defines the hosting scene
  49516. * @returns a new line system mesh
  49517. */
  49518. static CreateLineSystem(name: string, options: {
  49519. lines: Vector3[][];
  49520. updatable?: boolean;
  49521. instance?: Nullable<LinesMesh>;
  49522. colors?: Nullable<Color4[][]>;
  49523. useVertexAlpha?: boolean;
  49524. }, scene: Nullable<Scene>): LinesMesh;
  49525. /**
  49526. * Creates a line mesh
  49527. * 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
  49528. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  49529. * * The parameter `points` is an array successive Vector3
  49530. * * 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
  49531. * * The optional parameter `colors` is an array of successive Color4, one per line point
  49532. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  49533. * * When updating an instance, remember that only point positions can change, not the number of points
  49534. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49535. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  49536. * @param name defines the name of the new line system
  49537. * @param options defines the options used to create the line system
  49538. * @param scene defines the hosting scene
  49539. * @returns a new line mesh
  49540. */
  49541. static CreateLines(name: string, options: {
  49542. points: Vector3[];
  49543. updatable?: boolean;
  49544. instance?: Nullable<LinesMesh>;
  49545. colors?: Color4[];
  49546. useVertexAlpha?: boolean;
  49547. }, scene?: Nullable<Scene>): LinesMesh;
  49548. /**
  49549. * Creates a dashed line mesh
  49550. * * 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
  49551. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  49552. * * The parameter `points` is an array successive Vector3
  49553. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  49554. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  49555. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  49556. * * 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
  49557. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  49558. * * When updating an instance, remember that only point positions can change, not the number of points
  49559. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49560. * @param name defines the name of the mesh
  49561. * @param options defines the options used to create the mesh
  49562. * @param scene defines the hosting scene
  49563. * @returns the dashed line mesh
  49564. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  49565. */
  49566. static CreateDashedLines(name: string, options: {
  49567. points: Vector3[];
  49568. dashSize?: number;
  49569. gapSize?: number;
  49570. dashNb?: number;
  49571. updatable?: boolean;
  49572. instance?: LinesMesh;
  49573. useVertexAlpha?: boolean;
  49574. }, scene?: Nullable<Scene>): LinesMesh;
  49575. }
  49576. }
  49577. declare module "babylonjs/XR/features/WebXRControllerTeleportation" {
  49578. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  49579. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  49580. import { WebXRInput } from "babylonjs/XR/webXRInput";
  49581. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49582. import { Vector3 } from "babylonjs/Maths/math.vector";
  49583. import { Material } from "babylonjs/Materials/material";
  49584. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  49585. import { Scene } from "babylonjs/scene";
  49586. /**
  49587. * The options container for the teleportation module
  49588. */
  49589. export interface IWebXRTeleportationOptions {
  49590. /**
  49591. * if provided, this scene will be used to render meshes.
  49592. */
  49593. customUtilityLayerScene?: Scene;
  49594. /**
  49595. * Values to configure the default target mesh
  49596. */
  49597. defaultTargetMeshOptions?: {
  49598. /**
  49599. * Fill color of the teleportation area
  49600. */
  49601. teleportationFillColor?: string;
  49602. /**
  49603. * Border color for the teleportation area
  49604. */
  49605. teleportationBorderColor?: string;
  49606. /**
  49607. * Disable the mesh's animation sequence
  49608. */
  49609. disableAnimation?: boolean;
  49610. /**
  49611. * Disable lighting on the material or the ring and arrow
  49612. */
  49613. disableLighting?: boolean;
  49614. /**
  49615. * Override the default material of the torus and arrow
  49616. */
  49617. torusArrowMaterial?: Material;
  49618. };
  49619. /**
  49620. * A list of meshes to use as floor meshes.
  49621. * Meshes can be added and removed after initializing the feature using the
  49622. * addFloorMesh and removeFloorMesh functions
  49623. * If empty, rotation will still work
  49624. */
  49625. floorMeshes?: AbstractMesh[];
  49626. /**
  49627. * use this rendering group id for the meshes (optional)
  49628. */
  49629. renderingGroupId?: number;
  49630. /**
  49631. * Should teleportation move only to snap points
  49632. */
  49633. snapPointsOnly?: boolean;
  49634. /**
  49635. * An array of points to which the teleportation will snap to.
  49636. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  49637. */
  49638. snapPositions?: Vector3[];
  49639. /**
  49640. * How close should the teleportation ray be in order to snap to position.
  49641. * Default to 0.8 units (meters)
  49642. */
  49643. snapToPositionRadius?: number;
  49644. /**
  49645. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  49646. * If you want to support rotation, make sure your mesh has a direction indicator.
  49647. *
  49648. * When left untouched, the default mesh will be initialized.
  49649. */
  49650. teleportationTargetMesh?: AbstractMesh;
  49651. /**
  49652. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  49653. */
  49654. timeToTeleport?: number;
  49655. /**
  49656. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  49657. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  49658. */
  49659. useMainComponentOnly?: boolean;
  49660. /**
  49661. * Should meshes created here be added to a utility layer or the main scene
  49662. */
  49663. useUtilityLayer?: boolean;
  49664. /**
  49665. * Babylon XR Input class for controller
  49666. */
  49667. xrInput: WebXRInput;
  49668. }
  49669. /**
  49670. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  49671. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  49672. * the input of the attached controllers.
  49673. */
  49674. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  49675. private _options;
  49676. private _controllers;
  49677. private _currentTeleportationControllerId;
  49678. private _floorMeshes;
  49679. private _quadraticBezierCurve;
  49680. private _selectionFeature;
  49681. private _snapToPositions;
  49682. private _snappedToPoint;
  49683. private _teleportationRingMaterial?;
  49684. private _tmpRay;
  49685. private _tmpVector;
  49686. /**
  49687. * The module's name
  49688. */
  49689. static readonly Name: string;
  49690. /**
  49691. * The (Babylon) version of this module.
  49692. * This is an integer representing the implementation version.
  49693. * This number does not correspond to the webxr specs version
  49694. */
  49695. static readonly Version: number;
  49696. /**
  49697. * Is movement backwards enabled
  49698. */
  49699. backwardsMovementEnabled: boolean;
  49700. /**
  49701. * Distance to travel when moving backwards
  49702. */
  49703. backwardsTeleportationDistance: number;
  49704. /**
  49705. * The distance from the user to the inspection point in the direction of the controller
  49706. * A higher number will allow the user to move further
  49707. * defaults to 5 (meters, in xr units)
  49708. */
  49709. parabolicCheckRadius: number;
  49710. /**
  49711. * Should the module support parabolic ray on top of direct ray
  49712. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  49713. * Very helpful when moving between floors / different heights
  49714. */
  49715. parabolicRayEnabled: boolean;
  49716. /**
  49717. * How much rotation should be applied when rotating right and left
  49718. */
  49719. rotationAngle: number;
  49720. /**
  49721. * Is rotation enabled when moving forward?
  49722. * Disabling this feature will prevent the user from deciding the direction when teleporting
  49723. */
  49724. rotationEnabled: boolean;
  49725. /**
  49726. * constructs a new anchor system
  49727. * @param _xrSessionManager an instance of WebXRSessionManager
  49728. * @param _options configuration object for this feature
  49729. */
  49730. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  49731. /**
  49732. * Get the snapPointsOnly flag
  49733. */
  49734. get snapPointsOnly(): boolean;
  49735. /**
  49736. * Sets the snapPointsOnly flag
  49737. * @param snapToPoints should teleportation be exclusively to snap points
  49738. */
  49739. set snapPointsOnly(snapToPoints: boolean);
  49740. /**
  49741. * Add a new mesh to the floor meshes array
  49742. * @param mesh the mesh to use as floor mesh
  49743. */
  49744. addFloorMesh(mesh: AbstractMesh): void;
  49745. /**
  49746. * Add a new snap-to point to fix teleportation to this position
  49747. * @param newSnapPoint The new Snap-To point
  49748. */
  49749. addSnapPoint(newSnapPoint: Vector3): void;
  49750. attach(): boolean;
  49751. detach(): boolean;
  49752. dispose(): void;
  49753. /**
  49754. * Remove a mesh from the floor meshes array
  49755. * @param mesh the mesh to remove
  49756. */
  49757. removeFloorMesh(mesh: AbstractMesh): void;
  49758. /**
  49759. * Remove a mesh from the floor meshes array using its name
  49760. * @param name the mesh name to remove
  49761. */
  49762. removeFloorMeshByName(name: string): void;
  49763. /**
  49764. * 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
  49765. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  49766. * @returns was the point found and removed or not
  49767. */
  49768. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  49769. /**
  49770. * This function sets a selection feature that will be disabled when
  49771. * the forward ray is shown and will be reattached when hidden.
  49772. * This is used to remove the selection rays when moving.
  49773. * @param selectionFeature the feature to disable when forward movement is enabled
  49774. */
  49775. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  49776. protected _onXRFrame(_xrFrame: XRFrame): void;
  49777. private _attachController;
  49778. private _createDefaultTargetMesh;
  49779. private _detachController;
  49780. private _findClosestSnapPointWithRadius;
  49781. private _setTargetMeshPosition;
  49782. private _setTargetMeshVisibility;
  49783. private _showParabolicPath;
  49784. private _teleportForward;
  49785. }
  49786. }
  49787. declare module "babylonjs/XR/webXRDefaultExperience" {
  49788. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  49789. import { Scene } from "babylonjs/scene";
  49790. import { WebXRInput, IWebXRInputOptions } from "babylonjs/XR/webXRInput";
  49791. import { WebXRControllerPointerSelection } from "babylonjs/XR/features/WebXRControllerPointerSelection";
  49792. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  49793. import { WebXREnterExitUI, WebXREnterExitUIOptions } from "babylonjs/XR/webXREnterExitUI";
  49794. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49795. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  49796. import { WebXRMotionControllerTeleportation } from "babylonjs/XR/features/WebXRControllerTeleportation";
  49797. /**
  49798. * Options for the default xr helper
  49799. */
  49800. export class WebXRDefaultExperienceOptions {
  49801. /**
  49802. * Enable or disable default UI to enter XR
  49803. */
  49804. disableDefaultUI?: boolean;
  49805. /**
  49806. * Should teleportation not initialize. defaults to false.
  49807. */
  49808. disableTeleportation?: boolean;
  49809. /**
  49810. * Floor meshes that will be used for teleport
  49811. */
  49812. floorMeshes?: Array<AbstractMesh>;
  49813. /**
  49814. * If set to true, the first frame will not be used to reset position
  49815. * The first frame is mainly used when copying transformation from the old camera
  49816. * Mainly used in AR
  49817. */
  49818. ignoreNativeCameraTransformation?: boolean;
  49819. /**
  49820. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  49821. */
  49822. inputOptions?: IWebXRInputOptions;
  49823. /**
  49824. * optional configuration for the output canvas
  49825. */
  49826. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  49827. /**
  49828. * optional UI options. This can be used among other to change session mode and reference space type
  49829. */
  49830. uiOptions?: WebXREnterExitUIOptions;
  49831. /**
  49832. * When loading teleportation and pointer select, use stable versions instead of latest.
  49833. */
  49834. useStablePlugins?: boolean;
  49835. /**
  49836. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  49837. */
  49838. renderingGroupId?: number;
  49839. /**
  49840. * A list of optional features to init the session with
  49841. * If set to true, all features we support will be added
  49842. */
  49843. optionalFeatures?: boolean | string[];
  49844. }
  49845. /**
  49846. * Default experience which provides a similar setup to the previous webVRExperience
  49847. */
  49848. export class WebXRDefaultExperience {
  49849. /**
  49850. * Base experience
  49851. */
  49852. baseExperience: WebXRExperienceHelper;
  49853. /**
  49854. * Enables ui for entering/exiting xr
  49855. */
  49856. enterExitUI: WebXREnterExitUI;
  49857. /**
  49858. * Input experience extension
  49859. */
  49860. input: WebXRInput;
  49861. /**
  49862. * Enables laser pointer and selection
  49863. */
  49864. pointerSelection: WebXRControllerPointerSelection;
  49865. /**
  49866. * Default target xr should render to
  49867. */
  49868. renderTarget: WebXRRenderTarget;
  49869. /**
  49870. * Enables teleportation
  49871. */
  49872. teleportation: WebXRMotionControllerTeleportation;
  49873. private constructor();
  49874. /**
  49875. * Creates the default xr experience
  49876. * @param scene scene
  49877. * @param options options for basic configuration
  49878. * @returns resulting WebXRDefaultExperience
  49879. */
  49880. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  49881. /**
  49882. * DIsposes of the experience helper
  49883. */
  49884. dispose(): void;
  49885. }
  49886. }
  49887. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  49888. import { Observable } from "babylonjs/Misc/observable";
  49889. import { Nullable } from "babylonjs/types";
  49890. import { Camera } from "babylonjs/Cameras/camera";
  49891. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  49892. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  49893. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  49894. import { Scene } from "babylonjs/scene";
  49895. import { Vector3 } from "babylonjs/Maths/math.vector";
  49896. import { Color3 } from "babylonjs/Maths/math.color";
  49897. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49898. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49899. import { Mesh } from "babylonjs/Meshes/mesh";
  49900. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  49901. import { EasingFunction } from "babylonjs/Animations/easing";
  49902. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  49903. import "babylonjs/Meshes/Builders/groundBuilder";
  49904. import "babylonjs/Meshes/Builders/torusBuilder";
  49905. import "babylonjs/Meshes/Builders/cylinderBuilder";
  49906. import "babylonjs/Gamepads/gamepadSceneComponent";
  49907. import "babylonjs/Animations/animatable";
  49908. import { WebXRDefaultExperience } from "babylonjs/XR/webXRDefaultExperience";
  49909. /**
  49910. * Options to modify the vr teleportation behavior.
  49911. */
  49912. export interface VRTeleportationOptions {
  49913. /**
  49914. * The name of the mesh which should be used as the teleportation floor. (default: null)
  49915. */
  49916. floorMeshName?: string;
  49917. /**
  49918. * A list of meshes to be used as the teleportation floor. (default: empty)
  49919. */
  49920. floorMeshes?: Mesh[];
  49921. /**
  49922. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  49923. */
  49924. teleportationMode?: number;
  49925. /**
  49926. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  49927. */
  49928. teleportationTime?: number;
  49929. /**
  49930. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  49931. */
  49932. teleportationSpeed?: number;
  49933. /**
  49934. * The easing function used in the animation or null for Linear. (default CircleEase)
  49935. */
  49936. easingFunction?: EasingFunction;
  49937. }
  49938. /**
  49939. * Options to modify the vr experience helper's behavior.
  49940. */
  49941. export interface VRExperienceHelperOptions extends WebVROptions {
  49942. /**
  49943. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  49944. */
  49945. createDeviceOrientationCamera?: boolean;
  49946. /**
  49947. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  49948. */
  49949. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  49950. /**
  49951. * Uses the main button on the controller to toggle the laser casted. (default: true)
  49952. */
  49953. laserToggle?: boolean;
  49954. /**
  49955. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  49956. */
  49957. floorMeshes?: Mesh[];
  49958. /**
  49959. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  49960. */
  49961. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  49962. /**
  49963. * Defines if WebXR should be used instead of WebVR (if available)
  49964. */
  49965. useXR?: boolean;
  49966. }
  49967. /**
  49968. * Event containing information after VR has been entered
  49969. */
  49970. export class OnAfterEnteringVRObservableEvent {
  49971. /**
  49972. * If entering vr was successful
  49973. */
  49974. success: boolean;
  49975. }
  49976. /**
  49977. * Helps to quickly add VR support to an existing scene.
  49978. * See http://doc.babylonjs.com/how_to/webvr_helper
  49979. */
  49980. export class VRExperienceHelper {
  49981. /** Options to modify the vr experience helper's behavior. */
  49982. webVROptions: VRExperienceHelperOptions;
  49983. private _scene;
  49984. private _position;
  49985. private _btnVR;
  49986. private _btnVRDisplayed;
  49987. private _webVRsupported;
  49988. private _webVRready;
  49989. private _webVRrequesting;
  49990. private _webVRpresenting;
  49991. private _hasEnteredVR;
  49992. private _fullscreenVRpresenting;
  49993. private _inputElement;
  49994. private _webVRCamera;
  49995. private _vrDeviceOrientationCamera;
  49996. private _deviceOrientationCamera;
  49997. private _existingCamera;
  49998. private _onKeyDown;
  49999. private _onVrDisplayPresentChange;
  50000. private _onVRDisplayChanged;
  50001. private _onVRRequestPresentStart;
  50002. private _onVRRequestPresentComplete;
  50003. /**
  50004. * 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)
  50005. */
  50006. enableGazeEvenWhenNoPointerLock: boolean;
  50007. /**
  50008. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  50009. */
  50010. exitVROnDoubleTap: boolean;
  50011. /**
  50012. * Observable raised right before entering VR.
  50013. */
  50014. onEnteringVRObservable: Observable<VRExperienceHelper>;
  50015. /**
  50016. * Observable raised when entering VR has completed.
  50017. */
  50018. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  50019. /**
  50020. * Observable raised when exiting VR.
  50021. */
  50022. onExitingVRObservable: Observable<VRExperienceHelper>;
  50023. /**
  50024. * Observable raised when controller mesh is loaded.
  50025. */
  50026. onControllerMeshLoadedObservable: Observable<WebVRController>;
  50027. /** Return this.onEnteringVRObservable
  50028. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  50029. */
  50030. get onEnteringVR(): Observable<VRExperienceHelper>;
  50031. /** Return this.onExitingVRObservable
  50032. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  50033. */
  50034. get onExitingVR(): Observable<VRExperienceHelper>;
  50035. /** Return this.onControllerMeshLoadedObservable
  50036. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  50037. */
  50038. get onControllerMeshLoaded(): Observable<WebVRController>;
  50039. private _rayLength;
  50040. private _useCustomVRButton;
  50041. private _teleportationRequested;
  50042. private _teleportActive;
  50043. private _floorMeshName;
  50044. private _floorMeshesCollection;
  50045. private _teleportationMode;
  50046. private _teleportationTime;
  50047. private _teleportationSpeed;
  50048. private _teleportationEasing;
  50049. private _rotationAllowed;
  50050. private _teleportBackwardsVector;
  50051. private _teleportationTarget;
  50052. private _isDefaultTeleportationTarget;
  50053. private _postProcessMove;
  50054. private _teleportationFillColor;
  50055. private _teleportationBorderColor;
  50056. private _rotationAngle;
  50057. private _haloCenter;
  50058. private _cameraGazer;
  50059. private _padSensibilityUp;
  50060. private _padSensibilityDown;
  50061. private _leftController;
  50062. private _rightController;
  50063. private _gazeColor;
  50064. private _laserColor;
  50065. private _pickedLaserColor;
  50066. private _pickedGazeColor;
  50067. /**
  50068. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  50069. */
  50070. onNewMeshSelected: Observable<AbstractMesh>;
  50071. /**
  50072. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  50073. * This observable will provide the mesh and the controller used to select the mesh
  50074. */
  50075. onMeshSelectedWithController: Observable<{
  50076. mesh: AbstractMesh;
  50077. controller: WebVRController;
  50078. }>;
  50079. /**
  50080. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  50081. */
  50082. onNewMeshPicked: Observable<PickingInfo>;
  50083. private _circleEase;
  50084. /**
  50085. * Observable raised before camera teleportation
  50086. */
  50087. onBeforeCameraTeleport: Observable<Vector3>;
  50088. /**
  50089. * Observable raised after camera teleportation
  50090. */
  50091. onAfterCameraTeleport: Observable<Vector3>;
  50092. /**
  50093. * Observable raised when current selected mesh gets unselected
  50094. */
  50095. onSelectedMeshUnselected: Observable<AbstractMesh>;
  50096. private _raySelectionPredicate;
  50097. /**
  50098. * To be optionaly changed by user to define custom ray selection
  50099. */
  50100. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  50101. /**
  50102. * To be optionaly changed by user to define custom selection logic (after ray selection)
  50103. */
  50104. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  50105. /**
  50106. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  50107. */
  50108. teleportationEnabled: boolean;
  50109. private _defaultHeight;
  50110. private _teleportationInitialized;
  50111. private _interactionsEnabled;
  50112. private _interactionsRequested;
  50113. private _displayGaze;
  50114. private _displayLaserPointer;
  50115. /**
  50116. * The mesh used to display where the user is going to teleport.
  50117. */
  50118. get teleportationTarget(): Mesh;
  50119. /**
  50120. * Sets the mesh to be used to display where the user is going to teleport.
  50121. */
  50122. set teleportationTarget(value: Mesh);
  50123. /**
  50124. * 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
  50125. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  50126. * See http://doc.babylonjs.com/resources/baking_transformations
  50127. */
  50128. get gazeTrackerMesh(): Mesh;
  50129. set gazeTrackerMesh(value: Mesh);
  50130. /**
  50131. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  50132. */
  50133. updateGazeTrackerScale: boolean;
  50134. /**
  50135. * If the gaze trackers color should be updated when selecting meshes
  50136. */
  50137. updateGazeTrackerColor: boolean;
  50138. /**
  50139. * If the controller laser color should be updated when selecting meshes
  50140. */
  50141. updateControllerLaserColor: boolean;
  50142. /**
  50143. * The gaze tracking mesh corresponding to the left controller
  50144. */
  50145. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  50146. /**
  50147. * The gaze tracking mesh corresponding to the right controller
  50148. */
  50149. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  50150. /**
  50151. * If the ray of the gaze should be displayed.
  50152. */
  50153. get displayGaze(): boolean;
  50154. /**
  50155. * Sets if the ray of the gaze should be displayed.
  50156. */
  50157. set displayGaze(value: boolean);
  50158. /**
  50159. * If the ray of the LaserPointer should be displayed.
  50160. */
  50161. get displayLaserPointer(): boolean;
  50162. /**
  50163. * Sets if the ray of the LaserPointer should be displayed.
  50164. */
  50165. set displayLaserPointer(value: boolean);
  50166. /**
  50167. * The deviceOrientationCamera used as the camera when not in VR.
  50168. */
  50169. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  50170. /**
  50171. * Based on the current WebVR support, returns the current VR camera used.
  50172. */
  50173. get currentVRCamera(): Nullable<Camera>;
  50174. /**
  50175. * The webVRCamera which is used when in VR.
  50176. */
  50177. get webVRCamera(): WebVRFreeCamera;
  50178. /**
  50179. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  50180. */
  50181. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  50182. /**
  50183. * The html button that is used to trigger entering into VR.
  50184. */
  50185. get vrButton(): Nullable<HTMLButtonElement>;
  50186. private get _teleportationRequestInitiated();
  50187. /**
  50188. * Defines whether or not Pointer lock should be requested when switching to
  50189. * full screen.
  50190. */
  50191. requestPointerLockOnFullScreen: boolean;
  50192. /**
  50193. * If asking to force XR, this will be populated with the default xr experience
  50194. */
  50195. xr: WebXRDefaultExperience;
  50196. /**
  50197. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  50198. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  50199. */
  50200. xrTestDone: boolean;
  50201. /**
  50202. * Instantiates a VRExperienceHelper.
  50203. * Helps to quickly add VR support to an existing scene.
  50204. * @param scene The scene the VRExperienceHelper belongs to.
  50205. * @param webVROptions Options to modify the vr experience helper's behavior.
  50206. */
  50207. constructor(scene: Scene,
  50208. /** Options to modify the vr experience helper's behavior. */
  50209. webVROptions?: VRExperienceHelperOptions);
  50210. private completeVRInit;
  50211. private _onDefaultMeshLoaded;
  50212. private _onResize;
  50213. private _onFullscreenChange;
  50214. /**
  50215. * Gets a value indicating if we are currently in VR mode.
  50216. */
  50217. get isInVRMode(): boolean;
  50218. private onVrDisplayPresentChange;
  50219. private onVRDisplayChanged;
  50220. private moveButtonToBottomRight;
  50221. private displayVRButton;
  50222. private updateButtonVisibility;
  50223. private _cachedAngularSensibility;
  50224. /**
  50225. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  50226. * Otherwise, will use the fullscreen API.
  50227. */
  50228. enterVR(): void;
  50229. /**
  50230. * Attempt to exit VR, or fullscreen.
  50231. */
  50232. exitVR(): void;
  50233. /**
  50234. * The position of the vr experience helper.
  50235. */
  50236. get position(): Vector3;
  50237. /**
  50238. * Sets the position of the vr experience helper.
  50239. */
  50240. set position(value: Vector3);
  50241. /**
  50242. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  50243. */
  50244. enableInteractions(): void;
  50245. private get _noControllerIsActive();
  50246. private beforeRender;
  50247. private _isTeleportationFloor;
  50248. /**
  50249. * Adds a floor mesh to be used for teleportation.
  50250. * @param floorMesh the mesh to be used for teleportation.
  50251. */
  50252. addFloorMesh(floorMesh: Mesh): void;
  50253. /**
  50254. * Removes a floor mesh from being used for teleportation.
  50255. * @param floorMesh the mesh to be removed.
  50256. */
  50257. removeFloorMesh(floorMesh: Mesh): void;
  50258. /**
  50259. * Enables interactions and teleportation using the VR controllers and gaze.
  50260. * @param vrTeleportationOptions options to modify teleportation behavior.
  50261. */
  50262. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  50263. private _onNewGamepadConnected;
  50264. private _tryEnableInteractionOnController;
  50265. private _onNewGamepadDisconnected;
  50266. private _enableInteractionOnController;
  50267. private _checkTeleportWithRay;
  50268. private _checkRotate;
  50269. private _checkTeleportBackwards;
  50270. private _enableTeleportationOnController;
  50271. private _createTeleportationCircles;
  50272. private _displayTeleportationTarget;
  50273. private _hideTeleportationTarget;
  50274. private _rotateCamera;
  50275. private _moveTeleportationSelectorTo;
  50276. private _workingVector;
  50277. private _workingQuaternion;
  50278. private _workingMatrix;
  50279. /**
  50280. * Time Constant Teleportation Mode
  50281. */
  50282. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  50283. /**
  50284. * Speed Constant Teleportation Mode
  50285. */
  50286. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  50287. /**
  50288. * Teleports the users feet to the desired location
  50289. * @param location The location where the user's feet should be placed
  50290. */
  50291. teleportCamera(location: Vector3): void;
  50292. private _convertNormalToDirectionOfRay;
  50293. private _castRayAndSelectObject;
  50294. private _notifySelectedMeshUnselected;
  50295. /**
  50296. * Permanently set new colors for the laser pointer
  50297. * @param color the new laser color
  50298. * @param pickedColor the new laser color when picked mesh detected
  50299. */
  50300. setLaserColor(color: Color3, pickedColor?: Color3): void;
  50301. /**
  50302. * Set lighting enabled / disabled on the laser pointer of both controllers
  50303. * @param enabled should the lighting be enabled on the laser pointer
  50304. */
  50305. setLaserLightingState(enabled?: boolean): void;
  50306. /**
  50307. * Permanently set new colors for the gaze pointer
  50308. * @param color the new gaze color
  50309. * @param pickedColor the new gaze color when picked mesh detected
  50310. */
  50311. setGazeColor(color: Color3, pickedColor?: Color3): void;
  50312. /**
  50313. * Sets the color of the laser ray from the vr controllers.
  50314. * @param color new color for the ray.
  50315. */
  50316. changeLaserColor(color: Color3): void;
  50317. /**
  50318. * Sets the color of the ray from the vr headsets gaze.
  50319. * @param color new color for the ray.
  50320. */
  50321. changeGazeColor(color: Color3): void;
  50322. /**
  50323. * Exits VR and disposes of the vr experience helper
  50324. */
  50325. dispose(): void;
  50326. /**
  50327. * Gets the name of the VRExperienceHelper class
  50328. * @returns "VRExperienceHelper"
  50329. */
  50330. getClassName(): string;
  50331. }
  50332. }
  50333. declare module "babylonjs/Cameras/VR/index" {
  50334. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  50335. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  50336. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  50337. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  50338. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  50339. export * from "babylonjs/Cameras/VR/webVRCamera";
  50340. }
  50341. declare module "babylonjs/Cameras/RigModes/index" {
  50342. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  50343. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  50344. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  50345. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  50346. }
  50347. declare module "babylonjs/Cameras/index" {
  50348. export * from "babylonjs/Cameras/Inputs/index";
  50349. export * from "babylonjs/Cameras/cameraInputsManager";
  50350. export * from "babylonjs/Cameras/camera";
  50351. export * from "babylonjs/Cameras/targetCamera";
  50352. export * from "babylonjs/Cameras/freeCamera";
  50353. export * from "babylonjs/Cameras/freeCameraInputsManager";
  50354. export * from "babylonjs/Cameras/touchCamera";
  50355. export * from "babylonjs/Cameras/arcRotateCamera";
  50356. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  50357. export * from "babylonjs/Cameras/deviceOrientationCamera";
  50358. export * from "babylonjs/Cameras/flyCamera";
  50359. export * from "babylonjs/Cameras/flyCameraInputsManager";
  50360. export * from "babylonjs/Cameras/followCamera";
  50361. export * from "babylonjs/Cameras/followCameraInputsManager";
  50362. export * from "babylonjs/Cameras/gamepadCamera";
  50363. export * from "babylonjs/Cameras/Stereoscopic/index";
  50364. export * from "babylonjs/Cameras/universalCamera";
  50365. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  50366. export * from "babylonjs/Cameras/VR/index";
  50367. export * from "babylonjs/Cameras/RigModes/index";
  50368. }
  50369. declare module "babylonjs/Collisions/index" {
  50370. export * from "babylonjs/Collisions/collider";
  50371. export * from "babylonjs/Collisions/collisionCoordinator";
  50372. export * from "babylonjs/Collisions/pickingInfo";
  50373. export * from "babylonjs/Collisions/intersectionInfo";
  50374. export * from "babylonjs/Collisions/meshCollisionData";
  50375. }
  50376. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  50377. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  50378. import { Vector3 } from "babylonjs/Maths/math.vector";
  50379. import { Ray } from "babylonjs/Culling/ray";
  50380. import { Plane } from "babylonjs/Maths/math.plane";
  50381. /**
  50382. * Contains an array of blocks representing the octree
  50383. */
  50384. export interface IOctreeContainer<T> {
  50385. /**
  50386. * Blocks within the octree
  50387. */
  50388. blocks: Array<OctreeBlock<T>>;
  50389. }
  50390. /**
  50391. * Class used to store a cell in an octree
  50392. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50393. */
  50394. export class OctreeBlock<T> {
  50395. /**
  50396. * Gets the content of the current block
  50397. */
  50398. entries: T[];
  50399. /**
  50400. * Gets the list of block children
  50401. */
  50402. blocks: Array<OctreeBlock<T>>;
  50403. private _depth;
  50404. private _maxDepth;
  50405. private _capacity;
  50406. private _minPoint;
  50407. private _maxPoint;
  50408. private _boundingVectors;
  50409. private _creationFunc;
  50410. /**
  50411. * Creates a new block
  50412. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  50413. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  50414. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  50415. * @param depth defines the current depth of this block in the octree
  50416. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  50417. * @param creationFunc defines a callback to call when an element is added to the block
  50418. */
  50419. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  50420. /**
  50421. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  50422. */
  50423. get capacity(): number;
  50424. /**
  50425. * Gets the minimum vector (in world space) of the block's bounding box
  50426. */
  50427. get minPoint(): Vector3;
  50428. /**
  50429. * Gets the maximum vector (in world space) of the block's bounding box
  50430. */
  50431. get maxPoint(): Vector3;
  50432. /**
  50433. * Add a new element to this block
  50434. * @param entry defines the element to add
  50435. */
  50436. addEntry(entry: T): void;
  50437. /**
  50438. * Remove an element from this block
  50439. * @param entry defines the element to remove
  50440. */
  50441. removeEntry(entry: T): void;
  50442. /**
  50443. * Add an array of elements to this block
  50444. * @param entries defines the array of elements to add
  50445. */
  50446. addEntries(entries: T[]): void;
  50447. /**
  50448. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  50449. * @param frustumPlanes defines the frustum planes to test
  50450. * @param selection defines the array to store current content if selection is positive
  50451. * @param allowDuplicate defines if the selection array can contains duplicated entries
  50452. */
  50453. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  50454. /**
  50455. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  50456. * @param sphereCenter defines the bounding sphere center
  50457. * @param sphereRadius defines the bounding sphere radius
  50458. * @param selection defines the array to store current content if selection is positive
  50459. * @param allowDuplicate defines if the selection array can contains duplicated entries
  50460. */
  50461. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  50462. /**
  50463. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  50464. * @param ray defines the ray to test with
  50465. * @param selection defines the array to store current content if selection is positive
  50466. */
  50467. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  50468. /**
  50469. * Subdivide the content into child blocks (this block will then be empty)
  50470. */
  50471. createInnerBlocks(): void;
  50472. /**
  50473. * @hidden
  50474. */
  50475. 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;
  50476. }
  50477. }
  50478. declare module "babylonjs/Culling/Octrees/octree" {
  50479. import { SmartArray } from "babylonjs/Misc/smartArray";
  50480. import { Vector3 } from "babylonjs/Maths/math.vector";
  50481. import { SubMesh } from "babylonjs/Meshes/subMesh";
  50482. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50483. import { Ray } from "babylonjs/Culling/ray";
  50484. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  50485. import { Plane } from "babylonjs/Maths/math.plane";
  50486. /**
  50487. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  50488. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50489. */
  50490. export class Octree<T> {
  50491. /** 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.) */
  50492. maxDepth: number;
  50493. /**
  50494. * Blocks within the octree containing objects
  50495. */
  50496. blocks: Array<OctreeBlock<T>>;
  50497. /**
  50498. * Content stored in the octree
  50499. */
  50500. dynamicContent: T[];
  50501. private _maxBlockCapacity;
  50502. private _selectionContent;
  50503. private _creationFunc;
  50504. /**
  50505. * Creates a octree
  50506. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50507. * @param creationFunc function to be used to instatiate the octree
  50508. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  50509. * @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.)
  50510. */
  50511. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  50512. /** 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.) */
  50513. maxDepth?: number);
  50514. /**
  50515. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  50516. * @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);
  50517. * @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);
  50518. * @param entries meshes to be added to the octree blocks
  50519. */
  50520. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  50521. /**
  50522. * Adds a mesh to the octree
  50523. * @param entry Mesh to add to the octree
  50524. */
  50525. addMesh(entry: T): void;
  50526. /**
  50527. * Remove an element from the octree
  50528. * @param entry defines the element to remove
  50529. */
  50530. removeMesh(entry: T): void;
  50531. /**
  50532. * Selects an array of meshes within the frustum
  50533. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  50534. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  50535. * @returns array of meshes within the frustum
  50536. */
  50537. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  50538. /**
  50539. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  50540. * @param sphereCenter defines the bounding sphere center
  50541. * @param sphereRadius defines the bounding sphere radius
  50542. * @param allowDuplicate defines if the selection array can contains duplicated entries
  50543. * @returns an array of objects that intersect the sphere
  50544. */
  50545. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  50546. /**
  50547. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  50548. * @param ray defines the ray to test with
  50549. * @returns array of intersected objects
  50550. */
  50551. intersectsRay(ray: Ray): SmartArray<T>;
  50552. /**
  50553. * Adds a mesh into the octree block if it intersects the block
  50554. */
  50555. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  50556. /**
  50557. * Adds a submesh into the octree block if it intersects the block
  50558. */
  50559. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  50560. }
  50561. }
  50562. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  50563. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  50564. import { Scene } from "babylonjs/scene";
  50565. import { SubMesh } from "babylonjs/Meshes/subMesh";
  50566. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50567. import { Ray } from "babylonjs/Culling/ray";
  50568. import { Octree } from "babylonjs/Culling/Octrees/octree";
  50569. import { Collider } from "babylonjs/Collisions/collider";
  50570. module "babylonjs/scene" {
  50571. interface Scene {
  50572. /**
  50573. * @hidden
  50574. * Backing Filed
  50575. */
  50576. _selectionOctree: Octree<AbstractMesh>;
  50577. /**
  50578. * Gets the octree used to boost mesh selection (picking)
  50579. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50580. */
  50581. selectionOctree: Octree<AbstractMesh>;
  50582. /**
  50583. * Creates or updates the octree used to boost selection (picking)
  50584. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50585. * @param maxCapacity defines the maximum capacity per leaf
  50586. * @param maxDepth defines the maximum depth of the octree
  50587. * @returns an octree of AbstractMesh
  50588. */
  50589. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  50590. }
  50591. }
  50592. module "babylonjs/Meshes/abstractMesh" {
  50593. interface AbstractMesh {
  50594. /**
  50595. * @hidden
  50596. * Backing Field
  50597. */
  50598. _submeshesOctree: Octree<SubMesh>;
  50599. /**
  50600. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  50601. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  50602. * @param maxCapacity defines the maximum size of each block (64 by default)
  50603. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  50604. * @returns the new octree
  50605. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  50606. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50607. */
  50608. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  50609. }
  50610. }
  50611. /**
  50612. * Defines the octree scene component responsible to manage any octrees
  50613. * in a given scene.
  50614. */
  50615. export class OctreeSceneComponent {
  50616. /**
  50617. * The component name help to identify the component in the list of scene components.
  50618. */
  50619. readonly name: string;
  50620. /**
  50621. * The scene the component belongs to.
  50622. */
  50623. scene: Scene;
  50624. /**
  50625. * Indicates if the meshes have been checked to make sure they are isEnabled()
  50626. */
  50627. readonly checksIsEnabled: boolean;
  50628. /**
  50629. * Creates a new instance of the component for the given scene
  50630. * @param scene Defines the scene to register the component in
  50631. */
  50632. constructor(scene: Scene);
  50633. /**
  50634. * Registers the component in a given scene
  50635. */
  50636. register(): void;
  50637. /**
  50638. * Return the list of active meshes
  50639. * @returns the list of active meshes
  50640. */
  50641. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  50642. /**
  50643. * Return the list of active sub meshes
  50644. * @param mesh The mesh to get the candidates sub meshes from
  50645. * @returns the list of active sub meshes
  50646. */
  50647. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  50648. private _tempRay;
  50649. /**
  50650. * Return the list of sub meshes intersecting with a given local ray
  50651. * @param mesh defines the mesh to find the submesh for
  50652. * @param localRay defines the ray in local space
  50653. * @returns the list of intersecting sub meshes
  50654. */
  50655. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  50656. /**
  50657. * Return the list of sub meshes colliding with a collider
  50658. * @param mesh defines the mesh to find the submesh for
  50659. * @param collider defines the collider to evaluate the collision against
  50660. * @returns the list of colliding sub meshes
  50661. */
  50662. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  50663. /**
  50664. * Rebuilds the elements related to this component in case of
  50665. * context lost for instance.
  50666. */
  50667. rebuild(): void;
  50668. /**
  50669. * Disposes the component and the associated ressources.
  50670. */
  50671. dispose(): void;
  50672. }
  50673. }
  50674. declare module "babylonjs/Culling/Octrees/index" {
  50675. export * from "babylonjs/Culling/Octrees/octree";
  50676. export * from "babylonjs/Culling/Octrees/octreeBlock";
  50677. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  50678. }
  50679. declare module "babylonjs/Culling/index" {
  50680. export * from "babylonjs/Culling/boundingBox";
  50681. export * from "babylonjs/Culling/boundingInfo";
  50682. export * from "babylonjs/Culling/boundingSphere";
  50683. export * from "babylonjs/Culling/Octrees/index";
  50684. export * from "babylonjs/Culling/ray";
  50685. }
  50686. declare module "babylonjs/Gizmos/gizmo" {
  50687. import { Nullable } from "babylonjs/types";
  50688. import { IDisposable } from "babylonjs/scene";
  50689. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50690. import { Mesh } from "babylonjs/Meshes/mesh";
  50691. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50692. /**
  50693. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  50694. */
  50695. export class Gizmo implements IDisposable {
  50696. /** The utility layer the gizmo will be added to */
  50697. gizmoLayer: UtilityLayerRenderer;
  50698. /**
  50699. * The root mesh of the gizmo
  50700. */
  50701. _rootMesh: Mesh;
  50702. private _attachedMesh;
  50703. /**
  50704. * Ratio for the scale of the gizmo (Default: 1)
  50705. */
  50706. scaleRatio: number;
  50707. /**
  50708. * If a custom mesh has been set (Default: false)
  50709. */
  50710. protected _customMeshSet: boolean;
  50711. /**
  50712. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  50713. * * When set, interactions will be enabled
  50714. */
  50715. get attachedMesh(): Nullable<AbstractMesh>;
  50716. set attachedMesh(value: Nullable<AbstractMesh>);
  50717. /**
  50718. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  50719. * @param mesh The mesh to replace the default mesh of the gizmo
  50720. */
  50721. setCustomMesh(mesh: Mesh): void;
  50722. /**
  50723. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  50724. */
  50725. updateGizmoRotationToMatchAttachedMesh: boolean;
  50726. /**
  50727. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  50728. */
  50729. updateGizmoPositionToMatchAttachedMesh: boolean;
  50730. /**
  50731. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  50732. */
  50733. updateScale: boolean;
  50734. protected _interactionsEnabled: boolean;
  50735. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  50736. private _beforeRenderObserver;
  50737. private _tempVector;
  50738. /**
  50739. * Creates a gizmo
  50740. * @param gizmoLayer The utility layer the gizmo will be added to
  50741. */
  50742. constructor(
  50743. /** The utility layer the gizmo will be added to */
  50744. gizmoLayer?: UtilityLayerRenderer);
  50745. /**
  50746. * Updates the gizmo to match the attached mesh's position/rotation
  50747. */
  50748. protected _update(): void;
  50749. /**
  50750. * Disposes of the gizmo
  50751. */
  50752. dispose(): void;
  50753. }
  50754. }
  50755. declare module "babylonjs/Gizmos/planeDragGizmo" {
  50756. import { Observable } from "babylonjs/Misc/observable";
  50757. import { Nullable } from "babylonjs/types";
  50758. import { Vector3 } from "babylonjs/Maths/math.vector";
  50759. import { Color3 } from "babylonjs/Maths/math.color";
  50760. import { TransformNode } from "babylonjs/Meshes/transformNode";
  50761. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50762. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  50763. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50764. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50765. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  50766. import { Scene } from "babylonjs/scene";
  50767. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  50768. /**
  50769. * Single plane drag gizmo
  50770. */
  50771. export class PlaneDragGizmo extends Gizmo {
  50772. /**
  50773. * Drag behavior responsible for the gizmos dragging interactions
  50774. */
  50775. dragBehavior: PointerDragBehavior;
  50776. private _pointerObserver;
  50777. /**
  50778. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50779. */
  50780. snapDistance: number;
  50781. /**
  50782. * Event that fires each time the gizmo snaps to a new location.
  50783. * * snapDistance is the the change in distance
  50784. */
  50785. onSnapObservable: Observable<{
  50786. snapDistance: number;
  50787. }>;
  50788. private _plane;
  50789. private _coloredMaterial;
  50790. private _hoverMaterial;
  50791. private _isEnabled;
  50792. private _parent;
  50793. /** @hidden */
  50794. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  50795. /** @hidden */
  50796. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  50797. /**
  50798. * Creates a PlaneDragGizmo
  50799. * @param gizmoLayer The utility layer the gizmo will be added to
  50800. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  50801. * @param color The color of the gizmo
  50802. */
  50803. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  50804. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  50805. /**
  50806. * If the gizmo is enabled
  50807. */
  50808. set isEnabled(value: boolean);
  50809. get isEnabled(): boolean;
  50810. /**
  50811. * Disposes of the gizmo
  50812. */
  50813. dispose(): void;
  50814. }
  50815. }
  50816. declare module "babylonjs/Gizmos/positionGizmo" {
  50817. import { Observable } from "babylonjs/Misc/observable";
  50818. import { Nullable } from "babylonjs/types";
  50819. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50820. import { Mesh } from "babylonjs/Meshes/mesh";
  50821. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50822. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  50823. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  50824. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50825. /**
  50826. * Gizmo that enables dragging a mesh along 3 axis
  50827. */
  50828. export class PositionGizmo extends Gizmo {
  50829. /**
  50830. * Internal gizmo used for interactions on the x axis
  50831. */
  50832. xGizmo: AxisDragGizmo;
  50833. /**
  50834. * Internal gizmo used for interactions on the y axis
  50835. */
  50836. yGizmo: AxisDragGizmo;
  50837. /**
  50838. * Internal gizmo used for interactions on the z axis
  50839. */
  50840. zGizmo: AxisDragGizmo;
  50841. /**
  50842. * Internal gizmo used for interactions on the yz plane
  50843. */
  50844. xPlaneGizmo: PlaneDragGizmo;
  50845. /**
  50846. * Internal gizmo used for interactions on the xz plane
  50847. */
  50848. yPlaneGizmo: PlaneDragGizmo;
  50849. /**
  50850. * Internal gizmo used for interactions on the xy plane
  50851. */
  50852. zPlaneGizmo: PlaneDragGizmo;
  50853. /**
  50854. * private variables
  50855. */
  50856. private _meshAttached;
  50857. private _updateGizmoRotationToMatchAttachedMesh;
  50858. private _snapDistance;
  50859. private _scaleRatio;
  50860. /** Fires an event when any of it's sub gizmos are dragged */
  50861. onDragStartObservable: Observable<unknown>;
  50862. /** Fires an event when any of it's sub gizmos are released from dragging */
  50863. onDragEndObservable: Observable<unknown>;
  50864. /**
  50865. * If set to true, planar drag is enabled
  50866. */
  50867. private _planarGizmoEnabled;
  50868. get attachedMesh(): Nullable<AbstractMesh>;
  50869. set attachedMesh(mesh: Nullable<AbstractMesh>);
  50870. /**
  50871. * Creates a PositionGizmo
  50872. * @param gizmoLayer The utility layer the gizmo will be added to
  50873. */
  50874. constructor(gizmoLayer?: UtilityLayerRenderer);
  50875. /**
  50876. * If the planar drag gizmo is enabled
  50877. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  50878. */
  50879. set planarGizmoEnabled(value: boolean);
  50880. get planarGizmoEnabled(): boolean;
  50881. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  50882. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  50883. /**
  50884. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50885. */
  50886. set snapDistance(value: number);
  50887. get snapDistance(): number;
  50888. /**
  50889. * Ratio for the scale of the gizmo (Default: 1)
  50890. */
  50891. set scaleRatio(value: number);
  50892. get scaleRatio(): number;
  50893. /**
  50894. * Disposes of the gizmo
  50895. */
  50896. dispose(): void;
  50897. /**
  50898. * CustomMeshes are not supported by this gizmo
  50899. * @param mesh The mesh to replace the default mesh of the gizmo
  50900. */
  50901. setCustomMesh(mesh: Mesh): void;
  50902. }
  50903. }
  50904. declare module "babylonjs/Gizmos/axisDragGizmo" {
  50905. import { Observable } from "babylonjs/Misc/observable";
  50906. import { Nullable } from "babylonjs/types";
  50907. import { Vector3 } from "babylonjs/Maths/math.vector";
  50908. import { TransformNode } from "babylonjs/Meshes/transformNode";
  50909. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50910. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  50911. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50912. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50913. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  50914. import { Scene } from "babylonjs/scene";
  50915. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  50916. import { Color3 } from "babylonjs/Maths/math.color";
  50917. /**
  50918. * Single axis drag gizmo
  50919. */
  50920. export class AxisDragGizmo extends Gizmo {
  50921. /**
  50922. * Drag behavior responsible for the gizmos dragging interactions
  50923. */
  50924. dragBehavior: PointerDragBehavior;
  50925. private _pointerObserver;
  50926. /**
  50927. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50928. */
  50929. snapDistance: number;
  50930. /**
  50931. * Event that fires each time the gizmo snaps to a new location.
  50932. * * snapDistance is the the change in distance
  50933. */
  50934. onSnapObservable: Observable<{
  50935. snapDistance: number;
  50936. }>;
  50937. private _isEnabled;
  50938. private _parent;
  50939. private _arrow;
  50940. private _coloredMaterial;
  50941. private _hoverMaterial;
  50942. /** @hidden */
  50943. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  50944. /** @hidden */
  50945. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  50946. /**
  50947. * Creates an AxisDragGizmo
  50948. * @param gizmoLayer The utility layer the gizmo will be added to
  50949. * @param dragAxis The axis which the gizmo will be able to drag on
  50950. * @param color The color of the gizmo
  50951. */
  50952. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  50953. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  50954. /**
  50955. * If the gizmo is enabled
  50956. */
  50957. set isEnabled(value: boolean);
  50958. get isEnabled(): boolean;
  50959. /**
  50960. * Disposes of the gizmo
  50961. */
  50962. dispose(): void;
  50963. }
  50964. }
  50965. declare module "babylonjs/Debug/axesViewer" {
  50966. import { Vector3 } from "babylonjs/Maths/math.vector";
  50967. import { Nullable } from "babylonjs/types";
  50968. import { Scene } from "babylonjs/scene";
  50969. import { TransformNode } from "babylonjs/Meshes/transformNode";
  50970. /**
  50971. * The Axes viewer will show 3 axes in a specific point in space
  50972. */
  50973. export class AxesViewer {
  50974. private _xAxis;
  50975. private _yAxis;
  50976. private _zAxis;
  50977. private _scaleLinesFactor;
  50978. private _instanced;
  50979. /**
  50980. * Gets the hosting scene
  50981. */
  50982. scene: Scene;
  50983. /**
  50984. * Gets or sets a number used to scale line length
  50985. */
  50986. scaleLines: number;
  50987. /** Gets the node hierarchy used to render x-axis */
  50988. get xAxis(): TransformNode;
  50989. /** Gets the node hierarchy used to render y-axis */
  50990. get yAxis(): TransformNode;
  50991. /** Gets the node hierarchy used to render z-axis */
  50992. get zAxis(): TransformNode;
  50993. /**
  50994. * Creates a new AxesViewer
  50995. * @param scene defines the hosting scene
  50996. * @param scaleLines defines a number used to scale line length (1 by default)
  50997. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  50998. * @param xAxis defines the node hierarchy used to render the x-axis
  50999. * @param yAxis defines the node hierarchy used to render the y-axis
  51000. * @param zAxis defines the node hierarchy used to render the z-axis
  51001. */
  51002. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  51003. /**
  51004. * Force the viewer to update
  51005. * @param position defines the position of the viewer
  51006. * @param xaxis defines the x axis of the viewer
  51007. * @param yaxis defines the y axis of the viewer
  51008. * @param zaxis defines the z axis of the viewer
  51009. */
  51010. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  51011. /**
  51012. * Creates an instance of this axes viewer.
  51013. * @returns a new axes viewer with instanced meshes
  51014. */
  51015. createInstance(): AxesViewer;
  51016. /** Releases resources */
  51017. dispose(): void;
  51018. private static _SetRenderingGroupId;
  51019. }
  51020. }
  51021. declare module "babylonjs/Debug/boneAxesViewer" {
  51022. import { Nullable } from "babylonjs/types";
  51023. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  51024. import { Vector3 } from "babylonjs/Maths/math.vector";
  51025. import { Mesh } from "babylonjs/Meshes/mesh";
  51026. import { Bone } from "babylonjs/Bones/bone";
  51027. import { Scene } from "babylonjs/scene";
  51028. /**
  51029. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  51030. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  51031. */
  51032. export class BoneAxesViewer extends AxesViewer {
  51033. /**
  51034. * Gets or sets the target mesh where to display the axes viewer
  51035. */
  51036. mesh: Nullable<Mesh>;
  51037. /**
  51038. * Gets or sets the target bone where to display the axes viewer
  51039. */
  51040. bone: Nullable<Bone>;
  51041. /** Gets current position */
  51042. pos: Vector3;
  51043. /** Gets direction of X axis */
  51044. xaxis: Vector3;
  51045. /** Gets direction of Y axis */
  51046. yaxis: Vector3;
  51047. /** Gets direction of Z axis */
  51048. zaxis: Vector3;
  51049. /**
  51050. * Creates a new BoneAxesViewer
  51051. * @param scene defines the hosting scene
  51052. * @param bone defines the target bone
  51053. * @param mesh defines the target mesh
  51054. * @param scaleLines defines a scaling factor for line length (1 by default)
  51055. */
  51056. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  51057. /**
  51058. * Force the viewer to update
  51059. */
  51060. update(): void;
  51061. /** Releases resources */
  51062. dispose(): void;
  51063. }
  51064. }
  51065. declare module "babylonjs/Debug/debugLayer" {
  51066. import { Scene } from "babylonjs/scene";
  51067. /**
  51068. * Interface used to define scene explorer extensibility option
  51069. */
  51070. export interface IExplorerExtensibilityOption {
  51071. /**
  51072. * Define the option label
  51073. */
  51074. label: string;
  51075. /**
  51076. * Defines the action to execute on click
  51077. */
  51078. action: (entity: any) => void;
  51079. }
  51080. /**
  51081. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  51082. */
  51083. export interface IExplorerExtensibilityGroup {
  51084. /**
  51085. * Defines a predicate to test if a given type mut be extended
  51086. */
  51087. predicate: (entity: any) => boolean;
  51088. /**
  51089. * Gets the list of options added to a type
  51090. */
  51091. entries: IExplorerExtensibilityOption[];
  51092. }
  51093. /**
  51094. * Interface used to define the options to use to create the Inspector
  51095. */
  51096. export interface IInspectorOptions {
  51097. /**
  51098. * Display in overlay mode (default: false)
  51099. */
  51100. overlay?: boolean;
  51101. /**
  51102. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  51103. */
  51104. globalRoot?: HTMLElement;
  51105. /**
  51106. * Display the Scene explorer
  51107. */
  51108. showExplorer?: boolean;
  51109. /**
  51110. * Display the property inspector
  51111. */
  51112. showInspector?: boolean;
  51113. /**
  51114. * Display in embed mode (both panes on the right)
  51115. */
  51116. embedMode?: boolean;
  51117. /**
  51118. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  51119. */
  51120. handleResize?: boolean;
  51121. /**
  51122. * Allow the panes to popup (default: true)
  51123. */
  51124. enablePopup?: boolean;
  51125. /**
  51126. * Allow the panes to be closed by users (default: true)
  51127. */
  51128. enableClose?: boolean;
  51129. /**
  51130. * Optional list of extensibility entries
  51131. */
  51132. explorerExtensibility?: IExplorerExtensibilityGroup[];
  51133. /**
  51134. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  51135. */
  51136. inspectorURL?: string;
  51137. /**
  51138. * Optional initial tab (default to DebugLayerTab.Properties)
  51139. */
  51140. initialTab?: DebugLayerTab;
  51141. }
  51142. module "babylonjs/scene" {
  51143. interface Scene {
  51144. /**
  51145. * @hidden
  51146. * Backing field
  51147. */
  51148. _debugLayer: DebugLayer;
  51149. /**
  51150. * Gets the debug layer (aka Inspector) associated with the scene
  51151. * @see http://doc.babylonjs.com/features/playground_debuglayer
  51152. */
  51153. debugLayer: DebugLayer;
  51154. }
  51155. }
  51156. /**
  51157. * Enum of inspector action tab
  51158. */
  51159. export enum DebugLayerTab {
  51160. /**
  51161. * Properties tag (default)
  51162. */
  51163. Properties = 0,
  51164. /**
  51165. * Debug tab
  51166. */
  51167. Debug = 1,
  51168. /**
  51169. * Statistics tab
  51170. */
  51171. Statistics = 2,
  51172. /**
  51173. * Tools tab
  51174. */
  51175. Tools = 3,
  51176. /**
  51177. * Settings tab
  51178. */
  51179. Settings = 4
  51180. }
  51181. /**
  51182. * The debug layer (aka Inspector) is the go to tool in order to better understand
  51183. * what is happening in your scene
  51184. * @see http://doc.babylonjs.com/features/playground_debuglayer
  51185. */
  51186. export class DebugLayer {
  51187. /**
  51188. * Define the url to get the inspector script from.
  51189. * By default it uses the babylonjs CDN.
  51190. * @ignoreNaming
  51191. */
  51192. static InspectorURL: string;
  51193. private _scene;
  51194. private BJSINSPECTOR;
  51195. private _onPropertyChangedObservable?;
  51196. /**
  51197. * Observable triggered when a property is changed through the inspector.
  51198. */
  51199. get onPropertyChangedObservable(): any;
  51200. /**
  51201. * Instantiates a new debug layer.
  51202. * The debug layer (aka Inspector) is the go to tool in order to better understand
  51203. * what is happening in your scene
  51204. * @see http://doc.babylonjs.com/features/playground_debuglayer
  51205. * @param scene Defines the scene to inspect
  51206. */
  51207. constructor(scene: Scene);
  51208. /** Creates the inspector window. */
  51209. private _createInspector;
  51210. /**
  51211. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  51212. * @param entity defines the entity to select
  51213. * @param lineContainerTitle defines the specific block to highlight
  51214. */
  51215. select(entity: any, lineContainerTitle?: string): void;
  51216. /** Get the inspector from bundle or global */
  51217. private _getGlobalInspector;
  51218. /**
  51219. * Get if the inspector is visible or not.
  51220. * @returns true if visible otherwise, false
  51221. */
  51222. isVisible(): boolean;
  51223. /**
  51224. * Hide the inspector and close its window.
  51225. */
  51226. hide(): void;
  51227. /**
  51228. * Update the scene in the inspector
  51229. */
  51230. setAsActiveScene(): void;
  51231. /**
  51232. * Launch the debugLayer.
  51233. * @param config Define the configuration of the inspector
  51234. * @return a promise fulfilled when the debug layer is visible
  51235. */
  51236. show(config?: IInspectorOptions): Promise<DebugLayer>;
  51237. }
  51238. }
  51239. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  51240. import { Nullable } from "babylonjs/types";
  51241. import { Scene } from "babylonjs/scene";
  51242. import { Vector4 } from "babylonjs/Maths/math.vector";
  51243. import { Color4 } from "babylonjs/Maths/math.color";
  51244. import { Mesh } from "babylonjs/Meshes/mesh";
  51245. /**
  51246. * Class containing static functions to help procedurally build meshes
  51247. */
  51248. export class BoxBuilder {
  51249. /**
  51250. * Creates a box mesh
  51251. * * The parameter `size` sets the size (float) of each box side (default 1)
  51252. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  51253. * * 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)
  51254. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  51255. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51256. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51257. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51258. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  51259. * @param name defines the name of the mesh
  51260. * @param options defines the options used to create the mesh
  51261. * @param scene defines the hosting scene
  51262. * @returns the box mesh
  51263. */
  51264. static CreateBox(name: string, options: {
  51265. size?: number;
  51266. width?: number;
  51267. height?: number;
  51268. depth?: number;
  51269. faceUV?: Vector4[];
  51270. faceColors?: Color4[];
  51271. sideOrientation?: number;
  51272. frontUVs?: Vector4;
  51273. backUVs?: Vector4;
  51274. wrap?: boolean;
  51275. topBaseAt?: number;
  51276. bottomBaseAt?: number;
  51277. updatable?: boolean;
  51278. }, scene?: Nullable<Scene>): Mesh;
  51279. }
  51280. }
  51281. declare module "babylonjs/Debug/physicsViewer" {
  51282. import { Nullable } from "babylonjs/types";
  51283. import { Scene } from "babylonjs/scene";
  51284. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51285. import { Mesh } from "babylonjs/Meshes/mesh";
  51286. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  51287. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  51288. /**
  51289. * Used to show the physics impostor around the specific mesh
  51290. */
  51291. export class PhysicsViewer {
  51292. /** @hidden */
  51293. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  51294. /** @hidden */
  51295. protected _meshes: Array<Nullable<AbstractMesh>>;
  51296. /** @hidden */
  51297. protected _scene: Nullable<Scene>;
  51298. /** @hidden */
  51299. protected _numMeshes: number;
  51300. /** @hidden */
  51301. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  51302. private _renderFunction;
  51303. private _utilityLayer;
  51304. private _debugBoxMesh;
  51305. private _debugSphereMesh;
  51306. private _debugCylinderMesh;
  51307. private _debugMaterial;
  51308. private _debugMeshMeshes;
  51309. /**
  51310. * Creates a new PhysicsViewer
  51311. * @param scene defines the hosting scene
  51312. */
  51313. constructor(scene: Scene);
  51314. /** @hidden */
  51315. protected _updateDebugMeshes(): void;
  51316. /**
  51317. * Renders a specified physic impostor
  51318. * @param impostor defines the impostor to render
  51319. * @param targetMesh defines the mesh represented by the impostor
  51320. * @returns the new debug mesh used to render the impostor
  51321. */
  51322. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  51323. /**
  51324. * Hides a specified physic impostor
  51325. * @param impostor defines the impostor to hide
  51326. */
  51327. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  51328. private _getDebugMaterial;
  51329. private _getDebugBoxMesh;
  51330. private _getDebugSphereMesh;
  51331. private _getDebugCylinderMesh;
  51332. private _getDebugMeshMesh;
  51333. private _getDebugMesh;
  51334. /** Releases all resources */
  51335. dispose(): void;
  51336. }
  51337. }
  51338. declare module "babylonjs/Debug/rayHelper" {
  51339. import { Nullable } from "babylonjs/types";
  51340. import { Ray } from "babylonjs/Culling/ray";
  51341. import { Vector3 } from "babylonjs/Maths/math.vector";
  51342. import { Color3 } from "babylonjs/Maths/math.color";
  51343. import { Scene } from "babylonjs/scene";
  51344. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51345. import "babylonjs/Meshes/Builders/linesBuilder";
  51346. /**
  51347. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  51348. * in order to better appreciate the issue one might have.
  51349. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  51350. */
  51351. export class RayHelper {
  51352. /**
  51353. * Defines the ray we are currently tryin to visualize.
  51354. */
  51355. ray: Nullable<Ray>;
  51356. private _renderPoints;
  51357. private _renderLine;
  51358. private _renderFunction;
  51359. private _scene;
  51360. private _updateToMeshFunction;
  51361. private _attachedToMesh;
  51362. private _meshSpaceDirection;
  51363. private _meshSpaceOrigin;
  51364. /**
  51365. * Helper function to create a colored helper in a scene in one line.
  51366. * @param ray Defines the ray we are currently tryin to visualize
  51367. * @param scene Defines the scene the ray is used in
  51368. * @param color Defines the color we want to see the ray in
  51369. * @returns The newly created ray helper.
  51370. */
  51371. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  51372. /**
  51373. * Instantiate a new ray helper.
  51374. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  51375. * in order to better appreciate the issue one might have.
  51376. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  51377. * @param ray Defines the ray we are currently tryin to visualize
  51378. */
  51379. constructor(ray: Ray);
  51380. /**
  51381. * Shows the ray we are willing to debug.
  51382. * @param scene Defines the scene the ray needs to be rendered in
  51383. * @param color Defines the color the ray needs to be rendered in
  51384. */
  51385. show(scene: Scene, color?: Color3): void;
  51386. /**
  51387. * Hides the ray we are debugging.
  51388. */
  51389. hide(): void;
  51390. private _render;
  51391. /**
  51392. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  51393. * @param mesh Defines the mesh we want the helper attached to
  51394. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  51395. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  51396. * @param length Defines the length of the ray
  51397. */
  51398. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  51399. /**
  51400. * Detach the ray helper from the mesh it has previously been attached to.
  51401. */
  51402. detachFromMesh(): void;
  51403. private _updateToMesh;
  51404. /**
  51405. * Dispose the helper and release its associated resources.
  51406. */
  51407. dispose(): void;
  51408. }
  51409. }
  51410. declare module "babylonjs/Debug/skeletonViewer" {
  51411. import { Color3 } from "babylonjs/Maths/math.color";
  51412. import { Scene } from "babylonjs/scene";
  51413. import { Nullable } from "babylonjs/types";
  51414. import { Skeleton } from "babylonjs/Bones/skeleton";
  51415. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51416. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  51417. /**
  51418. * Class used to render a debug view of a given skeleton
  51419. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  51420. */
  51421. export class SkeletonViewer {
  51422. /** defines the skeleton to render */
  51423. skeleton: Skeleton;
  51424. /** defines the mesh attached to the skeleton */
  51425. mesh: AbstractMesh;
  51426. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  51427. autoUpdateBonesMatrices: boolean;
  51428. /** defines the rendering group id to use with the viewer */
  51429. renderingGroupId: number;
  51430. /** Gets or sets the color used to render the skeleton */
  51431. color: Color3;
  51432. private _scene;
  51433. private _debugLines;
  51434. private _debugMesh;
  51435. private _isEnabled;
  51436. private _renderFunction;
  51437. private _utilityLayer;
  51438. /**
  51439. * Returns the mesh used to render the bones
  51440. */
  51441. get debugMesh(): Nullable<LinesMesh>;
  51442. /**
  51443. * Creates a new SkeletonViewer
  51444. * @param skeleton defines the skeleton to render
  51445. * @param mesh defines the mesh attached to the skeleton
  51446. * @param scene defines the hosting scene
  51447. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  51448. * @param renderingGroupId defines the rendering group id to use with the viewer
  51449. */
  51450. constructor(
  51451. /** defines the skeleton to render */
  51452. skeleton: Skeleton,
  51453. /** defines the mesh attached to the skeleton */
  51454. mesh: AbstractMesh, scene: Scene,
  51455. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  51456. autoUpdateBonesMatrices?: boolean,
  51457. /** defines the rendering group id to use with the viewer */
  51458. renderingGroupId?: number);
  51459. /** Gets or sets a boolean indicating if the viewer is enabled */
  51460. set isEnabled(value: boolean);
  51461. get isEnabled(): boolean;
  51462. private _getBonePosition;
  51463. private _getLinesForBonesWithLength;
  51464. private _getLinesForBonesNoLength;
  51465. /** Update the viewer to sync with current skeleton state */
  51466. update(): void;
  51467. /** Release associated resources */
  51468. dispose(): void;
  51469. }
  51470. }
  51471. declare module "babylonjs/Debug/index" {
  51472. export * from "babylonjs/Debug/axesViewer";
  51473. export * from "babylonjs/Debug/boneAxesViewer";
  51474. export * from "babylonjs/Debug/debugLayer";
  51475. export * from "babylonjs/Debug/physicsViewer";
  51476. export * from "babylonjs/Debug/rayHelper";
  51477. export * from "babylonjs/Debug/skeletonViewer";
  51478. }
  51479. declare module "babylonjs/DeviceInput/InputDevices/deviceEnums" {
  51480. /**
  51481. * Enum for Device Types
  51482. */
  51483. export enum DeviceType {
  51484. /** Generic */
  51485. Generic = 0,
  51486. /** Keyboard */
  51487. Keyboard = 1,
  51488. /** Mouse */
  51489. Mouse = 2,
  51490. /** Touch Pointers */
  51491. Touch = 3,
  51492. /** PS4 Dual Shock */
  51493. DualShock = 4,
  51494. /** Xbox */
  51495. Xbox = 5,
  51496. /** Switch Controller */
  51497. Switch = 6
  51498. }
  51499. /**
  51500. * Enum for All Pointers (Touch/Mouse)
  51501. */
  51502. export enum PointerInput {
  51503. /** Horizontal Axis */
  51504. Horizontal = 0,
  51505. /** Vertical Axis */
  51506. Vertical = 1,
  51507. /** Left Click or Touch */
  51508. LeftClick = 2,
  51509. /** Middle Click */
  51510. MiddleClick = 3,
  51511. /** Right Click */
  51512. RightClick = 4,
  51513. /** Browser Back */
  51514. BrowserBack = 5,
  51515. /** Browser Forward */
  51516. BrowserForward = 6
  51517. }
  51518. /**
  51519. * Enum for Dual Shock Gamepad
  51520. */
  51521. export enum DualShockInput {
  51522. /** Cross */
  51523. Cross = 0,
  51524. /** Circle */
  51525. Circle = 1,
  51526. /** Square */
  51527. Square = 2,
  51528. /** Triangle */
  51529. Triangle = 3,
  51530. /** L1 */
  51531. L1 = 4,
  51532. /** R1 */
  51533. R1 = 5,
  51534. /** L2 */
  51535. L2 = 6,
  51536. /** R2 */
  51537. R2 = 7,
  51538. /** Share */
  51539. Share = 8,
  51540. /** Options */
  51541. Options = 9,
  51542. /** L3 */
  51543. L3 = 10,
  51544. /** R3 */
  51545. R3 = 11,
  51546. /** DPadUp */
  51547. DPadUp = 12,
  51548. /** DPadDown */
  51549. DPadDown = 13,
  51550. /** DPadLeft */
  51551. DPadLeft = 14,
  51552. /** DRight */
  51553. DPadRight = 15,
  51554. /** Home */
  51555. Home = 16,
  51556. /** TouchPad */
  51557. TouchPad = 17,
  51558. /** LStickXAxis */
  51559. LStickXAxis = 18,
  51560. /** LStickYAxis */
  51561. LStickYAxis = 19,
  51562. /** RStickXAxis */
  51563. RStickXAxis = 20,
  51564. /** RStickYAxis */
  51565. RStickYAxis = 21
  51566. }
  51567. /**
  51568. * Enum for Xbox Gamepad
  51569. */
  51570. export enum XboxInput {
  51571. /** A */
  51572. A = 0,
  51573. /** B */
  51574. B = 1,
  51575. /** X */
  51576. X = 2,
  51577. /** Y */
  51578. Y = 3,
  51579. /** LB */
  51580. LB = 4,
  51581. /** RB */
  51582. RB = 5,
  51583. /** LT */
  51584. LT = 6,
  51585. /** RT */
  51586. RT = 7,
  51587. /** Back */
  51588. Back = 8,
  51589. /** Start */
  51590. Start = 9,
  51591. /** LS */
  51592. LS = 10,
  51593. /** RS */
  51594. RS = 11,
  51595. /** DPadUp */
  51596. DPadUp = 12,
  51597. /** DPadDown */
  51598. DPadDown = 13,
  51599. /** DPadLeft */
  51600. DPadLeft = 14,
  51601. /** DRight */
  51602. DPadRight = 15,
  51603. /** Home */
  51604. Home = 16,
  51605. /** LStickXAxis */
  51606. LStickXAxis = 17,
  51607. /** LStickYAxis */
  51608. LStickYAxis = 18,
  51609. /** RStickXAxis */
  51610. RStickXAxis = 19,
  51611. /** RStickYAxis */
  51612. RStickYAxis = 20
  51613. }
  51614. /**
  51615. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  51616. */
  51617. export enum SwitchInput {
  51618. /** B */
  51619. B = 0,
  51620. /** A */
  51621. A = 1,
  51622. /** Y */
  51623. Y = 2,
  51624. /** X */
  51625. X = 3,
  51626. /** L */
  51627. L = 4,
  51628. /** R */
  51629. R = 5,
  51630. /** ZL */
  51631. ZL = 6,
  51632. /** ZR */
  51633. ZR = 7,
  51634. /** Minus */
  51635. Minus = 8,
  51636. /** Plus */
  51637. Plus = 9,
  51638. /** LS */
  51639. LS = 10,
  51640. /** RS */
  51641. RS = 11,
  51642. /** DPadUp */
  51643. DPadUp = 12,
  51644. /** DPadDown */
  51645. DPadDown = 13,
  51646. /** DPadLeft */
  51647. DPadLeft = 14,
  51648. /** DRight */
  51649. DPadRight = 15,
  51650. /** Home */
  51651. Home = 16,
  51652. /** Capture */
  51653. Capture = 17,
  51654. /** LStickXAxis */
  51655. LStickXAxis = 18,
  51656. /** LStickYAxis */
  51657. LStickYAxis = 19,
  51658. /** RStickXAxis */
  51659. RStickXAxis = 20,
  51660. /** RStickYAxis */
  51661. RStickYAxis = 21
  51662. }
  51663. }
  51664. declare module "babylonjs/DeviceInput/deviceInputSystem" {
  51665. import { Engine } from "babylonjs/Engines/engine";
  51666. import { IDisposable } from "babylonjs/scene";
  51667. import { Nullable } from "babylonjs/types";
  51668. import { DeviceType } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  51669. /**
  51670. * This class will take all inputs from Keyboard, Pointer, and
  51671. * any Gamepads and provide a polling system that all devices
  51672. * will use. This class assumes that there will only be one
  51673. * pointer device and one keyboard.
  51674. */
  51675. export class DeviceInputSystem implements IDisposable {
  51676. /**
  51677. * Callback to be triggered when a device is connected
  51678. */
  51679. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  51680. /**
  51681. * Callback to be triggered when a device is disconnected
  51682. */
  51683. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  51684. /**
  51685. * Callback to be triggered when event driven input is updated
  51686. */
  51687. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  51688. private _inputs;
  51689. private _gamepads;
  51690. private _keyboardActive;
  51691. private _pointerActive;
  51692. private _elementToAttachTo;
  51693. private _keyboardDownEvent;
  51694. private _keyboardUpEvent;
  51695. private _pointerMoveEvent;
  51696. private _pointerDownEvent;
  51697. private _pointerUpEvent;
  51698. private _gamepadConnectedEvent;
  51699. private _gamepadDisconnectedEvent;
  51700. private static _MAX_KEYCODES;
  51701. private static _MAX_POINTER_INPUTS;
  51702. /**
  51703. * Default Constructor
  51704. * @param engine - engine to pull input element from
  51705. */
  51706. constructor(engine: Engine);
  51707. /**
  51708. * Checks for current device input value, given an id and input index
  51709. * @param deviceName Id of connected device
  51710. * @param inputIndex Index of device input
  51711. * @returns Current value of input
  51712. */
  51713. /**
  51714. * Checks for current device input value, given an id and input index
  51715. * @param deviceType Enum specifiying device type
  51716. * @param deviceSlot "Slot" or index that device is referenced in
  51717. * @param inputIndex Id of input to be checked
  51718. * @returns Current value of input
  51719. */
  51720. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): Nullable<number>;
  51721. /**
  51722. * Dispose of all the eventlisteners
  51723. */
  51724. dispose(): void;
  51725. /**
  51726. * Add device and inputs to device array
  51727. * @param deviceType Enum specifiying device type
  51728. * @param deviceSlot "Slot" or index that device is referenced in
  51729. * @param numberOfInputs Number of input entries to create for given device
  51730. */
  51731. private _registerDevice;
  51732. /**
  51733. * Given a specific device name, remove that device from the device map
  51734. * @param deviceType Enum specifiying device type
  51735. * @param deviceSlot "Slot" or index that device is referenced in
  51736. */
  51737. private _unregisterDevice;
  51738. /**
  51739. * Handle all actions that come from keyboard interaction
  51740. */
  51741. private _handleKeyActions;
  51742. /**
  51743. * Handle all actions that come from pointer interaction
  51744. */
  51745. private _handlePointerActions;
  51746. /**
  51747. * Handle all actions that come from gamepad interaction
  51748. */
  51749. private _handleGamepadActions;
  51750. /**
  51751. * Update all non-event based devices with each frame
  51752. * @param deviceType Enum specifiying device type
  51753. * @param deviceSlot "Slot" or index that device is referenced in
  51754. * @param inputIndex Id of input to be checked
  51755. */
  51756. private _updateDevice;
  51757. /**
  51758. * Gets DeviceType from the device name
  51759. * @param deviceName Name of Device from DeviceInputSystem
  51760. * @returns DeviceType enum value
  51761. */
  51762. private _getGamepadDeviceType;
  51763. }
  51764. }
  51765. declare module "babylonjs/DeviceInput/InputDevices/deviceTypes" {
  51766. import { DeviceType, PointerInput, DualShockInput, XboxInput, SwitchInput } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  51767. /**
  51768. * Type to handle enforcement of inputs
  51769. */
  51770. 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;
  51771. }
  51772. declare module "babylonjs/DeviceInput/InputDevices/deviceSourceManager" {
  51773. import { DeviceInputSystem } from "babylonjs/DeviceInput/deviceInputSystem";
  51774. import { Engine } from "babylonjs/Engines/engine";
  51775. import { IDisposable } from "babylonjs/scene";
  51776. import { DeviceType } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  51777. import { Nullable } from "babylonjs/types";
  51778. import { Observable } from "babylonjs/Misc/observable";
  51779. import { DeviceInput } from "babylonjs/DeviceInput/InputDevices/deviceTypes";
  51780. /**
  51781. * Class that handles all input for a specific device
  51782. */
  51783. export class DeviceSource<T extends DeviceType> {
  51784. /** Type of device */
  51785. readonly deviceType: DeviceType;
  51786. /** "Slot" or index that device is referenced in */
  51787. readonly deviceSlot: number;
  51788. /**
  51789. * Observable to handle device input changes per device
  51790. */
  51791. readonly onInputChangedObservable: Observable<{
  51792. inputIndex: DeviceInput<T>;
  51793. previousState: Nullable<number>;
  51794. currentState: Nullable<number>;
  51795. }>;
  51796. private readonly _deviceInputSystem;
  51797. /**
  51798. * Default Constructor
  51799. * @param deviceInputSystem Reference to DeviceInputSystem
  51800. * @param deviceType Type of device
  51801. * @param deviceSlot "Slot" or index that device is referenced in
  51802. */
  51803. constructor(deviceInputSystem: DeviceInputSystem,
  51804. /** Type of device */
  51805. deviceType: DeviceType,
  51806. /** "Slot" or index that device is referenced in */
  51807. deviceSlot?: number);
  51808. /**
  51809. * Get input for specific input
  51810. * @param inputIndex index of specific input on device
  51811. * @returns Input value from DeviceInputSystem
  51812. */
  51813. getInput(inputIndex: DeviceInput<T>): Nullable<number>;
  51814. }
  51815. /**
  51816. * Class to keep track of devices
  51817. */
  51818. export class DeviceSourceManager implements IDisposable {
  51819. /**
  51820. * Observable to be triggered when before a device is connected
  51821. */
  51822. readonly onBeforeDeviceConnectedObservable: Observable<{
  51823. deviceType: DeviceType;
  51824. deviceSlot: number;
  51825. }>;
  51826. /**
  51827. * Observable to be triggered when before a device is disconnected
  51828. */
  51829. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  51830. deviceType: DeviceType;
  51831. deviceSlot: number;
  51832. }>;
  51833. /**
  51834. * Observable to be triggered when after a device is connected
  51835. */
  51836. readonly onAfterDeviceConnectedObservable: Observable<{
  51837. deviceType: DeviceType;
  51838. deviceSlot: number;
  51839. }>;
  51840. /**
  51841. * Observable to be triggered when after a device is disconnected
  51842. */
  51843. readonly onAfterDeviceDisconnectedObservable: Observable<{
  51844. deviceType: DeviceType;
  51845. deviceSlot: number;
  51846. }>;
  51847. private readonly _devices;
  51848. private readonly _firstDevice;
  51849. private readonly _deviceInputSystem;
  51850. /**
  51851. * Default Constructor
  51852. * @param engine engine to pull input element from
  51853. */
  51854. constructor(engine: Engine);
  51855. /**
  51856. * Gets a DeviceSource, given a type and slot
  51857. * @param deviceType Enum specifying device type
  51858. * @param deviceSlot "Slot" or index that device is referenced in
  51859. * @returns DeviceSource object
  51860. */
  51861. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  51862. /**
  51863. * Gets an array of DeviceSource objects for a given device type
  51864. * @param deviceType Enum specifying device type
  51865. * @returns Array of DeviceSource objects
  51866. */
  51867. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  51868. /**
  51869. * Dispose of DeviceInputSystem and other parts
  51870. */
  51871. dispose(): void;
  51872. /**
  51873. * Function to add device name to device list
  51874. * @param deviceType Enum specifying device type
  51875. * @param deviceSlot "Slot" or index that device is referenced in
  51876. */
  51877. private _addDevice;
  51878. /**
  51879. * Function to remove device name to device list
  51880. * @param deviceType Enum specifying device type
  51881. * @param deviceSlot "Slot" or index that device is referenced in
  51882. */
  51883. private _removeDevice;
  51884. /**
  51885. * Updates array storing first connected device of each type
  51886. * @param type Type of Device
  51887. */
  51888. private _updateFirstDevices;
  51889. }
  51890. }
  51891. declare module "babylonjs/DeviceInput/index" {
  51892. export * from "babylonjs/DeviceInput/deviceInputSystem";
  51893. export * from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  51894. export * from "babylonjs/DeviceInput/InputDevices/deviceTypes";
  51895. import "babylonjs/DeviceInput/InputDevices/deviceSourceManager";
  51896. export * from "babylonjs/DeviceInput/InputDevices/deviceSourceManager";
  51897. }
  51898. declare module "babylonjs/Engines/nullEngine" {
  51899. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  51900. import { Engine } from "babylonjs/Engines/engine";
  51901. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  51902. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  51903. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51904. import { Effect } from "babylonjs/Materials/effect";
  51905. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  51906. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  51907. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  51908. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  51909. /**
  51910. * Options to create the null engine
  51911. */
  51912. export class NullEngineOptions {
  51913. /**
  51914. * Render width (Default: 512)
  51915. */
  51916. renderWidth: number;
  51917. /**
  51918. * Render height (Default: 256)
  51919. */
  51920. renderHeight: number;
  51921. /**
  51922. * Texture size (Default: 512)
  51923. */
  51924. textureSize: number;
  51925. /**
  51926. * If delta time between frames should be constant
  51927. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  51928. */
  51929. deterministicLockstep: boolean;
  51930. /**
  51931. * Maximum about of steps between frames (Default: 4)
  51932. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  51933. */
  51934. lockstepMaxSteps: number;
  51935. }
  51936. /**
  51937. * The null engine class provides support for headless version of babylon.js.
  51938. * This can be used in server side scenario or for testing purposes
  51939. */
  51940. export class NullEngine extends Engine {
  51941. private _options;
  51942. /**
  51943. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  51944. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  51945. * @returns true if engine is in deterministic lock step mode
  51946. */
  51947. isDeterministicLockStep(): boolean;
  51948. /**
  51949. * Gets the max steps when engine is running in deterministic lock step
  51950. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  51951. * @returns the max steps
  51952. */
  51953. getLockstepMaxSteps(): number;
  51954. /**
  51955. * Gets the current hardware scaling level.
  51956. * By default the hardware scaling level is computed from the window device ratio.
  51957. * 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.
  51958. * @returns a number indicating the current hardware scaling level
  51959. */
  51960. getHardwareScalingLevel(): number;
  51961. constructor(options?: NullEngineOptions);
  51962. /**
  51963. * Creates a vertex buffer
  51964. * @param vertices the data for the vertex buffer
  51965. * @returns the new WebGL static buffer
  51966. */
  51967. createVertexBuffer(vertices: FloatArray): DataBuffer;
  51968. /**
  51969. * Creates a new index buffer
  51970. * @param indices defines the content of the index buffer
  51971. * @param updatable defines if the index buffer must be updatable
  51972. * @returns a new webGL buffer
  51973. */
  51974. createIndexBuffer(indices: IndicesArray): DataBuffer;
  51975. /**
  51976. * Clear the current render buffer or the current render target (if any is set up)
  51977. * @param color defines the color to use
  51978. * @param backBuffer defines if the back buffer must be cleared
  51979. * @param depth defines if the depth buffer must be cleared
  51980. * @param stencil defines if the stencil buffer must be cleared
  51981. */
  51982. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  51983. /**
  51984. * Gets the current render width
  51985. * @param useScreen defines if screen size must be used (or the current render target if any)
  51986. * @returns a number defining the current render width
  51987. */
  51988. getRenderWidth(useScreen?: boolean): number;
  51989. /**
  51990. * Gets the current render height
  51991. * @param useScreen defines if screen size must be used (or the current render target if any)
  51992. * @returns a number defining the current render height
  51993. */
  51994. getRenderHeight(useScreen?: boolean): number;
  51995. /**
  51996. * Set the WebGL's viewport
  51997. * @param viewport defines the viewport element to be used
  51998. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  51999. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  52000. */
  52001. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  52002. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  52003. /**
  52004. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  52005. * @param pipelineContext defines the pipeline context to use
  52006. * @param uniformsNames defines the list of uniform names
  52007. * @returns an array of webGL uniform locations
  52008. */
  52009. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  52010. /**
  52011. * Gets the lsit of active attributes for a given webGL program
  52012. * @param pipelineContext defines the pipeline context to use
  52013. * @param attributesNames defines the list of attribute names to get
  52014. * @returns an array of indices indicating the offset of each attribute
  52015. */
  52016. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  52017. /**
  52018. * Binds an effect to the webGL context
  52019. * @param effect defines the effect to bind
  52020. */
  52021. bindSamplers(effect: Effect): void;
  52022. /**
  52023. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  52024. * @param effect defines the effect to activate
  52025. */
  52026. enableEffect(effect: Effect): void;
  52027. /**
  52028. * Set various states to the webGL context
  52029. * @param culling defines backface culling state
  52030. * @param zOffset defines the value to apply to zOffset (0 by default)
  52031. * @param force defines if states must be applied even if cache is up to date
  52032. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  52033. */
  52034. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  52035. /**
  52036. * Set the value of an uniform to an array of int32
  52037. * @param uniform defines the webGL uniform location where to store the value
  52038. * @param array defines the array of int32 to store
  52039. */
  52040. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  52041. /**
  52042. * Set the value of an uniform to an array of int32 (stored as vec2)
  52043. * @param uniform defines the webGL uniform location where to store the value
  52044. * @param array defines the array of int32 to store
  52045. */
  52046. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  52047. /**
  52048. * Set the value of an uniform to an array of int32 (stored as vec3)
  52049. * @param uniform defines the webGL uniform location where to store the value
  52050. * @param array defines the array of int32 to store
  52051. */
  52052. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  52053. /**
  52054. * Set the value of an uniform to an array of int32 (stored as vec4)
  52055. * @param uniform defines the webGL uniform location where to store the value
  52056. * @param array defines the array of int32 to store
  52057. */
  52058. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  52059. /**
  52060. * Set the value of an uniform to an array of float32
  52061. * @param uniform defines the webGL uniform location where to store the value
  52062. * @param array defines the array of float32 to store
  52063. */
  52064. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  52065. /**
  52066. * Set the value of an uniform to an array of float32 (stored as vec2)
  52067. * @param uniform defines the webGL uniform location where to store the value
  52068. * @param array defines the array of float32 to store
  52069. */
  52070. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  52071. /**
  52072. * Set the value of an uniform to an array of float32 (stored as vec3)
  52073. * @param uniform defines the webGL uniform location where to store the value
  52074. * @param array defines the array of float32 to store
  52075. */
  52076. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  52077. /**
  52078. * Set the value of an uniform to an array of float32 (stored as vec4)
  52079. * @param uniform defines the webGL uniform location where to store the value
  52080. * @param array defines the array of float32 to store
  52081. */
  52082. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  52083. /**
  52084. * Set the value of an uniform to an array of number
  52085. * @param uniform defines the webGL uniform location where to store the value
  52086. * @param array defines the array of number to store
  52087. */
  52088. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  52089. /**
  52090. * Set the value of an uniform to an array of number (stored as vec2)
  52091. * @param uniform defines the webGL uniform location where to store the value
  52092. * @param array defines the array of number to store
  52093. */
  52094. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  52095. /**
  52096. * Set the value of an uniform to an array of number (stored as vec3)
  52097. * @param uniform defines the webGL uniform location where to store the value
  52098. * @param array defines the array of number to store
  52099. */
  52100. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  52101. /**
  52102. * Set the value of an uniform to an array of number (stored as vec4)
  52103. * @param uniform defines the webGL uniform location where to store the value
  52104. * @param array defines the array of number to store
  52105. */
  52106. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  52107. /**
  52108. * Set the value of an uniform to an array of float32 (stored as matrices)
  52109. * @param uniform defines the webGL uniform location where to store the value
  52110. * @param matrices defines the array of float32 to store
  52111. */
  52112. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  52113. /**
  52114. * Set the value of an uniform to a matrix (3x3)
  52115. * @param uniform defines the webGL uniform location where to store the value
  52116. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  52117. */
  52118. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  52119. /**
  52120. * Set the value of an uniform to a matrix (2x2)
  52121. * @param uniform defines the webGL uniform location where to store the value
  52122. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  52123. */
  52124. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  52125. /**
  52126. * Set the value of an uniform to a number (float)
  52127. * @param uniform defines the webGL uniform location where to store the value
  52128. * @param value defines the float number to store
  52129. */
  52130. setFloat(uniform: WebGLUniformLocation, value: number): void;
  52131. /**
  52132. * Set the value of an uniform to a vec2
  52133. * @param uniform defines the webGL uniform location where to store the value
  52134. * @param x defines the 1st component of the value
  52135. * @param y defines the 2nd component of the value
  52136. */
  52137. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  52138. /**
  52139. * Set the value of an uniform to a vec3
  52140. * @param uniform defines the webGL uniform location where to store the value
  52141. * @param x defines the 1st component of the value
  52142. * @param y defines the 2nd component of the value
  52143. * @param z defines the 3rd component of the value
  52144. */
  52145. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  52146. /**
  52147. * Set the value of an uniform to a boolean
  52148. * @param uniform defines the webGL uniform location where to store the value
  52149. * @param bool defines the boolean to store
  52150. */
  52151. setBool(uniform: WebGLUniformLocation, bool: number): void;
  52152. /**
  52153. * Set the value of an uniform to a vec4
  52154. * @param uniform defines the webGL uniform location where to store the value
  52155. * @param x defines the 1st component of the value
  52156. * @param y defines the 2nd component of the value
  52157. * @param z defines the 3rd component of the value
  52158. * @param w defines the 4th component of the value
  52159. */
  52160. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  52161. /**
  52162. * Sets the current alpha mode
  52163. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  52164. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  52165. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  52166. */
  52167. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  52168. /**
  52169. * Bind webGl buffers directly to the webGL context
  52170. * @param vertexBuffers defines the vertex buffer to bind
  52171. * @param indexBuffer defines the index buffer to bind
  52172. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  52173. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  52174. * @param effect defines the effect associated with the vertex buffer
  52175. */
  52176. bindBuffers(vertexBuffers: {
  52177. [key: string]: VertexBuffer;
  52178. }, indexBuffer: DataBuffer, effect: Effect): void;
  52179. /**
  52180. * Force the entire cache to be cleared
  52181. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  52182. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  52183. */
  52184. wipeCaches(bruteForce?: boolean): void;
  52185. /**
  52186. * Send a draw order
  52187. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  52188. * @param indexStart defines the starting index
  52189. * @param indexCount defines the number of index to draw
  52190. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52191. */
  52192. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  52193. /**
  52194. * Draw a list of indexed primitives
  52195. * @param fillMode defines the primitive to use
  52196. * @param indexStart defines the starting index
  52197. * @param indexCount defines the number of index to draw
  52198. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52199. */
  52200. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  52201. /**
  52202. * Draw a list of unindexed primitives
  52203. * @param fillMode defines the primitive to use
  52204. * @param verticesStart defines the index of first vertex to draw
  52205. * @param verticesCount defines the count of vertices to draw
  52206. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52207. */
  52208. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  52209. /** @hidden */
  52210. _createTexture(): WebGLTexture;
  52211. /** @hidden */
  52212. _releaseTexture(texture: InternalTexture): void;
  52213. /**
  52214. * Usually called from Texture.ts.
  52215. * Passed information to create a WebGLTexture
  52216. * @param urlArg defines a value which contains one of the following:
  52217. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  52218. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  52219. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  52220. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  52221. * @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)
  52222. * @param scene needed for loading to the correct scene
  52223. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  52224. * @param onLoad optional callback to be called upon successful completion
  52225. * @param onError optional callback to be called upon failure
  52226. * @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
  52227. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  52228. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  52229. * @param forcedExtension defines the extension to use to pick the right loader
  52230. * @param mimeType defines an optional mime type
  52231. * @returns a InternalTexture for assignment back into BABYLON.Texture
  52232. */
  52233. 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;
  52234. /**
  52235. * Creates a new render target texture
  52236. * @param size defines the size of the texture
  52237. * @param options defines the options used to create the texture
  52238. * @returns a new render target texture stored in an InternalTexture
  52239. */
  52240. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  52241. /**
  52242. * Update the sampling mode of a given texture
  52243. * @param samplingMode defines the required sampling mode
  52244. * @param texture defines the texture to update
  52245. */
  52246. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  52247. /**
  52248. * Binds the frame buffer to the specified texture.
  52249. * @param texture The texture to render to or null for the default canvas
  52250. * @param faceIndex The face of the texture to render to in case of cube texture
  52251. * @param requiredWidth The width of the target to render to
  52252. * @param requiredHeight The height of the target to render to
  52253. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  52254. * @param lodLevel defines le lod level to bind to the frame buffer
  52255. */
  52256. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  52257. /**
  52258. * Unbind the current render target texture from the webGL context
  52259. * @param texture defines the render target texture to unbind
  52260. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  52261. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  52262. */
  52263. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  52264. /**
  52265. * Creates a dynamic vertex buffer
  52266. * @param vertices the data for the dynamic vertex buffer
  52267. * @returns the new WebGL dynamic buffer
  52268. */
  52269. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  52270. /**
  52271. * Update the content of a dynamic texture
  52272. * @param texture defines the texture to update
  52273. * @param canvas defines the canvas containing the source
  52274. * @param invertY defines if data must be stored with Y axis inverted
  52275. * @param premulAlpha defines if alpha is stored as premultiplied
  52276. * @param format defines the format of the data
  52277. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  52278. */
  52279. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  52280. /**
  52281. * Gets a boolean indicating if all created effects are ready
  52282. * @returns true if all effects are ready
  52283. */
  52284. areAllEffectsReady(): boolean;
  52285. /**
  52286. * @hidden
  52287. * Get the current error code of the webGL context
  52288. * @returns the error code
  52289. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  52290. */
  52291. getError(): number;
  52292. /** @hidden */
  52293. _getUnpackAlignement(): number;
  52294. /** @hidden */
  52295. _unpackFlipY(value: boolean): void;
  52296. /**
  52297. * Update a dynamic index buffer
  52298. * @param indexBuffer defines the target index buffer
  52299. * @param indices defines the data to update
  52300. * @param offset defines the offset in the target index buffer where update should start
  52301. */
  52302. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  52303. /**
  52304. * Updates a dynamic vertex buffer.
  52305. * @param vertexBuffer the vertex buffer to update
  52306. * @param vertices the data used to update the vertex buffer
  52307. * @param byteOffset the byte offset of the data (optional)
  52308. * @param byteLength the byte length of the data (optional)
  52309. */
  52310. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  52311. /** @hidden */
  52312. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  52313. /** @hidden */
  52314. _bindTexture(channel: number, texture: InternalTexture): void;
  52315. protected _deleteBuffer(buffer: WebGLBuffer): void;
  52316. /**
  52317. * 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
  52318. */
  52319. releaseEffects(): void;
  52320. displayLoadingUI(): void;
  52321. hideLoadingUI(): void;
  52322. /** @hidden */
  52323. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52324. /** @hidden */
  52325. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52326. /** @hidden */
  52327. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52328. /** @hidden */
  52329. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  52330. }
  52331. }
  52332. declare module "babylonjs/Instrumentation/timeToken" {
  52333. import { Nullable } from "babylonjs/types";
  52334. /**
  52335. * @hidden
  52336. **/
  52337. export class _TimeToken {
  52338. _startTimeQuery: Nullable<WebGLQuery>;
  52339. _endTimeQuery: Nullable<WebGLQuery>;
  52340. _timeElapsedQuery: Nullable<WebGLQuery>;
  52341. _timeElapsedQueryEnded: boolean;
  52342. }
  52343. }
  52344. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  52345. import { Nullable, int } from "babylonjs/types";
  52346. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  52347. /** @hidden */
  52348. export class _OcclusionDataStorage {
  52349. /** @hidden */
  52350. occlusionInternalRetryCounter: number;
  52351. /** @hidden */
  52352. isOcclusionQueryInProgress: boolean;
  52353. /** @hidden */
  52354. isOccluded: boolean;
  52355. /** @hidden */
  52356. occlusionRetryCount: number;
  52357. /** @hidden */
  52358. occlusionType: number;
  52359. /** @hidden */
  52360. occlusionQueryAlgorithmType: number;
  52361. }
  52362. module "babylonjs/Engines/engine" {
  52363. interface Engine {
  52364. /**
  52365. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  52366. * @return the new query
  52367. */
  52368. createQuery(): WebGLQuery;
  52369. /**
  52370. * Delete and release a webGL query
  52371. * @param query defines the query to delete
  52372. * @return the current engine
  52373. */
  52374. deleteQuery(query: WebGLQuery): Engine;
  52375. /**
  52376. * Check if a given query has resolved and got its value
  52377. * @param query defines the query to check
  52378. * @returns true if the query got its value
  52379. */
  52380. isQueryResultAvailable(query: WebGLQuery): boolean;
  52381. /**
  52382. * Gets the value of a given query
  52383. * @param query defines the query to check
  52384. * @returns the value of the query
  52385. */
  52386. getQueryResult(query: WebGLQuery): number;
  52387. /**
  52388. * Initiates an occlusion query
  52389. * @param algorithmType defines the algorithm to use
  52390. * @param query defines the query to use
  52391. * @returns the current engine
  52392. * @see http://doc.babylonjs.com/features/occlusionquery
  52393. */
  52394. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  52395. /**
  52396. * Ends an occlusion query
  52397. * @see http://doc.babylonjs.com/features/occlusionquery
  52398. * @param algorithmType defines the algorithm to use
  52399. * @returns the current engine
  52400. */
  52401. endOcclusionQuery(algorithmType: number): Engine;
  52402. /**
  52403. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  52404. * Please note that only one query can be issued at a time
  52405. * @returns a time token used to track the time span
  52406. */
  52407. startTimeQuery(): Nullable<_TimeToken>;
  52408. /**
  52409. * Ends a time query
  52410. * @param token defines the token used to measure the time span
  52411. * @returns the time spent (in ns)
  52412. */
  52413. endTimeQuery(token: _TimeToken): int;
  52414. /** @hidden */
  52415. _currentNonTimestampToken: Nullable<_TimeToken>;
  52416. /** @hidden */
  52417. _createTimeQuery(): WebGLQuery;
  52418. /** @hidden */
  52419. _deleteTimeQuery(query: WebGLQuery): void;
  52420. /** @hidden */
  52421. _getGlAlgorithmType(algorithmType: number): number;
  52422. /** @hidden */
  52423. _getTimeQueryResult(query: WebGLQuery): any;
  52424. /** @hidden */
  52425. _getTimeQueryAvailability(query: WebGLQuery): any;
  52426. }
  52427. }
  52428. module "babylonjs/Meshes/abstractMesh" {
  52429. interface AbstractMesh {
  52430. /**
  52431. * Backing filed
  52432. * @hidden
  52433. */
  52434. __occlusionDataStorage: _OcclusionDataStorage;
  52435. /**
  52436. * Access property
  52437. * @hidden
  52438. */
  52439. _occlusionDataStorage: _OcclusionDataStorage;
  52440. /**
  52441. * 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.
  52442. * The default value is -1 which means don't break the query and wait till the result
  52443. * @see http://doc.babylonjs.com/features/occlusionquery
  52444. */
  52445. occlusionRetryCount: number;
  52446. /**
  52447. * 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:
  52448. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  52449. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  52450. * * 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.
  52451. * @see http://doc.babylonjs.com/features/occlusionquery
  52452. */
  52453. occlusionType: number;
  52454. /**
  52455. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  52456. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  52457. * * 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.
  52458. * @see http://doc.babylonjs.com/features/occlusionquery
  52459. */
  52460. occlusionQueryAlgorithmType: number;
  52461. /**
  52462. * 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
  52463. * @see http://doc.babylonjs.com/features/occlusionquery
  52464. */
  52465. isOccluded: boolean;
  52466. /**
  52467. * Flag to check the progress status of the query
  52468. * @see http://doc.babylonjs.com/features/occlusionquery
  52469. */
  52470. isOcclusionQueryInProgress: boolean;
  52471. }
  52472. }
  52473. }
  52474. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  52475. import { Nullable } from "babylonjs/types";
  52476. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  52477. /** @hidden */
  52478. export var _forceTransformFeedbackToBundle: boolean;
  52479. module "babylonjs/Engines/engine" {
  52480. interface Engine {
  52481. /**
  52482. * Creates a webGL transform feedback object
  52483. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  52484. * @returns the webGL transform feedback object
  52485. */
  52486. createTransformFeedback(): WebGLTransformFeedback;
  52487. /**
  52488. * Delete a webGL transform feedback object
  52489. * @param value defines the webGL transform feedback object to delete
  52490. */
  52491. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  52492. /**
  52493. * Bind a webGL transform feedback object to the webgl context
  52494. * @param value defines the webGL transform feedback object to bind
  52495. */
  52496. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  52497. /**
  52498. * Begins a transform feedback operation
  52499. * @param usePoints defines if points or triangles must be used
  52500. */
  52501. beginTransformFeedback(usePoints: boolean): void;
  52502. /**
  52503. * Ends a transform feedback operation
  52504. */
  52505. endTransformFeedback(): void;
  52506. /**
  52507. * Specify the varyings to use with transform feedback
  52508. * @param program defines the associated webGL program
  52509. * @param value defines the list of strings representing the varying names
  52510. */
  52511. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  52512. /**
  52513. * Bind a webGL buffer for a transform feedback operation
  52514. * @param value defines the webGL buffer to bind
  52515. */
  52516. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  52517. }
  52518. }
  52519. }
  52520. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  52521. import { Scene } from "babylonjs/scene";
  52522. import { Engine } from "babylonjs/Engines/engine";
  52523. import { Texture } from "babylonjs/Materials/Textures/texture";
  52524. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52525. import "babylonjs/Engines/Extensions/engine.multiRender";
  52526. /**
  52527. * Creation options of the multi render target texture.
  52528. */
  52529. export interface IMultiRenderTargetOptions {
  52530. /**
  52531. * Define if the texture needs to create mip maps after render.
  52532. */
  52533. generateMipMaps?: boolean;
  52534. /**
  52535. * Define the types of all the draw buffers we want to create
  52536. */
  52537. types?: number[];
  52538. /**
  52539. * Define the sampling modes of all the draw buffers we want to create
  52540. */
  52541. samplingModes?: number[];
  52542. /**
  52543. * Define if a depth buffer is required
  52544. */
  52545. generateDepthBuffer?: boolean;
  52546. /**
  52547. * Define if a stencil buffer is required
  52548. */
  52549. generateStencilBuffer?: boolean;
  52550. /**
  52551. * Define if a depth texture is required instead of a depth buffer
  52552. */
  52553. generateDepthTexture?: boolean;
  52554. /**
  52555. * Define the number of desired draw buffers
  52556. */
  52557. textureCount?: number;
  52558. /**
  52559. * Define if aspect ratio should be adapted to the texture or stay the scene one
  52560. */
  52561. doNotChangeAspectRatio?: boolean;
  52562. /**
  52563. * Define the default type of the buffers we are creating
  52564. */
  52565. defaultType?: number;
  52566. }
  52567. /**
  52568. * A multi render target, like a render target provides the ability to render to a texture.
  52569. * Unlike the render target, it can render to several draw buffers in one draw.
  52570. * This is specially interesting in deferred rendering or for any effects requiring more than
  52571. * just one color from a single pass.
  52572. */
  52573. export class MultiRenderTarget extends RenderTargetTexture {
  52574. private _internalTextures;
  52575. private _textures;
  52576. private _multiRenderTargetOptions;
  52577. /**
  52578. * Get if draw buffers are currently supported by the used hardware and browser.
  52579. */
  52580. get isSupported(): boolean;
  52581. /**
  52582. * Get the list of textures generated by the multi render target.
  52583. */
  52584. get textures(): Texture[];
  52585. /**
  52586. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  52587. */
  52588. get depthTexture(): Texture;
  52589. /**
  52590. * Set the wrapping mode on U of all the textures we are rendering to.
  52591. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  52592. */
  52593. set wrapU(wrap: number);
  52594. /**
  52595. * Set the wrapping mode on V of all the textures we are rendering to.
  52596. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  52597. */
  52598. set wrapV(wrap: number);
  52599. /**
  52600. * Instantiate a new multi render target texture.
  52601. * A multi render target, like a render target provides the ability to render to a texture.
  52602. * Unlike the render target, it can render to several draw buffers in one draw.
  52603. * This is specially interesting in deferred rendering or for any effects requiring more than
  52604. * just one color from a single pass.
  52605. * @param name Define the name of the texture
  52606. * @param size Define the size of the buffers to render to
  52607. * @param count Define the number of target we are rendering into
  52608. * @param scene Define the scene the texture belongs to
  52609. * @param options Define the options used to create the multi render target
  52610. */
  52611. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  52612. /** @hidden */
  52613. _rebuild(): void;
  52614. private _createInternalTextures;
  52615. private _createTextures;
  52616. /**
  52617. * Define the number of samples used if MSAA is enabled.
  52618. */
  52619. get samples(): number;
  52620. set samples(value: number);
  52621. /**
  52622. * Resize all the textures in the multi render target.
  52623. * Be carrefull as it will recreate all the data in the new texture.
  52624. * @param size Define the new size
  52625. */
  52626. resize(size: any): void;
  52627. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  52628. /**
  52629. * Dispose the render targets and their associated resources
  52630. */
  52631. dispose(): void;
  52632. /**
  52633. * Release all the underlying texture used as draw buffers.
  52634. */
  52635. releaseInternalTextures(): void;
  52636. }
  52637. }
  52638. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  52639. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  52640. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  52641. import { Nullable } from "babylonjs/types";
  52642. module "babylonjs/Engines/thinEngine" {
  52643. interface ThinEngine {
  52644. /**
  52645. * Unbind a list of render target textures from the webGL context
  52646. * This is used only when drawBuffer extension or webGL2 are active
  52647. * @param textures defines the render target textures to unbind
  52648. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  52649. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  52650. */
  52651. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  52652. /**
  52653. * Create a multi render target texture
  52654. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  52655. * @param size defines the size of the texture
  52656. * @param options defines the creation options
  52657. * @returns the cube texture as an InternalTexture
  52658. */
  52659. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  52660. /**
  52661. * Update the sample count for a given multiple render target texture
  52662. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  52663. * @param textures defines the textures to update
  52664. * @param samples defines the sample count to set
  52665. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  52666. */
  52667. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  52668. }
  52669. }
  52670. }
  52671. declare module "babylonjs/Engines/Extensions/engine.views" {
  52672. import { Camera } from "babylonjs/Cameras/camera";
  52673. import { Nullable } from "babylonjs/types";
  52674. /**
  52675. * Class used to define an additional view for the engine
  52676. * @see https://doc.babylonjs.com/how_to/multi_canvases
  52677. */
  52678. export class EngineView {
  52679. /** Defines the canvas where to render the view */
  52680. target: HTMLCanvasElement;
  52681. /** Defines an optional camera used to render the view (will use active camera else) */
  52682. camera?: Camera;
  52683. }
  52684. module "babylonjs/Engines/engine" {
  52685. interface Engine {
  52686. /**
  52687. * Gets or sets the HTML element to use for attaching events
  52688. */
  52689. inputElement: Nullable<HTMLElement>;
  52690. /**
  52691. * Gets the current engine view
  52692. * @see https://doc.babylonjs.com/how_to/multi_canvases
  52693. */
  52694. activeView: Nullable<EngineView>;
  52695. /** Gets or sets the list of views */
  52696. views: EngineView[];
  52697. /**
  52698. * Register a new child canvas
  52699. * @param canvas defines the canvas to register
  52700. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  52701. * @returns the associated view
  52702. */
  52703. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  52704. /**
  52705. * Remove a registered child canvas
  52706. * @param canvas defines the canvas to remove
  52707. * @returns the current engine
  52708. */
  52709. unRegisterView(canvas: HTMLCanvasElement): Engine;
  52710. }
  52711. }
  52712. }
  52713. declare module "babylonjs/Engines/Extensions/engine.textureSelector" {
  52714. import { Nullable } from "babylonjs/types";
  52715. module "babylonjs/Engines/engine" {
  52716. interface Engine {
  52717. /** @hidden */
  52718. _excludedCompressedTextures: string[];
  52719. /** @hidden */
  52720. _textureFormatInUse: string;
  52721. /**
  52722. * Gets the list of texture formats supported
  52723. */
  52724. readonly texturesSupported: Array<string>;
  52725. /**
  52726. * Gets the texture format in use
  52727. */
  52728. readonly textureFormatInUse: Nullable<string>;
  52729. /**
  52730. * Set the compressed texture extensions or file names to skip.
  52731. *
  52732. * @param skippedFiles defines the list of those texture files you want to skip
  52733. * Example: [".dds", ".env", "myfile.png"]
  52734. */
  52735. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  52736. /**
  52737. * Set the compressed texture format to use, based on the formats you have, and the formats
  52738. * supported by the hardware / browser.
  52739. *
  52740. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  52741. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  52742. * to API arguments needed to compressed textures. This puts the burden on the container
  52743. * generator to house the arcane code for determining these for current & future formats.
  52744. *
  52745. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  52746. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  52747. *
  52748. * Note: The result of this call is not taken into account when a texture is base64.
  52749. *
  52750. * @param formatsAvailable defines the list of those format families you have created
  52751. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  52752. *
  52753. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  52754. * @returns The extension selected.
  52755. */
  52756. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  52757. }
  52758. }
  52759. }
  52760. declare module "babylonjs/Engines/Extensions/index" {
  52761. export * from "babylonjs/Engines/Extensions/engine.alpha";
  52762. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  52763. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  52764. export * from "babylonjs/Engines/Extensions/engine.multiview";
  52765. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  52766. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  52767. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  52768. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  52769. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  52770. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  52771. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  52772. export * from "babylonjs/Engines/Extensions/engine.webVR";
  52773. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  52774. export * from "babylonjs/Engines/Extensions/engine.views";
  52775. export * from "babylonjs/Engines/Extensions/engine.readTexture";
  52776. import "babylonjs/Engines/Extensions/engine.textureSelector";
  52777. export * from "babylonjs/Engines/Extensions/engine.textureSelector";
  52778. }
  52779. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  52780. import { Nullable } from "babylonjs/types";
  52781. /**
  52782. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  52783. */
  52784. export interface CubeMapInfo {
  52785. /**
  52786. * The pixel array for the front face.
  52787. * This is stored in format, left to right, up to down format.
  52788. */
  52789. front: Nullable<ArrayBufferView>;
  52790. /**
  52791. * The pixel array for the back face.
  52792. * This is stored in format, left to right, up to down format.
  52793. */
  52794. back: Nullable<ArrayBufferView>;
  52795. /**
  52796. * The pixel array for the left face.
  52797. * This is stored in format, left to right, up to down format.
  52798. */
  52799. left: Nullable<ArrayBufferView>;
  52800. /**
  52801. * The pixel array for the right face.
  52802. * This is stored in format, left to right, up to down format.
  52803. */
  52804. right: Nullable<ArrayBufferView>;
  52805. /**
  52806. * The pixel array for the up face.
  52807. * This is stored in format, left to right, up to down format.
  52808. */
  52809. up: Nullable<ArrayBufferView>;
  52810. /**
  52811. * The pixel array for the down face.
  52812. * This is stored in format, left to right, up to down format.
  52813. */
  52814. down: Nullable<ArrayBufferView>;
  52815. /**
  52816. * The size of the cubemap stored.
  52817. *
  52818. * Each faces will be size * size pixels.
  52819. */
  52820. size: number;
  52821. /**
  52822. * The format of the texture.
  52823. *
  52824. * RGBA, RGB.
  52825. */
  52826. format: number;
  52827. /**
  52828. * The type of the texture data.
  52829. *
  52830. * UNSIGNED_INT, FLOAT.
  52831. */
  52832. type: number;
  52833. /**
  52834. * Specifies whether the texture is in gamma space.
  52835. */
  52836. gammaSpace: boolean;
  52837. }
  52838. /**
  52839. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  52840. */
  52841. export class PanoramaToCubeMapTools {
  52842. private static FACE_LEFT;
  52843. private static FACE_RIGHT;
  52844. private static FACE_FRONT;
  52845. private static FACE_BACK;
  52846. private static FACE_DOWN;
  52847. private static FACE_UP;
  52848. /**
  52849. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  52850. *
  52851. * @param float32Array The source data.
  52852. * @param inputWidth The width of the input panorama.
  52853. * @param inputHeight The height of the input panorama.
  52854. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  52855. * @return The cubemap data
  52856. */
  52857. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  52858. private static CreateCubemapTexture;
  52859. private static CalcProjectionSpherical;
  52860. }
  52861. }
  52862. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  52863. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  52864. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52865. import { Nullable } from "babylonjs/types";
  52866. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  52867. /**
  52868. * Helper class dealing with the extraction of spherical polynomial dataArray
  52869. * from a cube map.
  52870. */
  52871. export class CubeMapToSphericalPolynomialTools {
  52872. private static FileFaces;
  52873. /**
  52874. * Converts a texture to the according Spherical Polynomial data.
  52875. * This extracts the first 3 orders only as they are the only one used in the lighting.
  52876. *
  52877. * @param texture The texture to extract the information from.
  52878. * @return The Spherical Polynomial data.
  52879. */
  52880. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  52881. /**
  52882. * Converts a cubemap to the according Spherical Polynomial data.
  52883. * This extracts the first 3 orders only as they are the only one used in the lighting.
  52884. *
  52885. * @param cubeInfo The Cube map to extract the information from.
  52886. * @return The Spherical Polynomial data.
  52887. */
  52888. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  52889. }
  52890. }
  52891. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  52892. import { Nullable } from "babylonjs/types";
  52893. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  52894. module "babylonjs/Materials/Textures/baseTexture" {
  52895. interface BaseTexture {
  52896. /**
  52897. * Get the polynomial representation of the texture data.
  52898. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  52899. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  52900. */
  52901. sphericalPolynomial: Nullable<SphericalPolynomial>;
  52902. }
  52903. }
  52904. }
  52905. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  52906. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  52907. /** @hidden */
  52908. export var rgbdEncodePixelShader: {
  52909. name: string;
  52910. shader: string;
  52911. };
  52912. }
  52913. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  52914. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  52915. /** @hidden */
  52916. export var rgbdDecodePixelShader: {
  52917. name: string;
  52918. shader: string;
  52919. };
  52920. }
  52921. declare module "babylonjs/Misc/environmentTextureTools" {
  52922. import { Nullable } from "babylonjs/types";
  52923. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  52924. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  52925. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52926. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  52927. import "babylonjs/Engines/Extensions/engine.readTexture";
  52928. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  52929. import "babylonjs/Shaders/rgbdEncode.fragment";
  52930. import "babylonjs/Shaders/rgbdDecode.fragment";
  52931. /**
  52932. * Raw texture data and descriptor sufficient for WebGL texture upload
  52933. */
  52934. export interface EnvironmentTextureInfo {
  52935. /**
  52936. * Version of the environment map
  52937. */
  52938. version: number;
  52939. /**
  52940. * Width of image
  52941. */
  52942. width: number;
  52943. /**
  52944. * Irradiance information stored in the file.
  52945. */
  52946. irradiance: any;
  52947. /**
  52948. * Specular information stored in the file.
  52949. */
  52950. specular: any;
  52951. }
  52952. /**
  52953. * Defines One Image in the file. It requires only the position in the file
  52954. * as well as the length.
  52955. */
  52956. interface BufferImageData {
  52957. /**
  52958. * Length of the image data.
  52959. */
  52960. length: number;
  52961. /**
  52962. * Position of the data from the null terminator delimiting the end of the JSON.
  52963. */
  52964. position: number;
  52965. }
  52966. /**
  52967. * Defines the specular data enclosed in the file.
  52968. * This corresponds to the version 1 of the data.
  52969. */
  52970. export interface EnvironmentTextureSpecularInfoV1 {
  52971. /**
  52972. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  52973. */
  52974. specularDataPosition?: number;
  52975. /**
  52976. * This contains all the images data needed to reconstruct the cubemap.
  52977. */
  52978. mipmaps: Array<BufferImageData>;
  52979. /**
  52980. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  52981. */
  52982. lodGenerationScale: number;
  52983. }
  52984. /**
  52985. * Sets of helpers addressing the serialization and deserialization of environment texture
  52986. * stored in a BabylonJS env file.
  52987. * Those files are usually stored as .env files.
  52988. */
  52989. export class EnvironmentTextureTools {
  52990. /**
  52991. * Magic number identifying the env file.
  52992. */
  52993. private static _MagicBytes;
  52994. /**
  52995. * Gets the environment info from an env file.
  52996. * @param data The array buffer containing the .env bytes.
  52997. * @returns the environment file info (the json header) if successfully parsed.
  52998. */
  52999. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  53000. /**
  53001. * Creates an environment texture from a loaded cube texture.
  53002. * @param texture defines the cube texture to convert in env file
  53003. * @return a promise containing the environment data if succesfull.
  53004. */
  53005. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  53006. /**
  53007. * Creates a JSON representation of the spherical data.
  53008. * @param texture defines the texture containing the polynomials
  53009. * @return the JSON representation of the spherical info
  53010. */
  53011. private static _CreateEnvTextureIrradiance;
  53012. /**
  53013. * Creates the ArrayBufferViews used for initializing environment texture image data.
  53014. * @param data the image data
  53015. * @param info parameters that determine what views will be created for accessing the underlying buffer
  53016. * @return the views described by info providing access to the underlying buffer
  53017. */
  53018. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  53019. /**
  53020. * Uploads the texture info contained in the env file to the GPU.
  53021. * @param texture defines the internal texture to upload to
  53022. * @param data defines the data to load
  53023. * @param info defines the texture info retrieved through the GetEnvInfo method
  53024. * @returns a promise
  53025. */
  53026. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  53027. private static _OnImageReadyAsync;
  53028. /**
  53029. * Uploads the levels of image data to the GPU.
  53030. * @param texture defines the internal texture to upload to
  53031. * @param imageData defines the array buffer views of image data [mipmap][face]
  53032. * @returns a promise
  53033. */
  53034. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  53035. /**
  53036. * Uploads spherical polynomials information to the texture.
  53037. * @param texture defines the texture we are trying to upload the information to
  53038. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  53039. */
  53040. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  53041. /** @hidden */
  53042. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  53043. }
  53044. }
  53045. declare module "babylonjs/Engines/Native/nativeShaderProcessor" {
  53046. import { WebGL2ShaderProcessor } from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  53047. /** @hidden */
  53048. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  53049. private _genericAttributeLocation;
  53050. private _varyingLocationCount;
  53051. private _varyingLocationMap;
  53052. private _replacements;
  53053. private _textureCount;
  53054. private _uniforms;
  53055. lineProcessor(line: string): string;
  53056. attributeProcessor(attribute: string): string;
  53057. varyingProcessor(varying: string, isFragment: boolean): string;
  53058. uniformProcessor(uniform: string): string;
  53059. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  53060. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  53061. }
  53062. }
  53063. declare module "babylonjs/Engines/Processors/shaderCodeInliner" {
  53064. /** @hidden */
  53065. export class ShaderCodeInliner {
  53066. static readonly InlineToken: string;
  53067. static readonly RegexpFindFunctionNameAndType: RegExp;
  53068. private _sourceCode;
  53069. private _functionDescr;
  53070. private _numMaxIterations;
  53071. debug: boolean;
  53072. get code(): string;
  53073. constructor(sourceCode: string, numMaxIterations?: number);
  53074. processCode(): void;
  53075. private _collectFunctions;
  53076. private _processInlining;
  53077. private _extractBetweenMarkers;
  53078. private _skipWhitespaces;
  53079. private _removeComments;
  53080. private _replaceFunctionCallsByCode;
  53081. private _findBackward;
  53082. private _escapeRegExp;
  53083. private _replaceNames;
  53084. }
  53085. }
  53086. declare module "babylonjs/Engines/nativeEngine" {
  53087. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  53088. import { Engine } from "babylonjs/Engines/engine";
  53089. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  53090. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53091. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53092. import { Effect } from "babylonjs/Materials/effect";
  53093. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  53094. import { Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  53095. import { IColor4Like } from "babylonjs/Maths/math.like";
  53096. import { Scene } from "babylonjs/scene";
  53097. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  53098. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  53099. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  53100. /**
  53101. * Container for accessors for natively-stored mesh data buffers.
  53102. */
  53103. class NativeDataBuffer extends DataBuffer {
  53104. /**
  53105. * Accessor value used to identify/retrieve a natively-stored index buffer.
  53106. */
  53107. nativeIndexBuffer?: any;
  53108. /**
  53109. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  53110. */
  53111. nativeVertexBuffer?: any;
  53112. }
  53113. /** @hidden */
  53114. class NativeTexture extends InternalTexture {
  53115. getInternalTexture(): InternalTexture;
  53116. getViewCount(): number;
  53117. }
  53118. /** @hidden */
  53119. export class NativeEngine extends Engine {
  53120. private readonly _native;
  53121. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  53122. private readonly INVALID_HANDLE;
  53123. getHardwareScalingLevel(): number;
  53124. constructor();
  53125. dispose(): void;
  53126. /**
  53127. * Can be used to override the current requestAnimationFrame requester.
  53128. * @hidden
  53129. */
  53130. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  53131. /**
  53132. * Override default engine behavior.
  53133. * @param color
  53134. * @param backBuffer
  53135. * @param depth
  53136. * @param stencil
  53137. */
  53138. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  53139. /**
  53140. * Gets host document
  53141. * @returns the host document object
  53142. */
  53143. getHostDocument(): Nullable<Document>;
  53144. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  53145. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  53146. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  53147. recordVertexArrayObject(vertexBuffers: {
  53148. [key: string]: VertexBuffer;
  53149. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  53150. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  53151. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  53152. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  53153. /**
  53154. * Draw a list of indexed primitives
  53155. * @param fillMode defines the primitive to use
  53156. * @param indexStart defines the starting index
  53157. * @param indexCount defines the number of index to draw
  53158. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  53159. */
  53160. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  53161. /**
  53162. * Draw a list of unindexed primitives
  53163. * @param fillMode defines the primitive to use
  53164. * @param verticesStart defines the index of first vertex to draw
  53165. * @param verticesCount defines the count of vertices to draw
  53166. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  53167. */
  53168. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  53169. createPipelineContext(): IPipelineContext;
  53170. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  53171. /** @hidden */
  53172. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  53173. /** @hidden */
  53174. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  53175. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  53176. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  53177. protected _setProgram(program: WebGLProgram): void;
  53178. _releaseEffect(effect: Effect): void;
  53179. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  53180. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  53181. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  53182. bindSamplers(effect: Effect): void;
  53183. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  53184. getRenderWidth(useScreen?: boolean): number;
  53185. getRenderHeight(useScreen?: boolean): number;
  53186. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  53187. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  53188. /**
  53189. * Set the z offset to apply to current rendering
  53190. * @param value defines the offset to apply
  53191. */
  53192. setZOffset(value: number): void;
  53193. /**
  53194. * Gets the current value of the zOffset
  53195. * @returns the current zOffset state
  53196. */
  53197. getZOffset(): number;
  53198. /**
  53199. * Enable or disable depth buffering
  53200. * @param enable defines the state to set
  53201. */
  53202. setDepthBuffer(enable: boolean): void;
  53203. /**
  53204. * Gets a boolean indicating if depth writing is enabled
  53205. * @returns the current depth writing state
  53206. */
  53207. getDepthWrite(): boolean;
  53208. /**
  53209. * Enable or disable depth writing
  53210. * @param enable defines the state to set
  53211. */
  53212. setDepthWrite(enable: boolean): void;
  53213. /**
  53214. * Enable or disable color writing
  53215. * @param enable defines the state to set
  53216. */
  53217. setColorWrite(enable: boolean): void;
  53218. /**
  53219. * Gets a boolean indicating if color writing is enabled
  53220. * @returns the current color writing state
  53221. */
  53222. getColorWrite(): boolean;
  53223. /**
  53224. * Sets alpha constants used by some alpha blending modes
  53225. * @param r defines the red component
  53226. * @param g defines the green component
  53227. * @param b defines the blue component
  53228. * @param a defines the alpha component
  53229. */
  53230. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  53231. /**
  53232. * Sets the current alpha mode
  53233. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  53234. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  53235. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  53236. */
  53237. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  53238. /**
  53239. * Gets the current alpha mode
  53240. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  53241. * @returns the current alpha mode
  53242. */
  53243. getAlphaMode(): number;
  53244. setInt(uniform: WebGLUniformLocation, int: number): void;
  53245. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  53246. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  53247. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  53248. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  53249. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  53250. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  53251. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  53252. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  53253. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  53254. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  53255. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  53256. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  53257. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  53258. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  53259. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  53260. setFloat(uniform: WebGLUniformLocation, value: number): void;
  53261. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  53262. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  53263. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  53264. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  53265. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  53266. wipeCaches(bruteForce?: boolean): void;
  53267. _createTexture(): WebGLTexture;
  53268. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  53269. /**
  53270. * Usually called from Texture.ts.
  53271. * Passed information to create a WebGLTexture
  53272. * @param url defines a value which contains one of the following:
  53273. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  53274. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  53275. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  53276. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  53277. * @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)
  53278. * @param scene needed for loading to the correct scene
  53279. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  53280. * @param onLoad optional callback to be called upon successful completion
  53281. * @param onError optional callback to be called upon failure
  53282. * @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
  53283. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  53284. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  53285. * @param forcedExtension defines the extension to use to pick the right loader
  53286. * @param mimeType defines an optional mime type
  53287. * @returns a InternalTexture for assignment back into BABYLON.Texture
  53288. */
  53289. 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;
  53290. /**
  53291. * Creates a cube texture
  53292. * @param rootUrl defines the url where the files to load is located
  53293. * @param scene defines the current scene
  53294. * @param files defines the list of files to load (1 per face)
  53295. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  53296. * @param onLoad defines an optional callback raised when the texture is loaded
  53297. * @param onError defines an optional callback raised if there is an issue to load the texture
  53298. * @param format defines the format of the data
  53299. * @param forcedExtension defines the extension to use to pick the right loader
  53300. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  53301. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  53302. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  53303. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  53304. * @returns the cube texture as an InternalTexture
  53305. */
  53306. 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;
  53307. private _getSamplingFilter;
  53308. private static _GetNativeTextureFormat;
  53309. createRenderTargetTexture(size: number | {
  53310. width: number;
  53311. height: number;
  53312. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  53313. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  53314. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  53315. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  53316. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  53317. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  53318. /**
  53319. * Updates a dynamic vertex buffer.
  53320. * @param vertexBuffer the vertex buffer to update
  53321. * @param data the data used to update the vertex buffer
  53322. * @param byteOffset the byte offset of the data (optional)
  53323. * @param byteLength the byte length of the data (optional)
  53324. */
  53325. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  53326. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  53327. private _updateAnisotropicLevel;
  53328. private _getAddressMode;
  53329. /** @hidden */
  53330. _bindTexture(channel: number, texture: InternalTexture): void;
  53331. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  53332. releaseEffects(): void;
  53333. /** @hidden */
  53334. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  53335. /** @hidden */
  53336. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  53337. /** @hidden */
  53338. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  53339. /** @hidden */
  53340. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  53341. }
  53342. }
  53343. declare module "babylonjs/Engines/index" {
  53344. export * from "babylonjs/Engines/constants";
  53345. export * from "babylonjs/Engines/engineCapabilities";
  53346. export * from "babylonjs/Engines/instancingAttributeInfo";
  53347. export * from "babylonjs/Engines/thinEngine";
  53348. export * from "babylonjs/Engines/engine";
  53349. export * from "babylonjs/Engines/engineStore";
  53350. export * from "babylonjs/Engines/nullEngine";
  53351. export * from "babylonjs/Engines/Extensions/index";
  53352. export * from "babylonjs/Engines/IPipelineContext";
  53353. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  53354. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  53355. export * from "babylonjs/Engines/nativeEngine";
  53356. }
  53357. declare module "babylonjs/Events/clipboardEvents" {
  53358. /**
  53359. * Gather the list of clipboard event types as constants.
  53360. */
  53361. export class ClipboardEventTypes {
  53362. /**
  53363. * The clipboard event is fired when a copy command is active (pressed).
  53364. */
  53365. static readonly COPY: number;
  53366. /**
  53367. * The clipboard event is fired when a cut command is active (pressed).
  53368. */
  53369. static readonly CUT: number;
  53370. /**
  53371. * The clipboard event is fired when a paste command is active (pressed).
  53372. */
  53373. static readonly PASTE: number;
  53374. }
  53375. /**
  53376. * This class is used to store clipboard related info for the onClipboardObservable event.
  53377. */
  53378. export class ClipboardInfo {
  53379. /**
  53380. * Defines the type of event (BABYLON.ClipboardEventTypes)
  53381. */
  53382. type: number;
  53383. /**
  53384. * Defines the related dom event
  53385. */
  53386. event: ClipboardEvent;
  53387. /**
  53388. *Creates an instance of ClipboardInfo.
  53389. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  53390. * @param event Defines the related dom event
  53391. */
  53392. constructor(
  53393. /**
  53394. * Defines the type of event (BABYLON.ClipboardEventTypes)
  53395. */
  53396. type: number,
  53397. /**
  53398. * Defines the related dom event
  53399. */
  53400. event: ClipboardEvent);
  53401. /**
  53402. * Get the clipboard event's type from the keycode.
  53403. * @param keyCode Defines the keyCode for the current keyboard event.
  53404. * @return {number}
  53405. */
  53406. static GetTypeFromCharacter(keyCode: number): number;
  53407. }
  53408. }
  53409. declare module "babylonjs/Events/index" {
  53410. export * from "babylonjs/Events/keyboardEvents";
  53411. export * from "babylonjs/Events/pointerEvents";
  53412. export * from "babylonjs/Events/clipboardEvents";
  53413. }
  53414. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  53415. import { Scene } from "babylonjs/scene";
  53416. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53417. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  53418. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  53419. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  53420. /**
  53421. * Google Daydream controller
  53422. */
  53423. export class DaydreamController extends WebVRController {
  53424. /**
  53425. * Base Url for the controller model.
  53426. */
  53427. static MODEL_BASE_URL: string;
  53428. /**
  53429. * File name for the controller model.
  53430. */
  53431. static MODEL_FILENAME: string;
  53432. /**
  53433. * Gamepad Id prefix used to identify Daydream Controller.
  53434. */
  53435. static readonly GAMEPAD_ID_PREFIX: string;
  53436. /**
  53437. * Creates a new DaydreamController from a gamepad
  53438. * @param vrGamepad the gamepad that the controller should be created from
  53439. */
  53440. constructor(vrGamepad: any);
  53441. /**
  53442. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53443. * @param scene scene in which to add meshes
  53444. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53445. */
  53446. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  53447. /**
  53448. * Called once for each button that changed state since the last frame
  53449. * @param buttonIdx Which button index changed
  53450. * @param state New state of the button
  53451. * @param changes Which properties on the state changed since last frame
  53452. */
  53453. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53454. }
  53455. }
  53456. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  53457. import { Scene } from "babylonjs/scene";
  53458. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53459. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  53460. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  53461. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  53462. /**
  53463. * Gear VR Controller
  53464. */
  53465. export class GearVRController extends WebVRController {
  53466. /**
  53467. * Base Url for the controller model.
  53468. */
  53469. static MODEL_BASE_URL: string;
  53470. /**
  53471. * File name for the controller model.
  53472. */
  53473. static MODEL_FILENAME: string;
  53474. /**
  53475. * Gamepad Id prefix used to identify this controller.
  53476. */
  53477. static readonly GAMEPAD_ID_PREFIX: string;
  53478. private readonly _buttonIndexToObservableNameMap;
  53479. /**
  53480. * Creates a new GearVRController from a gamepad
  53481. * @param vrGamepad the gamepad that the controller should be created from
  53482. */
  53483. constructor(vrGamepad: any);
  53484. /**
  53485. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53486. * @param scene scene in which to add meshes
  53487. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53488. */
  53489. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  53490. /**
  53491. * Called once for each button that changed state since the last frame
  53492. * @param buttonIdx Which button index changed
  53493. * @param state New state of the button
  53494. * @param changes Which properties on the state changed since last frame
  53495. */
  53496. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53497. }
  53498. }
  53499. declare module "babylonjs/Gamepads/Controllers/genericController" {
  53500. import { Scene } from "babylonjs/scene";
  53501. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53502. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  53503. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  53504. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  53505. /**
  53506. * Generic Controller
  53507. */
  53508. export class GenericController extends WebVRController {
  53509. /**
  53510. * Base Url for the controller model.
  53511. */
  53512. static readonly MODEL_BASE_URL: string;
  53513. /**
  53514. * File name for the controller model.
  53515. */
  53516. static readonly MODEL_FILENAME: string;
  53517. /**
  53518. * Creates a new GenericController from a gamepad
  53519. * @param vrGamepad the gamepad that the controller should be created from
  53520. */
  53521. constructor(vrGamepad: any);
  53522. /**
  53523. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53524. * @param scene scene in which to add meshes
  53525. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53526. */
  53527. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  53528. /**
  53529. * Called once for each button that changed state since the last frame
  53530. * @param buttonIdx Which button index changed
  53531. * @param state New state of the button
  53532. * @param changes Which properties on the state changed since last frame
  53533. */
  53534. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53535. }
  53536. }
  53537. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  53538. import { Observable } from "babylonjs/Misc/observable";
  53539. import { Scene } from "babylonjs/scene";
  53540. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53541. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  53542. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  53543. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  53544. /**
  53545. * Oculus Touch Controller
  53546. */
  53547. export class OculusTouchController extends WebVRController {
  53548. /**
  53549. * Base Url for the controller model.
  53550. */
  53551. static MODEL_BASE_URL: string;
  53552. /**
  53553. * File name for the left controller model.
  53554. */
  53555. static MODEL_LEFT_FILENAME: string;
  53556. /**
  53557. * File name for the right controller model.
  53558. */
  53559. static MODEL_RIGHT_FILENAME: string;
  53560. /**
  53561. * Base Url for the Quest controller model.
  53562. */
  53563. static QUEST_MODEL_BASE_URL: string;
  53564. /**
  53565. * @hidden
  53566. * If the controllers are running on a device that needs the updated Quest controller models
  53567. */
  53568. static _IsQuest: boolean;
  53569. /**
  53570. * Fired when the secondary trigger on this controller is modified
  53571. */
  53572. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  53573. /**
  53574. * Fired when the thumb rest on this controller is modified
  53575. */
  53576. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  53577. /**
  53578. * Creates a new OculusTouchController from a gamepad
  53579. * @param vrGamepad the gamepad that the controller should be created from
  53580. */
  53581. constructor(vrGamepad: any);
  53582. /**
  53583. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53584. * @param scene scene in which to add meshes
  53585. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53586. */
  53587. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  53588. /**
  53589. * Fired when the A button on this controller is modified
  53590. */
  53591. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53592. /**
  53593. * Fired when the B button on this controller is modified
  53594. */
  53595. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53596. /**
  53597. * Fired when the X button on this controller is modified
  53598. */
  53599. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53600. /**
  53601. * Fired when the Y button on this controller is modified
  53602. */
  53603. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53604. /**
  53605. * Called once for each button that changed state since the last frame
  53606. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  53607. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  53608. * 2) secondary trigger (same)
  53609. * 3) A (right) X (left), touch, pressed = value
  53610. * 4) B / Y
  53611. * 5) thumb rest
  53612. * @param buttonIdx Which button index changed
  53613. * @param state New state of the button
  53614. * @param changes Which properties on the state changed since last frame
  53615. */
  53616. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53617. }
  53618. }
  53619. declare module "babylonjs/Gamepads/Controllers/viveController" {
  53620. import { Scene } from "babylonjs/scene";
  53621. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53622. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  53623. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  53624. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  53625. import { Observable } from "babylonjs/Misc/observable";
  53626. /**
  53627. * Vive Controller
  53628. */
  53629. export class ViveController extends WebVRController {
  53630. /**
  53631. * Base Url for the controller model.
  53632. */
  53633. static MODEL_BASE_URL: string;
  53634. /**
  53635. * File name for the controller model.
  53636. */
  53637. static MODEL_FILENAME: string;
  53638. /**
  53639. * Creates a new ViveController from a gamepad
  53640. * @param vrGamepad the gamepad that the controller should be created from
  53641. */
  53642. constructor(vrGamepad: any);
  53643. /**
  53644. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53645. * @param scene scene in which to add meshes
  53646. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53647. */
  53648. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  53649. /**
  53650. * Fired when the left button on this controller is modified
  53651. */
  53652. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53653. /**
  53654. * Fired when the right button on this controller is modified
  53655. */
  53656. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53657. /**
  53658. * Fired when the menu button on this controller is modified
  53659. */
  53660. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53661. /**
  53662. * Called once for each button that changed state since the last frame
  53663. * Vive mapping:
  53664. * 0: touchpad
  53665. * 1: trigger
  53666. * 2: left AND right buttons
  53667. * 3: menu button
  53668. * @param buttonIdx Which button index changed
  53669. * @param state New state of the button
  53670. * @param changes Which properties on the state changed since last frame
  53671. */
  53672. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53673. }
  53674. }
  53675. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  53676. import { Observable } from "babylonjs/Misc/observable";
  53677. import { Scene } from "babylonjs/scene";
  53678. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53679. import { Ray } from "babylonjs/Culling/ray";
  53680. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  53681. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  53682. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  53683. /**
  53684. * Defines the WindowsMotionController object that the state of the windows motion controller
  53685. */
  53686. export class WindowsMotionController extends WebVRController {
  53687. /**
  53688. * The base url used to load the left and right controller models
  53689. */
  53690. static MODEL_BASE_URL: string;
  53691. /**
  53692. * The name of the left controller model file
  53693. */
  53694. static MODEL_LEFT_FILENAME: string;
  53695. /**
  53696. * The name of the right controller model file
  53697. */
  53698. static MODEL_RIGHT_FILENAME: string;
  53699. /**
  53700. * The controller name prefix for this controller type
  53701. */
  53702. static readonly GAMEPAD_ID_PREFIX: string;
  53703. /**
  53704. * The controller id pattern for this controller type
  53705. */
  53706. private static readonly GAMEPAD_ID_PATTERN;
  53707. private _loadedMeshInfo;
  53708. protected readonly _mapping: {
  53709. buttons: string[];
  53710. buttonMeshNames: {
  53711. trigger: string;
  53712. menu: string;
  53713. grip: string;
  53714. thumbstick: string;
  53715. trackpad: string;
  53716. };
  53717. buttonObservableNames: {
  53718. trigger: string;
  53719. menu: string;
  53720. grip: string;
  53721. thumbstick: string;
  53722. trackpad: string;
  53723. };
  53724. axisMeshNames: string[];
  53725. pointingPoseMeshName: string;
  53726. };
  53727. /**
  53728. * Fired when the trackpad on this controller is clicked
  53729. */
  53730. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  53731. /**
  53732. * Fired when the trackpad on this controller is modified
  53733. */
  53734. onTrackpadValuesChangedObservable: Observable<StickValues>;
  53735. /**
  53736. * The current x and y values of this controller's trackpad
  53737. */
  53738. trackpad: StickValues;
  53739. /**
  53740. * Creates a new WindowsMotionController from a gamepad
  53741. * @param vrGamepad the gamepad that the controller should be created from
  53742. */
  53743. constructor(vrGamepad: any);
  53744. /**
  53745. * Fired when the trigger on this controller is modified
  53746. */
  53747. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53748. /**
  53749. * Fired when the menu button on this controller is modified
  53750. */
  53751. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53752. /**
  53753. * Fired when the grip button on this controller is modified
  53754. */
  53755. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53756. /**
  53757. * Fired when the thumbstick button on this controller is modified
  53758. */
  53759. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53760. /**
  53761. * Fired when the touchpad button on this controller is modified
  53762. */
  53763. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53764. /**
  53765. * Fired when the touchpad values on this controller are modified
  53766. */
  53767. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  53768. protected _updateTrackpad(): void;
  53769. /**
  53770. * Called once per frame by the engine.
  53771. */
  53772. update(): void;
  53773. /**
  53774. * Called once for each button that changed state since the last frame
  53775. * @param buttonIdx Which button index changed
  53776. * @param state New state of the button
  53777. * @param changes Which properties on the state changed since last frame
  53778. */
  53779. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53780. /**
  53781. * Moves the buttons on the controller mesh based on their current state
  53782. * @param buttonName the name of the button to move
  53783. * @param buttonValue the value of the button which determines the buttons new position
  53784. */
  53785. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  53786. /**
  53787. * Moves the axis on the controller mesh based on its current state
  53788. * @param axis the index of the axis
  53789. * @param axisValue the value of the axis which determines the meshes new position
  53790. * @hidden
  53791. */
  53792. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  53793. /**
  53794. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53795. * @param scene scene in which to add meshes
  53796. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53797. */
  53798. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  53799. /**
  53800. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  53801. * can be transformed by button presses and axes values, based on this._mapping.
  53802. *
  53803. * @param scene scene in which the meshes exist
  53804. * @param meshes list of meshes that make up the controller model to process
  53805. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  53806. */
  53807. private processModel;
  53808. private createMeshInfo;
  53809. /**
  53810. * Gets the ray of the controller in the direction the controller is pointing
  53811. * @param length the length the resulting ray should be
  53812. * @returns a ray in the direction the controller is pointing
  53813. */
  53814. getForwardRay(length?: number): Ray;
  53815. /**
  53816. * Disposes of the controller
  53817. */
  53818. dispose(): void;
  53819. }
  53820. /**
  53821. * This class represents a new windows motion controller in XR.
  53822. */
  53823. export class XRWindowsMotionController extends WindowsMotionController {
  53824. /**
  53825. * Changing the original WIndowsMotionController mapping to fir the new mapping
  53826. */
  53827. protected readonly _mapping: {
  53828. buttons: string[];
  53829. buttonMeshNames: {
  53830. trigger: string;
  53831. menu: string;
  53832. grip: string;
  53833. thumbstick: string;
  53834. trackpad: string;
  53835. };
  53836. buttonObservableNames: {
  53837. trigger: string;
  53838. menu: string;
  53839. grip: string;
  53840. thumbstick: string;
  53841. trackpad: string;
  53842. };
  53843. axisMeshNames: string[];
  53844. pointingPoseMeshName: string;
  53845. };
  53846. /**
  53847. * Construct a new XR-Based windows motion controller
  53848. *
  53849. * @param gamepadInfo the gamepad object from the browser
  53850. */
  53851. constructor(gamepadInfo: any);
  53852. /**
  53853. * holds the thumbstick values (X,Y)
  53854. */
  53855. thumbstickValues: StickValues;
  53856. /**
  53857. * Fired when the thumbstick on this controller is clicked
  53858. */
  53859. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  53860. /**
  53861. * Fired when the thumbstick on this controller is modified
  53862. */
  53863. onThumbstickValuesChangedObservable: Observable<StickValues>;
  53864. /**
  53865. * Fired when the touchpad button on this controller is modified
  53866. */
  53867. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  53868. /**
  53869. * Fired when the touchpad values on this controller are modified
  53870. */
  53871. onTrackpadValuesChangedObservable: Observable<StickValues>;
  53872. /**
  53873. * Fired when the thumbstick button on this controller is modified
  53874. * here to prevent breaking changes
  53875. */
  53876. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53877. /**
  53878. * updating the thumbstick(!) and not the trackpad.
  53879. * This is named this way due to the difference between WebVR and XR and to avoid
  53880. * changing the parent class.
  53881. */
  53882. protected _updateTrackpad(): void;
  53883. /**
  53884. * Disposes the class with joy
  53885. */
  53886. dispose(): void;
  53887. }
  53888. }
  53889. declare module "babylonjs/Gamepads/Controllers/index" {
  53890. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  53891. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  53892. export * from "babylonjs/Gamepads/Controllers/genericController";
  53893. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  53894. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  53895. export * from "babylonjs/Gamepads/Controllers/viveController";
  53896. export * from "babylonjs/Gamepads/Controllers/webVRController";
  53897. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  53898. }
  53899. declare module "babylonjs/Gamepads/index" {
  53900. export * from "babylonjs/Gamepads/Controllers/index";
  53901. export * from "babylonjs/Gamepads/gamepad";
  53902. export * from "babylonjs/Gamepads/gamepadManager";
  53903. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  53904. export * from "babylonjs/Gamepads/xboxGamepad";
  53905. export * from "babylonjs/Gamepads/dualShockGamepad";
  53906. }
  53907. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  53908. import { Scene } from "babylonjs/scene";
  53909. import { Vector4 } from "babylonjs/Maths/math.vector";
  53910. import { Color4 } from "babylonjs/Maths/math.color";
  53911. import { Mesh } from "babylonjs/Meshes/mesh";
  53912. import { Nullable } from "babylonjs/types";
  53913. /**
  53914. * Class containing static functions to help procedurally build meshes
  53915. */
  53916. export class PolyhedronBuilder {
  53917. /**
  53918. * Creates a polyhedron mesh
  53919. * * 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
  53920. * * The parameter `size` (positive float, default 1) sets the polygon size
  53921. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  53922. * * 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`
  53923. * * 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
  53924. * * 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)`)
  53925. * * 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
  53926. * * 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
  53927. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53928. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53929. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53930. * @param name defines the name of the mesh
  53931. * @param options defines the options used to create the mesh
  53932. * @param scene defines the hosting scene
  53933. * @returns the polyhedron mesh
  53934. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  53935. */
  53936. static CreatePolyhedron(name: string, options: {
  53937. type?: number;
  53938. size?: number;
  53939. sizeX?: number;
  53940. sizeY?: number;
  53941. sizeZ?: number;
  53942. custom?: any;
  53943. faceUV?: Vector4[];
  53944. faceColors?: Color4[];
  53945. flat?: boolean;
  53946. updatable?: boolean;
  53947. sideOrientation?: number;
  53948. frontUVs?: Vector4;
  53949. backUVs?: Vector4;
  53950. }, scene?: Nullable<Scene>): Mesh;
  53951. }
  53952. }
  53953. declare module "babylonjs/Gizmos/scaleGizmo" {
  53954. import { Observable } from "babylonjs/Misc/observable";
  53955. import { Nullable } from "babylonjs/types";
  53956. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53957. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  53958. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  53959. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  53960. /**
  53961. * Gizmo that enables scaling a mesh along 3 axis
  53962. */
  53963. export class ScaleGizmo extends Gizmo {
  53964. /**
  53965. * Internal gizmo used for interactions on the x axis
  53966. */
  53967. xGizmo: AxisScaleGizmo;
  53968. /**
  53969. * Internal gizmo used for interactions on the y axis
  53970. */
  53971. yGizmo: AxisScaleGizmo;
  53972. /**
  53973. * Internal gizmo used for interactions on the z axis
  53974. */
  53975. zGizmo: AxisScaleGizmo;
  53976. /**
  53977. * Internal gizmo used to scale all axis equally
  53978. */
  53979. uniformScaleGizmo: AxisScaleGizmo;
  53980. private _meshAttached;
  53981. private _updateGizmoRotationToMatchAttachedMesh;
  53982. private _snapDistance;
  53983. private _scaleRatio;
  53984. private _uniformScalingMesh;
  53985. private _octahedron;
  53986. private _sensitivity;
  53987. /** Fires an event when any of it's sub gizmos are dragged */
  53988. onDragStartObservable: Observable<unknown>;
  53989. /** Fires an event when any of it's sub gizmos are released from dragging */
  53990. onDragEndObservable: Observable<unknown>;
  53991. get attachedMesh(): Nullable<AbstractMesh>;
  53992. set attachedMesh(mesh: Nullable<AbstractMesh>);
  53993. /**
  53994. * Creates a ScaleGizmo
  53995. * @param gizmoLayer The utility layer the gizmo will be added to
  53996. */
  53997. constructor(gizmoLayer?: UtilityLayerRenderer);
  53998. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  53999. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  54000. /**
  54001. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  54002. */
  54003. set snapDistance(value: number);
  54004. get snapDistance(): number;
  54005. /**
  54006. * Ratio for the scale of the gizmo (Default: 1)
  54007. */
  54008. set scaleRatio(value: number);
  54009. get scaleRatio(): number;
  54010. /**
  54011. * Sensitivity factor for dragging (Default: 1)
  54012. */
  54013. set sensitivity(value: number);
  54014. get sensitivity(): number;
  54015. /**
  54016. * Disposes of the gizmo
  54017. */
  54018. dispose(): void;
  54019. }
  54020. }
  54021. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  54022. import { Observable } from "babylonjs/Misc/observable";
  54023. import { Nullable } from "babylonjs/types";
  54024. import { Vector3 } from "babylonjs/Maths/math.vector";
  54025. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54026. import { Mesh } from "babylonjs/Meshes/mesh";
  54027. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  54028. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  54029. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  54030. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  54031. import { Color3 } from "babylonjs/Maths/math.color";
  54032. /**
  54033. * Single axis scale gizmo
  54034. */
  54035. export class AxisScaleGizmo extends Gizmo {
  54036. /**
  54037. * Drag behavior responsible for the gizmos dragging interactions
  54038. */
  54039. dragBehavior: PointerDragBehavior;
  54040. private _pointerObserver;
  54041. /**
  54042. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  54043. */
  54044. snapDistance: number;
  54045. /**
  54046. * Event that fires each time the gizmo snaps to a new location.
  54047. * * snapDistance is the the change in distance
  54048. */
  54049. onSnapObservable: Observable<{
  54050. snapDistance: number;
  54051. }>;
  54052. /**
  54053. * If the scaling operation should be done on all axis (default: false)
  54054. */
  54055. uniformScaling: boolean;
  54056. /**
  54057. * Custom sensitivity value for the drag strength
  54058. */
  54059. sensitivity: number;
  54060. private _isEnabled;
  54061. private _parent;
  54062. private _arrow;
  54063. private _coloredMaterial;
  54064. private _hoverMaterial;
  54065. /**
  54066. * Creates an AxisScaleGizmo
  54067. * @param gizmoLayer The utility layer the gizmo will be added to
  54068. * @param dragAxis The axis which the gizmo will be able to scale on
  54069. * @param color The color of the gizmo
  54070. */
  54071. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  54072. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  54073. /**
  54074. * If the gizmo is enabled
  54075. */
  54076. set isEnabled(value: boolean);
  54077. get isEnabled(): boolean;
  54078. /**
  54079. * Disposes of the gizmo
  54080. */
  54081. dispose(): void;
  54082. /**
  54083. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  54084. * @param mesh The mesh to replace the default mesh of the gizmo
  54085. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  54086. */
  54087. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  54088. }
  54089. }
  54090. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  54091. import { Observable } from "babylonjs/Misc/observable";
  54092. import { Nullable } from "babylonjs/types";
  54093. import { Vector3 } from "babylonjs/Maths/math.vector";
  54094. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54095. import { Mesh } from "babylonjs/Meshes/mesh";
  54096. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  54097. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  54098. import { Color3 } from "babylonjs/Maths/math.color";
  54099. import "babylonjs/Meshes/Builders/boxBuilder";
  54100. /**
  54101. * Bounding box gizmo
  54102. */
  54103. export class BoundingBoxGizmo extends Gizmo {
  54104. private _lineBoundingBox;
  54105. private _rotateSpheresParent;
  54106. private _scaleBoxesParent;
  54107. private _boundingDimensions;
  54108. private _renderObserver;
  54109. private _pointerObserver;
  54110. private _scaleDragSpeed;
  54111. private _tmpQuaternion;
  54112. private _tmpVector;
  54113. private _tmpRotationMatrix;
  54114. /**
  54115. * 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)
  54116. */
  54117. ignoreChildren: boolean;
  54118. /**
  54119. * 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)
  54120. */
  54121. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  54122. /**
  54123. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  54124. */
  54125. rotationSphereSize: number;
  54126. /**
  54127. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  54128. */
  54129. scaleBoxSize: number;
  54130. /**
  54131. * 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)
  54132. */
  54133. fixedDragMeshScreenSize: boolean;
  54134. /**
  54135. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  54136. */
  54137. fixedDragMeshScreenSizeDistanceFactor: number;
  54138. /**
  54139. * Fired when a rotation sphere or scale box is dragged
  54140. */
  54141. onDragStartObservable: Observable<{}>;
  54142. /**
  54143. * Fired when a scale box is dragged
  54144. */
  54145. onScaleBoxDragObservable: Observable<{}>;
  54146. /**
  54147. * Fired when a scale box drag is ended
  54148. */
  54149. onScaleBoxDragEndObservable: Observable<{}>;
  54150. /**
  54151. * Fired when a rotation sphere is dragged
  54152. */
  54153. onRotationSphereDragObservable: Observable<{}>;
  54154. /**
  54155. * Fired when a rotation sphere drag is ended
  54156. */
  54157. onRotationSphereDragEndObservable: Observable<{}>;
  54158. /**
  54159. * 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)
  54160. */
  54161. scalePivot: Nullable<Vector3>;
  54162. /**
  54163. * Mesh used as a pivot to rotate the attached mesh
  54164. */
  54165. private _anchorMesh;
  54166. private _existingMeshScale;
  54167. private _dragMesh;
  54168. private pointerDragBehavior;
  54169. private coloredMaterial;
  54170. private hoverColoredMaterial;
  54171. /**
  54172. * Sets the color of the bounding box gizmo
  54173. * @param color the color to set
  54174. */
  54175. setColor(color: Color3): void;
  54176. /**
  54177. * Creates an BoundingBoxGizmo
  54178. * @param gizmoLayer The utility layer the gizmo will be added to
  54179. * @param color The color of the gizmo
  54180. */
  54181. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  54182. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  54183. private _selectNode;
  54184. /**
  54185. * Updates the bounding box information for the Gizmo
  54186. */
  54187. updateBoundingBox(): void;
  54188. private _updateRotationSpheres;
  54189. private _updateScaleBoxes;
  54190. /**
  54191. * Enables rotation on the specified axis and disables rotation on the others
  54192. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  54193. */
  54194. setEnabledRotationAxis(axis: string): void;
  54195. /**
  54196. * Enables/disables scaling
  54197. * @param enable if scaling should be enabled
  54198. * @param homogeneousScaling defines if scaling should only be homogeneous
  54199. */
  54200. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  54201. private _updateDummy;
  54202. /**
  54203. * Enables a pointer drag behavior on the bounding box of the gizmo
  54204. */
  54205. enableDragBehavior(): void;
  54206. /**
  54207. * Disposes of the gizmo
  54208. */
  54209. dispose(): void;
  54210. /**
  54211. * 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)
  54212. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  54213. * @returns the bounding box mesh with the passed in mesh as a child
  54214. */
  54215. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  54216. /**
  54217. * CustomMeshes are not supported by this gizmo
  54218. * @param mesh The mesh to replace the default mesh of the gizmo
  54219. */
  54220. setCustomMesh(mesh: Mesh): void;
  54221. }
  54222. }
  54223. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  54224. import { Observable } from "babylonjs/Misc/observable";
  54225. import { Nullable } from "babylonjs/types";
  54226. import { Vector3 } from "babylonjs/Maths/math.vector";
  54227. import { Color3 } from "babylonjs/Maths/math.color";
  54228. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54229. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  54230. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  54231. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  54232. import "babylonjs/Meshes/Builders/linesBuilder";
  54233. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  54234. /**
  54235. * Single plane rotation gizmo
  54236. */
  54237. export class PlaneRotationGizmo extends Gizmo {
  54238. /**
  54239. * Drag behavior responsible for the gizmos dragging interactions
  54240. */
  54241. dragBehavior: PointerDragBehavior;
  54242. private _pointerObserver;
  54243. /**
  54244. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  54245. */
  54246. snapDistance: number;
  54247. /**
  54248. * Event that fires each time the gizmo snaps to a new location.
  54249. * * snapDistance is the the change in distance
  54250. */
  54251. onSnapObservable: Observable<{
  54252. snapDistance: number;
  54253. }>;
  54254. private _isEnabled;
  54255. private _parent;
  54256. /**
  54257. * Creates a PlaneRotationGizmo
  54258. * @param gizmoLayer The utility layer the gizmo will be added to
  54259. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  54260. * @param color The color of the gizmo
  54261. * @param tessellation Amount of tessellation to be used when creating rotation circles
  54262. * @param useEulerRotation Use and update Euler angle instead of quaternion
  54263. */
  54264. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  54265. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  54266. /**
  54267. * If the gizmo is enabled
  54268. */
  54269. set isEnabled(value: boolean);
  54270. get isEnabled(): boolean;
  54271. /**
  54272. * Disposes of the gizmo
  54273. */
  54274. dispose(): void;
  54275. }
  54276. }
  54277. declare module "babylonjs/Gizmos/rotationGizmo" {
  54278. import { Observable } from "babylonjs/Misc/observable";
  54279. import { Nullable } from "babylonjs/types";
  54280. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54281. import { Mesh } from "babylonjs/Meshes/mesh";
  54282. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  54283. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  54284. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  54285. /**
  54286. * Gizmo that enables rotating a mesh along 3 axis
  54287. */
  54288. export class RotationGizmo extends Gizmo {
  54289. /**
  54290. * Internal gizmo used for interactions on the x axis
  54291. */
  54292. xGizmo: PlaneRotationGizmo;
  54293. /**
  54294. * Internal gizmo used for interactions on the y axis
  54295. */
  54296. yGizmo: PlaneRotationGizmo;
  54297. /**
  54298. * Internal gizmo used for interactions on the z axis
  54299. */
  54300. zGizmo: PlaneRotationGizmo;
  54301. /** Fires an event when any of it's sub gizmos are dragged */
  54302. onDragStartObservable: Observable<unknown>;
  54303. /** Fires an event when any of it's sub gizmos are released from dragging */
  54304. onDragEndObservable: Observable<unknown>;
  54305. private _meshAttached;
  54306. get attachedMesh(): Nullable<AbstractMesh>;
  54307. set attachedMesh(mesh: Nullable<AbstractMesh>);
  54308. /**
  54309. * Creates a RotationGizmo
  54310. * @param gizmoLayer The utility layer the gizmo will be added to
  54311. * @param tessellation Amount of tessellation to be used when creating rotation circles
  54312. * @param useEulerRotation Use and update Euler angle instead of quaternion
  54313. */
  54314. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  54315. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  54316. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  54317. /**
  54318. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  54319. */
  54320. set snapDistance(value: number);
  54321. get snapDistance(): number;
  54322. /**
  54323. * Ratio for the scale of the gizmo (Default: 1)
  54324. */
  54325. set scaleRatio(value: number);
  54326. get scaleRatio(): number;
  54327. /**
  54328. * Disposes of the gizmo
  54329. */
  54330. dispose(): void;
  54331. /**
  54332. * CustomMeshes are not supported by this gizmo
  54333. * @param mesh The mesh to replace the default mesh of the gizmo
  54334. */
  54335. setCustomMesh(mesh: Mesh): void;
  54336. }
  54337. }
  54338. declare module "babylonjs/Gizmos/gizmoManager" {
  54339. import { Observable } from "babylonjs/Misc/observable";
  54340. import { Nullable } from "babylonjs/types";
  54341. import { Scene, IDisposable } from "babylonjs/scene";
  54342. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54343. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  54344. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  54345. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  54346. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  54347. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  54348. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  54349. /**
  54350. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  54351. */
  54352. export class GizmoManager implements IDisposable {
  54353. private scene;
  54354. /**
  54355. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  54356. */
  54357. gizmos: {
  54358. positionGizmo: Nullable<PositionGizmo>;
  54359. rotationGizmo: Nullable<RotationGizmo>;
  54360. scaleGizmo: Nullable<ScaleGizmo>;
  54361. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  54362. };
  54363. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  54364. clearGizmoOnEmptyPointerEvent: boolean;
  54365. /** Fires an event when the manager is attached to a mesh */
  54366. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  54367. private _gizmosEnabled;
  54368. private _pointerObserver;
  54369. private _attachedMesh;
  54370. private _boundingBoxColor;
  54371. private _defaultUtilityLayer;
  54372. private _defaultKeepDepthUtilityLayer;
  54373. /**
  54374. * When bounding box gizmo is enabled, this can be used to track drag/end events
  54375. */
  54376. boundingBoxDragBehavior: SixDofDragBehavior;
  54377. /**
  54378. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  54379. */
  54380. attachableMeshes: Nullable<Array<AbstractMesh>>;
  54381. /**
  54382. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  54383. */
  54384. usePointerToAttachGizmos: boolean;
  54385. /**
  54386. * Utility layer that the bounding box gizmo belongs to
  54387. */
  54388. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  54389. /**
  54390. * Utility layer that all gizmos besides bounding box belong to
  54391. */
  54392. get utilityLayer(): UtilityLayerRenderer;
  54393. /**
  54394. * Instatiates a gizmo manager
  54395. * @param scene the scene to overlay the gizmos on top of
  54396. */
  54397. constructor(scene: Scene);
  54398. /**
  54399. * Attaches a set of gizmos to the specified mesh
  54400. * @param mesh The mesh the gizmo's should be attached to
  54401. */
  54402. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  54403. /**
  54404. * If the position gizmo is enabled
  54405. */
  54406. set positionGizmoEnabled(value: boolean);
  54407. get positionGizmoEnabled(): boolean;
  54408. /**
  54409. * If the rotation gizmo is enabled
  54410. */
  54411. set rotationGizmoEnabled(value: boolean);
  54412. get rotationGizmoEnabled(): boolean;
  54413. /**
  54414. * If the scale gizmo is enabled
  54415. */
  54416. set scaleGizmoEnabled(value: boolean);
  54417. get scaleGizmoEnabled(): boolean;
  54418. /**
  54419. * If the boundingBox gizmo is enabled
  54420. */
  54421. set boundingBoxGizmoEnabled(value: boolean);
  54422. get boundingBoxGizmoEnabled(): boolean;
  54423. /**
  54424. * Disposes of the gizmo manager
  54425. */
  54426. dispose(): void;
  54427. }
  54428. }
  54429. declare module "babylonjs/Lights/directionalLight" {
  54430. import { Camera } from "babylonjs/Cameras/camera";
  54431. import { Scene } from "babylonjs/scene";
  54432. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  54433. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54434. import { Light } from "babylonjs/Lights/light";
  54435. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  54436. import { Effect } from "babylonjs/Materials/effect";
  54437. /**
  54438. * A directional light is defined by a direction (what a surprise!).
  54439. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  54440. * 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.
  54441. * Documentation: https://doc.babylonjs.com/babylon101/lights
  54442. */
  54443. export class DirectionalLight extends ShadowLight {
  54444. private _shadowFrustumSize;
  54445. /**
  54446. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  54447. */
  54448. get shadowFrustumSize(): number;
  54449. /**
  54450. * Specifies a fix frustum size for the shadow generation.
  54451. */
  54452. set shadowFrustumSize(value: number);
  54453. private _shadowOrthoScale;
  54454. /**
  54455. * Gets the shadow projection scale against the optimal computed one.
  54456. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  54457. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  54458. */
  54459. get shadowOrthoScale(): number;
  54460. /**
  54461. * Sets the shadow projection scale against the optimal computed one.
  54462. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  54463. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  54464. */
  54465. set shadowOrthoScale(value: number);
  54466. /**
  54467. * Automatically compute the projection matrix to best fit (including all the casters)
  54468. * on each frame.
  54469. */
  54470. autoUpdateExtends: boolean;
  54471. /**
  54472. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  54473. * on each frame. autoUpdateExtends must be set to true for this to work
  54474. */
  54475. autoCalcShadowZBounds: boolean;
  54476. private _orthoLeft;
  54477. private _orthoRight;
  54478. private _orthoTop;
  54479. private _orthoBottom;
  54480. /**
  54481. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  54482. * The directional light is emitted from everywhere in the given direction.
  54483. * It can cast shadows.
  54484. * Documentation : https://doc.babylonjs.com/babylon101/lights
  54485. * @param name The friendly name of the light
  54486. * @param direction The direction of the light
  54487. * @param scene The scene the light belongs to
  54488. */
  54489. constructor(name: string, direction: Vector3, scene: Scene);
  54490. /**
  54491. * Returns the string "DirectionalLight".
  54492. * @return The class name
  54493. */
  54494. getClassName(): string;
  54495. /**
  54496. * Returns the integer 1.
  54497. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  54498. */
  54499. getTypeID(): number;
  54500. /**
  54501. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  54502. * Returns the DirectionalLight Shadow projection matrix.
  54503. */
  54504. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  54505. /**
  54506. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  54507. * Returns the DirectionalLight Shadow projection matrix.
  54508. */
  54509. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  54510. /**
  54511. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  54512. * Returns the DirectionalLight Shadow projection matrix.
  54513. */
  54514. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  54515. protected _buildUniformLayout(): void;
  54516. /**
  54517. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  54518. * @param effect The effect to update
  54519. * @param lightIndex The index of the light in the effect to update
  54520. * @returns The directional light
  54521. */
  54522. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  54523. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  54524. /**
  54525. * Gets the minZ used for shadow according to both the scene and the light.
  54526. *
  54527. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  54528. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  54529. * @param activeCamera The camera we are returning the min for
  54530. * @returns the depth min z
  54531. */
  54532. getDepthMinZ(activeCamera: Camera): number;
  54533. /**
  54534. * Gets the maxZ used for shadow according to both the scene and the light.
  54535. *
  54536. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  54537. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  54538. * @param activeCamera The camera we are returning the max for
  54539. * @returns the depth max z
  54540. */
  54541. getDepthMaxZ(activeCamera: Camera): number;
  54542. /**
  54543. * Prepares the list of defines specific to the light type.
  54544. * @param defines the list of defines
  54545. * @param lightIndex defines the index of the light for the effect
  54546. */
  54547. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  54548. }
  54549. }
  54550. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  54551. import { Mesh } from "babylonjs/Meshes/mesh";
  54552. /**
  54553. * Class containing static functions to help procedurally build meshes
  54554. */
  54555. export class HemisphereBuilder {
  54556. /**
  54557. * Creates a hemisphere mesh
  54558. * @param name defines the name of the mesh
  54559. * @param options defines the options used to create the mesh
  54560. * @param scene defines the hosting scene
  54561. * @returns the hemisphere mesh
  54562. */
  54563. static CreateHemisphere(name: string, options: {
  54564. segments?: number;
  54565. diameter?: number;
  54566. sideOrientation?: number;
  54567. }, scene: any): Mesh;
  54568. }
  54569. }
  54570. declare module "babylonjs/Lights/spotLight" {
  54571. import { Nullable } from "babylonjs/types";
  54572. import { Scene } from "babylonjs/scene";
  54573. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  54574. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54575. import { Effect } from "babylonjs/Materials/effect";
  54576. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54577. import { Light } from "babylonjs/Lights/light";
  54578. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  54579. /**
  54580. * A spot light is defined by a position, a direction, an angle, and an exponent.
  54581. * These values define a cone of light starting from the position, emitting toward the direction.
  54582. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  54583. * and the exponent defines the speed of the decay of the light with distance (reach).
  54584. * Documentation: https://doc.babylonjs.com/babylon101/lights
  54585. */
  54586. export class SpotLight extends ShadowLight {
  54587. private _angle;
  54588. private _innerAngle;
  54589. private _cosHalfAngle;
  54590. private _lightAngleScale;
  54591. private _lightAngleOffset;
  54592. /**
  54593. * Gets the cone angle of the spot light in Radians.
  54594. */
  54595. get angle(): number;
  54596. /**
  54597. * Sets the cone angle of the spot light in Radians.
  54598. */
  54599. set angle(value: number);
  54600. /**
  54601. * Only used in gltf falloff mode, this defines the angle where
  54602. * the directional falloff will start before cutting at angle which could be seen
  54603. * as outer angle.
  54604. */
  54605. get innerAngle(): number;
  54606. /**
  54607. * Only used in gltf falloff mode, this defines the angle where
  54608. * the directional falloff will start before cutting at angle which could be seen
  54609. * as outer angle.
  54610. */
  54611. set innerAngle(value: number);
  54612. private _shadowAngleScale;
  54613. /**
  54614. * Allows scaling the angle of the light for shadow generation only.
  54615. */
  54616. get shadowAngleScale(): number;
  54617. /**
  54618. * Allows scaling the angle of the light for shadow generation only.
  54619. */
  54620. set shadowAngleScale(value: number);
  54621. /**
  54622. * The light decay speed with the distance from the emission spot.
  54623. */
  54624. exponent: number;
  54625. private _projectionTextureMatrix;
  54626. /**
  54627. * Allows reading the projecton texture
  54628. */
  54629. get projectionTextureMatrix(): Matrix;
  54630. protected _projectionTextureLightNear: number;
  54631. /**
  54632. * Gets the near clip of the Spotlight for texture projection.
  54633. */
  54634. get projectionTextureLightNear(): number;
  54635. /**
  54636. * Sets the near clip of the Spotlight for texture projection.
  54637. */
  54638. set projectionTextureLightNear(value: number);
  54639. protected _projectionTextureLightFar: number;
  54640. /**
  54641. * Gets the far clip of the Spotlight for texture projection.
  54642. */
  54643. get projectionTextureLightFar(): number;
  54644. /**
  54645. * Sets the far clip of the Spotlight for texture projection.
  54646. */
  54647. set projectionTextureLightFar(value: number);
  54648. protected _projectionTextureUpDirection: Vector3;
  54649. /**
  54650. * Gets the Up vector of the Spotlight for texture projection.
  54651. */
  54652. get projectionTextureUpDirection(): Vector3;
  54653. /**
  54654. * Sets the Up vector of the Spotlight for texture projection.
  54655. */
  54656. set projectionTextureUpDirection(value: Vector3);
  54657. private _projectionTexture;
  54658. /**
  54659. * Gets the projection texture of the light.
  54660. */
  54661. get projectionTexture(): Nullable<BaseTexture>;
  54662. /**
  54663. * Sets the projection texture of the light.
  54664. */
  54665. set projectionTexture(value: Nullable<BaseTexture>);
  54666. private _projectionTextureViewLightDirty;
  54667. private _projectionTextureProjectionLightDirty;
  54668. private _projectionTextureDirty;
  54669. private _projectionTextureViewTargetVector;
  54670. private _projectionTextureViewLightMatrix;
  54671. private _projectionTextureProjectionLightMatrix;
  54672. private _projectionTextureScalingMatrix;
  54673. /**
  54674. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  54675. * It can cast shadows.
  54676. * Documentation : https://doc.babylonjs.com/babylon101/lights
  54677. * @param name The light friendly name
  54678. * @param position The position of the spot light in the scene
  54679. * @param direction The direction of the light in the scene
  54680. * @param angle The cone angle of the light in Radians
  54681. * @param exponent The light decay speed with the distance from the emission spot
  54682. * @param scene The scene the lights belongs to
  54683. */
  54684. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  54685. /**
  54686. * Returns the string "SpotLight".
  54687. * @returns the class name
  54688. */
  54689. getClassName(): string;
  54690. /**
  54691. * Returns the integer 2.
  54692. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  54693. */
  54694. getTypeID(): number;
  54695. /**
  54696. * Overrides the direction setter to recompute the projection texture view light Matrix.
  54697. */
  54698. protected _setDirection(value: Vector3): void;
  54699. /**
  54700. * Overrides the position setter to recompute the projection texture view light Matrix.
  54701. */
  54702. protected _setPosition(value: Vector3): void;
  54703. /**
  54704. * 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.
  54705. * Returns the SpotLight.
  54706. */
  54707. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  54708. protected _computeProjectionTextureViewLightMatrix(): void;
  54709. protected _computeProjectionTextureProjectionLightMatrix(): void;
  54710. /**
  54711. * Main function for light texture projection matrix computing.
  54712. */
  54713. protected _computeProjectionTextureMatrix(): void;
  54714. protected _buildUniformLayout(): void;
  54715. private _computeAngleValues;
  54716. /**
  54717. * Sets the passed Effect "effect" with the Light textures.
  54718. * @param effect The effect to update
  54719. * @param lightIndex The index of the light in the effect to update
  54720. * @returns The light
  54721. */
  54722. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  54723. /**
  54724. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  54725. * @param effect The effect to update
  54726. * @param lightIndex The index of the light in the effect to update
  54727. * @returns The spot light
  54728. */
  54729. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  54730. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  54731. /**
  54732. * Disposes the light and the associated resources.
  54733. */
  54734. dispose(): void;
  54735. /**
  54736. * Prepares the list of defines specific to the light type.
  54737. * @param defines the list of defines
  54738. * @param lightIndex defines the index of the light for the effect
  54739. */
  54740. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  54741. }
  54742. }
  54743. declare module "babylonjs/Gizmos/lightGizmo" {
  54744. import { Nullable } from "babylonjs/types";
  54745. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  54746. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  54747. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  54748. import { Light } from "babylonjs/Lights/light";
  54749. /**
  54750. * Gizmo that enables viewing a light
  54751. */
  54752. export class LightGizmo extends Gizmo {
  54753. private _lightMesh;
  54754. private _material;
  54755. private _cachedPosition;
  54756. private _cachedForward;
  54757. private _attachedMeshParent;
  54758. /**
  54759. * Creates a LightGizmo
  54760. * @param gizmoLayer The utility layer the gizmo will be added to
  54761. */
  54762. constructor(gizmoLayer?: UtilityLayerRenderer);
  54763. private _light;
  54764. /**
  54765. * The light that the gizmo is attached to
  54766. */
  54767. set light(light: Nullable<Light>);
  54768. get light(): Nullable<Light>;
  54769. /**
  54770. * Gets the material used to render the light gizmo
  54771. */
  54772. get material(): StandardMaterial;
  54773. /**
  54774. * @hidden
  54775. * Updates the gizmo to match the attached mesh's position/rotation
  54776. */
  54777. protected _update(): void;
  54778. private static _Scale;
  54779. /**
  54780. * Creates the lines for a light mesh
  54781. */
  54782. private static _CreateLightLines;
  54783. /**
  54784. * Disposes of the light gizmo
  54785. */
  54786. dispose(): void;
  54787. private static _CreateHemisphericLightMesh;
  54788. private static _CreatePointLightMesh;
  54789. private static _CreateSpotLightMesh;
  54790. private static _CreateDirectionalLightMesh;
  54791. }
  54792. }
  54793. declare module "babylonjs/Gizmos/index" {
  54794. export * from "babylonjs/Gizmos/axisDragGizmo";
  54795. export * from "babylonjs/Gizmos/axisScaleGizmo";
  54796. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  54797. export * from "babylonjs/Gizmos/gizmo";
  54798. export * from "babylonjs/Gizmos/gizmoManager";
  54799. export * from "babylonjs/Gizmos/planeRotationGizmo";
  54800. export * from "babylonjs/Gizmos/positionGizmo";
  54801. export * from "babylonjs/Gizmos/rotationGizmo";
  54802. export * from "babylonjs/Gizmos/scaleGizmo";
  54803. export * from "babylonjs/Gizmos/lightGizmo";
  54804. export * from "babylonjs/Gizmos/planeDragGizmo";
  54805. }
  54806. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  54807. /** @hidden */
  54808. export var backgroundFragmentDeclaration: {
  54809. name: string;
  54810. shader: string;
  54811. };
  54812. }
  54813. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  54814. /** @hidden */
  54815. export var backgroundUboDeclaration: {
  54816. name: string;
  54817. shader: string;
  54818. };
  54819. }
  54820. declare module "babylonjs/Shaders/background.fragment" {
  54821. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  54822. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  54823. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  54824. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  54825. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  54826. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  54827. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  54828. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  54829. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  54830. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  54831. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  54832. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  54833. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  54834. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  54835. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  54836. /** @hidden */
  54837. export var backgroundPixelShader: {
  54838. name: string;
  54839. shader: string;
  54840. };
  54841. }
  54842. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  54843. /** @hidden */
  54844. export var backgroundVertexDeclaration: {
  54845. name: string;
  54846. shader: string;
  54847. };
  54848. }
  54849. declare module "babylonjs/Shaders/background.vertex" {
  54850. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  54851. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  54852. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  54853. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  54854. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  54855. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  54856. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  54857. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  54858. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  54859. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  54860. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  54861. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  54862. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  54863. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  54864. /** @hidden */
  54865. export var backgroundVertexShader: {
  54866. name: string;
  54867. shader: string;
  54868. };
  54869. }
  54870. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  54871. import { Nullable, int, float } from "babylonjs/types";
  54872. import { Scene } from "babylonjs/scene";
  54873. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  54874. import { SubMesh } from "babylonjs/Meshes/subMesh";
  54875. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54876. import { Mesh } from "babylonjs/Meshes/mesh";
  54877. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  54878. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  54879. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  54880. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54881. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  54882. import { Color3 } from "babylonjs/Maths/math.color";
  54883. import "babylonjs/Shaders/background.fragment";
  54884. import "babylonjs/Shaders/background.vertex";
  54885. /**
  54886. * Background material used to create an efficient environement around your scene.
  54887. */
  54888. export class BackgroundMaterial extends PushMaterial {
  54889. /**
  54890. * Standard reflectance value at parallel view angle.
  54891. */
  54892. static StandardReflectance0: number;
  54893. /**
  54894. * Standard reflectance value at grazing angle.
  54895. */
  54896. static StandardReflectance90: number;
  54897. protected _primaryColor: Color3;
  54898. /**
  54899. * Key light Color (multiply against the environement texture)
  54900. */
  54901. primaryColor: Color3;
  54902. protected __perceptualColor: Nullable<Color3>;
  54903. /**
  54904. * Experimental Internal Use Only.
  54905. *
  54906. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  54907. * This acts as a helper to set the primary color to a more "human friendly" value.
  54908. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  54909. * output color as close as possible from the chosen value.
  54910. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  54911. * part of lighting setup.)
  54912. */
  54913. get _perceptualColor(): Nullable<Color3>;
  54914. set _perceptualColor(value: Nullable<Color3>);
  54915. protected _primaryColorShadowLevel: float;
  54916. /**
  54917. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  54918. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  54919. */
  54920. get primaryColorShadowLevel(): float;
  54921. set primaryColorShadowLevel(value: float);
  54922. protected _primaryColorHighlightLevel: float;
  54923. /**
  54924. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  54925. * The primary color is used at the level chosen to define what the white area would look.
  54926. */
  54927. get primaryColorHighlightLevel(): float;
  54928. set primaryColorHighlightLevel(value: float);
  54929. protected _reflectionTexture: Nullable<BaseTexture>;
  54930. /**
  54931. * Reflection Texture used in the material.
  54932. * Should be author in a specific way for the best result (refer to the documentation).
  54933. */
  54934. reflectionTexture: Nullable<BaseTexture>;
  54935. protected _reflectionBlur: float;
  54936. /**
  54937. * Reflection Texture level of blur.
  54938. *
  54939. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  54940. * texture twice.
  54941. */
  54942. reflectionBlur: float;
  54943. protected _diffuseTexture: Nullable<BaseTexture>;
  54944. /**
  54945. * Diffuse Texture used in the material.
  54946. * Should be author in a specific way for the best result (refer to the documentation).
  54947. */
  54948. diffuseTexture: Nullable<BaseTexture>;
  54949. protected _shadowLights: Nullable<IShadowLight[]>;
  54950. /**
  54951. * Specify the list of lights casting shadow on the material.
  54952. * All scene shadow lights will be included if null.
  54953. */
  54954. shadowLights: Nullable<IShadowLight[]>;
  54955. protected _shadowLevel: float;
  54956. /**
  54957. * Helps adjusting the shadow to a softer level if required.
  54958. * 0 means black shadows and 1 means no shadows.
  54959. */
  54960. shadowLevel: float;
  54961. protected _sceneCenter: Vector3;
  54962. /**
  54963. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  54964. * It is usually zero but might be interesting to modify according to your setup.
  54965. */
  54966. sceneCenter: Vector3;
  54967. protected _opacityFresnel: boolean;
  54968. /**
  54969. * This helps specifying that the material is falling off to the sky box at grazing angle.
  54970. * This helps ensuring a nice transition when the camera goes under the ground.
  54971. */
  54972. opacityFresnel: boolean;
  54973. protected _reflectionFresnel: boolean;
  54974. /**
  54975. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  54976. * This helps adding a mirror texture on the ground.
  54977. */
  54978. reflectionFresnel: boolean;
  54979. protected _reflectionFalloffDistance: number;
  54980. /**
  54981. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  54982. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  54983. */
  54984. reflectionFalloffDistance: number;
  54985. protected _reflectionAmount: number;
  54986. /**
  54987. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  54988. */
  54989. reflectionAmount: number;
  54990. protected _reflectionReflectance0: number;
  54991. /**
  54992. * This specifies the weight of the reflection at grazing angle.
  54993. */
  54994. reflectionReflectance0: number;
  54995. protected _reflectionReflectance90: number;
  54996. /**
  54997. * This specifies the weight of the reflection at a perpendicular point of view.
  54998. */
  54999. reflectionReflectance90: number;
  55000. /**
  55001. * Sets the reflection reflectance fresnel values according to the default standard
  55002. * empirically know to work well :-)
  55003. */
  55004. set reflectionStandardFresnelWeight(value: number);
  55005. protected _useRGBColor: boolean;
  55006. /**
  55007. * Helps to directly use the maps channels instead of their level.
  55008. */
  55009. useRGBColor: boolean;
  55010. protected _enableNoise: boolean;
  55011. /**
  55012. * This helps reducing the banding effect that could occur on the background.
  55013. */
  55014. enableNoise: boolean;
  55015. /**
  55016. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  55017. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  55018. * Recommended to be keep at 1.0 except for special cases.
  55019. */
  55020. get fovMultiplier(): number;
  55021. set fovMultiplier(value: number);
  55022. private _fovMultiplier;
  55023. /**
  55024. * Enable the FOV adjustment feature controlled by fovMultiplier.
  55025. */
  55026. useEquirectangularFOV: boolean;
  55027. private _maxSimultaneousLights;
  55028. /**
  55029. * Number of Simultaneous lights allowed on the material.
  55030. */
  55031. maxSimultaneousLights: int;
  55032. /**
  55033. * Default configuration related to image processing available in the Background Material.
  55034. */
  55035. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  55036. /**
  55037. * Keep track of the image processing observer to allow dispose and replace.
  55038. */
  55039. private _imageProcessingObserver;
  55040. /**
  55041. * Attaches a new image processing configuration to the PBR Material.
  55042. * @param configuration (if null the scene configuration will be use)
  55043. */
  55044. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  55045. /**
  55046. * Gets the image processing configuration used either in this material.
  55047. */
  55048. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  55049. /**
  55050. * Sets the Default image processing configuration used either in the this material.
  55051. *
  55052. * If sets to null, the scene one is in use.
  55053. */
  55054. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  55055. /**
  55056. * Gets wether the color curves effect is enabled.
  55057. */
  55058. get cameraColorCurvesEnabled(): boolean;
  55059. /**
  55060. * Sets wether the color curves effect is enabled.
  55061. */
  55062. set cameraColorCurvesEnabled(value: boolean);
  55063. /**
  55064. * Gets wether the color grading effect is enabled.
  55065. */
  55066. get cameraColorGradingEnabled(): boolean;
  55067. /**
  55068. * Gets wether the color grading effect is enabled.
  55069. */
  55070. set cameraColorGradingEnabled(value: boolean);
  55071. /**
  55072. * Gets wether tonemapping is enabled or not.
  55073. */
  55074. get cameraToneMappingEnabled(): boolean;
  55075. /**
  55076. * Sets wether tonemapping is enabled or not
  55077. */
  55078. set cameraToneMappingEnabled(value: boolean);
  55079. /**
  55080. * The camera exposure used on this material.
  55081. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  55082. * This corresponds to a photographic exposure.
  55083. */
  55084. get cameraExposure(): float;
  55085. /**
  55086. * The camera exposure used on this material.
  55087. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  55088. * This corresponds to a photographic exposure.
  55089. */
  55090. set cameraExposure(value: float);
  55091. /**
  55092. * Gets The camera contrast used on this material.
  55093. */
  55094. get cameraContrast(): float;
  55095. /**
  55096. * Sets The camera contrast used on this material.
  55097. */
  55098. set cameraContrast(value: float);
  55099. /**
  55100. * Gets the Color Grading 2D Lookup Texture.
  55101. */
  55102. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  55103. /**
  55104. * Sets the Color Grading 2D Lookup Texture.
  55105. */
  55106. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  55107. /**
  55108. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  55109. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  55110. * 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;
  55111. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  55112. */
  55113. get cameraColorCurves(): Nullable<ColorCurves>;
  55114. /**
  55115. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  55116. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  55117. * 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;
  55118. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  55119. */
  55120. set cameraColorCurves(value: Nullable<ColorCurves>);
  55121. /**
  55122. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  55123. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  55124. */
  55125. switchToBGR: boolean;
  55126. private _renderTargets;
  55127. private _reflectionControls;
  55128. private _white;
  55129. private _primaryShadowColor;
  55130. private _primaryHighlightColor;
  55131. /**
  55132. * Instantiates a Background Material in the given scene
  55133. * @param name The friendly name of the material
  55134. * @param scene The scene to add the material to
  55135. */
  55136. constructor(name: string, scene: Scene);
  55137. /**
  55138. * Gets a boolean indicating that current material needs to register RTT
  55139. */
  55140. get hasRenderTargetTextures(): boolean;
  55141. /**
  55142. * The entire material has been created in order to prevent overdraw.
  55143. * @returns false
  55144. */
  55145. needAlphaTesting(): boolean;
  55146. /**
  55147. * The entire material has been created in order to prevent overdraw.
  55148. * @returns true if blending is enable
  55149. */
  55150. needAlphaBlending(): boolean;
  55151. /**
  55152. * Checks wether the material is ready to be rendered for a given mesh.
  55153. * @param mesh The mesh to render
  55154. * @param subMesh The submesh to check against
  55155. * @param useInstances Specify wether or not the material is used with instances
  55156. * @returns true if all the dependencies are ready (Textures, Effects...)
  55157. */
  55158. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  55159. /**
  55160. * Compute the primary color according to the chosen perceptual color.
  55161. */
  55162. private _computePrimaryColorFromPerceptualColor;
  55163. /**
  55164. * Compute the highlights and shadow colors according to their chosen levels.
  55165. */
  55166. private _computePrimaryColors;
  55167. /**
  55168. * Build the uniform buffer used in the material.
  55169. */
  55170. buildUniformLayout(): void;
  55171. /**
  55172. * Unbind the material.
  55173. */
  55174. unbind(): void;
  55175. /**
  55176. * Bind only the world matrix to the material.
  55177. * @param world The world matrix to bind.
  55178. */
  55179. bindOnlyWorldMatrix(world: Matrix): void;
  55180. /**
  55181. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  55182. * @param world The world matrix to bind.
  55183. * @param subMesh The submesh to bind for.
  55184. */
  55185. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  55186. /**
  55187. * Checks to see if a texture is used in the material.
  55188. * @param texture - Base texture to use.
  55189. * @returns - Boolean specifying if a texture is used in the material.
  55190. */
  55191. hasTexture(texture: BaseTexture): boolean;
  55192. /**
  55193. * Dispose the material.
  55194. * @param forceDisposeEffect Force disposal of the associated effect.
  55195. * @param forceDisposeTextures Force disposal of the associated textures.
  55196. */
  55197. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  55198. /**
  55199. * Clones the material.
  55200. * @param name The cloned name.
  55201. * @returns The cloned material.
  55202. */
  55203. clone(name: string): BackgroundMaterial;
  55204. /**
  55205. * Serializes the current material to its JSON representation.
  55206. * @returns The JSON representation.
  55207. */
  55208. serialize(): any;
  55209. /**
  55210. * Gets the class name of the material
  55211. * @returns "BackgroundMaterial"
  55212. */
  55213. getClassName(): string;
  55214. /**
  55215. * Parse a JSON input to create back a background material.
  55216. * @param source The JSON data to parse
  55217. * @param scene The scene to create the parsed material in
  55218. * @param rootUrl The root url of the assets the material depends upon
  55219. * @returns the instantiated BackgroundMaterial.
  55220. */
  55221. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  55222. }
  55223. }
  55224. declare module "babylonjs/Helpers/environmentHelper" {
  55225. import { Observable } from "babylonjs/Misc/observable";
  55226. import { Nullable } from "babylonjs/types";
  55227. import { Scene } from "babylonjs/scene";
  55228. import { Vector3 } from "babylonjs/Maths/math.vector";
  55229. import { Color3 } from "babylonjs/Maths/math.color";
  55230. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55231. import { Mesh } from "babylonjs/Meshes/mesh";
  55232. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55233. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  55234. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  55235. import "babylonjs/Meshes/Builders/planeBuilder";
  55236. import "babylonjs/Meshes/Builders/boxBuilder";
  55237. /**
  55238. * Represents the different options available during the creation of
  55239. * a Environment helper.
  55240. *
  55241. * This can control the default ground, skybox and image processing setup of your scene.
  55242. */
  55243. export interface IEnvironmentHelperOptions {
  55244. /**
  55245. * Specifies whether or not to create a ground.
  55246. * True by default.
  55247. */
  55248. createGround: boolean;
  55249. /**
  55250. * Specifies the ground size.
  55251. * 15 by default.
  55252. */
  55253. groundSize: number;
  55254. /**
  55255. * The texture used on the ground for the main color.
  55256. * Comes from the BabylonJS CDN by default.
  55257. *
  55258. * Remarks: Can be either a texture or a url.
  55259. */
  55260. groundTexture: string | BaseTexture;
  55261. /**
  55262. * The color mixed in the ground texture by default.
  55263. * BabylonJS clearColor by default.
  55264. */
  55265. groundColor: Color3;
  55266. /**
  55267. * Specifies the ground opacity.
  55268. * 1 by default.
  55269. */
  55270. groundOpacity: number;
  55271. /**
  55272. * Enables the ground to receive shadows.
  55273. * True by default.
  55274. */
  55275. enableGroundShadow: boolean;
  55276. /**
  55277. * Helps preventing the shadow to be fully black on the ground.
  55278. * 0.5 by default.
  55279. */
  55280. groundShadowLevel: number;
  55281. /**
  55282. * Creates a mirror texture attach to the ground.
  55283. * false by default.
  55284. */
  55285. enableGroundMirror: boolean;
  55286. /**
  55287. * Specifies the ground mirror size ratio.
  55288. * 0.3 by default as the default kernel is 64.
  55289. */
  55290. groundMirrorSizeRatio: number;
  55291. /**
  55292. * Specifies the ground mirror blur kernel size.
  55293. * 64 by default.
  55294. */
  55295. groundMirrorBlurKernel: number;
  55296. /**
  55297. * Specifies the ground mirror visibility amount.
  55298. * 1 by default
  55299. */
  55300. groundMirrorAmount: number;
  55301. /**
  55302. * Specifies the ground mirror reflectance weight.
  55303. * This uses the standard weight of the background material to setup the fresnel effect
  55304. * of the mirror.
  55305. * 1 by default.
  55306. */
  55307. groundMirrorFresnelWeight: number;
  55308. /**
  55309. * Specifies the ground mirror Falloff distance.
  55310. * This can helps reducing the size of the reflection.
  55311. * 0 by Default.
  55312. */
  55313. groundMirrorFallOffDistance: number;
  55314. /**
  55315. * Specifies the ground mirror texture type.
  55316. * Unsigned Int by Default.
  55317. */
  55318. groundMirrorTextureType: number;
  55319. /**
  55320. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  55321. * the shown objects.
  55322. */
  55323. groundYBias: number;
  55324. /**
  55325. * Specifies whether or not to create a skybox.
  55326. * True by default.
  55327. */
  55328. createSkybox: boolean;
  55329. /**
  55330. * Specifies the skybox size.
  55331. * 20 by default.
  55332. */
  55333. skyboxSize: number;
  55334. /**
  55335. * The texture used on the skybox for the main color.
  55336. * Comes from the BabylonJS CDN by default.
  55337. *
  55338. * Remarks: Can be either a texture or a url.
  55339. */
  55340. skyboxTexture: string | BaseTexture;
  55341. /**
  55342. * The color mixed in the skybox texture by default.
  55343. * BabylonJS clearColor by default.
  55344. */
  55345. skyboxColor: Color3;
  55346. /**
  55347. * The background rotation around the Y axis of the scene.
  55348. * This helps aligning the key lights of your scene with the background.
  55349. * 0 by default.
  55350. */
  55351. backgroundYRotation: number;
  55352. /**
  55353. * Compute automatically the size of the elements to best fit with the scene.
  55354. */
  55355. sizeAuto: boolean;
  55356. /**
  55357. * Default position of the rootMesh if autoSize is not true.
  55358. */
  55359. rootPosition: Vector3;
  55360. /**
  55361. * Sets up the image processing in the scene.
  55362. * true by default.
  55363. */
  55364. setupImageProcessing: boolean;
  55365. /**
  55366. * The texture used as your environment texture in the scene.
  55367. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  55368. *
  55369. * Remarks: Can be either a texture or a url.
  55370. */
  55371. environmentTexture: string | BaseTexture;
  55372. /**
  55373. * The value of the exposure to apply to the scene.
  55374. * 0.6 by default if setupImageProcessing is true.
  55375. */
  55376. cameraExposure: number;
  55377. /**
  55378. * The value of the contrast to apply to the scene.
  55379. * 1.6 by default if setupImageProcessing is true.
  55380. */
  55381. cameraContrast: number;
  55382. /**
  55383. * Specifies whether or not tonemapping should be enabled in the scene.
  55384. * true by default if setupImageProcessing is true.
  55385. */
  55386. toneMappingEnabled: boolean;
  55387. }
  55388. /**
  55389. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  55390. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  55391. * It also helps with the default setup of your imageProcessing configuration.
  55392. */
  55393. export class EnvironmentHelper {
  55394. /**
  55395. * Default ground texture URL.
  55396. */
  55397. private static _groundTextureCDNUrl;
  55398. /**
  55399. * Default skybox texture URL.
  55400. */
  55401. private static _skyboxTextureCDNUrl;
  55402. /**
  55403. * Default environment texture URL.
  55404. */
  55405. private static _environmentTextureCDNUrl;
  55406. /**
  55407. * Creates the default options for the helper.
  55408. */
  55409. private static _getDefaultOptions;
  55410. private _rootMesh;
  55411. /**
  55412. * Gets the root mesh created by the helper.
  55413. */
  55414. get rootMesh(): Mesh;
  55415. private _skybox;
  55416. /**
  55417. * Gets the skybox created by the helper.
  55418. */
  55419. get skybox(): Nullable<Mesh>;
  55420. private _skyboxTexture;
  55421. /**
  55422. * Gets the skybox texture created by the helper.
  55423. */
  55424. get skyboxTexture(): Nullable<BaseTexture>;
  55425. private _skyboxMaterial;
  55426. /**
  55427. * Gets the skybox material created by the helper.
  55428. */
  55429. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  55430. private _ground;
  55431. /**
  55432. * Gets the ground mesh created by the helper.
  55433. */
  55434. get ground(): Nullable<Mesh>;
  55435. private _groundTexture;
  55436. /**
  55437. * Gets the ground texture created by the helper.
  55438. */
  55439. get groundTexture(): Nullable<BaseTexture>;
  55440. private _groundMirror;
  55441. /**
  55442. * Gets the ground mirror created by the helper.
  55443. */
  55444. get groundMirror(): Nullable<MirrorTexture>;
  55445. /**
  55446. * Gets the ground mirror render list to helps pushing the meshes
  55447. * you wish in the ground reflection.
  55448. */
  55449. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  55450. private _groundMaterial;
  55451. /**
  55452. * Gets the ground material created by the helper.
  55453. */
  55454. get groundMaterial(): Nullable<BackgroundMaterial>;
  55455. /**
  55456. * Stores the creation options.
  55457. */
  55458. private readonly _scene;
  55459. private _options;
  55460. /**
  55461. * This observable will be notified with any error during the creation of the environment,
  55462. * mainly texture creation errors.
  55463. */
  55464. onErrorObservable: Observable<{
  55465. message?: string;
  55466. exception?: any;
  55467. }>;
  55468. /**
  55469. * constructor
  55470. * @param options Defines the options we want to customize the helper
  55471. * @param scene The scene to add the material to
  55472. */
  55473. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  55474. /**
  55475. * Updates the background according to the new options
  55476. * @param options
  55477. */
  55478. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  55479. /**
  55480. * Sets the primary color of all the available elements.
  55481. * @param color the main color to affect to the ground and the background
  55482. */
  55483. setMainColor(color: Color3): void;
  55484. /**
  55485. * Setup the image processing according to the specified options.
  55486. */
  55487. private _setupImageProcessing;
  55488. /**
  55489. * Setup the environment texture according to the specified options.
  55490. */
  55491. private _setupEnvironmentTexture;
  55492. /**
  55493. * Setup the background according to the specified options.
  55494. */
  55495. private _setupBackground;
  55496. /**
  55497. * Get the scene sizes according to the setup.
  55498. */
  55499. private _getSceneSize;
  55500. /**
  55501. * Setup the ground according to the specified options.
  55502. */
  55503. private _setupGround;
  55504. /**
  55505. * Setup the ground material according to the specified options.
  55506. */
  55507. private _setupGroundMaterial;
  55508. /**
  55509. * Setup the ground diffuse texture according to the specified options.
  55510. */
  55511. private _setupGroundDiffuseTexture;
  55512. /**
  55513. * Setup the ground mirror texture according to the specified options.
  55514. */
  55515. private _setupGroundMirrorTexture;
  55516. /**
  55517. * Setup the ground to receive the mirror texture.
  55518. */
  55519. private _setupMirrorInGroundMaterial;
  55520. /**
  55521. * Setup the skybox according to the specified options.
  55522. */
  55523. private _setupSkybox;
  55524. /**
  55525. * Setup the skybox material according to the specified options.
  55526. */
  55527. private _setupSkyboxMaterial;
  55528. /**
  55529. * Setup the skybox reflection texture according to the specified options.
  55530. */
  55531. private _setupSkyboxReflectionTexture;
  55532. private _errorHandler;
  55533. /**
  55534. * Dispose all the elements created by the Helper.
  55535. */
  55536. dispose(): void;
  55537. }
  55538. }
  55539. declare module "babylonjs/Helpers/photoDome" {
  55540. import { Observable } from "babylonjs/Misc/observable";
  55541. import { Nullable } from "babylonjs/types";
  55542. import { Scene } from "babylonjs/scene";
  55543. import { TransformNode } from "babylonjs/Meshes/transformNode";
  55544. import { Mesh } from "babylonjs/Meshes/mesh";
  55545. import { Texture } from "babylonjs/Materials/Textures/texture";
  55546. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  55547. import "babylonjs/Meshes/Builders/sphereBuilder";
  55548. /**
  55549. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  55550. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  55551. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  55552. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  55553. */
  55554. export class PhotoDome extends TransformNode {
  55555. /**
  55556. * Define the image as a Monoscopic panoramic 360 image.
  55557. */
  55558. static readonly MODE_MONOSCOPIC: number;
  55559. /**
  55560. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  55561. */
  55562. static readonly MODE_TOPBOTTOM: number;
  55563. /**
  55564. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  55565. */
  55566. static readonly MODE_SIDEBYSIDE: number;
  55567. private _useDirectMapping;
  55568. /**
  55569. * The texture being displayed on the sphere
  55570. */
  55571. protected _photoTexture: Texture;
  55572. /**
  55573. * Gets or sets the texture being displayed on the sphere
  55574. */
  55575. get photoTexture(): Texture;
  55576. set photoTexture(value: Texture);
  55577. /**
  55578. * Observable raised when an error occured while loading the 360 image
  55579. */
  55580. onLoadErrorObservable: Observable<string>;
  55581. /**
  55582. * The skybox material
  55583. */
  55584. protected _material: BackgroundMaterial;
  55585. /**
  55586. * The surface used for the skybox
  55587. */
  55588. protected _mesh: Mesh;
  55589. /**
  55590. * Gets the mesh used for the skybox.
  55591. */
  55592. get mesh(): Mesh;
  55593. /**
  55594. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  55595. * Also see the options.resolution property.
  55596. */
  55597. get fovMultiplier(): number;
  55598. set fovMultiplier(value: number);
  55599. private _imageMode;
  55600. /**
  55601. * Gets or set the current video mode for the video. It can be:
  55602. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  55603. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  55604. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  55605. */
  55606. get imageMode(): number;
  55607. set imageMode(value: number);
  55608. /**
  55609. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  55610. * @param name Element's name, child elements will append suffixes for their own names.
  55611. * @param urlsOfPhoto defines the url of the photo to display
  55612. * @param options defines an object containing optional or exposed sub element properties
  55613. * @param onError defines a callback called when an error occured while loading the texture
  55614. */
  55615. constructor(name: string, urlOfPhoto: string, options: {
  55616. resolution?: number;
  55617. size?: number;
  55618. useDirectMapping?: boolean;
  55619. faceForward?: boolean;
  55620. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  55621. private _onBeforeCameraRenderObserver;
  55622. private _changeImageMode;
  55623. /**
  55624. * Releases resources associated with this node.
  55625. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  55626. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  55627. */
  55628. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  55629. }
  55630. }
  55631. declare module "babylonjs/Misc/rgbdTextureTools" {
  55632. import "babylonjs/Shaders/rgbdDecode.fragment";
  55633. import "babylonjs/Engines/Extensions/engine.renderTarget";
  55634. import { Texture } from "babylonjs/Materials/Textures/texture";
  55635. /**
  55636. * Class used to host RGBD texture specific utilities
  55637. */
  55638. export class RGBDTextureTools {
  55639. /**
  55640. * Expand the RGBD Texture from RGBD to Half Float if possible.
  55641. * @param texture the texture to expand.
  55642. */
  55643. static ExpandRGBDTexture(texture: Texture): void;
  55644. }
  55645. }
  55646. declare module "babylonjs/Misc/brdfTextureTools" {
  55647. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55648. import { Scene } from "babylonjs/scene";
  55649. /**
  55650. * Class used to host texture specific utilities
  55651. */
  55652. export class BRDFTextureTools {
  55653. /**
  55654. * Prevents texture cache collision
  55655. */
  55656. private static _instanceNumber;
  55657. /**
  55658. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  55659. * @param scene defines the hosting scene
  55660. * @returns the environment BRDF texture
  55661. */
  55662. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  55663. private static _environmentBRDFBase64Texture;
  55664. }
  55665. }
  55666. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  55667. import { Nullable } from "babylonjs/types";
  55668. import { Color3 } from "babylonjs/Maths/math.color";
  55669. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55670. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  55671. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  55672. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  55673. import { Engine } from "babylonjs/Engines/engine";
  55674. import { Scene } from "babylonjs/scene";
  55675. /**
  55676. * @hidden
  55677. */
  55678. export interface IMaterialClearCoatDefines {
  55679. CLEARCOAT: boolean;
  55680. CLEARCOAT_DEFAULTIOR: boolean;
  55681. CLEARCOAT_TEXTURE: boolean;
  55682. CLEARCOAT_TEXTUREDIRECTUV: number;
  55683. CLEARCOAT_BUMP: boolean;
  55684. CLEARCOAT_BUMPDIRECTUV: number;
  55685. CLEARCOAT_TINT: boolean;
  55686. CLEARCOAT_TINT_TEXTURE: boolean;
  55687. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  55688. /** @hidden */
  55689. _areTexturesDirty: boolean;
  55690. }
  55691. /**
  55692. * Define the code related to the clear coat parameters of the pbr material.
  55693. */
  55694. export class PBRClearCoatConfiguration {
  55695. /**
  55696. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  55697. * The default fits with a polyurethane material.
  55698. */
  55699. private static readonly _DefaultIndexOfRefraction;
  55700. private _isEnabled;
  55701. /**
  55702. * Defines if the clear coat is enabled in the material.
  55703. */
  55704. isEnabled: boolean;
  55705. /**
  55706. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  55707. */
  55708. intensity: number;
  55709. /**
  55710. * Defines the clear coat layer roughness.
  55711. */
  55712. roughness: number;
  55713. private _indexOfRefraction;
  55714. /**
  55715. * Defines the index of refraction of the clear coat.
  55716. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  55717. * The default fits with a polyurethane material.
  55718. * Changing the default value is more performance intensive.
  55719. */
  55720. indexOfRefraction: number;
  55721. private _texture;
  55722. /**
  55723. * Stores the clear coat values in a texture.
  55724. */
  55725. texture: Nullable<BaseTexture>;
  55726. private _bumpTexture;
  55727. /**
  55728. * Define the clear coat specific bump texture.
  55729. */
  55730. bumpTexture: Nullable<BaseTexture>;
  55731. private _isTintEnabled;
  55732. /**
  55733. * Defines if the clear coat tint is enabled in the material.
  55734. */
  55735. isTintEnabled: boolean;
  55736. /**
  55737. * Defines the clear coat tint of the material.
  55738. * This is only use if tint is enabled
  55739. */
  55740. tintColor: Color3;
  55741. /**
  55742. * Defines the distance at which the tint color should be found in the
  55743. * clear coat media.
  55744. * This is only use if tint is enabled
  55745. */
  55746. tintColorAtDistance: number;
  55747. /**
  55748. * Defines the clear coat layer thickness.
  55749. * This is only use if tint is enabled
  55750. */
  55751. tintThickness: number;
  55752. private _tintTexture;
  55753. /**
  55754. * Stores the clear tint values in a texture.
  55755. * rgb is tint
  55756. * a is a thickness factor
  55757. */
  55758. tintTexture: Nullable<BaseTexture>;
  55759. /** @hidden */
  55760. private _internalMarkAllSubMeshesAsTexturesDirty;
  55761. /** @hidden */
  55762. _markAllSubMeshesAsTexturesDirty(): void;
  55763. /**
  55764. * Instantiate a new istance of clear coat configuration.
  55765. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  55766. */
  55767. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  55768. /**
  55769. * Gets wehter the submesh is ready to be used or not.
  55770. * @param defines the list of "defines" to update.
  55771. * @param scene defines the scene the material belongs to.
  55772. * @param engine defines the engine the material belongs to.
  55773. * @param disableBumpMap defines wether the material disables bump or not.
  55774. * @returns - boolean indicating that the submesh is ready or not.
  55775. */
  55776. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  55777. /**
  55778. * Checks to see if a texture is used in the material.
  55779. * @param defines the list of "defines" to update.
  55780. * @param scene defines the scene to the material belongs to.
  55781. */
  55782. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  55783. /**
  55784. * Binds the material data.
  55785. * @param uniformBuffer defines the Uniform buffer to fill in.
  55786. * @param scene defines the scene the material belongs to.
  55787. * @param engine defines the engine the material belongs to.
  55788. * @param disableBumpMap defines wether the material disables bump or not.
  55789. * @param isFrozen defines wether the material is frozen or not.
  55790. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  55791. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  55792. */
  55793. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  55794. /**
  55795. * Checks to see if a texture is used in the material.
  55796. * @param texture - Base texture to use.
  55797. * @returns - Boolean specifying if a texture is used in the material.
  55798. */
  55799. hasTexture(texture: BaseTexture): boolean;
  55800. /**
  55801. * Returns an array of the actively used textures.
  55802. * @param activeTextures Array of BaseTextures
  55803. */
  55804. getActiveTextures(activeTextures: BaseTexture[]): void;
  55805. /**
  55806. * Returns the animatable textures.
  55807. * @param animatables Array of animatable textures.
  55808. */
  55809. getAnimatables(animatables: IAnimatable[]): void;
  55810. /**
  55811. * Disposes the resources of the material.
  55812. * @param forceDisposeTextures - Forces the disposal of all textures.
  55813. */
  55814. dispose(forceDisposeTextures?: boolean): void;
  55815. /**
  55816. * Get the current class name of the texture useful for serialization or dynamic coding.
  55817. * @returns "PBRClearCoatConfiguration"
  55818. */
  55819. getClassName(): string;
  55820. /**
  55821. * Add fallbacks to the effect fallbacks list.
  55822. * @param defines defines the Base texture to use.
  55823. * @param fallbacks defines the current fallback list.
  55824. * @param currentRank defines the current fallback rank.
  55825. * @returns the new fallback rank.
  55826. */
  55827. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  55828. /**
  55829. * Add the required uniforms to the current list.
  55830. * @param uniforms defines the current uniform list.
  55831. */
  55832. static AddUniforms(uniforms: string[]): void;
  55833. /**
  55834. * Add the required samplers to the current list.
  55835. * @param samplers defines the current sampler list.
  55836. */
  55837. static AddSamplers(samplers: string[]): void;
  55838. /**
  55839. * Add the required uniforms to the current buffer.
  55840. * @param uniformBuffer defines the current uniform buffer.
  55841. */
  55842. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  55843. /**
  55844. * Makes a duplicate of the current configuration into another one.
  55845. * @param clearCoatConfiguration define the config where to copy the info
  55846. */
  55847. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  55848. /**
  55849. * Serializes this clear coat configuration.
  55850. * @returns - An object with the serialized config.
  55851. */
  55852. serialize(): any;
  55853. /**
  55854. * Parses a anisotropy Configuration from a serialized object.
  55855. * @param source - Serialized object.
  55856. * @param scene Defines the scene we are parsing for
  55857. * @param rootUrl Defines the rootUrl to load from
  55858. */
  55859. parse(source: any, scene: Scene, rootUrl: string): void;
  55860. }
  55861. }
  55862. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  55863. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  55864. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55865. import { Vector2 } from "babylonjs/Maths/math.vector";
  55866. import { Scene } from "babylonjs/scene";
  55867. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55868. import { Nullable } from "babylonjs/types";
  55869. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  55870. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  55871. /**
  55872. * @hidden
  55873. */
  55874. export interface IMaterialAnisotropicDefines {
  55875. ANISOTROPIC: boolean;
  55876. ANISOTROPIC_TEXTURE: boolean;
  55877. ANISOTROPIC_TEXTUREDIRECTUV: number;
  55878. MAINUV1: boolean;
  55879. _areTexturesDirty: boolean;
  55880. _needUVs: boolean;
  55881. }
  55882. /**
  55883. * Define the code related to the anisotropic parameters of the pbr material.
  55884. */
  55885. export class PBRAnisotropicConfiguration {
  55886. private _isEnabled;
  55887. /**
  55888. * Defines if the anisotropy is enabled in the material.
  55889. */
  55890. isEnabled: boolean;
  55891. /**
  55892. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  55893. */
  55894. intensity: number;
  55895. /**
  55896. * Defines if the effect is along the tangents, bitangents or in between.
  55897. * By default, the effect is "strectching" the highlights along the tangents.
  55898. */
  55899. direction: Vector2;
  55900. private _texture;
  55901. /**
  55902. * Stores the anisotropy values in a texture.
  55903. * rg is direction (like normal from -1 to 1)
  55904. * b is a intensity
  55905. */
  55906. texture: Nullable<BaseTexture>;
  55907. /** @hidden */
  55908. private _internalMarkAllSubMeshesAsTexturesDirty;
  55909. /** @hidden */
  55910. _markAllSubMeshesAsTexturesDirty(): void;
  55911. /**
  55912. * Instantiate a new istance of anisotropy configuration.
  55913. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  55914. */
  55915. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  55916. /**
  55917. * Specifies that the submesh is ready to be used.
  55918. * @param defines the list of "defines" to update.
  55919. * @param scene defines the scene the material belongs to.
  55920. * @returns - boolean indicating that the submesh is ready or not.
  55921. */
  55922. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  55923. /**
  55924. * Checks to see if a texture is used in the material.
  55925. * @param defines the list of "defines" to update.
  55926. * @param mesh the mesh we are preparing the defines for.
  55927. * @param scene defines the scene the material belongs to.
  55928. */
  55929. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  55930. /**
  55931. * Binds the material data.
  55932. * @param uniformBuffer defines the Uniform buffer to fill in.
  55933. * @param scene defines the scene the material belongs to.
  55934. * @param isFrozen defines wether the material is frozen or not.
  55935. */
  55936. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  55937. /**
  55938. * Checks to see if a texture is used in the material.
  55939. * @param texture - Base texture to use.
  55940. * @returns - Boolean specifying if a texture is used in the material.
  55941. */
  55942. hasTexture(texture: BaseTexture): boolean;
  55943. /**
  55944. * Returns an array of the actively used textures.
  55945. * @param activeTextures Array of BaseTextures
  55946. */
  55947. getActiveTextures(activeTextures: BaseTexture[]): void;
  55948. /**
  55949. * Returns the animatable textures.
  55950. * @param animatables Array of animatable textures.
  55951. */
  55952. getAnimatables(animatables: IAnimatable[]): void;
  55953. /**
  55954. * Disposes the resources of the material.
  55955. * @param forceDisposeTextures - Forces the disposal of all textures.
  55956. */
  55957. dispose(forceDisposeTextures?: boolean): void;
  55958. /**
  55959. * Get the current class name of the texture useful for serialization or dynamic coding.
  55960. * @returns "PBRAnisotropicConfiguration"
  55961. */
  55962. getClassName(): string;
  55963. /**
  55964. * Add fallbacks to the effect fallbacks list.
  55965. * @param defines defines the Base texture to use.
  55966. * @param fallbacks defines the current fallback list.
  55967. * @param currentRank defines the current fallback rank.
  55968. * @returns the new fallback rank.
  55969. */
  55970. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  55971. /**
  55972. * Add the required uniforms to the current list.
  55973. * @param uniforms defines the current uniform list.
  55974. */
  55975. static AddUniforms(uniforms: string[]): void;
  55976. /**
  55977. * Add the required uniforms to the current buffer.
  55978. * @param uniformBuffer defines the current uniform buffer.
  55979. */
  55980. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  55981. /**
  55982. * Add the required samplers to the current list.
  55983. * @param samplers defines the current sampler list.
  55984. */
  55985. static AddSamplers(samplers: string[]): void;
  55986. /**
  55987. * Makes a duplicate of the current configuration into another one.
  55988. * @param anisotropicConfiguration define the config where to copy the info
  55989. */
  55990. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  55991. /**
  55992. * Serializes this anisotropy configuration.
  55993. * @returns - An object with the serialized config.
  55994. */
  55995. serialize(): any;
  55996. /**
  55997. * Parses a anisotropy Configuration from a serialized object.
  55998. * @param source - Serialized object.
  55999. * @param scene Defines the scene we are parsing for
  56000. * @param rootUrl Defines the rootUrl to load from
  56001. */
  56002. parse(source: any, scene: Scene, rootUrl: string): void;
  56003. }
  56004. }
  56005. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  56006. import { Scene } from "babylonjs/scene";
  56007. /**
  56008. * @hidden
  56009. */
  56010. export interface IMaterialBRDFDefines {
  56011. BRDF_V_HEIGHT_CORRELATED: boolean;
  56012. MS_BRDF_ENERGY_CONSERVATION: boolean;
  56013. SPHERICAL_HARMONICS: boolean;
  56014. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  56015. /** @hidden */
  56016. _areMiscDirty: boolean;
  56017. }
  56018. /**
  56019. * Define the code related to the BRDF parameters of the pbr material.
  56020. */
  56021. export class PBRBRDFConfiguration {
  56022. /**
  56023. * Default value used for the energy conservation.
  56024. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  56025. */
  56026. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  56027. /**
  56028. * Default value used for the Smith Visibility Height Correlated mode.
  56029. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  56030. */
  56031. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  56032. /**
  56033. * Default value used for the IBL diffuse part.
  56034. * This can help switching back to the polynomials mode globally which is a tiny bit
  56035. * less GPU intensive at the drawback of a lower quality.
  56036. */
  56037. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  56038. /**
  56039. * Default value used for activating energy conservation for the specular workflow.
  56040. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  56041. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  56042. */
  56043. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  56044. private _useEnergyConservation;
  56045. /**
  56046. * Defines if the material uses energy conservation.
  56047. */
  56048. useEnergyConservation: boolean;
  56049. private _useSmithVisibilityHeightCorrelated;
  56050. /**
  56051. * LEGACY Mode set to false
  56052. * Defines if the material uses height smith correlated visibility term.
  56053. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  56054. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  56055. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  56056. * Not relying on height correlated will also disable energy conservation.
  56057. */
  56058. useSmithVisibilityHeightCorrelated: boolean;
  56059. private _useSphericalHarmonics;
  56060. /**
  56061. * LEGACY Mode set to false
  56062. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  56063. * diffuse part of the IBL.
  56064. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  56065. * to the ground truth.
  56066. */
  56067. useSphericalHarmonics: boolean;
  56068. private _useSpecularGlossinessInputEnergyConservation;
  56069. /**
  56070. * Defines if the material uses energy conservation, when the specular workflow is active.
  56071. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  56072. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  56073. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  56074. */
  56075. useSpecularGlossinessInputEnergyConservation: boolean;
  56076. /** @hidden */
  56077. private _internalMarkAllSubMeshesAsMiscDirty;
  56078. /** @hidden */
  56079. _markAllSubMeshesAsMiscDirty(): void;
  56080. /**
  56081. * Instantiate a new istance of clear coat configuration.
  56082. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  56083. */
  56084. constructor(markAllSubMeshesAsMiscDirty: () => void);
  56085. /**
  56086. * Checks to see if a texture is used in the material.
  56087. * @param defines the list of "defines" to update.
  56088. */
  56089. prepareDefines(defines: IMaterialBRDFDefines): void;
  56090. /**
  56091. * Get the current class name of the texture useful for serialization or dynamic coding.
  56092. * @returns "PBRClearCoatConfiguration"
  56093. */
  56094. getClassName(): string;
  56095. /**
  56096. * Makes a duplicate of the current configuration into another one.
  56097. * @param brdfConfiguration define the config where to copy the info
  56098. */
  56099. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  56100. /**
  56101. * Serializes this BRDF configuration.
  56102. * @returns - An object with the serialized config.
  56103. */
  56104. serialize(): any;
  56105. /**
  56106. * Parses a anisotropy Configuration from a serialized object.
  56107. * @param source - Serialized object.
  56108. * @param scene Defines the scene we are parsing for
  56109. * @param rootUrl Defines the rootUrl to load from
  56110. */
  56111. parse(source: any, scene: Scene, rootUrl: string): void;
  56112. }
  56113. }
  56114. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  56115. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  56116. import { Color3 } from "babylonjs/Maths/math.color";
  56117. import { Scene } from "babylonjs/scene";
  56118. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56119. import { Nullable } from "babylonjs/types";
  56120. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  56121. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  56122. /**
  56123. * @hidden
  56124. */
  56125. export interface IMaterialSheenDefines {
  56126. SHEEN: boolean;
  56127. SHEEN_TEXTURE: boolean;
  56128. SHEEN_TEXTUREDIRECTUV: number;
  56129. SHEEN_LINKWITHALBEDO: boolean;
  56130. SHEEN_ROUGHNESS: boolean;
  56131. SHEEN_ALBEDOSCALING: boolean;
  56132. /** @hidden */
  56133. _areTexturesDirty: boolean;
  56134. }
  56135. /**
  56136. * Define the code related to the Sheen parameters of the pbr material.
  56137. */
  56138. export class PBRSheenConfiguration {
  56139. private _isEnabled;
  56140. /**
  56141. * Defines if the material uses sheen.
  56142. */
  56143. isEnabled: boolean;
  56144. private _linkSheenWithAlbedo;
  56145. /**
  56146. * Defines if the sheen is linked to the sheen color.
  56147. */
  56148. linkSheenWithAlbedo: boolean;
  56149. /**
  56150. * Defines the sheen intensity.
  56151. */
  56152. intensity: number;
  56153. /**
  56154. * Defines the sheen color.
  56155. */
  56156. color: Color3;
  56157. private _texture;
  56158. /**
  56159. * Stores the sheen tint values in a texture.
  56160. * rgb is tint
  56161. * a is a intensity
  56162. */
  56163. texture: Nullable<BaseTexture>;
  56164. private _roughness;
  56165. /**
  56166. * Defines the sheen roughness.
  56167. * It is not taken into account if linkSheenWithAlbedo is true.
  56168. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  56169. */
  56170. roughness: Nullable<number>;
  56171. private _albedoScaling;
  56172. /**
  56173. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  56174. * It allows the strength of the sheen effect to not depend on the base color of the material,
  56175. * making it easier to setup and tweak the effect
  56176. */
  56177. albedoScaling: boolean;
  56178. /** @hidden */
  56179. private _internalMarkAllSubMeshesAsTexturesDirty;
  56180. /** @hidden */
  56181. _markAllSubMeshesAsTexturesDirty(): void;
  56182. /**
  56183. * Instantiate a new istance of clear coat configuration.
  56184. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  56185. */
  56186. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  56187. /**
  56188. * Specifies that the submesh is ready to be used.
  56189. * @param defines the list of "defines" to update.
  56190. * @param scene defines the scene the material belongs to.
  56191. * @returns - boolean indicating that the submesh is ready or not.
  56192. */
  56193. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  56194. /**
  56195. * Checks to see if a texture is used in the material.
  56196. * @param defines the list of "defines" to update.
  56197. * @param scene defines the scene the material belongs to.
  56198. */
  56199. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  56200. /**
  56201. * Binds the material data.
  56202. * @param uniformBuffer defines the Uniform buffer to fill in.
  56203. * @param scene defines the scene the material belongs to.
  56204. * @param isFrozen defines wether the material is frozen or not.
  56205. */
  56206. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  56207. /**
  56208. * Checks to see if a texture is used in the material.
  56209. * @param texture - Base texture to use.
  56210. * @returns - Boolean specifying if a texture is used in the material.
  56211. */
  56212. hasTexture(texture: BaseTexture): boolean;
  56213. /**
  56214. * Returns an array of the actively used textures.
  56215. * @param activeTextures Array of BaseTextures
  56216. */
  56217. getActiveTextures(activeTextures: BaseTexture[]): void;
  56218. /**
  56219. * Returns the animatable textures.
  56220. * @param animatables Array of animatable textures.
  56221. */
  56222. getAnimatables(animatables: IAnimatable[]): void;
  56223. /**
  56224. * Disposes the resources of the material.
  56225. * @param forceDisposeTextures - Forces the disposal of all textures.
  56226. */
  56227. dispose(forceDisposeTextures?: boolean): void;
  56228. /**
  56229. * Get the current class name of the texture useful for serialization or dynamic coding.
  56230. * @returns "PBRSheenConfiguration"
  56231. */
  56232. getClassName(): string;
  56233. /**
  56234. * Add fallbacks to the effect fallbacks list.
  56235. * @param defines defines the Base texture to use.
  56236. * @param fallbacks defines the current fallback list.
  56237. * @param currentRank defines the current fallback rank.
  56238. * @returns the new fallback rank.
  56239. */
  56240. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  56241. /**
  56242. * Add the required uniforms to the current list.
  56243. * @param uniforms defines the current uniform list.
  56244. */
  56245. static AddUniforms(uniforms: string[]): void;
  56246. /**
  56247. * Add the required uniforms to the current buffer.
  56248. * @param uniformBuffer defines the current uniform buffer.
  56249. */
  56250. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  56251. /**
  56252. * Add the required samplers to the current list.
  56253. * @param samplers defines the current sampler list.
  56254. */
  56255. static AddSamplers(samplers: string[]): void;
  56256. /**
  56257. * Makes a duplicate of the current configuration into another one.
  56258. * @param sheenConfiguration define the config where to copy the info
  56259. */
  56260. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  56261. /**
  56262. * Serializes this BRDF configuration.
  56263. * @returns - An object with the serialized config.
  56264. */
  56265. serialize(): any;
  56266. /**
  56267. * Parses a anisotropy Configuration from a serialized object.
  56268. * @param source - Serialized object.
  56269. * @param scene Defines the scene we are parsing for
  56270. * @param rootUrl Defines the rootUrl to load from
  56271. */
  56272. parse(source: any, scene: Scene, rootUrl: string): void;
  56273. }
  56274. }
  56275. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  56276. import { Nullable } from "babylonjs/types";
  56277. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  56278. import { Color3 } from "babylonjs/Maths/math.color";
  56279. import { SmartArray } from "babylonjs/Misc/smartArray";
  56280. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56281. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56282. import { Effect } from "babylonjs/Materials/effect";
  56283. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  56284. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  56285. import { Engine } from "babylonjs/Engines/engine";
  56286. import { Scene } from "babylonjs/scene";
  56287. /**
  56288. * @hidden
  56289. */
  56290. export interface IMaterialSubSurfaceDefines {
  56291. SUBSURFACE: boolean;
  56292. SS_REFRACTION: boolean;
  56293. SS_TRANSLUCENCY: boolean;
  56294. SS_SCATERRING: boolean;
  56295. SS_THICKNESSANDMASK_TEXTURE: boolean;
  56296. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  56297. SS_REFRACTIONMAP_3D: boolean;
  56298. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  56299. SS_LODINREFRACTIONALPHA: boolean;
  56300. SS_GAMMAREFRACTION: boolean;
  56301. SS_RGBDREFRACTION: boolean;
  56302. SS_LINEARSPECULARREFRACTION: boolean;
  56303. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  56304. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  56305. /** @hidden */
  56306. _areTexturesDirty: boolean;
  56307. }
  56308. /**
  56309. * Define the code related to the sub surface parameters of the pbr material.
  56310. */
  56311. export class PBRSubSurfaceConfiguration {
  56312. private _isRefractionEnabled;
  56313. /**
  56314. * Defines if the refraction is enabled in the material.
  56315. */
  56316. isRefractionEnabled: boolean;
  56317. private _isTranslucencyEnabled;
  56318. /**
  56319. * Defines if the translucency is enabled in the material.
  56320. */
  56321. isTranslucencyEnabled: boolean;
  56322. private _isScatteringEnabled;
  56323. /**
  56324. * Defines the refraction intensity of the material.
  56325. * The refraction when enabled replaces the Diffuse part of the material.
  56326. * The intensity helps transitionning between diffuse and refraction.
  56327. */
  56328. refractionIntensity: number;
  56329. /**
  56330. * Defines the translucency intensity of the material.
  56331. * When translucency has been enabled, this defines how much of the "translucency"
  56332. * is addded to the diffuse part of the material.
  56333. */
  56334. translucencyIntensity: number;
  56335. /**
  56336. * Defines the scattering intensity of the material.
  56337. * When scattering has been enabled, this defines how much of the "scattered light"
  56338. * is addded to the diffuse part of the material.
  56339. */
  56340. scatteringIntensity: number;
  56341. private _thicknessTexture;
  56342. /**
  56343. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  56344. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  56345. * 0 would mean minimumThickness
  56346. * 1 would mean maximumThickness
  56347. * The other channels might be use as a mask to vary the different effects intensity.
  56348. */
  56349. thicknessTexture: Nullable<BaseTexture>;
  56350. private _refractionTexture;
  56351. /**
  56352. * Defines the texture to use for refraction.
  56353. */
  56354. refractionTexture: Nullable<BaseTexture>;
  56355. private _indexOfRefraction;
  56356. /**
  56357. * Index of refraction of the material base layer.
  56358. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  56359. *
  56360. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  56361. *
  56362. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  56363. */
  56364. indexOfRefraction: number;
  56365. private _invertRefractionY;
  56366. /**
  56367. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  56368. */
  56369. invertRefractionY: boolean;
  56370. private _linkRefractionWithTransparency;
  56371. /**
  56372. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  56373. * Materials half opaque for instance using refraction could benefit from this control.
  56374. */
  56375. linkRefractionWithTransparency: boolean;
  56376. /**
  56377. * Defines the minimum thickness stored in the thickness map.
  56378. * If no thickness map is defined, this value will be used to simulate thickness.
  56379. */
  56380. minimumThickness: number;
  56381. /**
  56382. * Defines the maximum thickness stored in the thickness map.
  56383. */
  56384. maximumThickness: number;
  56385. /**
  56386. * Defines the volume tint of the material.
  56387. * This is used for both translucency and scattering.
  56388. */
  56389. tintColor: Color3;
  56390. /**
  56391. * Defines the distance at which the tint color should be found in the media.
  56392. * This is used for refraction only.
  56393. */
  56394. tintColorAtDistance: number;
  56395. /**
  56396. * Defines how far each channel transmit through the media.
  56397. * It is defined as a color to simplify it selection.
  56398. */
  56399. diffusionDistance: Color3;
  56400. private _useMaskFromThicknessTexture;
  56401. /**
  56402. * Stores the intensity of the different subsurface effects in the thickness texture.
  56403. * * the green channel is the translucency intensity.
  56404. * * the blue channel is the scattering intensity.
  56405. * * the alpha channel is the refraction intensity.
  56406. */
  56407. useMaskFromThicknessTexture: boolean;
  56408. /** @hidden */
  56409. private _internalMarkAllSubMeshesAsTexturesDirty;
  56410. /** @hidden */
  56411. _markAllSubMeshesAsTexturesDirty(): void;
  56412. /**
  56413. * Instantiate a new istance of sub surface configuration.
  56414. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  56415. */
  56416. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  56417. /**
  56418. * Gets wehter the submesh is ready to be used or not.
  56419. * @param defines the list of "defines" to update.
  56420. * @param scene defines the scene the material belongs to.
  56421. * @returns - boolean indicating that the submesh is ready or not.
  56422. */
  56423. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  56424. /**
  56425. * Checks to see if a texture is used in the material.
  56426. * @param defines the list of "defines" to update.
  56427. * @param scene defines the scene to the material belongs to.
  56428. */
  56429. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  56430. /**
  56431. * Binds the material data.
  56432. * @param uniformBuffer defines the Uniform buffer to fill in.
  56433. * @param scene defines the scene the material belongs to.
  56434. * @param engine defines the engine the material belongs to.
  56435. * @param isFrozen defines whether the material is frozen or not.
  56436. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  56437. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  56438. */
  56439. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  56440. /**
  56441. * Unbinds the material from the mesh.
  56442. * @param activeEffect defines the effect that should be unbound from.
  56443. * @returns true if unbound, otherwise false
  56444. */
  56445. unbind(activeEffect: Effect): boolean;
  56446. /**
  56447. * Returns the texture used for refraction or null if none is used.
  56448. * @param scene defines the scene the material belongs to.
  56449. * @returns - Refraction texture if present. If no refraction texture and refraction
  56450. * is linked with transparency, returns environment texture. Otherwise, returns null.
  56451. */
  56452. private _getRefractionTexture;
  56453. /**
  56454. * Returns true if alpha blending should be disabled.
  56455. */
  56456. get disableAlphaBlending(): boolean;
  56457. /**
  56458. * Fills the list of render target textures.
  56459. * @param renderTargets the list of render targets to update
  56460. */
  56461. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  56462. /**
  56463. * Checks to see if a texture is used in the material.
  56464. * @param texture - Base texture to use.
  56465. * @returns - Boolean specifying if a texture is used in the material.
  56466. */
  56467. hasTexture(texture: BaseTexture): boolean;
  56468. /**
  56469. * Gets a boolean indicating that current material needs to register RTT
  56470. * @returns true if this uses a render target otherwise false.
  56471. */
  56472. hasRenderTargetTextures(): boolean;
  56473. /**
  56474. * Returns an array of the actively used textures.
  56475. * @param activeTextures Array of BaseTextures
  56476. */
  56477. getActiveTextures(activeTextures: BaseTexture[]): void;
  56478. /**
  56479. * Returns the animatable textures.
  56480. * @param animatables Array of animatable textures.
  56481. */
  56482. getAnimatables(animatables: IAnimatable[]): void;
  56483. /**
  56484. * Disposes the resources of the material.
  56485. * @param forceDisposeTextures - Forces the disposal of all textures.
  56486. */
  56487. dispose(forceDisposeTextures?: boolean): void;
  56488. /**
  56489. * Get the current class name of the texture useful for serialization or dynamic coding.
  56490. * @returns "PBRSubSurfaceConfiguration"
  56491. */
  56492. getClassName(): string;
  56493. /**
  56494. * Add fallbacks to the effect fallbacks list.
  56495. * @param defines defines the Base texture to use.
  56496. * @param fallbacks defines the current fallback list.
  56497. * @param currentRank defines the current fallback rank.
  56498. * @returns the new fallback rank.
  56499. */
  56500. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  56501. /**
  56502. * Add the required uniforms to the current list.
  56503. * @param uniforms defines the current uniform list.
  56504. */
  56505. static AddUniforms(uniforms: string[]): void;
  56506. /**
  56507. * Add the required samplers to the current list.
  56508. * @param samplers defines the current sampler list.
  56509. */
  56510. static AddSamplers(samplers: string[]): void;
  56511. /**
  56512. * Add the required uniforms to the current buffer.
  56513. * @param uniformBuffer defines the current uniform buffer.
  56514. */
  56515. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  56516. /**
  56517. * Makes a duplicate of the current configuration into another one.
  56518. * @param configuration define the config where to copy the info
  56519. */
  56520. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  56521. /**
  56522. * Serializes this Sub Surface configuration.
  56523. * @returns - An object with the serialized config.
  56524. */
  56525. serialize(): any;
  56526. /**
  56527. * Parses a anisotropy Configuration from a serialized object.
  56528. * @param source - Serialized object.
  56529. * @param scene Defines the scene we are parsing for
  56530. * @param rootUrl Defines the rootUrl to load from
  56531. */
  56532. parse(source: any, scene: Scene, rootUrl: string): void;
  56533. }
  56534. }
  56535. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  56536. /** @hidden */
  56537. export var pbrFragmentDeclaration: {
  56538. name: string;
  56539. shader: string;
  56540. };
  56541. }
  56542. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  56543. /** @hidden */
  56544. export var pbrUboDeclaration: {
  56545. name: string;
  56546. shader: string;
  56547. };
  56548. }
  56549. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  56550. /** @hidden */
  56551. export var pbrFragmentExtraDeclaration: {
  56552. name: string;
  56553. shader: string;
  56554. };
  56555. }
  56556. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  56557. /** @hidden */
  56558. export var pbrFragmentSamplersDeclaration: {
  56559. name: string;
  56560. shader: string;
  56561. };
  56562. }
  56563. declare module "babylonjs/Shaders/ShadersInclude/importanceSampling" {
  56564. /** @hidden */
  56565. export var importanceSampling: {
  56566. name: string;
  56567. shader: string;
  56568. };
  56569. }
  56570. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  56571. /** @hidden */
  56572. export var pbrHelperFunctions: {
  56573. name: string;
  56574. shader: string;
  56575. };
  56576. }
  56577. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  56578. /** @hidden */
  56579. export var harmonicsFunctions: {
  56580. name: string;
  56581. shader: string;
  56582. };
  56583. }
  56584. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  56585. /** @hidden */
  56586. export var pbrDirectLightingSetupFunctions: {
  56587. name: string;
  56588. shader: string;
  56589. };
  56590. }
  56591. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  56592. /** @hidden */
  56593. export var pbrDirectLightingFalloffFunctions: {
  56594. name: string;
  56595. shader: string;
  56596. };
  56597. }
  56598. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  56599. /** @hidden */
  56600. export var pbrBRDFFunctions: {
  56601. name: string;
  56602. shader: string;
  56603. };
  56604. }
  56605. declare module "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions" {
  56606. /** @hidden */
  56607. export var hdrFilteringFunctions: {
  56608. name: string;
  56609. shader: string;
  56610. };
  56611. }
  56612. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  56613. /** @hidden */
  56614. export var pbrDirectLightingFunctions: {
  56615. name: string;
  56616. shader: string;
  56617. };
  56618. }
  56619. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  56620. /** @hidden */
  56621. export var pbrIBLFunctions: {
  56622. name: string;
  56623. shader: string;
  56624. };
  56625. }
  56626. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity" {
  56627. /** @hidden */
  56628. export var pbrBlockAlbedoOpacity: {
  56629. name: string;
  56630. shader: string;
  56631. };
  56632. }
  56633. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity" {
  56634. /** @hidden */
  56635. export var pbrBlockReflectivity: {
  56636. name: string;
  56637. shader: string;
  56638. };
  56639. }
  56640. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion" {
  56641. /** @hidden */
  56642. export var pbrBlockAmbientOcclusion: {
  56643. name: string;
  56644. shader: string;
  56645. };
  56646. }
  56647. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel" {
  56648. /** @hidden */
  56649. export var pbrBlockAlphaFresnel: {
  56650. name: string;
  56651. shader: string;
  56652. };
  56653. }
  56654. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic" {
  56655. /** @hidden */
  56656. export var pbrBlockAnisotropic: {
  56657. name: string;
  56658. shader: string;
  56659. };
  56660. }
  56661. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflection" {
  56662. /** @hidden */
  56663. export var pbrBlockReflection: {
  56664. name: string;
  56665. shader: string;
  56666. };
  56667. }
  56668. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSheen" {
  56669. /** @hidden */
  56670. export var pbrBlockSheen: {
  56671. name: string;
  56672. shader: string;
  56673. };
  56674. }
  56675. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat" {
  56676. /** @hidden */
  56677. export var pbrBlockClearcoat: {
  56678. name: string;
  56679. shader: string;
  56680. };
  56681. }
  56682. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface" {
  56683. /** @hidden */
  56684. export var pbrBlockSubSurface: {
  56685. name: string;
  56686. shader: string;
  56687. };
  56688. }
  56689. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric" {
  56690. /** @hidden */
  56691. export var pbrBlockNormalGeometric: {
  56692. name: string;
  56693. shader: string;
  56694. };
  56695. }
  56696. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal" {
  56697. /** @hidden */
  56698. export var pbrBlockNormalFinal: {
  56699. name: string;
  56700. shader: string;
  56701. };
  56702. }
  56703. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo" {
  56704. /** @hidden */
  56705. export var pbrBlockGeometryInfo: {
  56706. name: string;
  56707. shader: string;
  56708. };
  56709. }
  56710. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0" {
  56711. /** @hidden */
  56712. export var pbrBlockReflectance0: {
  56713. name: string;
  56714. shader: string;
  56715. };
  56716. }
  56717. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance" {
  56718. /** @hidden */
  56719. export var pbrBlockReflectance: {
  56720. name: string;
  56721. shader: string;
  56722. };
  56723. }
  56724. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting" {
  56725. /** @hidden */
  56726. export var pbrBlockDirectLighting: {
  56727. name: string;
  56728. shader: string;
  56729. };
  56730. }
  56731. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents" {
  56732. /** @hidden */
  56733. export var pbrBlockFinalLitComponents: {
  56734. name: string;
  56735. shader: string;
  56736. };
  56737. }
  56738. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents" {
  56739. /** @hidden */
  56740. export var pbrBlockFinalUnlitComponents: {
  56741. name: string;
  56742. shader: string;
  56743. };
  56744. }
  56745. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition" {
  56746. /** @hidden */
  56747. export var pbrBlockFinalColorComposition: {
  56748. name: string;
  56749. shader: string;
  56750. };
  56751. }
  56752. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing" {
  56753. /** @hidden */
  56754. export var pbrBlockImageProcessing: {
  56755. name: string;
  56756. shader: string;
  56757. };
  56758. }
  56759. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  56760. /** @hidden */
  56761. export var pbrDebug: {
  56762. name: string;
  56763. shader: string;
  56764. };
  56765. }
  56766. declare module "babylonjs/Shaders/pbr.fragment" {
  56767. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  56768. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  56769. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  56770. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  56771. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  56772. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  56773. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  56774. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  56775. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  56776. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  56777. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56778. import "babylonjs/Shaders/ShadersInclude/importanceSampling";
  56779. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  56780. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  56781. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  56782. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  56783. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  56784. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  56785. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  56786. import "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions";
  56787. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  56788. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  56789. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  56790. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  56791. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  56792. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity";
  56793. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity";
  56794. import "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion";
  56795. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel";
  56796. import "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic";
  56797. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflection";
  56798. import "babylonjs/Shaders/ShadersInclude/pbrBlockSheen";
  56799. import "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat";
  56800. import "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface";
  56801. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  56802. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric";
  56803. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  56804. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal";
  56805. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  56806. import "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo";
  56807. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0";
  56808. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance";
  56809. import "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting";
  56810. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  56811. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents";
  56812. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents";
  56813. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition";
  56814. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  56815. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  56816. import "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing";
  56817. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  56818. /** @hidden */
  56819. export var pbrPixelShader: {
  56820. name: string;
  56821. shader: string;
  56822. };
  56823. }
  56824. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  56825. /** @hidden */
  56826. export var pbrVertexDeclaration: {
  56827. name: string;
  56828. shader: string;
  56829. };
  56830. }
  56831. declare module "babylonjs/Shaders/pbr.vertex" {
  56832. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  56833. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  56834. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56835. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  56836. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  56837. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  56838. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  56839. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  56840. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  56841. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  56842. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  56843. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  56844. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  56845. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  56846. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  56847. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  56848. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  56849. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  56850. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  56851. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  56852. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  56853. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  56854. /** @hidden */
  56855. export var pbrVertexShader: {
  56856. name: string;
  56857. shader: string;
  56858. };
  56859. }
  56860. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  56861. import { Nullable } from "babylonjs/types";
  56862. import { Scene } from "babylonjs/scene";
  56863. import { Matrix } from "babylonjs/Maths/math.vector";
  56864. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56865. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56866. import { Mesh } from "babylonjs/Meshes/mesh";
  56867. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  56868. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  56869. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  56870. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  56871. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  56872. import { Color3 } from "babylonjs/Maths/math.color";
  56873. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  56874. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  56875. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  56876. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  56877. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56878. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  56879. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  56880. import "babylonjs/Shaders/pbr.fragment";
  56881. import "babylonjs/Shaders/pbr.vertex";
  56882. /**
  56883. * Manages the defines for the PBR Material.
  56884. * @hidden
  56885. */
  56886. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  56887. PBR: boolean;
  56888. NUM_SAMPLES: string;
  56889. REALTIME_FILTERING: boolean;
  56890. MAINUV1: boolean;
  56891. MAINUV2: boolean;
  56892. UV1: boolean;
  56893. UV2: boolean;
  56894. ALBEDO: boolean;
  56895. GAMMAALBEDO: boolean;
  56896. ALBEDODIRECTUV: number;
  56897. VERTEXCOLOR: boolean;
  56898. AMBIENT: boolean;
  56899. AMBIENTDIRECTUV: number;
  56900. AMBIENTINGRAYSCALE: boolean;
  56901. OPACITY: boolean;
  56902. VERTEXALPHA: boolean;
  56903. OPACITYDIRECTUV: number;
  56904. OPACITYRGB: boolean;
  56905. ALPHATEST: boolean;
  56906. DEPTHPREPASS: boolean;
  56907. ALPHABLEND: boolean;
  56908. ALPHAFROMALBEDO: boolean;
  56909. ALPHATESTVALUE: string;
  56910. SPECULAROVERALPHA: boolean;
  56911. RADIANCEOVERALPHA: boolean;
  56912. ALPHAFRESNEL: boolean;
  56913. LINEARALPHAFRESNEL: boolean;
  56914. PREMULTIPLYALPHA: boolean;
  56915. EMISSIVE: boolean;
  56916. EMISSIVEDIRECTUV: number;
  56917. REFLECTIVITY: boolean;
  56918. REFLECTIVITYDIRECTUV: number;
  56919. SPECULARTERM: boolean;
  56920. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  56921. MICROSURFACEAUTOMATIC: boolean;
  56922. LODBASEDMICROSFURACE: boolean;
  56923. MICROSURFACEMAP: boolean;
  56924. MICROSURFACEMAPDIRECTUV: number;
  56925. METALLICWORKFLOW: boolean;
  56926. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  56927. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  56928. METALLNESSSTOREINMETALMAPBLUE: boolean;
  56929. AOSTOREINMETALMAPRED: boolean;
  56930. METALLIC_REFLECTANCE: boolean;
  56931. METALLIC_REFLECTANCEDIRECTUV: number;
  56932. ENVIRONMENTBRDF: boolean;
  56933. ENVIRONMENTBRDF_RGBD: boolean;
  56934. NORMAL: boolean;
  56935. TANGENT: boolean;
  56936. BUMP: boolean;
  56937. BUMPDIRECTUV: number;
  56938. OBJECTSPACE_NORMALMAP: boolean;
  56939. PARALLAX: boolean;
  56940. PARALLAXOCCLUSION: boolean;
  56941. NORMALXYSCALE: boolean;
  56942. LIGHTMAP: boolean;
  56943. LIGHTMAPDIRECTUV: number;
  56944. USELIGHTMAPASSHADOWMAP: boolean;
  56945. GAMMALIGHTMAP: boolean;
  56946. RGBDLIGHTMAP: boolean;
  56947. REFLECTION: boolean;
  56948. REFLECTIONMAP_3D: boolean;
  56949. REFLECTIONMAP_SPHERICAL: boolean;
  56950. REFLECTIONMAP_PLANAR: boolean;
  56951. REFLECTIONMAP_CUBIC: boolean;
  56952. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  56953. REFLECTIONMAP_PROJECTION: boolean;
  56954. REFLECTIONMAP_SKYBOX: boolean;
  56955. REFLECTIONMAP_EXPLICIT: boolean;
  56956. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  56957. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  56958. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  56959. INVERTCUBICMAP: boolean;
  56960. USESPHERICALFROMREFLECTIONMAP: boolean;
  56961. USEIRRADIANCEMAP: boolean;
  56962. SPHERICAL_HARMONICS: boolean;
  56963. USESPHERICALINVERTEX: boolean;
  56964. REFLECTIONMAP_OPPOSITEZ: boolean;
  56965. LODINREFLECTIONALPHA: boolean;
  56966. GAMMAREFLECTION: boolean;
  56967. RGBDREFLECTION: boolean;
  56968. LINEARSPECULARREFLECTION: boolean;
  56969. RADIANCEOCCLUSION: boolean;
  56970. HORIZONOCCLUSION: boolean;
  56971. INSTANCES: boolean;
  56972. NUM_BONE_INFLUENCERS: number;
  56973. BonesPerMesh: number;
  56974. BONETEXTURE: boolean;
  56975. NONUNIFORMSCALING: boolean;
  56976. MORPHTARGETS: boolean;
  56977. MORPHTARGETS_NORMAL: boolean;
  56978. MORPHTARGETS_TANGENT: boolean;
  56979. MORPHTARGETS_UV: boolean;
  56980. NUM_MORPH_INFLUENCERS: number;
  56981. IMAGEPROCESSING: boolean;
  56982. VIGNETTE: boolean;
  56983. VIGNETTEBLENDMODEMULTIPLY: boolean;
  56984. VIGNETTEBLENDMODEOPAQUE: boolean;
  56985. TONEMAPPING: boolean;
  56986. TONEMAPPING_ACES: boolean;
  56987. CONTRAST: boolean;
  56988. COLORCURVES: boolean;
  56989. COLORGRADING: boolean;
  56990. COLORGRADING3D: boolean;
  56991. SAMPLER3DGREENDEPTH: boolean;
  56992. SAMPLER3DBGRMAP: boolean;
  56993. IMAGEPROCESSINGPOSTPROCESS: boolean;
  56994. EXPOSURE: boolean;
  56995. MULTIVIEW: boolean;
  56996. USEPHYSICALLIGHTFALLOFF: boolean;
  56997. USEGLTFLIGHTFALLOFF: boolean;
  56998. TWOSIDEDLIGHTING: boolean;
  56999. SHADOWFLOAT: boolean;
  57000. CLIPPLANE: boolean;
  57001. CLIPPLANE2: boolean;
  57002. CLIPPLANE3: boolean;
  57003. CLIPPLANE4: boolean;
  57004. CLIPPLANE5: boolean;
  57005. CLIPPLANE6: boolean;
  57006. POINTSIZE: boolean;
  57007. FOG: boolean;
  57008. LOGARITHMICDEPTH: boolean;
  57009. FORCENORMALFORWARD: boolean;
  57010. SPECULARAA: boolean;
  57011. CLEARCOAT: boolean;
  57012. CLEARCOAT_DEFAULTIOR: boolean;
  57013. CLEARCOAT_TEXTURE: boolean;
  57014. CLEARCOAT_TEXTUREDIRECTUV: number;
  57015. CLEARCOAT_BUMP: boolean;
  57016. CLEARCOAT_BUMPDIRECTUV: number;
  57017. CLEARCOAT_TINT: boolean;
  57018. CLEARCOAT_TINT_TEXTURE: boolean;
  57019. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  57020. ANISOTROPIC: boolean;
  57021. ANISOTROPIC_TEXTURE: boolean;
  57022. ANISOTROPIC_TEXTUREDIRECTUV: number;
  57023. BRDF_V_HEIGHT_CORRELATED: boolean;
  57024. MS_BRDF_ENERGY_CONSERVATION: boolean;
  57025. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  57026. SHEEN: boolean;
  57027. SHEEN_TEXTURE: boolean;
  57028. SHEEN_TEXTUREDIRECTUV: number;
  57029. SHEEN_LINKWITHALBEDO: boolean;
  57030. SHEEN_ROUGHNESS: boolean;
  57031. SHEEN_ALBEDOSCALING: boolean;
  57032. SUBSURFACE: boolean;
  57033. SS_REFRACTION: boolean;
  57034. SS_TRANSLUCENCY: boolean;
  57035. SS_SCATERRING: boolean;
  57036. SS_THICKNESSANDMASK_TEXTURE: boolean;
  57037. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  57038. SS_REFRACTIONMAP_3D: boolean;
  57039. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  57040. SS_LODINREFRACTIONALPHA: boolean;
  57041. SS_GAMMAREFRACTION: boolean;
  57042. SS_RGBDREFRACTION: boolean;
  57043. SS_LINEARSPECULARREFRACTION: boolean;
  57044. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  57045. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  57046. UNLIT: boolean;
  57047. DEBUGMODE: number;
  57048. /**
  57049. * Initializes the PBR Material defines.
  57050. */
  57051. constructor();
  57052. /**
  57053. * Resets the PBR Material defines.
  57054. */
  57055. reset(): void;
  57056. }
  57057. /**
  57058. * The Physically based material base class of BJS.
  57059. *
  57060. * This offers the main features of a standard PBR material.
  57061. * For more information, please refer to the documentation :
  57062. * https://doc.babylonjs.com/how_to/physically_based_rendering
  57063. */
  57064. export abstract class PBRBaseMaterial extends PushMaterial {
  57065. /**
  57066. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  57067. */
  57068. static readonly PBRMATERIAL_OPAQUE: number;
  57069. /**
  57070. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  57071. */
  57072. static readonly PBRMATERIAL_ALPHATEST: number;
  57073. /**
  57074. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  57075. */
  57076. static readonly PBRMATERIAL_ALPHABLEND: number;
  57077. /**
  57078. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  57079. * They are also discarded below the alpha cutoff threshold to improve performances.
  57080. */
  57081. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  57082. /**
  57083. * Defines the default value of how much AO map is occluding the analytical lights
  57084. * (point spot...).
  57085. */
  57086. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  57087. /**
  57088. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  57089. */
  57090. static readonly LIGHTFALLOFF_PHYSICAL: number;
  57091. /**
  57092. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  57093. * to enhance interoperability with other engines.
  57094. */
  57095. static readonly LIGHTFALLOFF_GLTF: number;
  57096. /**
  57097. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  57098. * to enhance interoperability with other materials.
  57099. */
  57100. static readonly LIGHTFALLOFF_STANDARD: number;
  57101. /**
  57102. * Intensity of the direct lights e.g. the four lights available in your scene.
  57103. * This impacts both the direct diffuse and specular highlights.
  57104. */
  57105. protected _directIntensity: number;
  57106. /**
  57107. * Intensity of the emissive part of the material.
  57108. * This helps controlling the emissive effect without modifying the emissive color.
  57109. */
  57110. protected _emissiveIntensity: number;
  57111. /**
  57112. * Intensity of the environment e.g. how much the environment will light the object
  57113. * either through harmonics for rough material or through the refelction for shiny ones.
  57114. */
  57115. protected _environmentIntensity: number;
  57116. /**
  57117. * This is a special control allowing the reduction of the specular highlights coming from the
  57118. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  57119. */
  57120. protected _specularIntensity: number;
  57121. /**
  57122. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  57123. */
  57124. private _lightingInfos;
  57125. /**
  57126. * Debug Control allowing disabling the bump map on this material.
  57127. */
  57128. protected _disableBumpMap: boolean;
  57129. /**
  57130. * AKA Diffuse Texture in standard nomenclature.
  57131. */
  57132. protected _albedoTexture: Nullable<BaseTexture>;
  57133. /**
  57134. * AKA Occlusion Texture in other nomenclature.
  57135. */
  57136. protected _ambientTexture: Nullable<BaseTexture>;
  57137. /**
  57138. * AKA Occlusion Texture Intensity in other nomenclature.
  57139. */
  57140. protected _ambientTextureStrength: number;
  57141. /**
  57142. * Defines how much the AO map is occluding the analytical lights (point spot...).
  57143. * 1 means it completely occludes it
  57144. * 0 mean it has no impact
  57145. */
  57146. protected _ambientTextureImpactOnAnalyticalLights: number;
  57147. /**
  57148. * Stores the alpha values in a texture.
  57149. */
  57150. protected _opacityTexture: Nullable<BaseTexture>;
  57151. /**
  57152. * Stores the reflection values in a texture.
  57153. */
  57154. protected _reflectionTexture: Nullable<BaseTexture>;
  57155. /**
  57156. * Stores the emissive values in a texture.
  57157. */
  57158. protected _emissiveTexture: Nullable<BaseTexture>;
  57159. /**
  57160. * AKA Specular texture in other nomenclature.
  57161. */
  57162. protected _reflectivityTexture: Nullable<BaseTexture>;
  57163. /**
  57164. * Used to switch from specular/glossiness to metallic/roughness workflow.
  57165. */
  57166. protected _metallicTexture: Nullable<BaseTexture>;
  57167. /**
  57168. * Specifies the metallic scalar of the metallic/roughness workflow.
  57169. * Can also be used to scale the metalness values of the metallic texture.
  57170. */
  57171. protected _metallic: Nullable<number>;
  57172. /**
  57173. * Specifies the roughness scalar of the metallic/roughness workflow.
  57174. * Can also be used to scale the roughness values of the metallic texture.
  57175. */
  57176. protected _roughness: Nullable<number>;
  57177. /**
  57178. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  57179. * By default the indexOfrefraction is used to compute F0;
  57180. *
  57181. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  57182. *
  57183. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  57184. * F90 = metallicReflectanceColor;
  57185. */
  57186. protected _metallicF0Factor: number;
  57187. /**
  57188. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  57189. * By default the F90 is always 1;
  57190. *
  57191. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  57192. *
  57193. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  57194. * F90 = metallicReflectanceColor;
  57195. */
  57196. protected _metallicReflectanceColor: Color3;
  57197. /**
  57198. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  57199. * This is multiply against the scalar values defined in the material.
  57200. */
  57201. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  57202. /**
  57203. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  57204. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  57205. */
  57206. protected _microSurfaceTexture: Nullable<BaseTexture>;
  57207. /**
  57208. * Stores surface normal data used to displace a mesh in a texture.
  57209. */
  57210. protected _bumpTexture: Nullable<BaseTexture>;
  57211. /**
  57212. * Stores the pre-calculated light information of a mesh in a texture.
  57213. */
  57214. protected _lightmapTexture: Nullable<BaseTexture>;
  57215. /**
  57216. * The color of a material in ambient lighting.
  57217. */
  57218. protected _ambientColor: Color3;
  57219. /**
  57220. * AKA Diffuse Color in other nomenclature.
  57221. */
  57222. protected _albedoColor: Color3;
  57223. /**
  57224. * AKA Specular Color in other nomenclature.
  57225. */
  57226. protected _reflectivityColor: Color3;
  57227. /**
  57228. * The color applied when light is reflected from a material.
  57229. */
  57230. protected _reflectionColor: Color3;
  57231. /**
  57232. * The color applied when light is emitted from a material.
  57233. */
  57234. protected _emissiveColor: Color3;
  57235. /**
  57236. * AKA Glossiness in other nomenclature.
  57237. */
  57238. protected _microSurface: number;
  57239. /**
  57240. * Specifies that the material will use the light map as a show map.
  57241. */
  57242. protected _useLightmapAsShadowmap: boolean;
  57243. /**
  57244. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  57245. * makes the reflect vector face the model (under horizon).
  57246. */
  57247. protected _useHorizonOcclusion: boolean;
  57248. /**
  57249. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  57250. * too much the area relying on ambient texture to define their ambient occlusion.
  57251. */
  57252. protected _useRadianceOcclusion: boolean;
  57253. /**
  57254. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  57255. */
  57256. protected _useAlphaFromAlbedoTexture: boolean;
  57257. /**
  57258. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  57259. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  57260. */
  57261. protected _useSpecularOverAlpha: boolean;
  57262. /**
  57263. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  57264. */
  57265. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  57266. /**
  57267. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  57268. */
  57269. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  57270. /**
  57271. * Specifies if the metallic texture contains the roughness information in its green channel.
  57272. */
  57273. protected _useRoughnessFromMetallicTextureGreen: boolean;
  57274. /**
  57275. * Specifies if the metallic texture contains the metallness information in its blue channel.
  57276. */
  57277. protected _useMetallnessFromMetallicTextureBlue: boolean;
  57278. /**
  57279. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  57280. */
  57281. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  57282. /**
  57283. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  57284. */
  57285. protected _useAmbientInGrayScale: boolean;
  57286. /**
  57287. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  57288. * The material will try to infer what glossiness each pixel should be.
  57289. */
  57290. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  57291. /**
  57292. * Defines the falloff type used in this material.
  57293. * It by default is Physical.
  57294. */
  57295. protected _lightFalloff: number;
  57296. /**
  57297. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  57298. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  57299. */
  57300. protected _useRadianceOverAlpha: boolean;
  57301. /**
  57302. * Allows using an object space normal map (instead of tangent space).
  57303. */
  57304. protected _useObjectSpaceNormalMap: boolean;
  57305. /**
  57306. * Allows using the bump map in parallax mode.
  57307. */
  57308. protected _useParallax: boolean;
  57309. /**
  57310. * Allows using the bump map in parallax occlusion mode.
  57311. */
  57312. protected _useParallaxOcclusion: boolean;
  57313. /**
  57314. * Controls the scale bias of the parallax mode.
  57315. */
  57316. protected _parallaxScaleBias: number;
  57317. /**
  57318. * If sets to true, disables all the lights affecting the material.
  57319. */
  57320. protected _disableLighting: boolean;
  57321. /**
  57322. * Number of Simultaneous lights allowed on the material.
  57323. */
  57324. protected _maxSimultaneousLights: number;
  57325. /**
  57326. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  57327. */
  57328. protected _invertNormalMapX: boolean;
  57329. /**
  57330. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  57331. */
  57332. protected _invertNormalMapY: boolean;
  57333. /**
  57334. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  57335. */
  57336. protected _twoSidedLighting: boolean;
  57337. /**
  57338. * Defines the alpha limits in alpha test mode.
  57339. */
  57340. protected _alphaCutOff: number;
  57341. /**
  57342. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  57343. */
  57344. protected _forceAlphaTest: boolean;
  57345. /**
  57346. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  57347. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  57348. */
  57349. protected _useAlphaFresnel: boolean;
  57350. /**
  57351. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  57352. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  57353. */
  57354. protected _useLinearAlphaFresnel: boolean;
  57355. /**
  57356. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  57357. * from cos thetav and roughness:
  57358. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  57359. */
  57360. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  57361. /**
  57362. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  57363. */
  57364. protected _forceIrradianceInFragment: boolean;
  57365. private _realTimeFiltering;
  57366. /**
  57367. * Enables realtime filtering on the texture.
  57368. */
  57369. get realTimeFiltering(): boolean;
  57370. set realTimeFiltering(b: boolean);
  57371. private _realTimeFilteringQuality;
  57372. /**
  57373. * Quality switch for realtime filtering
  57374. */
  57375. get realTimeFilteringQuality(): number;
  57376. set realTimeFilteringQuality(n: number);
  57377. /**
  57378. * Force normal to face away from face.
  57379. */
  57380. protected _forceNormalForward: boolean;
  57381. /**
  57382. * Enables specular anti aliasing in the PBR shader.
  57383. * It will both interacts on the Geometry for analytical and IBL lighting.
  57384. * It also prefilter the roughness map based on the bump values.
  57385. */
  57386. protected _enableSpecularAntiAliasing: boolean;
  57387. /**
  57388. * Default configuration related to image processing available in the PBR Material.
  57389. */
  57390. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  57391. /**
  57392. * Keep track of the image processing observer to allow dispose and replace.
  57393. */
  57394. private _imageProcessingObserver;
  57395. /**
  57396. * Attaches a new image processing configuration to the PBR Material.
  57397. * @param configuration
  57398. */
  57399. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  57400. /**
  57401. * Stores the available render targets.
  57402. */
  57403. private _renderTargets;
  57404. /**
  57405. * Sets the global ambient color for the material used in lighting calculations.
  57406. */
  57407. private _globalAmbientColor;
  57408. /**
  57409. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  57410. */
  57411. private _useLogarithmicDepth;
  57412. /**
  57413. * If set to true, no lighting calculations will be applied.
  57414. */
  57415. private _unlit;
  57416. private _debugMode;
  57417. /**
  57418. * @hidden
  57419. * This is reserved for the inspector.
  57420. * Defines the material debug mode.
  57421. * It helps seeing only some components of the material while troubleshooting.
  57422. */
  57423. debugMode: number;
  57424. /**
  57425. * @hidden
  57426. * This is reserved for the inspector.
  57427. * Specify from where on screen the debug mode should start.
  57428. * The value goes from -1 (full screen) to 1 (not visible)
  57429. * It helps with side by side comparison against the final render
  57430. * This defaults to -1
  57431. */
  57432. private debugLimit;
  57433. /**
  57434. * @hidden
  57435. * This is reserved for the inspector.
  57436. * As the default viewing range might not be enough (if the ambient is really small for instance)
  57437. * You can use the factor to better multiply the final value.
  57438. */
  57439. private debugFactor;
  57440. /**
  57441. * Defines the clear coat layer parameters for the material.
  57442. */
  57443. readonly clearCoat: PBRClearCoatConfiguration;
  57444. /**
  57445. * Defines the anisotropic parameters for the material.
  57446. */
  57447. readonly anisotropy: PBRAnisotropicConfiguration;
  57448. /**
  57449. * Defines the BRDF parameters for the material.
  57450. */
  57451. readonly brdf: PBRBRDFConfiguration;
  57452. /**
  57453. * Defines the Sheen parameters for the material.
  57454. */
  57455. readonly sheen: PBRSheenConfiguration;
  57456. /**
  57457. * Defines the SubSurface parameters for the material.
  57458. */
  57459. readonly subSurface: PBRSubSurfaceConfiguration;
  57460. protected _rebuildInParallel: boolean;
  57461. /**
  57462. * Instantiates a new PBRMaterial instance.
  57463. *
  57464. * @param name The material name
  57465. * @param scene The scene the material will be use in.
  57466. */
  57467. constructor(name: string, scene: Scene);
  57468. /**
  57469. * Gets a boolean indicating that current material needs to register RTT
  57470. */
  57471. get hasRenderTargetTextures(): boolean;
  57472. /**
  57473. * Gets the name of the material class.
  57474. */
  57475. getClassName(): string;
  57476. /**
  57477. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  57478. */
  57479. get useLogarithmicDepth(): boolean;
  57480. /**
  57481. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  57482. */
  57483. set useLogarithmicDepth(value: boolean);
  57484. /**
  57485. * Returns true if alpha blending should be disabled.
  57486. */
  57487. protected get _disableAlphaBlending(): boolean;
  57488. /**
  57489. * Specifies whether or not this material should be rendered in alpha blend mode.
  57490. */
  57491. needAlphaBlending(): boolean;
  57492. /**
  57493. * Specifies whether or not this material should be rendered in alpha test mode.
  57494. */
  57495. needAlphaTesting(): boolean;
  57496. /**
  57497. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  57498. */
  57499. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  57500. /**
  57501. * Gets the texture used for the alpha test.
  57502. */
  57503. getAlphaTestTexture(): Nullable<BaseTexture>;
  57504. /**
  57505. * Specifies that the submesh is ready to be used.
  57506. * @param mesh - BJS mesh.
  57507. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  57508. * @param useInstances - Specifies that instances should be used.
  57509. * @returns - boolean indicating that the submesh is ready or not.
  57510. */
  57511. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  57512. /**
  57513. * Specifies if the material uses metallic roughness workflow.
  57514. * @returns boolean specifiying if the material uses metallic roughness workflow.
  57515. */
  57516. isMetallicWorkflow(): boolean;
  57517. private _prepareEffect;
  57518. private _prepareDefines;
  57519. /**
  57520. * Force shader compilation
  57521. */
  57522. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  57523. /**
  57524. * Initializes the uniform buffer layout for the shader.
  57525. */
  57526. buildUniformLayout(): void;
  57527. /**
  57528. * Unbinds the material from the mesh
  57529. */
  57530. unbind(): void;
  57531. /**
  57532. * Binds the submesh data.
  57533. * @param world - The world matrix.
  57534. * @param mesh - The BJS mesh.
  57535. * @param subMesh - A submesh of the BJS mesh.
  57536. */
  57537. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  57538. /**
  57539. * Returns the animatable textures.
  57540. * @returns - Array of animatable textures.
  57541. */
  57542. getAnimatables(): IAnimatable[];
  57543. /**
  57544. * Returns the texture used for reflections.
  57545. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  57546. */
  57547. private _getReflectionTexture;
  57548. /**
  57549. * Returns an array of the actively used textures.
  57550. * @returns - Array of BaseTextures
  57551. */
  57552. getActiveTextures(): BaseTexture[];
  57553. /**
  57554. * Checks to see if a texture is used in the material.
  57555. * @param texture - Base texture to use.
  57556. * @returns - Boolean specifying if a texture is used in the material.
  57557. */
  57558. hasTexture(texture: BaseTexture): boolean;
  57559. /**
  57560. * Disposes the resources of the material.
  57561. * @param forceDisposeEffect - Forces the disposal of effects.
  57562. * @param forceDisposeTextures - Forces the disposal of all textures.
  57563. */
  57564. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  57565. }
  57566. }
  57567. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  57568. import { Nullable } from "babylonjs/types";
  57569. import { Scene } from "babylonjs/scene";
  57570. import { Color3 } from "babylonjs/Maths/math.color";
  57571. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  57572. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  57573. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57574. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  57575. /**
  57576. * The Physically based material of BJS.
  57577. *
  57578. * This offers the main features of a standard PBR material.
  57579. * For more information, please refer to the documentation :
  57580. * https://doc.babylonjs.com/how_to/physically_based_rendering
  57581. */
  57582. export class PBRMaterial extends PBRBaseMaterial {
  57583. /**
  57584. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  57585. */
  57586. static readonly PBRMATERIAL_OPAQUE: number;
  57587. /**
  57588. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  57589. */
  57590. static readonly PBRMATERIAL_ALPHATEST: number;
  57591. /**
  57592. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  57593. */
  57594. static readonly PBRMATERIAL_ALPHABLEND: number;
  57595. /**
  57596. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  57597. * They are also discarded below the alpha cutoff threshold to improve performances.
  57598. */
  57599. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  57600. /**
  57601. * Defines the default value of how much AO map is occluding the analytical lights
  57602. * (point spot...).
  57603. */
  57604. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  57605. /**
  57606. * Intensity of the direct lights e.g. the four lights available in your scene.
  57607. * This impacts both the direct diffuse and specular highlights.
  57608. */
  57609. directIntensity: number;
  57610. /**
  57611. * Intensity of the emissive part of the material.
  57612. * This helps controlling the emissive effect without modifying the emissive color.
  57613. */
  57614. emissiveIntensity: number;
  57615. /**
  57616. * Intensity of the environment e.g. how much the environment will light the object
  57617. * either through harmonics for rough material or through the refelction for shiny ones.
  57618. */
  57619. environmentIntensity: number;
  57620. /**
  57621. * This is a special control allowing the reduction of the specular highlights coming from the
  57622. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  57623. */
  57624. specularIntensity: number;
  57625. /**
  57626. * Debug Control allowing disabling the bump map on this material.
  57627. */
  57628. disableBumpMap: boolean;
  57629. /**
  57630. * AKA Diffuse Texture in standard nomenclature.
  57631. */
  57632. albedoTexture: BaseTexture;
  57633. /**
  57634. * AKA Occlusion Texture in other nomenclature.
  57635. */
  57636. ambientTexture: BaseTexture;
  57637. /**
  57638. * AKA Occlusion Texture Intensity in other nomenclature.
  57639. */
  57640. ambientTextureStrength: number;
  57641. /**
  57642. * Defines how much the AO map is occluding the analytical lights (point spot...).
  57643. * 1 means it completely occludes it
  57644. * 0 mean it has no impact
  57645. */
  57646. ambientTextureImpactOnAnalyticalLights: number;
  57647. /**
  57648. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  57649. */
  57650. opacityTexture: BaseTexture;
  57651. /**
  57652. * Stores the reflection values in a texture.
  57653. */
  57654. reflectionTexture: Nullable<BaseTexture>;
  57655. /**
  57656. * Stores the emissive values in a texture.
  57657. */
  57658. emissiveTexture: BaseTexture;
  57659. /**
  57660. * AKA Specular texture in other nomenclature.
  57661. */
  57662. reflectivityTexture: BaseTexture;
  57663. /**
  57664. * Used to switch from specular/glossiness to metallic/roughness workflow.
  57665. */
  57666. metallicTexture: BaseTexture;
  57667. /**
  57668. * Specifies the metallic scalar of the metallic/roughness workflow.
  57669. * Can also be used to scale the metalness values of the metallic texture.
  57670. */
  57671. metallic: Nullable<number>;
  57672. /**
  57673. * Specifies the roughness scalar of the metallic/roughness workflow.
  57674. * Can also be used to scale the roughness values of the metallic texture.
  57675. */
  57676. roughness: Nullable<number>;
  57677. /**
  57678. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  57679. * By default the indexOfrefraction is used to compute F0;
  57680. *
  57681. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  57682. *
  57683. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  57684. * F90 = metallicReflectanceColor;
  57685. */
  57686. metallicF0Factor: number;
  57687. /**
  57688. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  57689. * By default the F90 is always 1;
  57690. *
  57691. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  57692. *
  57693. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  57694. * F90 = metallicReflectanceColor;
  57695. */
  57696. metallicReflectanceColor: Color3;
  57697. /**
  57698. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  57699. * This is multiply against the scalar values defined in the material.
  57700. */
  57701. metallicReflectanceTexture: Nullable<BaseTexture>;
  57702. /**
  57703. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  57704. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  57705. */
  57706. microSurfaceTexture: BaseTexture;
  57707. /**
  57708. * Stores surface normal data used to displace a mesh in a texture.
  57709. */
  57710. bumpTexture: BaseTexture;
  57711. /**
  57712. * Stores the pre-calculated light information of a mesh in a texture.
  57713. */
  57714. lightmapTexture: BaseTexture;
  57715. /**
  57716. * Stores the refracted light information in a texture.
  57717. */
  57718. get refractionTexture(): Nullable<BaseTexture>;
  57719. set refractionTexture(value: Nullable<BaseTexture>);
  57720. /**
  57721. * The color of a material in ambient lighting.
  57722. */
  57723. ambientColor: Color3;
  57724. /**
  57725. * AKA Diffuse Color in other nomenclature.
  57726. */
  57727. albedoColor: Color3;
  57728. /**
  57729. * AKA Specular Color in other nomenclature.
  57730. */
  57731. reflectivityColor: Color3;
  57732. /**
  57733. * The color reflected from the material.
  57734. */
  57735. reflectionColor: Color3;
  57736. /**
  57737. * The color emitted from the material.
  57738. */
  57739. emissiveColor: Color3;
  57740. /**
  57741. * AKA Glossiness in other nomenclature.
  57742. */
  57743. microSurface: number;
  57744. /**
  57745. * Index of refraction of the material base layer.
  57746. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  57747. *
  57748. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  57749. *
  57750. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  57751. */
  57752. get indexOfRefraction(): number;
  57753. set indexOfRefraction(value: number);
  57754. /**
  57755. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  57756. */
  57757. get invertRefractionY(): boolean;
  57758. set invertRefractionY(value: boolean);
  57759. /**
  57760. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  57761. * Materials half opaque for instance using refraction could benefit from this control.
  57762. */
  57763. get linkRefractionWithTransparency(): boolean;
  57764. set linkRefractionWithTransparency(value: boolean);
  57765. /**
  57766. * If true, the light map contains occlusion information instead of lighting info.
  57767. */
  57768. useLightmapAsShadowmap: boolean;
  57769. /**
  57770. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  57771. */
  57772. useAlphaFromAlbedoTexture: boolean;
  57773. /**
  57774. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  57775. */
  57776. forceAlphaTest: boolean;
  57777. /**
  57778. * Defines the alpha limits in alpha test mode.
  57779. */
  57780. alphaCutOff: number;
  57781. /**
  57782. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  57783. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  57784. */
  57785. useSpecularOverAlpha: boolean;
  57786. /**
  57787. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  57788. */
  57789. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  57790. /**
  57791. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  57792. */
  57793. useRoughnessFromMetallicTextureAlpha: boolean;
  57794. /**
  57795. * Specifies if the metallic texture contains the roughness information in its green channel.
  57796. */
  57797. useRoughnessFromMetallicTextureGreen: boolean;
  57798. /**
  57799. * Specifies if the metallic texture contains the metallness information in its blue channel.
  57800. */
  57801. useMetallnessFromMetallicTextureBlue: boolean;
  57802. /**
  57803. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  57804. */
  57805. useAmbientOcclusionFromMetallicTextureRed: boolean;
  57806. /**
  57807. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  57808. */
  57809. useAmbientInGrayScale: boolean;
  57810. /**
  57811. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  57812. * The material will try to infer what glossiness each pixel should be.
  57813. */
  57814. useAutoMicroSurfaceFromReflectivityMap: boolean;
  57815. /**
  57816. * BJS is using an harcoded light falloff based on a manually sets up range.
  57817. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  57818. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  57819. */
  57820. get usePhysicalLightFalloff(): boolean;
  57821. /**
  57822. * BJS is using an harcoded light falloff based on a manually sets up range.
  57823. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  57824. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  57825. */
  57826. set usePhysicalLightFalloff(value: boolean);
  57827. /**
  57828. * In order to support the falloff compatibility with gltf, a special mode has been added
  57829. * to reproduce the gltf light falloff.
  57830. */
  57831. get useGLTFLightFalloff(): boolean;
  57832. /**
  57833. * In order to support the falloff compatibility with gltf, a special mode has been added
  57834. * to reproduce the gltf light falloff.
  57835. */
  57836. set useGLTFLightFalloff(value: boolean);
  57837. /**
  57838. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  57839. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  57840. */
  57841. useRadianceOverAlpha: boolean;
  57842. /**
  57843. * Allows using an object space normal map (instead of tangent space).
  57844. */
  57845. useObjectSpaceNormalMap: boolean;
  57846. /**
  57847. * Allows using the bump map in parallax mode.
  57848. */
  57849. useParallax: boolean;
  57850. /**
  57851. * Allows using the bump map in parallax occlusion mode.
  57852. */
  57853. useParallaxOcclusion: boolean;
  57854. /**
  57855. * Controls the scale bias of the parallax mode.
  57856. */
  57857. parallaxScaleBias: number;
  57858. /**
  57859. * If sets to true, disables all the lights affecting the material.
  57860. */
  57861. disableLighting: boolean;
  57862. /**
  57863. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  57864. */
  57865. forceIrradianceInFragment: boolean;
  57866. /**
  57867. * Number of Simultaneous lights allowed on the material.
  57868. */
  57869. maxSimultaneousLights: number;
  57870. /**
  57871. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  57872. */
  57873. invertNormalMapX: boolean;
  57874. /**
  57875. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  57876. */
  57877. invertNormalMapY: boolean;
  57878. /**
  57879. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  57880. */
  57881. twoSidedLighting: boolean;
  57882. /**
  57883. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  57884. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  57885. */
  57886. useAlphaFresnel: boolean;
  57887. /**
  57888. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  57889. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  57890. */
  57891. useLinearAlphaFresnel: boolean;
  57892. /**
  57893. * Let user defines the brdf lookup texture used for IBL.
  57894. * A default 8bit version is embedded but you could point at :
  57895. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  57896. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  57897. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  57898. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  57899. */
  57900. environmentBRDFTexture: Nullable<BaseTexture>;
  57901. /**
  57902. * Force normal to face away from face.
  57903. */
  57904. forceNormalForward: boolean;
  57905. /**
  57906. * Enables specular anti aliasing in the PBR shader.
  57907. * It will both interacts on the Geometry for analytical and IBL lighting.
  57908. * It also prefilter the roughness map based on the bump values.
  57909. */
  57910. enableSpecularAntiAliasing: boolean;
  57911. /**
  57912. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  57913. * makes the reflect vector face the model (under horizon).
  57914. */
  57915. useHorizonOcclusion: boolean;
  57916. /**
  57917. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  57918. * too much the area relying on ambient texture to define their ambient occlusion.
  57919. */
  57920. useRadianceOcclusion: boolean;
  57921. /**
  57922. * If set to true, no lighting calculations will be applied.
  57923. */
  57924. unlit: boolean;
  57925. /**
  57926. * Gets the image processing configuration used either in this material.
  57927. */
  57928. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  57929. /**
  57930. * Sets the Default image processing configuration used either in the this material.
  57931. *
  57932. * If sets to null, the scene one is in use.
  57933. */
  57934. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  57935. /**
  57936. * Gets wether the color curves effect is enabled.
  57937. */
  57938. get cameraColorCurvesEnabled(): boolean;
  57939. /**
  57940. * Sets wether the color curves effect is enabled.
  57941. */
  57942. set cameraColorCurvesEnabled(value: boolean);
  57943. /**
  57944. * Gets wether the color grading effect is enabled.
  57945. */
  57946. get cameraColorGradingEnabled(): boolean;
  57947. /**
  57948. * Gets wether the color grading effect is enabled.
  57949. */
  57950. set cameraColorGradingEnabled(value: boolean);
  57951. /**
  57952. * Gets wether tonemapping is enabled or not.
  57953. */
  57954. get cameraToneMappingEnabled(): boolean;
  57955. /**
  57956. * Sets wether tonemapping is enabled or not
  57957. */
  57958. set cameraToneMappingEnabled(value: boolean);
  57959. /**
  57960. * The camera exposure used on this material.
  57961. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  57962. * This corresponds to a photographic exposure.
  57963. */
  57964. get cameraExposure(): number;
  57965. /**
  57966. * The camera exposure used on this material.
  57967. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  57968. * This corresponds to a photographic exposure.
  57969. */
  57970. set cameraExposure(value: number);
  57971. /**
  57972. * Gets The camera contrast used on this material.
  57973. */
  57974. get cameraContrast(): number;
  57975. /**
  57976. * Sets The camera contrast used on this material.
  57977. */
  57978. set cameraContrast(value: number);
  57979. /**
  57980. * Gets the Color Grading 2D Lookup Texture.
  57981. */
  57982. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  57983. /**
  57984. * Sets the Color Grading 2D Lookup Texture.
  57985. */
  57986. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  57987. /**
  57988. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  57989. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  57990. * 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;
  57991. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  57992. */
  57993. get cameraColorCurves(): Nullable<ColorCurves>;
  57994. /**
  57995. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  57996. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  57997. * 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;
  57998. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  57999. */
  58000. set cameraColorCurves(value: Nullable<ColorCurves>);
  58001. /**
  58002. * Instantiates a new PBRMaterial instance.
  58003. *
  58004. * @param name The material name
  58005. * @param scene The scene the material will be use in.
  58006. */
  58007. constructor(name: string, scene: Scene);
  58008. /**
  58009. * Returns the name of this material class.
  58010. */
  58011. getClassName(): string;
  58012. /**
  58013. * Makes a duplicate of the current material.
  58014. * @param name - name to use for the new material.
  58015. */
  58016. clone(name: string): PBRMaterial;
  58017. /**
  58018. * Serializes this PBR Material.
  58019. * @returns - An object with the serialized material.
  58020. */
  58021. serialize(): any;
  58022. /**
  58023. * Parses a PBR Material from a serialized object.
  58024. * @param source - Serialized object.
  58025. * @param scene - BJS scene instance.
  58026. * @param rootUrl - url for the scene object
  58027. * @returns - PBRMaterial
  58028. */
  58029. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  58030. }
  58031. }
  58032. declare module "babylonjs/Misc/dds" {
  58033. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  58034. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58035. import { Nullable } from "babylonjs/types";
  58036. import { Scene } from "babylonjs/scene";
  58037. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  58038. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  58039. /**
  58040. * Direct draw surface info
  58041. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  58042. */
  58043. export interface DDSInfo {
  58044. /**
  58045. * Width of the texture
  58046. */
  58047. width: number;
  58048. /**
  58049. * Width of the texture
  58050. */
  58051. height: number;
  58052. /**
  58053. * Number of Mipmaps for the texture
  58054. * @see https://en.wikipedia.org/wiki/Mipmap
  58055. */
  58056. mipmapCount: number;
  58057. /**
  58058. * If the textures format is a known fourCC format
  58059. * @see https://www.fourcc.org/
  58060. */
  58061. isFourCC: boolean;
  58062. /**
  58063. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  58064. */
  58065. isRGB: boolean;
  58066. /**
  58067. * If the texture is a lumincance format
  58068. */
  58069. isLuminance: boolean;
  58070. /**
  58071. * If this is a cube texture
  58072. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  58073. */
  58074. isCube: boolean;
  58075. /**
  58076. * If the texture is a compressed format eg. FOURCC_DXT1
  58077. */
  58078. isCompressed: boolean;
  58079. /**
  58080. * The dxgiFormat of the texture
  58081. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  58082. */
  58083. dxgiFormat: number;
  58084. /**
  58085. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  58086. */
  58087. textureType: number;
  58088. /**
  58089. * Sphericle polynomial created for the dds texture
  58090. */
  58091. sphericalPolynomial?: SphericalPolynomial;
  58092. }
  58093. /**
  58094. * Class used to provide DDS decompression tools
  58095. */
  58096. export class DDSTools {
  58097. /**
  58098. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  58099. */
  58100. static StoreLODInAlphaChannel: boolean;
  58101. /**
  58102. * Gets DDS information from an array buffer
  58103. * @param data defines the array buffer view to read data from
  58104. * @returns the DDS information
  58105. */
  58106. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  58107. private static _FloatView;
  58108. private static _Int32View;
  58109. private static _ToHalfFloat;
  58110. private static _FromHalfFloat;
  58111. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  58112. private static _GetHalfFloatRGBAArrayBuffer;
  58113. private static _GetFloatRGBAArrayBuffer;
  58114. private static _GetFloatAsUIntRGBAArrayBuffer;
  58115. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  58116. private static _GetRGBAArrayBuffer;
  58117. private static _ExtractLongWordOrder;
  58118. private static _GetRGBArrayBuffer;
  58119. private static _GetLuminanceArrayBuffer;
  58120. /**
  58121. * Uploads DDS Levels to a Babylon Texture
  58122. * @hidden
  58123. */
  58124. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  58125. }
  58126. module "babylonjs/Engines/thinEngine" {
  58127. interface ThinEngine {
  58128. /**
  58129. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  58130. * @param rootUrl defines the url where the file to load is located
  58131. * @param scene defines the current scene
  58132. * @param lodScale defines scale to apply to the mip map selection
  58133. * @param lodOffset defines offset to apply to the mip map selection
  58134. * @param onLoad defines an optional callback raised when the texture is loaded
  58135. * @param onError defines an optional callback raised if there is an issue to load the texture
  58136. * @param format defines the format of the data
  58137. * @param forcedExtension defines the extension to use to pick the right loader
  58138. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  58139. * @returns the cube texture as an InternalTexture
  58140. */
  58141. 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;
  58142. }
  58143. }
  58144. }
  58145. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  58146. import { Nullable } from "babylonjs/types";
  58147. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58148. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  58149. /**
  58150. * Implementation of the DDS Texture Loader.
  58151. * @hidden
  58152. */
  58153. export class _DDSTextureLoader implements IInternalTextureLoader {
  58154. /**
  58155. * Defines wether the loader supports cascade loading the different faces.
  58156. */
  58157. readonly supportCascades: boolean;
  58158. /**
  58159. * This returns if the loader support the current file information.
  58160. * @param extension defines the file extension of the file being loaded
  58161. * @returns true if the loader can load the specified file
  58162. */
  58163. canLoad(extension: string): boolean;
  58164. /**
  58165. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  58166. * @param data contains the texture data
  58167. * @param texture defines the BabylonJS internal texture
  58168. * @param createPolynomials will be true if polynomials have been requested
  58169. * @param onLoad defines the callback to trigger once the texture is ready
  58170. * @param onError defines the callback to trigger in case of error
  58171. */
  58172. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58173. /**
  58174. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  58175. * @param data contains the texture data
  58176. * @param texture defines the BabylonJS internal texture
  58177. * @param callback defines the method to call once ready to upload
  58178. */
  58179. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  58180. }
  58181. }
  58182. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  58183. import { Nullable } from "babylonjs/types";
  58184. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58185. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  58186. /**
  58187. * Implementation of the ENV Texture Loader.
  58188. * @hidden
  58189. */
  58190. export class _ENVTextureLoader implements IInternalTextureLoader {
  58191. /**
  58192. * Defines wether the loader supports cascade loading the different faces.
  58193. */
  58194. readonly supportCascades: boolean;
  58195. /**
  58196. * This returns if the loader support the current file information.
  58197. * @param extension defines the file extension of the file being loaded
  58198. * @returns true if the loader can load the specified file
  58199. */
  58200. canLoad(extension: string): boolean;
  58201. /**
  58202. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  58203. * @param data contains the texture data
  58204. * @param texture defines the BabylonJS internal texture
  58205. * @param createPolynomials will be true if polynomials have been requested
  58206. * @param onLoad defines the callback to trigger once the texture is ready
  58207. * @param onError defines the callback to trigger in case of error
  58208. */
  58209. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58210. /**
  58211. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  58212. * @param data contains the texture data
  58213. * @param texture defines the BabylonJS internal texture
  58214. * @param callback defines the method to call once ready to upload
  58215. */
  58216. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  58217. }
  58218. }
  58219. declare module "babylonjs/Misc/khronosTextureContainer" {
  58220. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58221. /**
  58222. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  58223. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  58224. */
  58225. export class KhronosTextureContainer {
  58226. /** contents of the KTX container file */
  58227. data: ArrayBufferView;
  58228. private static HEADER_LEN;
  58229. private static COMPRESSED_2D;
  58230. private static COMPRESSED_3D;
  58231. private static TEX_2D;
  58232. private static TEX_3D;
  58233. /**
  58234. * Gets the openGL type
  58235. */
  58236. glType: number;
  58237. /**
  58238. * Gets the openGL type size
  58239. */
  58240. glTypeSize: number;
  58241. /**
  58242. * Gets the openGL format
  58243. */
  58244. glFormat: number;
  58245. /**
  58246. * Gets the openGL internal format
  58247. */
  58248. glInternalFormat: number;
  58249. /**
  58250. * Gets the base internal format
  58251. */
  58252. glBaseInternalFormat: number;
  58253. /**
  58254. * Gets image width in pixel
  58255. */
  58256. pixelWidth: number;
  58257. /**
  58258. * Gets image height in pixel
  58259. */
  58260. pixelHeight: number;
  58261. /**
  58262. * Gets image depth in pixels
  58263. */
  58264. pixelDepth: number;
  58265. /**
  58266. * Gets the number of array elements
  58267. */
  58268. numberOfArrayElements: number;
  58269. /**
  58270. * Gets the number of faces
  58271. */
  58272. numberOfFaces: number;
  58273. /**
  58274. * Gets the number of mipmap levels
  58275. */
  58276. numberOfMipmapLevels: number;
  58277. /**
  58278. * Gets the bytes of key value data
  58279. */
  58280. bytesOfKeyValueData: number;
  58281. /**
  58282. * Gets the load type
  58283. */
  58284. loadType: number;
  58285. /**
  58286. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  58287. */
  58288. isInvalid: boolean;
  58289. /**
  58290. * Creates a new KhronosTextureContainer
  58291. * @param data contents of the KTX container file
  58292. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  58293. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  58294. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  58295. */
  58296. constructor(
  58297. /** contents of the KTX container file */
  58298. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  58299. /**
  58300. * Uploads KTX content to a Babylon Texture.
  58301. * It is assumed that the texture has already been created & is currently bound
  58302. * @hidden
  58303. */
  58304. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  58305. private _upload2DCompressedLevels;
  58306. /**
  58307. * Checks if the given data starts with a KTX file identifier.
  58308. * @param data the data to check
  58309. * @returns true if the data is a KTX file or false otherwise
  58310. */
  58311. static IsValid(data: ArrayBufferView): boolean;
  58312. }
  58313. }
  58314. declare module "babylonjs/Misc/khronosTextureContainer2" {
  58315. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58316. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  58317. /**
  58318. * Class for loading KTX2 files
  58319. * !!! Experimental Extension Subject to Changes !!!
  58320. * @hidden
  58321. */
  58322. export class KhronosTextureContainer2 {
  58323. private static _ModulePromise;
  58324. private static _TranscodeFormat;
  58325. constructor(engine: ThinEngine);
  58326. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  58327. private _determineTranscodeFormat;
  58328. /**
  58329. * Checks if the given data starts with a KTX2 file identifier.
  58330. * @param data the data to check
  58331. * @returns true if the data is a KTX2 file or false otherwise
  58332. */
  58333. static IsValid(data: ArrayBufferView): boolean;
  58334. }
  58335. }
  58336. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  58337. import { Nullable } from "babylonjs/types";
  58338. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58339. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  58340. /**
  58341. * Implementation of the KTX Texture Loader.
  58342. * @hidden
  58343. */
  58344. export class _KTXTextureLoader implements IInternalTextureLoader {
  58345. /**
  58346. * Defines wether the loader supports cascade loading the different faces.
  58347. */
  58348. readonly supportCascades: boolean;
  58349. /**
  58350. * This returns if the loader support the current file information.
  58351. * @param extension defines the file extension of the file being loaded
  58352. * @returns true if the loader can load the specified file
  58353. */
  58354. canLoad(extension: string): boolean;
  58355. /**
  58356. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  58357. * @param data contains the texture data
  58358. * @param texture defines the BabylonJS internal texture
  58359. * @param createPolynomials will be true if polynomials have been requested
  58360. * @param onLoad defines the callback to trigger once the texture is ready
  58361. * @param onError defines the callback to trigger in case of error
  58362. */
  58363. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58364. /**
  58365. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  58366. * @param data contains the texture data
  58367. * @param texture defines the BabylonJS internal texture
  58368. * @param callback defines the method to call once ready to upload
  58369. */
  58370. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  58371. }
  58372. }
  58373. declare module "babylonjs/Helpers/sceneHelpers" {
  58374. import { Nullable } from "babylonjs/types";
  58375. import { Mesh } from "babylonjs/Meshes/mesh";
  58376. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58377. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  58378. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  58379. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  58380. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  58381. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  58382. import "babylonjs/Meshes/Builders/boxBuilder";
  58383. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/XR/webXRDefaultExperience";
  58384. /** @hidden */
  58385. export var _forceSceneHelpersToBundle: boolean;
  58386. module "babylonjs/scene" {
  58387. interface Scene {
  58388. /**
  58389. * Creates a default light for the scene.
  58390. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  58391. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  58392. */
  58393. createDefaultLight(replace?: boolean): void;
  58394. /**
  58395. * Creates a default camera for the scene.
  58396. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  58397. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  58398. * @param replace has default false, when true replaces the active camera in the scene
  58399. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  58400. */
  58401. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  58402. /**
  58403. * Creates a default camera and a default light.
  58404. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  58405. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  58406. * @param replace has the default false, when true replaces the active camera/light in the scene
  58407. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  58408. */
  58409. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  58410. /**
  58411. * Creates a new sky box
  58412. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  58413. * @param environmentTexture defines the texture to use as environment texture
  58414. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  58415. * @param scale defines the overall scale of the skybox
  58416. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  58417. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  58418. * @returns a new mesh holding the sky box
  58419. */
  58420. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  58421. /**
  58422. * Creates a new environment
  58423. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  58424. * @param options defines the options you can use to configure the environment
  58425. * @returns the new EnvironmentHelper
  58426. */
  58427. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  58428. /**
  58429. * Creates a new VREXperienceHelper
  58430. * @see http://doc.babylonjs.com/how_to/webvr_helper
  58431. * @param webVROptions defines the options used to create the new VREXperienceHelper
  58432. * @returns a new VREXperienceHelper
  58433. */
  58434. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  58435. /**
  58436. * Creates a new WebXRDefaultExperience
  58437. * @see http://doc.babylonjs.com/how_to/webxr
  58438. * @param options experience options
  58439. * @returns a promise for a new WebXRDefaultExperience
  58440. */
  58441. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  58442. }
  58443. }
  58444. }
  58445. declare module "babylonjs/Helpers/videoDome" {
  58446. import { Scene } from "babylonjs/scene";
  58447. import { TransformNode } from "babylonjs/Meshes/transformNode";
  58448. import { Mesh } from "babylonjs/Meshes/mesh";
  58449. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  58450. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  58451. import "babylonjs/Meshes/Builders/sphereBuilder";
  58452. /**
  58453. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  58454. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  58455. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  58456. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  58457. */
  58458. export class VideoDome extends TransformNode {
  58459. /**
  58460. * Define the video source as a Monoscopic panoramic 360 video.
  58461. */
  58462. static readonly MODE_MONOSCOPIC: number;
  58463. /**
  58464. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  58465. */
  58466. static readonly MODE_TOPBOTTOM: number;
  58467. /**
  58468. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  58469. */
  58470. static readonly MODE_SIDEBYSIDE: number;
  58471. private _halfDome;
  58472. private _useDirectMapping;
  58473. /**
  58474. * The video texture being displayed on the sphere
  58475. */
  58476. protected _videoTexture: VideoTexture;
  58477. /**
  58478. * Gets the video texture being displayed on the sphere
  58479. */
  58480. get videoTexture(): VideoTexture;
  58481. /**
  58482. * The skybox material
  58483. */
  58484. protected _material: BackgroundMaterial;
  58485. /**
  58486. * The surface used for the skybox
  58487. */
  58488. protected _mesh: Mesh;
  58489. /**
  58490. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  58491. */
  58492. private _halfDomeMask;
  58493. /**
  58494. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  58495. * Also see the options.resolution property.
  58496. */
  58497. get fovMultiplier(): number;
  58498. set fovMultiplier(value: number);
  58499. private _videoMode;
  58500. /**
  58501. * Gets or set the current video mode for the video. It can be:
  58502. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  58503. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  58504. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  58505. */
  58506. get videoMode(): number;
  58507. set videoMode(value: number);
  58508. /**
  58509. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  58510. *
  58511. */
  58512. get halfDome(): boolean;
  58513. /**
  58514. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  58515. */
  58516. set halfDome(enabled: boolean);
  58517. /**
  58518. * Oberserver used in Stereoscopic VR Mode.
  58519. */
  58520. private _onBeforeCameraRenderObserver;
  58521. /**
  58522. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  58523. * @param name Element's name, child elements will append suffixes for their own names.
  58524. * @param urlsOrVideo defines the url(s) or the video element to use
  58525. * @param options An object containing optional or exposed sub element properties
  58526. */
  58527. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  58528. resolution?: number;
  58529. clickToPlay?: boolean;
  58530. autoPlay?: boolean;
  58531. loop?: boolean;
  58532. size?: number;
  58533. poster?: string;
  58534. faceForward?: boolean;
  58535. useDirectMapping?: boolean;
  58536. halfDomeMode?: boolean;
  58537. }, scene: Scene);
  58538. private _changeVideoMode;
  58539. /**
  58540. * Releases resources associated with this node.
  58541. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  58542. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  58543. */
  58544. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  58545. }
  58546. }
  58547. declare module "babylonjs/Helpers/index" {
  58548. export * from "babylonjs/Helpers/environmentHelper";
  58549. export * from "babylonjs/Helpers/photoDome";
  58550. export * from "babylonjs/Helpers/sceneHelpers";
  58551. export * from "babylonjs/Helpers/videoDome";
  58552. }
  58553. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  58554. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  58555. import { IDisposable } from "babylonjs/scene";
  58556. import { Engine } from "babylonjs/Engines/engine";
  58557. /**
  58558. * This class can be used to get instrumentation data from a Babylon engine
  58559. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  58560. */
  58561. export class EngineInstrumentation implements IDisposable {
  58562. /**
  58563. * Define the instrumented engine.
  58564. */
  58565. engine: Engine;
  58566. private _captureGPUFrameTime;
  58567. private _gpuFrameTimeToken;
  58568. private _gpuFrameTime;
  58569. private _captureShaderCompilationTime;
  58570. private _shaderCompilationTime;
  58571. private _onBeginFrameObserver;
  58572. private _onEndFrameObserver;
  58573. private _onBeforeShaderCompilationObserver;
  58574. private _onAfterShaderCompilationObserver;
  58575. /**
  58576. * Gets the perf counter used for GPU frame time
  58577. */
  58578. get gpuFrameTimeCounter(): PerfCounter;
  58579. /**
  58580. * Gets the GPU frame time capture status
  58581. */
  58582. get captureGPUFrameTime(): boolean;
  58583. /**
  58584. * Enable or disable the GPU frame time capture
  58585. */
  58586. set captureGPUFrameTime(value: boolean);
  58587. /**
  58588. * Gets the perf counter used for shader compilation time
  58589. */
  58590. get shaderCompilationTimeCounter(): PerfCounter;
  58591. /**
  58592. * Gets the shader compilation time capture status
  58593. */
  58594. get captureShaderCompilationTime(): boolean;
  58595. /**
  58596. * Enable or disable the shader compilation time capture
  58597. */
  58598. set captureShaderCompilationTime(value: boolean);
  58599. /**
  58600. * Instantiates a new engine instrumentation.
  58601. * This class can be used to get instrumentation data from a Babylon engine
  58602. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  58603. * @param engine Defines the engine to instrument
  58604. */
  58605. constructor(
  58606. /**
  58607. * Define the instrumented engine.
  58608. */
  58609. engine: Engine);
  58610. /**
  58611. * Dispose and release associated resources.
  58612. */
  58613. dispose(): void;
  58614. }
  58615. }
  58616. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  58617. import { Scene, IDisposable } from "babylonjs/scene";
  58618. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  58619. /**
  58620. * This class can be used to get instrumentation data from a Babylon engine
  58621. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  58622. */
  58623. export class SceneInstrumentation implements IDisposable {
  58624. /**
  58625. * Defines the scene to instrument
  58626. */
  58627. scene: Scene;
  58628. private _captureActiveMeshesEvaluationTime;
  58629. private _activeMeshesEvaluationTime;
  58630. private _captureRenderTargetsRenderTime;
  58631. private _renderTargetsRenderTime;
  58632. private _captureFrameTime;
  58633. private _frameTime;
  58634. private _captureRenderTime;
  58635. private _renderTime;
  58636. private _captureInterFrameTime;
  58637. private _interFrameTime;
  58638. private _captureParticlesRenderTime;
  58639. private _particlesRenderTime;
  58640. private _captureSpritesRenderTime;
  58641. private _spritesRenderTime;
  58642. private _capturePhysicsTime;
  58643. private _physicsTime;
  58644. private _captureAnimationsTime;
  58645. private _animationsTime;
  58646. private _captureCameraRenderTime;
  58647. private _cameraRenderTime;
  58648. private _onBeforeActiveMeshesEvaluationObserver;
  58649. private _onAfterActiveMeshesEvaluationObserver;
  58650. private _onBeforeRenderTargetsRenderObserver;
  58651. private _onAfterRenderTargetsRenderObserver;
  58652. private _onAfterRenderObserver;
  58653. private _onBeforeDrawPhaseObserver;
  58654. private _onAfterDrawPhaseObserver;
  58655. private _onBeforeAnimationsObserver;
  58656. private _onBeforeParticlesRenderingObserver;
  58657. private _onAfterParticlesRenderingObserver;
  58658. private _onBeforeSpritesRenderingObserver;
  58659. private _onAfterSpritesRenderingObserver;
  58660. private _onBeforePhysicsObserver;
  58661. private _onAfterPhysicsObserver;
  58662. private _onAfterAnimationsObserver;
  58663. private _onBeforeCameraRenderObserver;
  58664. private _onAfterCameraRenderObserver;
  58665. /**
  58666. * Gets the perf counter used for active meshes evaluation time
  58667. */
  58668. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  58669. /**
  58670. * Gets the active meshes evaluation time capture status
  58671. */
  58672. get captureActiveMeshesEvaluationTime(): boolean;
  58673. /**
  58674. * Enable or disable the active meshes evaluation time capture
  58675. */
  58676. set captureActiveMeshesEvaluationTime(value: boolean);
  58677. /**
  58678. * Gets the perf counter used for render targets render time
  58679. */
  58680. get renderTargetsRenderTimeCounter(): PerfCounter;
  58681. /**
  58682. * Gets the render targets render time capture status
  58683. */
  58684. get captureRenderTargetsRenderTime(): boolean;
  58685. /**
  58686. * Enable or disable the render targets render time capture
  58687. */
  58688. set captureRenderTargetsRenderTime(value: boolean);
  58689. /**
  58690. * Gets the perf counter used for particles render time
  58691. */
  58692. get particlesRenderTimeCounter(): PerfCounter;
  58693. /**
  58694. * Gets the particles render time capture status
  58695. */
  58696. get captureParticlesRenderTime(): boolean;
  58697. /**
  58698. * Enable or disable the particles render time capture
  58699. */
  58700. set captureParticlesRenderTime(value: boolean);
  58701. /**
  58702. * Gets the perf counter used for sprites render time
  58703. */
  58704. get spritesRenderTimeCounter(): PerfCounter;
  58705. /**
  58706. * Gets the sprites render time capture status
  58707. */
  58708. get captureSpritesRenderTime(): boolean;
  58709. /**
  58710. * Enable or disable the sprites render time capture
  58711. */
  58712. set captureSpritesRenderTime(value: boolean);
  58713. /**
  58714. * Gets the perf counter used for physics time
  58715. */
  58716. get physicsTimeCounter(): PerfCounter;
  58717. /**
  58718. * Gets the physics time capture status
  58719. */
  58720. get capturePhysicsTime(): boolean;
  58721. /**
  58722. * Enable or disable the physics time capture
  58723. */
  58724. set capturePhysicsTime(value: boolean);
  58725. /**
  58726. * Gets the perf counter used for animations time
  58727. */
  58728. get animationsTimeCounter(): PerfCounter;
  58729. /**
  58730. * Gets the animations time capture status
  58731. */
  58732. get captureAnimationsTime(): boolean;
  58733. /**
  58734. * Enable or disable the animations time capture
  58735. */
  58736. set captureAnimationsTime(value: boolean);
  58737. /**
  58738. * Gets the perf counter used for frame time capture
  58739. */
  58740. get frameTimeCounter(): PerfCounter;
  58741. /**
  58742. * Gets the frame time capture status
  58743. */
  58744. get captureFrameTime(): boolean;
  58745. /**
  58746. * Enable or disable the frame time capture
  58747. */
  58748. set captureFrameTime(value: boolean);
  58749. /**
  58750. * Gets the perf counter used for inter-frames time capture
  58751. */
  58752. get interFrameTimeCounter(): PerfCounter;
  58753. /**
  58754. * Gets the inter-frames time capture status
  58755. */
  58756. get captureInterFrameTime(): boolean;
  58757. /**
  58758. * Enable or disable the inter-frames time capture
  58759. */
  58760. set captureInterFrameTime(value: boolean);
  58761. /**
  58762. * Gets the perf counter used for render time capture
  58763. */
  58764. get renderTimeCounter(): PerfCounter;
  58765. /**
  58766. * Gets the render time capture status
  58767. */
  58768. get captureRenderTime(): boolean;
  58769. /**
  58770. * Enable or disable the render time capture
  58771. */
  58772. set captureRenderTime(value: boolean);
  58773. /**
  58774. * Gets the perf counter used for camera render time capture
  58775. */
  58776. get cameraRenderTimeCounter(): PerfCounter;
  58777. /**
  58778. * Gets the camera render time capture status
  58779. */
  58780. get captureCameraRenderTime(): boolean;
  58781. /**
  58782. * Enable or disable the camera render time capture
  58783. */
  58784. set captureCameraRenderTime(value: boolean);
  58785. /**
  58786. * Gets the perf counter used for draw calls
  58787. */
  58788. get drawCallsCounter(): PerfCounter;
  58789. /**
  58790. * Instantiates a new scene instrumentation.
  58791. * This class can be used to get instrumentation data from a Babylon engine
  58792. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  58793. * @param scene Defines the scene to instrument
  58794. */
  58795. constructor(
  58796. /**
  58797. * Defines the scene to instrument
  58798. */
  58799. scene: Scene);
  58800. /**
  58801. * Dispose and release associated resources.
  58802. */
  58803. dispose(): void;
  58804. }
  58805. }
  58806. declare module "babylonjs/Instrumentation/index" {
  58807. export * from "babylonjs/Instrumentation/engineInstrumentation";
  58808. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  58809. export * from "babylonjs/Instrumentation/timeToken";
  58810. }
  58811. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  58812. /** @hidden */
  58813. export var glowMapGenerationPixelShader: {
  58814. name: string;
  58815. shader: string;
  58816. };
  58817. }
  58818. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  58819. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  58820. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  58821. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  58822. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  58823. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  58824. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  58825. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  58826. /** @hidden */
  58827. export var glowMapGenerationVertexShader: {
  58828. name: string;
  58829. shader: string;
  58830. };
  58831. }
  58832. declare module "babylonjs/Layers/effectLayer" {
  58833. import { Observable } from "babylonjs/Misc/observable";
  58834. import { Nullable } from "babylonjs/types";
  58835. import { Camera } from "babylonjs/Cameras/camera";
  58836. import { Scene } from "babylonjs/scene";
  58837. import { ISize } from "babylonjs/Maths/math.size";
  58838. import { Color4 } from "babylonjs/Maths/math.color";
  58839. import { Engine } from "babylonjs/Engines/engine";
  58840. import { SubMesh } from "babylonjs/Meshes/subMesh";
  58841. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58842. import { Mesh } from "babylonjs/Meshes/mesh";
  58843. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  58844. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58845. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  58846. import { Effect } from "babylonjs/Materials/effect";
  58847. import { Material } from "babylonjs/Materials/material";
  58848. import "babylonjs/Shaders/glowMapGeneration.fragment";
  58849. import "babylonjs/Shaders/glowMapGeneration.vertex";
  58850. /**
  58851. * Effect layer options. This helps customizing the behaviour
  58852. * of the effect layer.
  58853. */
  58854. export interface IEffectLayerOptions {
  58855. /**
  58856. * Multiplication factor apply to the canvas size to compute the render target size
  58857. * used to generated the objects (the smaller the faster).
  58858. */
  58859. mainTextureRatio: number;
  58860. /**
  58861. * Enforces a fixed size texture to ensure effect stability across devices.
  58862. */
  58863. mainTextureFixedSize?: number;
  58864. /**
  58865. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  58866. */
  58867. alphaBlendingMode: number;
  58868. /**
  58869. * The camera attached to the layer.
  58870. */
  58871. camera: Nullable<Camera>;
  58872. /**
  58873. * The rendering group to draw the layer in.
  58874. */
  58875. renderingGroupId: number;
  58876. }
  58877. /**
  58878. * The effect layer Helps adding post process effect blended with the main pass.
  58879. *
  58880. * This can be for instance use to generate glow or higlight effects on the scene.
  58881. *
  58882. * The effect layer class can not be used directly and is intented to inherited from to be
  58883. * customized per effects.
  58884. */
  58885. export abstract class EffectLayer {
  58886. private _vertexBuffers;
  58887. private _indexBuffer;
  58888. private _cachedDefines;
  58889. private _effectLayerMapGenerationEffect;
  58890. private _effectLayerOptions;
  58891. private _mergeEffect;
  58892. protected _scene: Scene;
  58893. protected _engine: Engine;
  58894. protected _maxSize: number;
  58895. protected _mainTextureDesiredSize: ISize;
  58896. protected _mainTexture: RenderTargetTexture;
  58897. protected _shouldRender: boolean;
  58898. protected _postProcesses: PostProcess[];
  58899. protected _textures: BaseTexture[];
  58900. protected _emissiveTextureAndColor: {
  58901. texture: Nullable<BaseTexture>;
  58902. color: Color4;
  58903. };
  58904. /**
  58905. * The name of the layer
  58906. */
  58907. name: string;
  58908. /**
  58909. * The clear color of the texture used to generate the glow map.
  58910. */
  58911. neutralColor: Color4;
  58912. /**
  58913. * Specifies whether the highlight layer is enabled or not.
  58914. */
  58915. isEnabled: boolean;
  58916. /**
  58917. * Gets the camera attached to the layer.
  58918. */
  58919. get camera(): Nullable<Camera>;
  58920. /**
  58921. * Gets the rendering group id the layer should render in.
  58922. */
  58923. get renderingGroupId(): number;
  58924. set renderingGroupId(renderingGroupId: number);
  58925. /**
  58926. * An event triggered when the effect layer has been disposed.
  58927. */
  58928. onDisposeObservable: Observable<EffectLayer>;
  58929. /**
  58930. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  58931. */
  58932. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  58933. /**
  58934. * An event triggered when the generated texture is being merged in the scene.
  58935. */
  58936. onBeforeComposeObservable: Observable<EffectLayer>;
  58937. /**
  58938. * An event triggered when the mesh is rendered into the effect render target.
  58939. */
  58940. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  58941. /**
  58942. * An event triggered after the mesh has been rendered into the effect render target.
  58943. */
  58944. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  58945. /**
  58946. * An event triggered when the generated texture has been merged in the scene.
  58947. */
  58948. onAfterComposeObservable: Observable<EffectLayer>;
  58949. /**
  58950. * An event triggered when the efffect layer changes its size.
  58951. */
  58952. onSizeChangedObservable: Observable<EffectLayer>;
  58953. /** @hidden */
  58954. static _SceneComponentInitialization: (scene: Scene) => void;
  58955. /**
  58956. * Instantiates a new effect Layer and references it in the scene.
  58957. * @param name The name of the layer
  58958. * @param scene The scene to use the layer in
  58959. */
  58960. constructor(
  58961. /** The Friendly of the effect in the scene */
  58962. name: string, scene: Scene);
  58963. /**
  58964. * Get the effect name of the layer.
  58965. * @return The effect name
  58966. */
  58967. abstract getEffectName(): string;
  58968. /**
  58969. * Checks for the readiness of the element composing the layer.
  58970. * @param subMesh the mesh to check for
  58971. * @param useInstances specify whether or not to use instances to render the mesh
  58972. * @return true if ready otherwise, false
  58973. */
  58974. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  58975. /**
  58976. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  58977. * @returns true if the effect requires stencil during the main canvas render pass.
  58978. */
  58979. abstract needStencil(): boolean;
  58980. /**
  58981. * Create the merge effect. This is the shader use to blit the information back
  58982. * to the main canvas at the end of the scene rendering.
  58983. * @returns The effect containing the shader used to merge the effect on the main canvas
  58984. */
  58985. protected abstract _createMergeEffect(): Effect;
  58986. /**
  58987. * Creates the render target textures and post processes used in the effect layer.
  58988. */
  58989. protected abstract _createTextureAndPostProcesses(): void;
  58990. /**
  58991. * Implementation specific of rendering the generating effect on the main canvas.
  58992. * @param effect The effect used to render through
  58993. */
  58994. protected abstract _internalRender(effect: Effect): void;
  58995. /**
  58996. * Sets the required values for both the emissive texture and and the main color.
  58997. */
  58998. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  58999. /**
  59000. * Free any resources and references associated to a mesh.
  59001. * Internal use
  59002. * @param mesh The mesh to free.
  59003. */
  59004. abstract _disposeMesh(mesh: Mesh): void;
  59005. /**
  59006. * Serializes this layer (Glow or Highlight for example)
  59007. * @returns a serialized layer object
  59008. */
  59009. abstract serialize?(): any;
  59010. /**
  59011. * Initializes the effect layer with the required options.
  59012. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  59013. */
  59014. protected _init(options: Partial<IEffectLayerOptions>): void;
  59015. /**
  59016. * Generates the index buffer of the full screen quad blending to the main canvas.
  59017. */
  59018. private _generateIndexBuffer;
  59019. /**
  59020. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  59021. */
  59022. private _generateVertexBuffer;
  59023. /**
  59024. * Sets the main texture desired size which is the closest power of two
  59025. * of the engine canvas size.
  59026. */
  59027. private _setMainTextureSize;
  59028. /**
  59029. * Creates the main texture for the effect layer.
  59030. */
  59031. protected _createMainTexture(): void;
  59032. /**
  59033. * Adds specific effects defines.
  59034. * @param defines The defines to add specifics to.
  59035. */
  59036. protected _addCustomEffectDefines(defines: string[]): void;
  59037. /**
  59038. * Checks for the readiness of the element composing the layer.
  59039. * @param subMesh the mesh to check for
  59040. * @param useInstances specify whether or not to use instances to render the mesh
  59041. * @param emissiveTexture the associated emissive texture used to generate the glow
  59042. * @return true if ready otherwise, false
  59043. */
  59044. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  59045. /**
  59046. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  59047. */
  59048. render(): void;
  59049. /**
  59050. * Determine if a given mesh will be used in the current effect.
  59051. * @param mesh mesh to test
  59052. * @returns true if the mesh will be used
  59053. */
  59054. hasMesh(mesh: AbstractMesh): boolean;
  59055. /**
  59056. * Returns true if the layer contains information to display, otherwise false.
  59057. * @returns true if the glow layer should be rendered
  59058. */
  59059. shouldRender(): boolean;
  59060. /**
  59061. * Returns true if the mesh should render, otherwise false.
  59062. * @param mesh The mesh to render
  59063. * @returns true if it should render otherwise false
  59064. */
  59065. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  59066. /**
  59067. * Returns true if the mesh can be rendered, otherwise false.
  59068. * @param mesh The mesh to render
  59069. * @param material The material used on the mesh
  59070. * @returns true if it can be rendered otherwise false
  59071. */
  59072. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  59073. /**
  59074. * Returns true if the mesh should render, otherwise false.
  59075. * @param mesh The mesh to render
  59076. * @returns true if it should render otherwise false
  59077. */
  59078. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  59079. /**
  59080. * Renders the submesh passed in parameter to the generation map.
  59081. */
  59082. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  59083. /**
  59084. * Defines whether the current material of the mesh should be use to render the effect.
  59085. * @param mesh defines the current mesh to render
  59086. */
  59087. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  59088. /**
  59089. * Rebuild the required buffers.
  59090. * @hidden Internal use only.
  59091. */
  59092. _rebuild(): void;
  59093. /**
  59094. * Dispose only the render target textures and post process.
  59095. */
  59096. private _disposeTextureAndPostProcesses;
  59097. /**
  59098. * Dispose the highlight layer and free resources.
  59099. */
  59100. dispose(): void;
  59101. /**
  59102. * Gets the class name of the effect layer
  59103. * @returns the string with the class name of the effect layer
  59104. */
  59105. getClassName(): string;
  59106. /**
  59107. * Creates an effect layer from parsed effect layer data
  59108. * @param parsedEffectLayer defines effect layer data
  59109. * @param scene defines the current scene
  59110. * @param rootUrl defines the root URL containing the effect layer information
  59111. * @returns a parsed effect Layer
  59112. */
  59113. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  59114. }
  59115. }
  59116. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  59117. import { Scene } from "babylonjs/scene";
  59118. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  59119. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  59120. import { AbstractScene } from "babylonjs/abstractScene";
  59121. module "babylonjs/abstractScene" {
  59122. interface AbstractScene {
  59123. /**
  59124. * The list of effect layers (highlights/glow) added to the scene
  59125. * @see http://doc.babylonjs.com/how_to/highlight_layer
  59126. * @see http://doc.babylonjs.com/how_to/glow_layer
  59127. */
  59128. effectLayers: Array<EffectLayer>;
  59129. /**
  59130. * Removes the given effect layer from this scene.
  59131. * @param toRemove defines the effect layer to remove
  59132. * @returns the index of the removed effect layer
  59133. */
  59134. removeEffectLayer(toRemove: EffectLayer): number;
  59135. /**
  59136. * Adds the given effect layer to this scene
  59137. * @param newEffectLayer defines the effect layer to add
  59138. */
  59139. addEffectLayer(newEffectLayer: EffectLayer): void;
  59140. }
  59141. }
  59142. /**
  59143. * Defines the layer scene component responsible to manage any effect layers
  59144. * in a given scene.
  59145. */
  59146. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  59147. /**
  59148. * The component name helpfull to identify the component in the list of scene components.
  59149. */
  59150. readonly name: string;
  59151. /**
  59152. * The scene the component belongs to.
  59153. */
  59154. scene: Scene;
  59155. private _engine;
  59156. private _renderEffects;
  59157. private _needStencil;
  59158. private _previousStencilState;
  59159. /**
  59160. * Creates a new instance of the component for the given scene
  59161. * @param scene Defines the scene to register the component in
  59162. */
  59163. constructor(scene: Scene);
  59164. /**
  59165. * Registers the component in a given scene
  59166. */
  59167. register(): void;
  59168. /**
  59169. * Rebuilds the elements related to this component in case of
  59170. * context lost for instance.
  59171. */
  59172. rebuild(): void;
  59173. /**
  59174. * Serializes the component data to the specified json object
  59175. * @param serializationObject The object to serialize to
  59176. */
  59177. serialize(serializationObject: any): void;
  59178. /**
  59179. * Adds all the elements from the container to the scene
  59180. * @param container the container holding the elements
  59181. */
  59182. addFromContainer(container: AbstractScene): void;
  59183. /**
  59184. * Removes all the elements in the container from the scene
  59185. * @param container contains the elements to remove
  59186. * @param dispose if the removed element should be disposed (default: false)
  59187. */
  59188. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  59189. /**
  59190. * Disposes the component and the associated ressources.
  59191. */
  59192. dispose(): void;
  59193. private _isReadyForMesh;
  59194. private _renderMainTexture;
  59195. private _setStencil;
  59196. private _setStencilBack;
  59197. private _draw;
  59198. private _drawCamera;
  59199. private _drawRenderingGroup;
  59200. }
  59201. }
  59202. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  59203. /** @hidden */
  59204. export var glowMapMergePixelShader: {
  59205. name: string;
  59206. shader: string;
  59207. };
  59208. }
  59209. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  59210. /** @hidden */
  59211. export var glowMapMergeVertexShader: {
  59212. name: string;
  59213. shader: string;
  59214. };
  59215. }
  59216. declare module "babylonjs/Layers/glowLayer" {
  59217. import { Nullable } from "babylonjs/types";
  59218. import { Camera } from "babylonjs/Cameras/camera";
  59219. import { Scene } from "babylonjs/scene";
  59220. import { SubMesh } from "babylonjs/Meshes/subMesh";
  59221. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59222. import { Mesh } from "babylonjs/Meshes/mesh";
  59223. import { Texture } from "babylonjs/Materials/Textures/texture";
  59224. import { Effect } from "babylonjs/Materials/effect";
  59225. import { Material } from "babylonjs/Materials/material";
  59226. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  59227. import { Color4 } from "babylonjs/Maths/math.color";
  59228. import "babylonjs/Shaders/glowMapMerge.fragment";
  59229. import "babylonjs/Shaders/glowMapMerge.vertex";
  59230. import "babylonjs/Layers/effectLayerSceneComponent";
  59231. module "babylonjs/abstractScene" {
  59232. interface AbstractScene {
  59233. /**
  59234. * Return a the first highlight layer of the scene with a given name.
  59235. * @param name The name of the highlight layer to look for.
  59236. * @return The highlight layer if found otherwise null.
  59237. */
  59238. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  59239. }
  59240. }
  59241. /**
  59242. * Glow layer options. This helps customizing the behaviour
  59243. * of the glow layer.
  59244. */
  59245. export interface IGlowLayerOptions {
  59246. /**
  59247. * Multiplication factor apply to the canvas size to compute the render target size
  59248. * used to generated the glowing objects (the smaller the faster).
  59249. */
  59250. mainTextureRatio: number;
  59251. /**
  59252. * Enforces a fixed size texture to ensure resize independant blur.
  59253. */
  59254. mainTextureFixedSize?: number;
  59255. /**
  59256. * How big is the kernel of the blur texture.
  59257. */
  59258. blurKernelSize: number;
  59259. /**
  59260. * The camera attached to the layer.
  59261. */
  59262. camera: Nullable<Camera>;
  59263. /**
  59264. * Enable MSAA by chosing the number of samples.
  59265. */
  59266. mainTextureSamples?: number;
  59267. /**
  59268. * The rendering group to draw the layer in.
  59269. */
  59270. renderingGroupId: number;
  59271. }
  59272. /**
  59273. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  59274. *
  59275. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  59276. *
  59277. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  59278. */
  59279. export class GlowLayer extends EffectLayer {
  59280. /**
  59281. * Effect Name of the layer.
  59282. */
  59283. static readonly EffectName: string;
  59284. /**
  59285. * The default blur kernel size used for the glow.
  59286. */
  59287. static DefaultBlurKernelSize: number;
  59288. /**
  59289. * The default texture size ratio used for the glow.
  59290. */
  59291. static DefaultTextureRatio: number;
  59292. /**
  59293. * Sets the kernel size of the blur.
  59294. */
  59295. set blurKernelSize(value: number);
  59296. /**
  59297. * Gets the kernel size of the blur.
  59298. */
  59299. get blurKernelSize(): number;
  59300. /**
  59301. * Sets the glow intensity.
  59302. */
  59303. set intensity(value: number);
  59304. /**
  59305. * Gets the glow intensity.
  59306. */
  59307. get intensity(): number;
  59308. private _options;
  59309. private _intensity;
  59310. private _horizontalBlurPostprocess1;
  59311. private _verticalBlurPostprocess1;
  59312. private _horizontalBlurPostprocess2;
  59313. private _verticalBlurPostprocess2;
  59314. private _blurTexture1;
  59315. private _blurTexture2;
  59316. private _postProcesses1;
  59317. private _postProcesses2;
  59318. private _includedOnlyMeshes;
  59319. private _excludedMeshes;
  59320. private _meshesUsingTheirOwnMaterials;
  59321. /**
  59322. * Callback used to let the user override the color selection on a per mesh basis
  59323. */
  59324. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  59325. /**
  59326. * Callback used to let the user override the texture selection on a per mesh basis
  59327. */
  59328. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  59329. /**
  59330. * Instantiates a new glow Layer and references it to the scene.
  59331. * @param name The name of the layer
  59332. * @param scene The scene to use the layer in
  59333. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  59334. */
  59335. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  59336. /**
  59337. * Get the effect name of the layer.
  59338. * @return The effect name
  59339. */
  59340. getEffectName(): string;
  59341. /**
  59342. * Create the merge effect. This is the shader use to blit the information back
  59343. * to the main canvas at the end of the scene rendering.
  59344. */
  59345. protected _createMergeEffect(): Effect;
  59346. /**
  59347. * Creates the render target textures and post processes used in the glow layer.
  59348. */
  59349. protected _createTextureAndPostProcesses(): void;
  59350. /**
  59351. * Checks for the readiness of the element composing the layer.
  59352. * @param subMesh the mesh to check for
  59353. * @param useInstances specify wether or not to use instances to render the mesh
  59354. * @param emissiveTexture the associated emissive texture used to generate the glow
  59355. * @return true if ready otherwise, false
  59356. */
  59357. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59358. /**
  59359. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  59360. */
  59361. needStencil(): boolean;
  59362. /**
  59363. * Returns true if the mesh can be rendered, otherwise false.
  59364. * @param mesh The mesh to render
  59365. * @param material The material used on the mesh
  59366. * @returns true if it can be rendered otherwise false
  59367. */
  59368. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  59369. /**
  59370. * Implementation specific of rendering the generating effect on the main canvas.
  59371. * @param effect The effect used to render through
  59372. */
  59373. protected _internalRender(effect: Effect): void;
  59374. /**
  59375. * Sets the required values for both the emissive texture and and the main color.
  59376. */
  59377. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  59378. /**
  59379. * Returns true if the mesh should render, otherwise false.
  59380. * @param mesh The mesh to render
  59381. * @returns true if it should render otherwise false
  59382. */
  59383. protected _shouldRenderMesh(mesh: Mesh): boolean;
  59384. /**
  59385. * Adds specific effects defines.
  59386. * @param defines The defines to add specifics to.
  59387. */
  59388. protected _addCustomEffectDefines(defines: string[]): void;
  59389. /**
  59390. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  59391. * @param mesh The mesh to exclude from the glow layer
  59392. */
  59393. addExcludedMesh(mesh: Mesh): void;
  59394. /**
  59395. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  59396. * @param mesh The mesh to remove
  59397. */
  59398. removeExcludedMesh(mesh: Mesh): void;
  59399. /**
  59400. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  59401. * @param mesh The mesh to include in the glow layer
  59402. */
  59403. addIncludedOnlyMesh(mesh: Mesh): void;
  59404. /**
  59405. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  59406. * @param mesh The mesh to remove
  59407. */
  59408. removeIncludedOnlyMesh(mesh: Mesh): void;
  59409. /**
  59410. * Determine if a given mesh will be used in the glow layer
  59411. * @param mesh The mesh to test
  59412. * @returns true if the mesh will be highlighted by the current glow layer
  59413. */
  59414. hasMesh(mesh: AbstractMesh): boolean;
  59415. /**
  59416. * Defines whether the current material of the mesh should be use to render the effect.
  59417. * @param mesh defines the current mesh to render
  59418. */
  59419. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  59420. /**
  59421. * Add a mesh to be rendered through its own material and not with emissive only.
  59422. * @param mesh The mesh for which we need to use its material
  59423. */
  59424. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  59425. /**
  59426. * Remove a mesh from being rendered through its own material and not with emissive only.
  59427. * @param mesh The mesh for which we need to not use its material
  59428. */
  59429. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  59430. /**
  59431. * Free any resources and references associated to a mesh.
  59432. * Internal use
  59433. * @param mesh The mesh to free.
  59434. * @hidden
  59435. */
  59436. _disposeMesh(mesh: Mesh): void;
  59437. /**
  59438. * Gets the class name of the effect layer
  59439. * @returns the string with the class name of the effect layer
  59440. */
  59441. getClassName(): string;
  59442. /**
  59443. * Serializes this glow layer
  59444. * @returns a serialized glow layer object
  59445. */
  59446. serialize(): any;
  59447. /**
  59448. * Creates a Glow Layer from parsed glow layer data
  59449. * @param parsedGlowLayer defines glow layer data
  59450. * @param scene defines the current scene
  59451. * @param rootUrl defines the root URL containing the glow layer information
  59452. * @returns a parsed Glow Layer
  59453. */
  59454. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  59455. }
  59456. }
  59457. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  59458. /** @hidden */
  59459. export var glowBlurPostProcessPixelShader: {
  59460. name: string;
  59461. shader: string;
  59462. };
  59463. }
  59464. declare module "babylonjs/Layers/highlightLayer" {
  59465. import { Observable } from "babylonjs/Misc/observable";
  59466. import { Nullable } from "babylonjs/types";
  59467. import { Camera } from "babylonjs/Cameras/camera";
  59468. import { Scene } from "babylonjs/scene";
  59469. import { SubMesh } from "babylonjs/Meshes/subMesh";
  59470. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59471. import { Mesh } from "babylonjs/Meshes/mesh";
  59472. import { Effect } from "babylonjs/Materials/effect";
  59473. import { Material } from "babylonjs/Materials/material";
  59474. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  59475. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  59476. import "babylonjs/Shaders/glowMapMerge.fragment";
  59477. import "babylonjs/Shaders/glowMapMerge.vertex";
  59478. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  59479. module "babylonjs/abstractScene" {
  59480. interface AbstractScene {
  59481. /**
  59482. * Return a the first highlight layer of the scene with a given name.
  59483. * @param name The name of the highlight layer to look for.
  59484. * @return The highlight layer if found otherwise null.
  59485. */
  59486. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  59487. }
  59488. }
  59489. /**
  59490. * Highlight layer options. This helps customizing the behaviour
  59491. * of the highlight layer.
  59492. */
  59493. export interface IHighlightLayerOptions {
  59494. /**
  59495. * Multiplication factor apply to the canvas size to compute the render target size
  59496. * used to generated the glowing objects (the smaller the faster).
  59497. */
  59498. mainTextureRatio: number;
  59499. /**
  59500. * Enforces a fixed size texture to ensure resize independant blur.
  59501. */
  59502. mainTextureFixedSize?: number;
  59503. /**
  59504. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  59505. * of the picture to blur (the smaller the faster).
  59506. */
  59507. blurTextureSizeRatio: number;
  59508. /**
  59509. * How big in texel of the blur texture is the vertical blur.
  59510. */
  59511. blurVerticalSize: number;
  59512. /**
  59513. * How big in texel of the blur texture is the horizontal blur.
  59514. */
  59515. blurHorizontalSize: number;
  59516. /**
  59517. * Alpha blending mode used to apply the blur. Default is combine.
  59518. */
  59519. alphaBlendingMode: number;
  59520. /**
  59521. * The camera attached to the layer.
  59522. */
  59523. camera: Nullable<Camera>;
  59524. /**
  59525. * Should we display highlight as a solid stroke?
  59526. */
  59527. isStroke?: boolean;
  59528. /**
  59529. * The rendering group to draw the layer in.
  59530. */
  59531. renderingGroupId: number;
  59532. }
  59533. /**
  59534. * The highlight layer Helps adding a glow effect around a mesh.
  59535. *
  59536. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  59537. * glowy meshes to your scene.
  59538. *
  59539. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  59540. */
  59541. export class HighlightLayer extends EffectLayer {
  59542. name: string;
  59543. /**
  59544. * Effect Name of the highlight layer.
  59545. */
  59546. static readonly EffectName: string;
  59547. /**
  59548. * The neutral color used during the preparation of the glow effect.
  59549. * This is black by default as the blend operation is a blend operation.
  59550. */
  59551. static NeutralColor: Color4;
  59552. /**
  59553. * Stencil value used for glowing meshes.
  59554. */
  59555. static GlowingMeshStencilReference: number;
  59556. /**
  59557. * Stencil value used for the other meshes in the scene.
  59558. */
  59559. static NormalMeshStencilReference: number;
  59560. /**
  59561. * Specifies whether or not the inner glow is ACTIVE in the layer.
  59562. */
  59563. innerGlow: boolean;
  59564. /**
  59565. * Specifies whether or not the outer glow is ACTIVE in the layer.
  59566. */
  59567. outerGlow: boolean;
  59568. /**
  59569. * Specifies the horizontal size of the blur.
  59570. */
  59571. set blurHorizontalSize(value: number);
  59572. /**
  59573. * Specifies the vertical size of the blur.
  59574. */
  59575. set blurVerticalSize(value: number);
  59576. /**
  59577. * Gets the horizontal size of the blur.
  59578. */
  59579. get blurHorizontalSize(): number;
  59580. /**
  59581. * Gets the vertical size of the blur.
  59582. */
  59583. get blurVerticalSize(): number;
  59584. /**
  59585. * An event triggered when the highlight layer is being blurred.
  59586. */
  59587. onBeforeBlurObservable: Observable<HighlightLayer>;
  59588. /**
  59589. * An event triggered when the highlight layer has been blurred.
  59590. */
  59591. onAfterBlurObservable: Observable<HighlightLayer>;
  59592. private _instanceGlowingMeshStencilReference;
  59593. private _options;
  59594. private _downSamplePostprocess;
  59595. private _horizontalBlurPostprocess;
  59596. private _verticalBlurPostprocess;
  59597. private _blurTexture;
  59598. private _meshes;
  59599. private _excludedMeshes;
  59600. /**
  59601. * Instantiates a new highlight Layer and references it to the scene..
  59602. * @param name The name of the layer
  59603. * @param scene The scene to use the layer in
  59604. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  59605. */
  59606. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  59607. /**
  59608. * Get the effect name of the layer.
  59609. * @return The effect name
  59610. */
  59611. getEffectName(): string;
  59612. /**
  59613. * Create the merge effect. This is the shader use to blit the information back
  59614. * to the main canvas at the end of the scene rendering.
  59615. */
  59616. protected _createMergeEffect(): Effect;
  59617. /**
  59618. * Creates the render target textures and post processes used in the highlight layer.
  59619. */
  59620. protected _createTextureAndPostProcesses(): void;
  59621. /**
  59622. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  59623. */
  59624. needStencil(): boolean;
  59625. /**
  59626. * Checks for the readiness of the element composing the layer.
  59627. * @param subMesh the mesh to check for
  59628. * @param useInstances specify wether or not to use instances to render the mesh
  59629. * @param emissiveTexture the associated emissive texture used to generate the glow
  59630. * @return true if ready otherwise, false
  59631. */
  59632. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59633. /**
  59634. * Implementation specific of rendering the generating effect on the main canvas.
  59635. * @param effect The effect used to render through
  59636. */
  59637. protected _internalRender(effect: Effect): void;
  59638. /**
  59639. * Returns true if the layer contains information to display, otherwise false.
  59640. */
  59641. shouldRender(): boolean;
  59642. /**
  59643. * Returns true if the mesh should render, otherwise false.
  59644. * @param mesh The mesh to render
  59645. * @returns true if it should render otherwise false
  59646. */
  59647. protected _shouldRenderMesh(mesh: Mesh): boolean;
  59648. /**
  59649. * Adds specific effects defines.
  59650. * @param defines The defines to add specifics to.
  59651. */
  59652. protected _addCustomEffectDefines(defines: string[]): void;
  59653. /**
  59654. * Sets the required values for both the emissive texture and and the main color.
  59655. */
  59656. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  59657. /**
  59658. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  59659. * @param mesh The mesh to exclude from the highlight layer
  59660. */
  59661. addExcludedMesh(mesh: Mesh): void;
  59662. /**
  59663. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  59664. * @param mesh The mesh to highlight
  59665. */
  59666. removeExcludedMesh(mesh: Mesh): void;
  59667. /**
  59668. * Determine if a given mesh will be highlighted by the current HighlightLayer
  59669. * @param mesh mesh to test
  59670. * @returns true if the mesh will be highlighted by the current HighlightLayer
  59671. */
  59672. hasMesh(mesh: AbstractMesh): boolean;
  59673. /**
  59674. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  59675. * @param mesh The mesh to highlight
  59676. * @param color The color of the highlight
  59677. * @param glowEmissiveOnly Extract the glow from the emissive texture
  59678. */
  59679. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  59680. /**
  59681. * Remove a mesh from the highlight layer in order to make it stop glowing.
  59682. * @param mesh The mesh to highlight
  59683. */
  59684. removeMesh(mesh: Mesh): void;
  59685. /**
  59686. * Remove all the meshes currently referenced in the highlight layer
  59687. */
  59688. removeAllMeshes(): void;
  59689. /**
  59690. * Force the stencil to the normal expected value for none glowing parts
  59691. */
  59692. private _defaultStencilReference;
  59693. /**
  59694. * Free any resources and references associated to a mesh.
  59695. * Internal use
  59696. * @param mesh The mesh to free.
  59697. * @hidden
  59698. */
  59699. _disposeMesh(mesh: Mesh): void;
  59700. /**
  59701. * Dispose the highlight layer and free resources.
  59702. */
  59703. dispose(): void;
  59704. /**
  59705. * Gets the class name of the effect layer
  59706. * @returns the string with the class name of the effect layer
  59707. */
  59708. getClassName(): string;
  59709. /**
  59710. * Serializes this Highlight layer
  59711. * @returns a serialized Highlight layer object
  59712. */
  59713. serialize(): any;
  59714. /**
  59715. * Creates a Highlight layer from parsed Highlight layer data
  59716. * @param parsedHightlightLayer defines the Highlight layer data
  59717. * @param scene defines the current scene
  59718. * @param rootUrl defines the root URL containing the Highlight layer information
  59719. * @returns a parsed Highlight layer
  59720. */
  59721. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  59722. }
  59723. }
  59724. declare module "babylonjs/Layers/layerSceneComponent" {
  59725. import { Scene } from "babylonjs/scene";
  59726. import { ISceneComponent } from "babylonjs/sceneComponent";
  59727. import { Layer } from "babylonjs/Layers/layer";
  59728. import { AbstractScene } from "babylonjs/abstractScene";
  59729. module "babylonjs/abstractScene" {
  59730. interface AbstractScene {
  59731. /**
  59732. * The list of layers (background and foreground) of the scene
  59733. */
  59734. layers: Array<Layer>;
  59735. }
  59736. }
  59737. /**
  59738. * Defines the layer scene component responsible to manage any layers
  59739. * in a given scene.
  59740. */
  59741. export class LayerSceneComponent implements ISceneComponent {
  59742. /**
  59743. * The component name helpfull to identify the component in the list of scene components.
  59744. */
  59745. readonly name: string;
  59746. /**
  59747. * The scene the component belongs to.
  59748. */
  59749. scene: Scene;
  59750. private _engine;
  59751. /**
  59752. * Creates a new instance of the component for the given scene
  59753. * @param scene Defines the scene to register the component in
  59754. */
  59755. constructor(scene: Scene);
  59756. /**
  59757. * Registers the component in a given scene
  59758. */
  59759. register(): void;
  59760. /**
  59761. * Rebuilds the elements related to this component in case of
  59762. * context lost for instance.
  59763. */
  59764. rebuild(): void;
  59765. /**
  59766. * Disposes the component and the associated ressources.
  59767. */
  59768. dispose(): void;
  59769. private _draw;
  59770. private _drawCameraPredicate;
  59771. private _drawCameraBackground;
  59772. private _drawCameraForeground;
  59773. private _drawRenderTargetPredicate;
  59774. private _drawRenderTargetBackground;
  59775. private _drawRenderTargetForeground;
  59776. /**
  59777. * Adds all the elements from the container to the scene
  59778. * @param container the container holding the elements
  59779. */
  59780. addFromContainer(container: AbstractScene): void;
  59781. /**
  59782. * Removes all the elements in the container from the scene
  59783. * @param container contains the elements to remove
  59784. * @param dispose if the removed element should be disposed (default: false)
  59785. */
  59786. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  59787. }
  59788. }
  59789. declare module "babylonjs/Shaders/layer.fragment" {
  59790. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  59791. /** @hidden */
  59792. export var layerPixelShader: {
  59793. name: string;
  59794. shader: string;
  59795. };
  59796. }
  59797. declare module "babylonjs/Shaders/layer.vertex" {
  59798. /** @hidden */
  59799. export var layerVertexShader: {
  59800. name: string;
  59801. shader: string;
  59802. };
  59803. }
  59804. declare module "babylonjs/Layers/layer" {
  59805. import { Observable } from "babylonjs/Misc/observable";
  59806. import { Nullable } from "babylonjs/types";
  59807. import { Scene } from "babylonjs/scene";
  59808. import { Vector2 } from "babylonjs/Maths/math.vector";
  59809. import { Color4 } from "babylonjs/Maths/math.color";
  59810. import { Texture } from "babylonjs/Materials/Textures/texture";
  59811. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  59812. import "babylonjs/Shaders/layer.fragment";
  59813. import "babylonjs/Shaders/layer.vertex";
  59814. /**
  59815. * This represents a full screen 2d layer.
  59816. * This can be useful to display a picture in the background of your scene for instance.
  59817. * @see https://www.babylonjs-playground.com/#08A2BS#1
  59818. */
  59819. export class Layer {
  59820. /**
  59821. * Define the name of the layer.
  59822. */
  59823. name: string;
  59824. /**
  59825. * Define the texture the layer should display.
  59826. */
  59827. texture: Nullable<Texture>;
  59828. /**
  59829. * Is the layer in background or foreground.
  59830. */
  59831. isBackground: boolean;
  59832. /**
  59833. * Define the color of the layer (instead of texture).
  59834. */
  59835. color: Color4;
  59836. /**
  59837. * Define the scale of the layer in order to zoom in out of the texture.
  59838. */
  59839. scale: Vector2;
  59840. /**
  59841. * Define an offset for the layer in order to shift the texture.
  59842. */
  59843. offset: Vector2;
  59844. /**
  59845. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  59846. */
  59847. alphaBlendingMode: number;
  59848. /**
  59849. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  59850. * Alpha test will not mix with the background color in case of transparency.
  59851. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  59852. */
  59853. alphaTest: boolean;
  59854. /**
  59855. * Define a mask to restrict the layer to only some of the scene cameras.
  59856. */
  59857. layerMask: number;
  59858. /**
  59859. * Define the list of render target the layer is visible into.
  59860. */
  59861. renderTargetTextures: RenderTargetTexture[];
  59862. /**
  59863. * Define if the layer is only used in renderTarget or if it also
  59864. * renders in the main frame buffer of the canvas.
  59865. */
  59866. renderOnlyInRenderTargetTextures: boolean;
  59867. private _scene;
  59868. private _vertexBuffers;
  59869. private _indexBuffer;
  59870. private _effect;
  59871. private _previousDefines;
  59872. /**
  59873. * An event triggered when the layer is disposed.
  59874. */
  59875. onDisposeObservable: Observable<Layer>;
  59876. private _onDisposeObserver;
  59877. /**
  59878. * Back compatibility with callback before the onDisposeObservable existed.
  59879. * The set callback will be triggered when the layer has been disposed.
  59880. */
  59881. set onDispose(callback: () => void);
  59882. /**
  59883. * An event triggered before rendering the scene
  59884. */
  59885. onBeforeRenderObservable: Observable<Layer>;
  59886. private _onBeforeRenderObserver;
  59887. /**
  59888. * Back compatibility with callback before the onBeforeRenderObservable existed.
  59889. * The set callback will be triggered just before rendering the layer.
  59890. */
  59891. set onBeforeRender(callback: () => void);
  59892. /**
  59893. * An event triggered after rendering the scene
  59894. */
  59895. onAfterRenderObservable: Observable<Layer>;
  59896. private _onAfterRenderObserver;
  59897. /**
  59898. * Back compatibility with callback before the onAfterRenderObservable existed.
  59899. * The set callback will be triggered just after rendering the layer.
  59900. */
  59901. set onAfterRender(callback: () => void);
  59902. /**
  59903. * Instantiates a new layer.
  59904. * This represents a full screen 2d layer.
  59905. * This can be useful to display a picture in the background of your scene for instance.
  59906. * @see https://www.babylonjs-playground.com/#08A2BS#1
  59907. * @param name Define the name of the layer in the scene
  59908. * @param imgUrl Define the url of the texture to display in the layer
  59909. * @param scene Define the scene the layer belongs to
  59910. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  59911. * @param color Defines a color for the layer
  59912. */
  59913. constructor(
  59914. /**
  59915. * Define the name of the layer.
  59916. */
  59917. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  59918. private _createIndexBuffer;
  59919. /** @hidden */
  59920. _rebuild(): void;
  59921. /**
  59922. * Renders the layer in the scene.
  59923. */
  59924. render(): void;
  59925. /**
  59926. * Disposes and releases the associated ressources.
  59927. */
  59928. dispose(): void;
  59929. }
  59930. }
  59931. declare module "babylonjs/Layers/index" {
  59932. export * from "babylonjs/Layers/effectLayer";
  59933. export * from "babylonjs/Layers/effectLayerSceneComponent";
  59934. export * from "babylonjs/Layers/glowLayer";
  59935. export * from "babylonjs/Layers/highlightLayer";
  59936. export * from "babylonjs/Layers/layer";
  59937. export * from "babylonjs/Layers/layerSceneComponent";
  59938. }
  59939. declare module "babylonjs/Shaders/lensFlare.fragment" {
  59940. /** @hidden */
  59941. export var lensFlarePixelShader: {
  59942. name: string;
  59943. shader: string;
  59944. };
  59945. }
  59946. declare module "babylonjs/Shaders/lensFlare.vertex" {
  59947. /** @hidden */
  59948. export var lensFlareVertexShader: {
  59949. name: string;
  59950. shader: string;
  59951. };
  59952. }
  59953. declare module "babylonjs/LensFlares/lensFlareSystem" {
  59954. import { Scene } from "babylonjs/scene";
  59955. import { Vector3 } from "babylonjs/Maths/math.vector";
  59956. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59957. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  59958. import "babylonjs/Shaders/lensFlare.fragment";
  59959. import "babylonjs/Shaders/lensFlare.vertex";
  59960. import { Viewport } from "babylonjs/Maths/math.viewport";
  59961. /**
  59962. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  59963. * It is usually composed of several `lensFlare`.
  59964. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  59965. */
  59966. export class LensFlareSystem {
  59967. /**
  59968. * Define the name of the lens flare system
  59969. */
  59970. name: string;
  59971. /**
  59972. * List of lens flares used in this system.
  59973. */
  59974. lensFlares: LensFlare[];
  59975. /**
  59976. * Define a limit from the border the lens flare can be visible.
  59977. */
  59978. borderLimit: number;
  59979. /**
  59980. * Define a viewport border we do not want to see the lens flare in.
  59981. */
  59982. viewportBorder: number;
  59983. /**
  59984. * Define a predicate which could limit the list of meshes able to occlude the effect.
  59985. */
  59986. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  59987. /**
  59988. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  59989. */
  59990. layerMask: number;
  59991. /**
  59992. * Define the id of the lens flare system in the scene.
  59993. * (equal to name by default)
  59994. */
  59995. id: string;
  59996. private _scene;
  59997. private _emitter;
  59998. private _vertexBuffers;
  59999. private _indexBuffer;
  60000. private _effect;
  60001. private _positionX;
  60002. private _positionY;
  60003. private _isEnabled;
  60004. /** @hidden */
  60005. static _SceneComponentInitialization: (scene: Scene) => void;
  60006. /**
  60007. * Instantiates a lens flare system.
  60008. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  60009. * It is usually composed of several `lensFlare`.
  60010. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60011. * @param name Define the name of the lens flare system in the scene
  60012. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  60013. * @param scene Define the scene the lens flare system belongs to
  60014. */
  60015. constructor(
  60016. /**
  60017. * Define the name of the lens flare system
  60018. */
  60019. name: string, emitter: any, scene: Scene);
  60020. /**
  60021. * Define if the lens flare system is enabled.
  60022. */
  60023. get isEnabled(): boolean;
  60024. set isEnabled(value: boolean);
  60025. /**
  60026. * Get the scene the effects belongs to.
  60027. * @returns the scene holding the lens flare system
  60028. */
  60029. getScene(): Scene;
  60030. /**
  60031. * Get the emitter of the lens flare system.
  60032. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  60033. * @returns the emitter of the lens flare system
  60034. */
  60035. getEmitter(): any;
  60036. /**
  60037. * Set the emitter of the lens flare system.
  60038. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  60039. * @param newEmitter Define the new emitter of the system
  60040. */
  60041. setEmitter(newEmitter: any): void;
  60042. /**
  60043. * Get the lens flare system emitter position.
  60044. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  60045. * @returns the position
  60046. */
  60047. getEmitterPosition(): Vector3;
  60048. /**
  60049. * @hidden
  60050. */
  60051. computeEffectivePosition(globalViewport: Viewport): boolean;
  60052. /** @hidden */
  60053. _isVisible(): boolean;
  60054. /**
  60055. * @hidden
  60056. */
  60057. render(): boolean;
  60058. /**
  60059. * Dispose and release the lens flare with its associated resources.
  60060. */
  60061. dispose(): void;
  60062. /**
  60063. * Parse a lens flare system from a JSON repressentation
  60064. * @param parsedLensFlareSystem Define the JSON to parse
  60065. * @param scene Define the scene the parsed system should be instantiated in
  60066. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  60067. * @returns the parsed system
  60068. */
  60069. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  60070. /**
  60071. * Serialize the current Lens Flare System into a JSON representation.
  60072. * @returns the serialized JSON
  60073. */
  60074. serialize(): any;
  60075. }
  60076. }
  60077. declare module "babylonjs/LensFlares/lensFlare" {
  60078. import { Nullable } from "babylonjs/types";
  60079. import { Color3 } from "babylonjs/Maths/math.color";
  60080. import { Texture } from "babylonjs/Materials/Textures/texture";
  60081. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  60082. /**
  60083. * This represents one of the lens effect in a `lensFlareSystem`.
  60084. * It controls one of the indiviual texture used in the effect.
  60085. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60086. */
  60087. export class LensFlare {
  60088. /**
  60089. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  60090. */
  60091. size: number;
  60092. /**
  60093. * 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.
  60094. */
  60095. position: number;
  60096. /**
  60097. * Define the lens color.
  60098. */
  60099. color: Color3;
  60100. /**
  60101. * Define the lens texture.
  60102. */
  60103. texture: Nullable<Texture>;
  60104. /**
  60105. * Define the alpha mode to render this particular lens.
  60106. */
  60107. alphaMode: number;
  60108. private _system;
  60109. /**
  60110. * Creates a new Lens Flare.
  60111. * This represents one of the lens effect in a `lensFlareSystem`.
  60112. * It controls one of the indiviual texture used in the effect.
  60113. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60114. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  60115. * @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.
  60116. * @param color Define the lens color
  60117. * @param imgUrl Define the lens texture url
  60118. * @param system Define the `lensFlareSystem` this flare is part of
  60119. * @returns The newly created Lens Flare
  60120. */
  60121. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  60122. /**
  60123. * Instantiates a new Lens Flare.
  60124. * This represents one of the lens effect in a `lensFlareSystem`.
  60125. * It controls one of the indiviual texture used in the effect.
  60126. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60127. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  60128. * @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.
  60129. * @param color Define the lens color
  60130. * @param imgUrl Define the lens texture url
  60131. * @param system Define the `lensFlareSystem` this flare is part of
  60132. */
  60133. constructor(
  60134. /**
  60135. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  60136. */
  60137. size: number,
  60138. /**
  60139. * 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.
  60140. */
  60141. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  60142. /**
  60143. * Dispose and release the lens flare with its associated resources.
  60144. */
  60145. dispose(): void;
  60146. }
  60147. }
  60148. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  60149. import { Nullable } from "babylonjs/types";
  60150. import { Scene } from "babylonjs/scene";
  60151. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  60152. import { AbstractScene } from "babylonjs/abstractScene";
  60153. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  60154. module "babylonjs/abstractScene" {
  60155. interface AbstractScene {
  60156. /**
  60157. * The list of lens flare system added to the scene
  60158. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60159. */
  60160. lensFlareSystems: Array<LensFlareSystem>;
  60161. /**
  60162. * Removes the given lens flare system from this scene.
  60163. * @param toRemove The lens flare system to remove
  60164. * @returns The index of the removed lens flare system
  60165. */
  60166. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  60167. /**
  60168. * Adds the given lens flare system to this scene
  60169. * @param newLensFlareSystem The lens flare system to add
  60170. */
  60171. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  60172. /**
  60173. * Gets a lens flare system using its name
  60174. * @param name defines the name to look for
  60175. * @returns the lens flare system or null if not found
  60176. */
  60177. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  60178. /**
  60179. * Gets a lens flare system using its id
  60180. * @param id defines the id to look for
  60181. * @returns the lens flare system or null if not found
  60182. */
  60183. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  60184. }
  60185. }
  60186. /**
  60187. * Defines the lens flare scene component responsible to manage any lens flares
  60188. * in a given scene.
  60189. */
  60190. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  60191. /**
  60192. * The component name helpfull to identify the component in the list of scene components.
  60193. */
  60194. readonly name: string;
  60195. /**
  60196. * The scene the component belongs to.
  60197. */
  60198. scene: Scene;
  60199. /**
  60200. * Creates a new instance of the component for the given scene
  60201. * @param scene Defines the scene to register the component in
  60202. */
  60203. constructor(scene: Scene);
  60204. /**
  60205. * Registers the component in a given scene
  60206. */
  60207. register(): void;
  60208. /**
  60209. * Rebuilds the elements related to this component in case of
  60210. * context lost for instance.
  60211. */
  60212. rebuild(): void;
  60213. /**
  60214. * Adds all the elements from the container to the scene
  60215. * @param container the container holding the elements
  60216. */
  60217. addFromContainer(container: AbstractScene): void;
  60218. /**
  60219. * Removes all the elements in the container from the scene
  60220. * @param container contains the elements to remove
  60221. * @param dispose if the removed element should be disposed (default: false)
  60222. */
  60223. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  60224. /**
  60225. * Serializes the component data to the specified json object
  60226. * @param serializationObject The object to serialize to
  60227. */
  60228. serialize(serializationObject: any): void;
  60229. /**
  60230. * Disposes the component and the associated ressources.
  60231. */
  60232. dispose(): void;
  60233. private _draw;
  60234. }
  60235. }
  60236. declare module "babylonjs/LensFlares/index" {
  60237. export * from "babylonjs/LensFlares/lensFlare";
  60238. export * from "babylonjs/LensFlares/lensFlareSystem";
  60239. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  60240. }
  60241. declare module "babylonjs/Shaders/depth.fragment" {
  60242. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  60243. /** @hidden */
  60244. export var depthPixelShader: {
  60245. name: string;
  60246. shader: string;
  60247. };
  60248. }
  60249. declare module "babylonjs/Shaders/depth.vertex" {
  60250. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  60251. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  60252. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  60253. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  60254. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  60255. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  60256. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  60257. /** @hidden */
  60258. export var depthVertexShader: {
  60259. name: string;
  60260. shader: string;
  60261. };
  60262. }
  60263. declare module "babylonjs/Rendering/depthRenderer" {
  60264. import { Nullable } from "babylonjs/types";
  60265. import { SubMesh } from "babylonjs/Meshes/subMesh";
  60266. import { Scene } from "babylonjs/scene";
  60267. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  60268. import { Camera } from "babylonjs/Cameras/camera";
  60269. import "babylonjs/Shaders/depth.fragment";
  60270. import "babylonjs/Shaders/depth.vertex";
  60271. /**
  60272. * This represents a depth renderer in Babylon.
  60273. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  60274. */
  60275. export class DepthRenderer {
  60276. private _scene;
  60277. private _depthMap;
  60278. private _effect;
  60279. private readonly _storeNonLinearDepth;
  60280. private readonly _clearColor;
  60281. /** Get if the depth renderer is using packed depth or not */
  60282. readonly isPacked: boolean;
  60283. private _cachedDefines;
  60284. private _camera;
  60285. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  60286. enabled: boolean;
  60287. /**
  60288. * Specifiess that the depth renderer will only be used within
  60289. * the camera it is created for.
  60290. * This can help forcing its rendering during the camera processing.
  60291. */
  60292. useOnlyInActiveCamera: boolean;
  60293. /** @hidden */
  60294. static _SceneComponentInitialization: (scene: Scene) => void;
  60295. /**
  60296. * Instantiates a depth renderer
  60297. * @param scene The scene the renderer belongs to
  60298. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  60299. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  60300. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  60301. */
  60302. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  60303. /**
  60304. * Creates the depth rendering effect and checks if the effect is ready.
  60305. * @param subMesh The submesh to be used to render the depth map of
  60306. * @param useInstances If multiple world instances should be used
  60307. * @returns if the depth renderer is ready to render the depth map
  60308. */
  60309. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60310. /**
  60311. * Gets the texture which the depth map will be written to.
  60312. * @returns The depth map texture
  60313. */
  60314. getDepthMap(): RenderTargetTexture;
  60315. /**
  60316. * Disposes of the depth renderer.
  60317. */
  60318. dispose(): void;
  60319. }
  60320. }
  60321. declare module "babylonjs/Shaders/minmaxRedux.fragment" {
  60322. /** @hidden */
  60323. export var minmaxReduxPixelShader: {
  60324. name: string;
  60325. shader: string;
  60326. };
  60327. }
  60328. declare module "babylonjs/Misc/minMaxReducer" {
  60329. import { Nullable } from "babylonjs/types";
  60330. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  60331. import { Camera } from "babylonjs/Cameras/camera";
  60332. import { Observer } from "babylonjs/Misc/observable";
  60333. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  60334. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  60335. import { Observable } from "babylonjs/Misc/observable";
  60336. import "babylonjs/Shaders/minmaxRedux.fragment";
  60337. /**
  60338. * This class computes a min/max reduction from a texture: it means it computes the minimum
  60339. * and maximum values from all values of the texture.
  60340. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  60341. * The source values are read from the red channel of the texture.
  60342. */
  60343. export class MinMaxReducer {
  60344. /**
  60345. * Observable triggered when the computation has been performed
  60346. */
  60347. onAfterReductionPerformed: Observable<{
  60348. min: number;
  60349. max: number;
  60350. }>;
  60351. protected _camera: Camera;
  60352. protected _sourceTexture: Nullable<RenderTargetTexture>;
  60353. protected _reductionSteps: Nullable<Array<PostProcess>>;
  60354. protected _postProcessManager: PostProcessManager;
  60355. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  60356. protected _forceFullscreenViewport: boolean;
  60357. /**
  60358. * Creates a min/max reducer
  60359. * @param camera The camera to use for the post processes
  60360. */
  60361. constructor(camera: Camera);
  60362. /**
  60363. * Gets the texture used to read the values from.
  60364. */
  60365. get sourceTexture(): Nullable<RenderTargetTexture>;
  60366. /**
  60367. * Sets the source texture to read the values from.
  60368. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  60369. * because in such textures '1' value must not be taken into account to compute the maximum
  60370. * as this value is used to clear the texture.
  60371. * Note that the computation is not activated by calling this function, you must call activate() for that!
  60372. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  60373. * @param depthRedux Indicates if the texture is a depth texture or not
  60374. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  60375. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  60376. */
  60377. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  60378. /**
  60379. * Defines the refresh rate of the computation.
  60380. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  60381. */
  60382. get refreshRate(): number;
  60383. set refreshRate(value: number);
  60384. protected _activated: boolean;
  60385. /**
  60386. * Gets the activation status of the reducer
  60387. */
  60388. get activated(): boolean;
  60389. /**
  60390. * Activates the reduction computation.
  60391. * When activated, the observers registered in onAfterReductionPerformed are
  60392. * called after the compuation is performed
  60393. */
  60394. activate(): void;
  60395. /**
  60396. * Deactivates the reduction computation.
  60397. */
  60398. deactivate(): void;
  60399. /**
  60400. * Disposes the min/max reducer
  60401. * @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.
  60402. */
  60403. dispose(disposeAll?: boolean): void;
  60404. }
  60405. }
  60406. declare module "babylonjs/Misc/depthReducer" {
  60407. import { Nullable } from "babylonjs/types";
  60408. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  60409. import { Camera } from "babylonjs/Cameras/camera";
  60410. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  60411. import { MinMaxReducer } from "babylonjs/Misc/minMaxReducer";
  60412. /**
  60413. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  60414. */
  60415. export class DepthReducer extends MinMaxReducer {
  60416. private _depthRenderer;
  60417. private _depthRendererId;
  60418. /**
  60419. * Gets the depth renderer used for the computation.
  60420. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  60421. */
  60422. get depthRenderer(): Nullable<DepthRenderer>;
  60423. /**
  60424. * Creates a depth reducer
  60425. * @param camera The camera used to render the depth texture
  60426. */
  60427. constructor(camera: Camera);
  60428. /**
  60429. * Sets the depth renderer to use to generate the depth map
  60430. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  60431. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  60432. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  60433. */
  60434. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  60435. /** @hidden */
  60436. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  60437. /**
  60438. * Activates the reduction computation.
  60439. * When activated, the observers registered in onAfterReductionPerformed are
  60440. * called after the compuation is performed
  60441. */
  60442. activate(): void;
  60443. /**
  60444. * Deactivates the reduction computation.
  60445. */
  60446. deactivate(): void;
  60447. /**
  60448. * Disposes the depth reducer
  60449. * @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.
  60450. */
  60451. dispose(disposeAll?: boolean): void;
  60452. }
  60453. }
  60454. declare module "babylonjs/Lights/Shadows/cascadedShadowGenerator" {
  60455. import { Nullable } from "babylonjs/types";
  60456. import { Scene } from "babylonjs/scene";
  60457. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  60458. import { SubMesh } from "babylonjs/Meshes/subMesh";
  60459. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60460. import { Effect } from "babylonjs/Materials/effect";
  60461. import "babylonjs/Shaders/shadowMap.fragment";
  60462. import "babylonjs/Shaders/shadowMap.vertex";
  60463. import "babylonjs/Shaders/depthBoxBlur.fragment";
  60464. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  60465. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  60466. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  60467. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  60468. /**
  60469. * A CSM implementation allowing casting shadows on large scenes.
  60470. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  60471. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  60472. */
  60473. export class CascadedShadowGenerator extends ShadowGenerator {
  60474. private static readonly frustumCornersNDCSpace;
  60475. /**
  60476. * Name of the CSM class
  60477. */
  60478. static CLASSNAME: string;
  60479. /**
  60480. * Defines the default number of cascades used by the CSM.
  60481. */
  60482. static readonly DEFAULT_CASCADES_COUNT: number;
  60483. /**
  60484. * Defines the minimum number of cascades used by the CSM.
  60485. */
  60486. static readonly MIN_CASCADES_COUNT: number;
  60487. /**
  60488. * Defines the maximum number of cascades used by the CSM.
  60489. */
  60490. static readonly MAX_CASCADES_COUNT: number;
  60491. protected _validateFilter(filter: number): number;
  60492. /**
  60493. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  60494. */
  60495. penumbraDarkness: number;
  60496. private _numCascades;
  60497. /**
  60498. * Gets or set the number of cascades used by the CSM.
  60499. */
  60500. get numCascades(): number;
  60501. set numCascades(value: number);
  60502. /**
  60503. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  60504. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  60505. */
  60506. stabilizeCascades: boolean;
  60507. private _freezeShadowCastersBoundingInfo;
  60508. private _freezeShadowCastersBoundingInfoObservable;
  60509. /**
  60510. * Enables or disables the shadow casters bounding info computation.
  60511. * If your shadow casters don't move, you can disable this feature.
  60512. * If it is enabled, the bounding box computation is done every frame.
  60513. */
  60514. get freezeShadowCastersBoundingInfo(): boolean;
  60515. set freezeShadowCastersBoundingInfo(freeze: boolean);
  60516. private _scbiMin;
  60517. private _scbiMax;
  60518. protected _computeShadowCastersBoundingInfo(): void;
  60519. protected _shadowCastersBoundingInfo: BoundingInfo;
  60520. /**
  60521. * Gets or sets the shadow casters bounding info.
  60522. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  60523. * so that the system won't overwrite the bounds you provide
  60524. */
  60525. get shadowCastersBoundingInfo(): BoundingInfo;
  60526. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  60527. protected _breaksAreDirty: boolean;
  60528. protected _minDistance: number;
  60529. protected _maxDistance: number;
  60530. /**
  60531. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  60532. *
  60533. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  60534. * If you don't know these values, simply leave them to their defaults and don't call this function.
  60535. * @param min minimal distance for the breaks (default to 0.)
  60536. * @param max maximal distance for the breaks (default to 1.)
  60537. */
  60538. setMinMaxDistance(min: number, max: number): void;
  60539. /** Gets the minimal distance used in the cascade break computation */
  60540. get minDistance(): number;
  60541. /** Gets the maximal distance used in the cascade break computation */
  60542. get maxDistance(): number;
  60543. /**
  60544. * Gets the class name of that object
  60545. * @returns "CascadedShadowGenerator"
  60546. */
  60547. getClassName(): string;
  60548. private _cascadeMinExtents;
  60549. private _cascadeMaxExtents;
  60550. /**
  60551. * Gets a cascade minimum extents
  60552. * @param cascadeIndex index of the cascade
  60553. * @returns the minimum cascade extents
  60554. */
  60555. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  60556. /**
  60557. * Gets a cascade maximum extents
  60558. * @param cascadeIndex index of the cascade
  60559. * @returns the maximum cascade extents
  60560. */
  60561. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  60562. private _cascades;
  60563. private _currentLayer;
  60564. private _viewSpaceFrustumsZ;
  60565. private _viewMatrices;
  60566. private _projectionMatrices;
  60567. private _transformMatrices;
  60568. private _transformMatricesAsArray;
  60569. private _frustumLengths;
  60570. private _lightSizeUVCorrection;
  60571. private _depthCorrection;
  60572. private _frustumCornersWorldSpace;
  60573. private _frustumCenter;
  60574. private _shadowCameraPos;
  60575. private _shadowMaxZ;
  60576. /**
  60577. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  60578. * It defaults to camera.maxZ
  60579. */
  60580. get shadowMaxZ(): number;
  60581. /**
  60582. * Sets the shadow max z distance.
  60583. */
  60584. set shadowMaxZ(value: number);
  60585. protected _debug: boolean;
  60586. /**
  60587. * Gets or sets the debug flag.
  60588. * When enabled, the cascades are materialized by different colors on the screen.
  60589. */
  60590. get debug(): boolean;
  60591. set debug(dbg: boolean);
  60592. private _depthClamp;
  60593. /**
  60594. * Gets or sets the depth clamping value.
  60595. *
  60596. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  60597. * to account for the shadow casters far away.
  60598. *
  60599. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  60600. */
  60601. get depthClamp(): boolean;
  60602. set depthClamp(value: boolean);
  60603. private _cascadeBlendPercentage;
  60604. /**
  60605. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  60606. * It defaults to 0.1 (10% blending).
  60607. */
  60608. get cascadeBlendPercentage(): number;
  60609. set cascadeBlendPercentage(value: number);
  60610. private _lambda;
  60611. /**
  60612. * Gets or set the lambda parameter.
  60613. * This parameter is used to split the camera frustum and create the cascades.
  60614. * 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.
  60615. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  60616. */
  60617. get lambda(): number;
  60618. set lambda(value: number);
  60619. /**
  60620. * Gets the view matrix corresponding to a given cascade
  60621. * @param cascadeNum cascade to retrieve the view matrix from
  60622. * @returns the cascade view matrix
  60623. */
  60624. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  60625. /**
  60626. * Gets the projection matrix corresponding to a given cascade
  60627. * @param cascadeNum cascade to retrieve the projection matrix from
  60628. * @returns the cascade projection matrix
  60629. */
  60630. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  60631. /**
  60632. * Gets the transformation matrix corresponding to a given cascade
  60633. * @param cascadeNum cascade to retrieve the transformation matrix from
  60634. * @returns the cascade transformation matrix
  60635. */
  60636. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  60637. private _depthRenderer;
  60638. /**
  60639. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  60640. *
  60641. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  60642. *
  60643. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  60644. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  60645. * @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
  60646. */
  60647. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  60648. private _depthReducer;
  60649. private _autoCalcDepthBounds;
  60650. /**
  60651. * Gets or sets the autoCalcDepthBounds property.
  60652. *
  60653. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  60654. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  60655. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  60656. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  60657. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  60658. */
  60659. get autoCalcDepthBounds(): boolean;
  60660. set autoCalcDepthBounds(value: boolean);
  60661. /**
  60662. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  60663. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  60664. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  60665. * for setting the refresh rate on the renderer yourself!
  60666. */
  60667. get autoCalcDepthBoundsRefreshRate(): number;
  60668. set autoCalcDepthBoundsRefreshRate(value: number);
  60669. /**
  60670. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  60671. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  60672. * you change the camera near/far planes!
  60673. */
  60674. splitFrustum(): void;
  60675. private _splitFrustum;
  60676. private _computeMatrices;
  60677. private _computeFrustumInWorldSpace;
  60678. private _computeCascadeFrustum;
  60679. /**
  60680. * Support test.
  60681. */
  60682. static get IsSupported(): boolean;
  60683. /** @hidden */
  60684. static _SceneComponentInitialization: (scene: Scene) => void;
  60685. /**
  60686. * Creates a Cascaded Shadow Generator object.
  60687. * A ShadowGenerator is the required tool to use the shadows.
  60688. * Each directional light casting shadows needs to use its own ShadowGenerator.
  60689. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  60690. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  60691. * @param light The directional light object generating the shadows.
  60692. * @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.
  60693. */
  60694. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  60695. protected _initializeGenerator(): void;
  60696. protected _createTargetRenderTexture(): void;
  60697. protected _initializeShadowMap(): void;
  60698. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  60699. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  60700. /**
  60701. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  60702. * @param defines Defines of the material we want to update
  60703. * @param lightIndex Index of the light in the enabled light list of the material
  60704. */
  60705. prepareDefines(defines: any, lightIndex: number): void;
  60706. /**
  60707. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  60708. * defined in the generator but impacting the effect).
  60709. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  60710. * @param effect The effect we are binfing the information for
  60711. */
  60712. bindShadowLight(lightIndex: string, effect: Effect): void;
  60713. /**
  60714. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  60715. * (eq to view projection * shadow projection matrices)
  60716. * @returns The transform matrix used to create the shadow map
  60717. */
  60718. getTransformMatrix(): Matrix;
  60719. /**
  60720. * Disposes the ShadowGenerator.
  60721. * Returns nothing.
  60722. */
  60723. dispose(): void;
  60724. /**
  60725. * Serializes the shadow generator setup to a json object.
  60726. * @returns The serialized JSON object
  60727. */
  60728. serialize(): any;
  60729. /**
  60730. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  60731. * @param parsedShadowGenerator The JSON object to parse
  60732. * @param scene The scene to create the shadow map for
  60733. * @returns The parsed shadow generator
  60734. */
  60735. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  60736. }
  60737. }
  60738. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  60739. import { Scene } from "babylonjs/scene";
  60740. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  60741. import { AbstractScene } from "babylonjs/abstractScene";
  60742. /**
  60743. * Defines the shadow generator component responsible to manage any shadow generators
  60744. * in a given scene.
  60745. */
  60746. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  60747. /**
  60748. * The component name helpfull to identify the component in the list of scene components.
  60749. */
  60750. readonly name: string;
  60751. /**
  60752. * The scene the component belongs to.
  60753. */
  60754. scene: Scene;
  60755. /**
  60756. * Creates a new instance of the component for the given scene
  60757. * @param scene Defines the scene to register the component in
  60758. */
  60759. constructor(scene: Scene);
  60760. /**
  60761. * Registers the component in a given scene
  60762. */
  60763. register(): void;
  60764. /**
  60765. * Rebuilds the elements related to this component in case of
  60766. * context lost for instance.
  60767. */
  60768. rebuild(): void;
  60769. /**
  60770. * Serializes the component data to the specified json object
  60771. * @param serializationObject The object to serialize to
  60772. */
  60773. serialize(serializationObject: any): void;
  60774. /**
  60775. * Adds all the elements from the container to the scene
  60776. * @param container the container holding the elements
  60777. */
  60778. addFromContainer(container: AbstractScene): void;
  60779. /**
  60780. * Removes all the elements in the container from the scene
  60781. * @param container contains the elements to remove
  60782. * @param dispose if the removed element should be disposed (default: false)
  60783. */
  60784. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  60785. /**
  60786. * Rebuilds the elements related to this component in case of
  60787. * context lost for instance.
  60788. */
  60789. dispose(): void;
  60790. private _gatherRenderTargets;
  60791. }
  60792. }
  60793. declare module "babylonjs/Lights/Shadows/index" {
  60794. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  60795. export * from "babylonjs/Lights/Shadows/cascadedShadowGenerator";
  60796. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  60797. }
  60798. declare module "babylonjs/Lights/pointLight" {
  60799. import { Scene } from "babylonjs/scene";
  60800. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  60801. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60802. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  60803. import { Effect } from "babylonjs/Materials/effect";
  60804. /**
  60805. * A point light is a light defined by an unique point in world space.
  60806. * The light is emitted in every direction from this point.
  60807. * A good example of a point light is a standard light bulb.
  60808. * Documentation: https://doc.babylonjs.com/babylon101/lights
  60809. */
  60810. export class PointLight extends ShadowLight {
  60811. private _shadowAngle;
  60812. /**
  60813. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  60814. * This specifies what angle the shadow will use to be created.
  60815. *
  60816. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  60817. */
  60818. get shadowAngle(): number;
  60819. /**
  60820. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  60821. * This specifies what angle the shadow will use to be created.
  60822. *
  60823. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  60824. */
  60825. set shadowAngle(value: number);
  60826. /**
  60827. * Gets the direction if it has been set.
  60828. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  60829. */
  60830. get direction(): Vector3;
  60831. /**
  60832. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  60833. */
  60834. set direction(value: Vector3);
  60835. /**
  60836. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  60837. * A PointLight emits the light in every direction.
  60838. * It can cast shadows.
  60839. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  60840. * ```javascript
  60841. * var pointLight = new PointLight("pl", camera.position, scene);
  60842. * ```
  60843. * Documentation : https://doc.babylonjs.com/babylon101/lights
  60844. * @param name The light friendly name
  60845. * @param position The position of the point light in the scene
  60846. * @param scene The scene the lights belongs to
  60847. */
  60848. constructor(name: string, position: Vector3, scene: Scene);
  60849. /**
  60850. * Returns the string "PointLight"
  60851. * @returns the class name
  60852. */
  60853. getClassName(): string;
  60854. /**
  60855. * Returns the integer 0.
  60856. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  60857. */
  60858. getTypeID(): number;
  60859. /**
  60860. * Specifies wether or not the shadowmap should be a cube texture.
  60861. * @returns true if the shadowmap needs to be a cube texture.
  60862. */
  60863. needCube(): boolean;
  60864. /**
  60865. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  60866. * @param faceIndex The index of the face we are computed the direction to generate shadow
  60867. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  60868. */
  60869. getShadowDirection(faceIndex?: number): Vector3;
  60870. /**
  60871. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  60872. * - fov = PI / 2
  60873. * - aspect ratio : 1.0
  60874. * - z-near and far equal to the active camera minZ and maxZ.
  60875. * Returns the PointLight.
  60876. */
  60877. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  60878. protected _buildUniformLayout(): void;
  60879. /**
  60880. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  60881. * @param effect The effect to update
  60882. * @param lightIndex The index of the light in the effect to update
  60883. * @returns The point light
  60884. */
  60885. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  60886. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  60887. /**
  60888. * Prepares the list of defines specific to the light type.
  60889. * @param defines the list of defines
  60890. * @param lightIndex defines the index of the light for the effect
  60891. */
  60892. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  60893. }
  60894. }
  60895. declare module "babylonjs/Lights/index" {
  60896. export * from "babylonjs/Lights/light";
  60897. export * from "babylonjs/Lights/shadowLight";
  60898. export * from "babylonjs/Lights/Shadows/index";
  60899. export * from "babylonjs/Lights/directionalLight";
  60900. export * from "babylonjs/Lights/hemisphericLight";
  60901. export * from "babylonjs/Lights/pointLight";
  60902. export * from "babylonjs/Lights/spotLight";
  60903. }
  60904. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  60905. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  60906. /**
  60907. * Header information of HDR texture files.
  60908. */
  60909. export interface HDRInfo {
  60910. /**
  60911. * The height of the texture in pixels.
  60912. */
  60913. height: number;
  60914. /**
  60915. * The width of the texture in pixels.
  60916. */
  60917. width: number;
  60918. /**
  60919. * The index of the beginning of the data in the binary file.
  60920. */
  60921. dataPosition: number;
  60922. }
  60923. /**
  60924. * This groups tools to convert HDR texture to native colors array.
  60925. */
  60926. export class HDRTools {
  60927. private static Ldexp;
  60928. private static Rgbe2float;
  60929. private static readStringLine;
  60930. /**
  60931. * Reads header information from an RGBE texture stored in a native array.
  60932. * More information on this format are available here:
  60933. * https://en.wikipedia.org/wiki/RGBE_image_format
  60934. *
  60935. * @param uint8array The binary file stored in native array.
  60936. * @return The header information.
  60937. */
  60938. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  60939. /**
  60940. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  60941. * This RGBE texture needs to store the information as a panorama.
  60942. *
  60943. * More information on this format are available here:
  60944. * https://en.wikipedia.org/wiki/RGBE_image_format
  60945. *
  60946. * @param buffer The binary file stored in an array buffer.
  60947. * @param size The expected size of the extracted cubemap.
  60948. * @return The Cube Map information.
  60949. */
  60950. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  60951. /**
  60952. * Returns the pixels data extracted from an RGBE texture.
  60953. * This pixels will be stored left to right up to down in the R G B order in one array.
  60954. *
  60955. * More information on this format are available here:
  60956. * https://en.wikipedia.org/wiki/RGBE_image_format
  60957. *
  60958. * @param uint8array The binary file stored in an array buffer.
  60959. * @param hdrInfo The header information of the file.
  60960. * @return The pixels data in RGB right to left up to down order.
  60961. */
  60962. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  60963. private static RGBE_ReadPixels_RLE;
  60964. }
  60965. }
  60966. declare module "babylonjs/Materials/effectRenderer" {
  60967. import { Nullable } from "babylonjs/types";
  60968. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  60969. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  60970. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  60971. import { Viewport } from "babylonjs/Maths/math.viewport";
  60972. import { Observable } from "babylonjs/Misc/observable";
  60973. import { Effect } from "babylonjs/Materials/effect";
  60974. import "babylonjs/Shaders/postprocess.vertex";
  60975. /**
  60976. * Effect Render Options
  60977. */
  60978. export interface IEffectRendererOptions {
  60979. /**
  60980. * Defines the vertices positions.
  60981. */
  60982. positions?: number[];
  60983. /**
  60984. * Defines the indices.
  60985. */
  60986. indices?: number[];
  60987. }
  60988. /**
  60989. * Helper class to render one or more effects.
  60990. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  60991. */
  60992. export class EffectRenderer {
  60993. private engine;
  60994. private static _DefaultOptions;
  60995. private _vertexBuffers;
  60996. private _indexBuffer;
  60997. private _fullscreenViewport;
  60998. /**
  60999. * Creates an effect renderer
  61000. * @param engine the engine to use for rendering
  61001. * @param options defines the options of the effect renderer
  61002. */
  61003. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  61004. /**
  61005. * Sets the current viewport in normalized coordinates 0-1
  61006. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  61007. */
  61008. setViewport(viewport?: Viewport): void;
  61009. /**
  61010. * Binds the embedded attributes buffer to the effect.
  61011. * @param effect Defines the effect to bind the attributes for
  61012. */
  61013. bindBuffers(effect: Effect): void;
  61014. /**
  61015. * Sets the current effect wrapper to use during draw.
  61016. * The effect needs to be ready before calling this api.
  61017. * This also sets the default full screen position attribute.
  61018. * @param effectWrapper Defines the effect to draw with
  61019. */
  61020. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  61021. /**
  61022. * Restores engine states
  61023. */
  61024. restoreStates(): void;
  61025. /**
  61026. * Draws a full screen quad.
  61027. */
  61028. draw(): void;
  61029. private isRenderTargetTexture;
  61030. /**
  61031. * renders one or more effects to a specified texture
  61032. * @param effectWrapper the effect to renderer
  61033. * @param outputTexture texture to draw to, if null it will render to the screen.
  61034. */
  61035. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  61036. /**
  61037. * Disposes of the effect renderer
  61038. */
  61039. dispose(): void;
  61040. }
  61041. /**
  61042. * Options to create an EffectWrapper
  61043. */
  61044. interface EffectWrapperCreationOptions {
  61045. /**
  61046. * Engine to use to create the effect
  61047. */
  61048. engine: ThinEngine;
  61049. /**
  61050. * Fragment shader for the effect
  61051. */
  61052. fragmentShader: string;
  61053. /**
  61054. * Use the shader store instead of direct source code
  61055. */
  61056. useShaderStore?: boolean;
  61057. /**
  61058. * Vertex shader for the effect
  61059. */
  61060. vertexShader?: string;
  61061. /**
  61062. * Attributes to use in the shader
  61063. */
  61064. attributeNames?: Array<string>;
  61065. /**
  61066. * Uniforms to use in the shader
  61067. */
  61068. uniformNames?: Array<string>;
  61069. /**
  61070. * Texture sampler names to use in the shader
  61071. */
  61072. samplerNames?: Array<string>;
  61073. /**
  61074. * Defines to use in the shader
  61075. */
  61076. defines?: Array<string>;
  61077. /**
  61078. * Callback when effect is compiled
  61079. */
  61080. onCompiled?: Nullable<(effect: Effect) => void>;
  61081. /**
  61082. * The friendly name of the effect displayed in Spector.
  61083. */
  61084. name?: string;
  61085. }
  61086. /**
  61087. * Wraps an effect to be used for rendering
  61088. */
  61089. export class EffectWrapper {
  61090. /**
  61091. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  61092. */
  61093. onApplyObservable: Observable<{}>;
  61094. /**
  61095. * The underlying effect
  61096. */
  61097. effect: Effect;
  61098. /**
  61099. * Creates an effect to be renderer
  61100. * @param creationOptions options to create the effect
  61101. */
  61102. constructor(creationOptions: EffectWrapperCreationOptions);
  61103. /**
  61104. * Disposes of the effect wrapper
  61105. */
  61106. dispose(): void;
  61107. }
  61108. }
  61109. declare module "babylonjs/Shaders/hdrFiltering.vertex" {
  61110. /** @hidden */
  61111. export var hdrFilteringVertexShader: {
  61112. name: string;
  61113. shader: string;
  61114. };
  61115. }
  61116. declare module "babylonjs/Shaders/hdrFiltering.fragment" {
  61117. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61118. import "babylonjs/Shaders/ShadersInclude/importanceSampling";
  61119. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  61120. import "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions";
  61121. /** @hidden */
  61122. export var hdrFilteringPixelShader: {
  61123. name: string;
  61124. shader: string;
  61125. };
  61126. }
  61127. declare module "babylonjs/Materials/Textures/Filtering/hdrFiltering" {
  61128. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  61129. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  61130. import { Nullable } from "babylonjs/types";
  61131. import "babylonjs/Shaders/hdrFiltering.vertex";
  61132. import "babylonjs/Shaders/hdrFiltering.fragment";
  61133. /**
  61134. * Options for texture filtering
  61135. */
  61136. interface IHDRFilteringOptions {
  61137. /**
  61138. * Scales pixel intensity for the input HDR map.
  61139. */
  61140. hdrScale?: number;
  61141. /**
  61142. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  61143. */
  61144. quality?: number;
  61145. }
  61146. /**
  61147. * Filters HDR maps to get correct renderings of PBR reflections
  61148. */
  61149. export class HDRFiltering {
  61150. private _engine;
  61151. private _effectRenderer;
  61152. private _effectWrapper;
  61153. private _lodGenerationOffset;
  61154. private _lodGenerationScale;
  61155. /**
  61156. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  61157. * you care about baking speed.
  61158. */
  61159. quality: number;
  61160. /**
  61161. * Scales pixel intensity for the input HDR map.
  61162. */
  61163. hdrScale: number;
  61164. /**
  61165. * Instantiates HDR filter for reflection maps
  61166. *
  61167. * @param engine Thin engine
  61168. * @param options Options
  61169. */
  61170. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  61171. private _createRenderTarget;
  61172. private _prefilterInternal;
  61173. private _createEffect;
  61174. /**
  61175. * Get a value indicating if the filter is ready to be used
  61176. * @param texture Texture to filter
  61177. * @returns true if the filter is ready
  61178. */
  61179. isReady(texture: BaseTexture): boolean;
  61180. /**
  61181. * Prefilters a cube texture to have mipmap levels representing roughness values.
  61182. * Prefiltering will be invoked at the end of next rendering pass.
  61183. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  61184. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  61185. * @param texture Texture to filter
  61186. * @param onFinished Callback when filtering is done
  61187. * @return Promise called when prefiltering is done
  61188. */
  61189. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  61190. }
  61191. }
  61192. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  61193. import { Nullable } from "babylonjs/types";
  61194. import { Scene } from "babylonjs/scene";
  61195. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  61196. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  61197. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  61198. import "babylonjs/Engines/Extensions/engine.rawTexture";
  61199. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  61200. /**
  61201. * This represents a texture coming from an HDR input.
  61202. *
  61203. * The only supported format is currently panorama picture stored in RGBE format.
  61204. * Example of such files can be found on HDRLib: http://hdrlib.com/
  61205. */
  61206. export class HDRCubeTexture extends BaseTexture {
  61207. private static _facesMapping;
  61208. private _generateHarmonics;
  61209. private _noMipmap;
  61210. private _prefilterOnLoad;
  61211. private _textureMatrix;
  61212. private _size;
  61213. private _onLoad;
  61214. private _onError;
  61215. /**
  61216. * The texture URL.
  61217. */
  61218. url: string;
  61219. /**
  61220. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  61221. */
  61222. coordinatesMode: number;
  61223. protected _isBlocking: boolean;
  61224. /**
  61225. * Sets wether or not the texture is blocking during loading.
  61226. */
  61227. set isBlocking(value: boolean);
  61228. /**
  61229. * Gets wether or not the texture is blocking during loading.
  61230. */
  61231. get isBlocking(): boolean;
  61232. protected _rotationY: number;
  61233. /**
  61234. * Sets texture matrix rotation angle around Y axis in radians.
  61235. */
  61236. set rotationY(value: number);
  61237. /**
  61238. * Gets texture matrix rotation angle around Y axis radians.
  61239. */
  61240. get rotationY(): number;
  61241. /**
  61242. * Gets or sets the center of the bounding box associated with the cube texture
  61243. * It must define where the camera used to render the texture was set
  61244. */
  61245. boundingBoxPosition: Vector3;
  61246. private _boundingBoxSize;
  61247. /**
  61248. * Gets or sets the size of the bounding box associated with the cube texture
  61249. * When defined, the cubemap will switch to local mode
  61250. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  61251. * @example https://www.babylonjs-playground.com/#RNASML
  61252. */
  61253. set boundingBoxSize(value: Vector3);
  61254. get boundingBoxSize(): Vector3;
  61255. /**
  61256. * Instantiates an HDRTexture from the following parameters.
  61257. *
  61258. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  61259. * @param sceneOrEngine The scene or engine the texture will be used in
  61260. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  61261. * @param noMipmap Forces to not generate the mipmap if true
  61262. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  61263. * @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)
  61264. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  61265. */
  61266. 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>);
  61267. /**
  61268. * Get the current class name of the texture useful for serialization or dynamic coding.
  61269. * @returns "HDRCubeTexture"
  61270. */
  61271. getClassName(): string;
  61272. /**
  61273. * Occurs when the file is raw .hdr file.
  61274. */
  61275. private loadTexture;
  61276. clone(): HDRCubeTexture;
  61277. delayLoad(): void;
  61278. /**
  61279. * Get the texture reflection matrix used to rotate/transform the reflection.
  61280. * @returns the reflection matrix
  61281. */
  61282. getReflectionTextureMatrix(): Matrix;
  61283. /**
  61284. * Set the texture reflection matrix used to rotate/transform the reflection.
  61285. * @param value Define the reflection matrix to set
  61286. */
  61287. setReflectionTextureMatrix(value: Matrix): void;
  61288. /**
  61289. * Parses a JSON representation of an HDR Texture in order to create the texture
  61290. * @param parsedTexture Define the JSON representation
  61291. * @param scene Define the scene the texture should be created in
  61292. * @param rootUrl Define the root url in case we need to load relative dependencies
  61293. * @returns the newly created texture after parsing
  61294. */
  61295. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  61296. serialize(): any;
  61297. }
  61298. }
  61299. declare module "babylonjs/Physics/physicsEngine" {
  61300. import { Nullable } from "babylonjs/types";
  61301. import { Vector3 } from "babylonjs/Maths/math.vector";
  61302. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  61303. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  61304. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  61305. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  61306. /**
  61307. * Class used to control physics engine
  61308. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  61309. */
  61310. export class PhysicsEngine implements IPhysicsEngine {
  61311. private _physicsPlugin;
  61312. /**
  61313. * Global value used to control the smallest number supported by the simulation
  61314. */
  61315. static Epsilon: number;
  61316. private _impostors;
  61317. private _joints;
  61318. private _subTimeStep;
  61319. /**
  61320. * Gets the gravity vector used by the simulation
  61321. */
  61322. gravity: Vector3;
  61323. /**
  61324. * Factory used to create the default physics plugin.
  61325. * @returns The default physics plugin
  61326. */
  61327. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  61328. /**
  61329. * Creates a new Physics Engine
  61330. * @param gravity defines the gravity vector used by the simulation
  61331. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  61332. */
  61333. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  61334. /**
  61335. * Sets the gravity vector used by the simulation
  61336. * @param gravity defines the gravity vector to use
  61337. */
  61338. setGravity(gravity: Vector3): void;
  61339. /**
  61340. * Set the time step of the physics engine.
  61341. * Default is 1/60.
  61342. * To slow it down, enter 1/600 for example.
  61343. * To speed it up, 1/30
  61344. * @param newTimeStep defines the new timestep to apply to this world.
  61345. */
  61346. setTimeStep(newTimeStep?: number): void;
  61347. /**
  61348. * Get the time step of the physics engine.
  61349. * @returns the current time step
  61350. */
  61351. getTimeStep(): number;
  61352. /**
  61353. * Set the sub time step of the physics engine.
  61354. * Default is 0 meaning there is no sub steps
  61355. * To increase physics resolution precision, set a small value (like 1 ms)
  61356. * @param subTimeStep defines the new sub timestep used for physics resolution.
  61357. */
  61358. setSubTimeStep(subTimeStep?: number): void;
  61359. /**
  61360. * Get the sub time step of the physics engine.
  61361. * @returns the current sub time step
  61362. */
  61363. getSubTimeStep(): number;
  61364. /**
  61365. * Release all resources
  61366. */
  61367. dispose(): void;
  61368. /**
  61369. * Gets the name of the current physics plugin
  61370. * @returns the name of the plugin
  61371. */
  61372. getPhysicsPluginName(): string;
  61373. /**
  61374. * Adding a new impostor for the impostor tracking.
  61375. * This will be done by the impostor itself.
  61376. * @param impostor the impostor to add
  61377. */
  61378. addImpostor(impostor: PhysicsImpostor): void;
  61379. /**
  61380. * Remove an impostor from the engine.
  61381. * This impostor and its mesh will not longer be updated by the physics engine.
  61382. * @param impostor the impostor to remove
  61383. */
  61384. removeImpostor(impostor: PhysicsImpostor): void;
  61385. /**
  61386. * Add a joint to the physics engine
  61387. * @param mainImpostor defines the main impostor to which the joint is added.
  61388. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  61389. * @param joint defines the joint that will connect both impostors.
  61390. */
  61391. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  61392. /**
  61393. * Removes a joint from the simulation
  61394. * @param mainImpostor defines the impostor used with the joint
  61395. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  61396. * @param joint defines the joint to remove
  61397. */
  61398. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  61399. /**
  61400. * Called by the scene. No need to call it.
  61401. * @param delta defines the timespam between frames
  61402. */
  61403. _step(delta: number): void;
  61404. /**
  61405. * Gets the current plugin used to run the simulation
  61406. * @returns current plugin
  61407. */
  61408. getPhysicsPlugin(): IPhysicsEnginePlugin;
  61409. /**
  61410. * Gets the list of physic impostors
  61411. * @returns an array of PhysicsImpostor
  61412. */
  61413. getImpostors(): Array<PhysicsImpostor>;
  61414. /**
  61415. * Gets the impostor for a physics enabled object
  61416. * @param object defines the object impersonated by the impostor
  61417. * @returns the PhysicsImpostor or null if not found
  61418. */
  61419. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  61420. /**
  61421. * Gets the impostor for a physics body object
  61422. * @param body defines physics body used by the impostor
  61423. * @returns the PhysicsImpostor or null if not found
  61424. */
  61425. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  61426. /**
  61427. * Does a raycast in the physics world
  61428. * @param from when should the ray start?
  61429. * @param to when should the ray end?
  61430. * @returns PhysicsRaycastResult
  61431. */
  61432. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  61433. }
  61434. }
  61435. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  61436. import { Nullable } from "babylonjs/types";
  61437. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  61438. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61439. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  61440. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  61441. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  61442. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  61443. /** @hidden */
  61444. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  61445. private _useDeltaForWorldStep;
  61446. world: any;
  61447. name: string;
  61448. private _physicsMaterials;
  61449. private _fixedTimeStep;
  61450. private _cannonRaycastResult;
  61451. private _raycastResult;
  61452. private _physicsBodysToRemoveAfterStep;
  61453. private _firstFrame;
  61454. BJSCANNON: any;
  61455. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  61456. setGravity(gravity: Vector3): void;
  61457. setTimeStep(timeStep: number): void;
  61458. getTimeStep(): number;
  61459. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  61460. private _removeMarkedPhysicsBodiesFromWorld;
  61461. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61462. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61463. generatePhysicsBody(impostor: PhysicsImpostor): void;
  61464. private _processChildMeshes;
  61465. removePhysicsBody(impostor: PhysicsImpostor): void;
  61466. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  61467. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  61468. private _addMaterial;
  61469. private _checkWithEpsilon;
  61470. private _createShape;
  61471. private _createHeightmap;
  61472. private _minus90X;
  61473. private _plus90X;
  61474. private _tmpPosition;
  61475. private _tmpDeltaPosition;
  61476. private _tmpUnityRotation;
  61477. private _updatePhysicsBodyTransformation;
  61478. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  61479. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  61480. isSupported(): boolean;
  61481. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  61482. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  61483. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  61484. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  61485. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  61486. getBodyMass(impostor: PhysicsImpostor): number;
  61487. getBodyFriction(impostor: PhysicsImpostor): number;
  61488. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  61489. getBodyRestitution(impostor: PhysicsImpostor): number;
  61490. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  61491. sleepBody(impostor: PhysicsImpostor): void;
  61492. wakeUpBody(impostor: PhysicsImpostor): void;
  61493. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  61494. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  61495. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  61496. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  61497. getRadius(impostor: PhysicsImpostor): number;
  61498. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  61499. dispose(): void;
  61500. private _extendNamespace;
  61501. /**
  61502. * Does a raycast in the physics world
  61503. * @param from when should the ray start?
  61504. * @param to when should the ray end?
  61505. * @returns PhysicsRaycastResult
  61506. */
  61507. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  61508. }
  61509. }
  61510. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  61511. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  61512. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  61513. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  61514. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61515. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  61516. import { Nullable } from "babylonjs/types";
  61517. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  61518. /** @hidden */
  61519. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  61520. private _useDeltaForWorldStep;
  61521. world: any;
  61522. name: string;
  61523. BJSOIMO: any;
  61524. private _raycastResult;
  61525. private _fixedTimeStep;
  61526. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  61527. setGravity(gravity: Vector3): void;
  61528. setTimeStep(timeStep: number): void;
  61529. getTimeStep(): number;
  61530. private _tmpImpostorsArray;
  61531. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  61532. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61533. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61534. generatePhysicsBody(impostor: PhysicsImpostor): void;
  61535. private _tmpPositionVector;
  61536. removePhysicsBody(impostor: PhysicsImpostor): void;
  61537. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  61538. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  61539. isSupported(): boolean;
  61540. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  61541. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  61542. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  61543. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  61544. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  61545. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  61546. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  61547. getBodyMass(impostor: PhysicsImpostor): number;
  61548. getBodyFriction(impostor: PhysicsImpostor): number;
  61549. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  61550. getBodyRestitution(impostor: PhysicsImpostor): number;
  61551. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  61552. sleepBody(impostor: PhysicsImpostor): void;
  61553. wakeUpBody(impostor: PhysicsImpostor): void;
  61554. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  61555. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  61556. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  61557. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  61558. getRadius(impostor: PhysicsImpostor): number;
  61559. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  61560. dispose(): void;
  61561. /**
  61562. * Does a raycast in the physics world
  61563. * @param from when should the ray start?
  61564. * @param to when should the ray end?
  61565. * @returns PhysicsRaycastResult
  61566. */
  61567. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  61568. }
  61569. }
  61570. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  61571. import { Nullable } from "babylonjs/types";
  61572. import { Scene } from "babylonjs/scene";
  61573. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  61574. import { Color4 } from "babylonjs/Maths/math.color";
  61575. import { Mesh } from "babylonjs/Meshes/mesh";
  61576. /**
  61577. * Class containing static functions to help procedurally build meshes
  61578. */
  61579. export class RibbonBuilder {
  61580. /**
  61581. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  61582. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  61583. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  61584. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  61585. * * 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
  61586. * * 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
  61587. * * 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
  61588. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61589. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61590. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61591. * * 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
  61592. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  61593. * * 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
  61594. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  61595. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61596. * @param name defines the name of the mesh
  61597. * @param options defines the options used to create the mesh
  61598. * @param scene defines the hosting scene
  61599. * @returns the ribbon mesh
  61600. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  61601. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61602. */
  61603. static CreateRibbon(name: string, options: {
  61604. pathArray: Vector3[][];
  61605. closeArray?: boolean;
  61606. closePath?: boolean;
  61607. offset?: number;
  61608. updatable?: boolean;
  61609. sideOrientation?: number;
  61610. frontUVs?: Vector4;
  61611. backUVs?: Vector4;
  61612. instance?: Mesh;
  61613. invertUV?: boolean;
  61614. uvs?: Vector2[];
  61615. colors?: Color4[];
  61616. }, scene?: Nullable<Scene>): Mesh;
  61617. }
  61618. }
  61619. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  61620. import { Nullable } from "babylonjs/types";
  61621. import { Scene } from "babylonjs/scene";
  61622. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  61623. import { Mesh } from "babylonjs/Meshes/mesh";
  61624. /**
  61625. * Class containing static functions to help procedurally build meshes
  61626. */
  61627. export class ShapeBuilder {
  61628. /**
  61629. * 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.
  61630. * * 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.
  61631. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  61632. * * 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.
  61633. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  61634. * * 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
  61635. * * 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
  61636. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  61637. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61638. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61639. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  61640. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61641. * @param name defines the name of the mesh
  61642. * @param options defines the options used to create the mesh
  61643. * @param scene defines the hosting scene
  61644. * @returns the extruded shape mesh
  61645. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61646. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  61647. */
  61648. static ExtrudeShape(name: string, options: {
  61649. shape: Vector3[];
  61650. path: Vector3[];
  61651. scale?: number;
  61652. rotation?: number;
  61653. cap?: number;
  61654. updatable?: boolean;
  61655. sideOrientation?: number;
  61656. frontUVs?: Vector4;
  61657. backUVs?: Vector4;
  61658. instance?: Mesh;
  61659. invertUV?: boolean;
  61660. }, scene?: Nullable<Scene>): Mesh;
  61661. /**
  61662. * Creates an custom extruded shape mesh.
  61663. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  61664. * * 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.
  61665. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  61666. * * 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
  61667. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  61668. * * 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
  61669. * * It must returns a float value that will be the scale value applied to the shape on each path point
  61670. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  61671. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  61672. * * 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
  61673. * * 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
  61674. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  61675. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61676. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61677. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61678. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61679. * @param name defines the name of the mesh
  61680. * @param options defines the options used to create the mesh
  61681. * @param scene defines the hosting scene
  61682. * @returns the custom extruded shape mesh
  61683. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  61684. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61685. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  61686. */
  61687. static ExtrudeShapeCustom(name: string, options: {
  61688. shape: Vector3[];
  61689. path: Vector3[];
  61690. scaleFunction?: any;
  61691. rotationFunction?: any;
  61692. ribbonCloseArray?: boolean;
  61693. ribbonClosePath?: boolean;
  61694. cap?: number;
  61695. updatable?: boolean;
  61696. sideOrientation?: number;
  61697. frontUVs?: Vector4;
  61698. backUVs?: Vector4;
  61699. instance?: Mesh;
  61700. invertUV?: boolean;
  61701. }, scene?: Nullable<Scene>): Mesh;
  61702. private static _ExtrudeShapeGeneric;
  61703. }
  61704. }
  61705. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  61706. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  61707. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  61708. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  61709. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  61710. import { Nullable } from "babylonjs/types";
  61711. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61712. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  61713. /**
  61714. * AmmoJS Physics plugin
  61715. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  61716. * @see https://github.com/kripken/ammo.js/
  61717. */
  61718. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  61719. private _useDeltaForWorldStep;
  61720. /**
  61721. * Reference to the Ammo library
  61722. */
  61723. bjsAMMO: any;
  61724. /**
  61725. * Created ammoJS world which physics bodies are added to
  61726. */
  61727. world: any;
  61728. /**
  61729. * Name of the plugin
  61730. */
  61731. name: string;
  61732. private _timeStep;
  61733. private _fixedTimeStep;
  61734. private _maxSteps;
  61735. private _tmpQuaternion;
  61736. private _tmpAmmoTransform;
  61737. private _tmpAmmoQuaternion;
  61738. private _tmpAmmoConcreteContactResultCallback;
  61739. private _collisionConfiguration;
  61740. private _dispatcher;
  61741. private _overlappingPairCache;
  61742. private _solver;
  61743. private _softBodySolver;
  61744. private _tmpAmmoVectorA;
  61745. private _tmpAmmoVectorB;
  61746. private _tmpAmmoVectorC;
  61747. private _tmpAmmoVectorD;
  61748. private _tmpContactCallbackResult;
  61749. private _tmpAmmoVectorRCA;
  61750. private _tmpAmmoVectorRCB;
  61751. private _raycastResult;
  61752. private static readonly DISABLE_COLLISION_FLAG;
  61753. private static readonly KINEMATIC_FLAG;
  61754. private static readonly DISABLE_DEACTIVATION_FLAG;
  61755. /**
  61756. * Initializes the ammoJS plugin
  61757. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  61758. * @param ammoInjection can be used to inject your own ammo reference
  61759. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  61760. */
  61761. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  61762. /**
  61763. * Sets the gravity of the physics world (m/(s^2))
  61764. * @param gravity Gravity to set
  61765. */
  61766. setGravity(gravity: Vector3): void;
  61767. /**
  61768. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  61769. * @param timeStep timestep to use in seconds
  61770. */
  61771. setTimeStep(timeStep: number): void;
  61772. /**
  61773. * 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)
  61774. * @param fixedTimeStep fixedTimeStep to use in seconds
  61775. */
  61776. setFixedTimeStep(fixedTimeStep: number): void;
  61777. /**
  61778. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  61779. * @param maxSteps the maximum number of steps by the physics engine per frame
  61780. */
  61781. setMaxSteps(maxSteps: number): void;
  61782. /**
  61783. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  61784. * @returns the current timestep in seconds
  61785. */
  61786. getTimeStep(): number;
  61787. /**
  61788. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  61789. */
  61790. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  61791. private _isImpostorInContact;
  61792. private _isImpostorPairInContact;
  61793. private _stepSimulation;
  61794. /**
  61795. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  61796. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  61797. * After the step the babylon meshes are set to the position of the physics imposters
  61798. * @param delta amount of time to step forward
  61799. * @param impostors array of imposters to update before/after the step
  61800. */
  61801. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  61802. /**
  61803. * Update babylon mesh to match physics world object
  61804. * @param impostor imposter to match
  61805. */
  61806. private _afterSoftStep;
  61807. /**
  61808. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  61809. * @param impostor imposter to match
  61810. */
  61811. private _ropeStep;
  61812. /**
  61813. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  61814. * @param impostor imposter to match
  61815. */
  61816. private _softbodyOrClothStep;
  61817. private _tmpMatrix;
  61818. /**
  61819. * Applies an impulse on the imposter
  61820. * @param impostor imposter to apply impulse to
  61821. * @param force amount of force to be applied to the imposter
  61822. * @param contactPoint the location to apply the impulse on the imposter
  61823. */
  61824. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61825. /**
  61826. * Applies a force on the imposter
  61827. * @param impostor imposter to apply force
  61828. * @param force amount of force to be applied to the imposter
  61829. * @param contactPoint the location to apply the force on the imposter
  61830. */
  61831. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61832. /**
  61833. * Creates a physics body using the plugin
  61834. * @param impostor the imposter to create the physics body on
  61835. */
  61836. generatePhysicsBody(impostor: PhysicsImpostor): void;
  61837. /**
  61838. * Removes the physics body from the imposter and disposes of the body's memory
  61839. * @param impostor imposter to remove the physics body from
  61840. */
  61841. removePhysicsBody(impostor: PhysicsImpostor): void;
  61842. /**
  61843. * Generates a joint
  61844. * @param impostorJoint the imposter joint to create the joint with
  61845. */
  61846. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  61847. /**
  61848. * Removes a joint
  61849. * @param impostorJoint the imposter joint to remove the joint from
  61850. */
  61851. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  61852. private _addMeshVerts;
  61853. /**
  61854. * Initialise the soft body vertices to match its object's (mesh) vertices
  61855. * Softbody vertices (nodes) are in world space and to match this
  61856. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  61857. * @param impostor to create the softbody for
  61858. */
  61859. private _softVertexData;
  61860. /**
  61861. * Create an impostor's soft body
  61862. * @param impostor to create the softbody for
  61863. */
  61864. private _createSoftbody;
  61865. /**
  61866. * Create cloth for an impostor
  61867. * @param impostor to create the softbody for
  61868. */
  61869. private _createCloth;
  61870. /**
  61871. * Create rope for an impostor
  61872. * @param impostor to create the softbody for
  61873. */
  61874. private _createRope;
  61875. /**
  61876. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  61877. * @param impostor to create the custom physics shape for
  61878. */
  61879. private _createCustom;
  61880. private _addHullVerts;
  61881. private _createShape;
  61882. /**
  61883. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  61884. * @param impostor imposter containing the physics body and babylon object
  61885. */
  61886. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  61887. /**
  61888. * Sets the babylon object's position/rotation from the physics body's position/rotation
  61889. * @param impostor imposter containing the physics body and babylon object
  61890. * @param newPosition new position
  61891. * @param newRotation new rotation
  61892. */
  61893. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  61894. /**
  61895. * If this plugin is supported
  61896. * @returns true if its supported
  61897. */
  61898. isSupported(): boolean;
  61899. /**
  61900. * Sets the linear velocity of the physics body
  61901. * @param impostor imposter to set the velocity on
  61902. * @param velocity velocity to set
  61903. */
  61904. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  61905. /**
  61906. * Sets the angular velocity of the physics body
  61907. * @param impostor imposter to set the velocity on
  61908. * @param velocity velocity to set
  61909. */
  61910. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  61911. /**
  61912. * gets the linear velocity
  61913. * @param impostor imposter to get linear velocity from
  61914. * @returns linear velocity
  61915. */
  61916. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  61917. /**
  61918. * gets the angular velocity
  61919. * @param impostor imposter to get angular velocity from
  61920. * @returns angular velocity
  61921. */
  61922. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  61923. /**
  61924. * Sets the mass of physics body
  61925. * @param impostor imposter to set the mass on
  61926. * @param mass mass to set
  61927. */
  61928. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  61929. /**
  61930. * Gets the mass of the physics body
  61931. * @param impostor imposter to get the mass from
  61932. * @returns mass
  61933. */
  61934. getBodyMass(impostor: PhysicsImpostor): number;
  61935. /**
  61936. * Gets friction of the impostor
  61937. * @param impostor impostor to get friction from
  61938. * @returns friction value
  61939. */
  61940. getBodyFriction(impostor: PhysicsImpostor): number;
  61941. /**
  61942. * Sets friction of the impostor
  61943. * @param impostor impostor to set friction on
  61944. * @param friction friction value
  61945. */
  61946. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  61947. /**
  61948. * Gets restitution of the impostor
  61949. * @param impostor impostor to get restitution from
  61950. * @returns restitution value
  61951. */
  61952. getBodyRestitution(impostor: PhysicsImpostor): number;
  61953. /**
  61954. * Sets resitution of the impostor
  61955. * @param impostor impostor to set resitution on
  61956. * @param restitution resitution value
  61957. */
  61958. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  61959. /**
  61960. * Gets pressure inside the impostor
  61961. * @param impostor impostor to get pressure from
  61962. * @returns pressure value
  61963. */
  61964. getBodyPressure(impostor: PhysicsImpostor): number;
  61965. /**
  61966. * Sets pressure inside a soft body impostor
  61967. * Cloth and rope must remain 0 pressure
  61968. * @param impostor impostor to set pressure on
  61969. * @param pressure pressure value
  61970. */
  61971. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  61972. /**
  61973. * Gets stiffness of the impostor
  61974. * @param impostor impostor to get stiffness from
  61975. * @returns pressure value
  61976. */
  61977. getBodyStiffness(impostor: PhysicsImpostor): number;
  61978. /**
  61979. * Sets stiffness of the impostor
  61980. * @param impostor impostor to set stiffness on
  61981. * @param stiffness stiffness value from 0 to 1
  61982. */
  61983. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  61984. /**
  61985. * Gets velocityIterations of the impostor
  61986. * @param impostor impostor to get velocity iterations from
  61987. * @returns velocityIterations value
  61988. */
  61989. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  61990. /**
  61991. * Sets velocityIterations of the impostor
  61992. * @param impostor impostor to set velocity iterations on
  61993. * @param velocityIterations velocityIterations value
  61994. */
  61995. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  61996. /**
  61997. * Gets positionIterations of the impostor
  61998. * @param impostor impostor to get position iterations from
  61999. * @returns positionIterations value
  62000. */
  62001. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  62002. /**
  62003. * Sets positionIterations of the impostor
  62004. * @param impostor impostor to set position on
  62005. * @param positionIterations positionIterations value
  62006. */
  62007. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  62008. /**
  62009. * Append an anchor to a cloth object
  62010. * @param impostor is the cloth impostor to add anchor to
  62011. * @param otherImpostor is the rigid impostor to anchor to
  62012. * @param width ratio across width from 0 to 1
  62013. * @param height ratio up height from 0 to 1
  62014. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  62015. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  62016. */
  62017. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  62018. /**
  62019. * Append an hook to a rope object
  62020. * @param impostor is the rope impostor to add hook to
  62021. * @param otherImpostor is the rigid impostor to hook to
  62022. * @param length ratio along the rope from 0 to 1
  62023. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  62024. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  62025. */
  62026. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  62027. /**
  62028. * Sleeps the physics body and stops it from being active
  62029. * @param impostor impostor to sleep
  62030. */
  62031. sleepBody(impostor: PhysicsImpostor): void;
  62032. /**
  62033. * Activates the physics body
  62034. * @param impostor impostor to activate
  62035. */
  62036. wakeUpBody(impostor: PhysicsImpostor): void;
  62037. /**
  62038. * Updates the distance parameters of the joint
  62039. * @param joint joint to update
  62040. * @param maxDistance maximum distance of the joint
  62041. * @param minDistance minimum distance of the joint
  62042. */
  62043. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  62044. /**
  62045. * Sets a motor on the joint
  62046. * @param joint joint to set motor on
  62047. * @param speed speed of the motor
  62048. * @param maxForce maximum force of the motor
  62049. * @param motorIndex index of the motor
  62050. */
  62051. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  62052. /**
  62053. * Sets the motors limit
  62054. * @param joint joint to set limit on
  62055. * @param upperLimit upper limit
  62056. * @param lowerLimit lower limit
  62057. */
  62058. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  62059. /**
  62060. * Syncs the position and rotation of a mesh with the impostor
  62061. * @param mesh mesh to sync
  62062. * @param impostor impostor to update the mesh with
  62063. */
  62064. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  62065. /**
  62066. * Gets the radius of the impostor
  62067. * @param impostor impostor to get radius from
  62068. * @returns the radius
  62069. */
  62070. getRadius(impostor: PhysicsImpostor): number;
  62071. /**
  62072. * Gets the box size of the impostor
  62073. * @param impostor impostor to get box size from
  62074. * @param result the resulting box size
  62075. */
  62076. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  62077. /**
  62078. * Disposes of the impostor
  62079. */
  62080. dispose(): void;
  62081. /**
  62082. * Does a raycast in the physics world
  62083. * @param from when should the ray start?
  62084. * @param to when should the ray end?
  62085. * @returns PhysicsRaycastResult
  62086. */
  62087. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  62088. }
  62089. }
  62090. declare module "babylonjs/Probes/reflectionProbe" {
  62091. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62092. import { Vector3 } from "babylonjs/Maths/math.vector";
  62093. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62094. import { Nullable } from "babylonjs/types";
  62095. import { Scene } from "babylonjs/scene";
  62096. module "babylonjs/abstractScene" {
  62097. interface AbstractScene {
  62098. /**
  62099. * The list of reflection probes added to the scene
  62100. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  62101. */
  62102. reflectionProbes: Array<ReflectionProbe>;
  62103. /**
  62104. * Removes the given reflection probe from this scene.
  62105. * @param toRemove The reflection probe to remove
  62106. * @returns The index of the removed reflection probe
  62107. */
  62108. removeReflectionProbe(toRemove: ReflectionProbe): number;
  62109. /**
  62110. * Adds the given reflection probe to this scene.
  62111. * @param newReflectionProbe The reflection probe to add
  62112. */
  62113. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  62114. }
  62115. }
  62116. /**
  62117. * Class used to generate realtime reflection / refraction cube textures
  62118. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  62119. */
  62120. export class ReflectionProbe {
  62121. /** defines the name of the probe */
  62122. name: string;
  62123. private _scene;
  62124. private _renderTargetTexture;
  62125. private _projectionMatrix;
  62126. private _viewMatrix;
  62127. private _target;
  62128. private _add;
  62129. private _attachedMesh;
  62130. private _invertYAxis;
  62131. /** Gets or sets probe position (center of the cube map) */
  62132. position: Vector3;
  62133. /**
  62134. * Creates a new reflection probe
  62135. * @param name defines the name of the probe
  62136. * @param size defines the texture resolution (for each face)
  62137. * @param scene defines the hosting scene
  62138. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  62139. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  62140. */
  62141. constructor(
  62142. /** defines the name of the probe */
  62143. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  62144. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  62145. get samples(): number;
  62146. set samples(value: number);
  62147. /** Gets or sets the refresh rate to use (on every frame by default) */
  62148. get refreshRate(): number;
  62149. set refreshRate(value: number);
  62150. /**
  62151. * Gets the hosting scene
  62152. * @returns a Scene
  62153. */
  62154. getScene(): Scene;
  62155. /** Gets the internal CubeTexture used to render to */
  62156. get cubeTexture(): RenderTargetTexture;
  62157. /** Gets the list of meshes to render */
  62158. get renderList(): Nullable<AbstractMesh[]>;
  62159. /**
  62160. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  62161. * @param mesh defines the mesh to attach to
  62162. */
  62163. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  62164. /**
  62165. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  62166. * @param renderingGroupId The rendering group id corresponding to its index
  62167. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  62168. */
  62169. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  62170. /**
  62171. * Clean all associated resources
  62172. */
  62173. dispose(): void;
  62174. /**
  62175. * Converts the reflection probe information to a readable string for debug purpose.
  62176. * @param fullDetails Supports for multiple levels of logging within scene loading
  62177. * @returns the human readable reflection probe info
  62178. */
  62179. toString(fullDetails?: boolean): string;
  62180. /**
  62181. * Get the class name of the relfection probe.
  62182. * @returns "ReflectionProbe"
  62183. */
  62184. getClassName(): string;
  62185. /**
  62186. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  62187. * @returns The JSON representation of the texture
  62188. */
  62189. serialize(): any;
  62190. /**
  62191. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  62192. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  62193. * @param scene Define the scene the parsed reflection probe should be instantiated in
  62194. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  62195. * @returns The parsed reflection probe if successful
  62196. */
  62197. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  62198. }
  62199. }
  62200. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  62201. /** @hidden */
  62202. export var _BabylonLoaderRegistered: boolean;
  62203. /**
  62204. * Helps setting up some configuration for the babylon file loader.
  62205. */
  62206. export class BabylonFileLoaderConfiguration {
  62207. /**
  62208. * The loader does not allow injecting custom physix engine into the plugins.
  62209. * Unfortunately in ES6, we need to manually inject them into the plugin.
  62210. * So you could set this variable to your engine import to make it work.
  62211. */
  62212. static LoaderInjectedPhysicsEngine: any;
  62213. }
  62214. }
  62215. declare module "babylonjs/Loading/Plugins/index" {
  62216. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  62217. }
  62218. declare module "babylonjs/Loading/index" {
  62219. export * from "babylonjs/Loading/loadingScreen";
  62220. export * from "babylonjs/Loading/Plugins/index";
  62221. export * from "babylonjs/Loading/sceneLoader";
  62222. export * from "babylonjs/Loading/sceneLoaderFlags";
  62223. }
  62224. declare module "babylonjs/Materials/Background/index" {
  62225. export * from "babylonjs/Materials/Background/backgroundMaterial";
  62226. }
  62227. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  62228. import { Scene } from "babylonjs/scene";
  62229. import { Color3 } from "babylonjs/Maths/math.color";
  62230. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  62231. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  62232. /**
  62233. * The Physically based simple base material of BJS.
  62234. *
  62235. * This enables better naming and convention enforcements on top of the pbrMaterial.
  62236. * It is used as the base class for both the specGloss and metalRough conventions.
  62237. */
  62238. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  62239. /**
  62240. * Number of Simultaneous lights allowed on the material.
  62241. */
  62242. maxSimultaneousLights: number;
  62243. /**
  62244. * If sets to true, disables all the lights affecting the material.
  62245. */
  62246. disableLighting: boolean;
  62247. /**
  62248. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  62249. */
  62250. environmentTexture: BaseTexture;
  62251. /**
  62252. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  62253. */
  62254. invertNormalMapX: boolean;
  62255. /**
  62256. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  62257. */
  62258. invertNormalMapY: boolean;
  62259. /**
  62260. * Normal map used in the model.
  62261. */
  62262. normalTexture: BaseTexture;
  62263. /**
  62264. * Emissivie color used to self-illuminate the model.
  62265. */
  62266. emissiveColor: Color3;
  62267. /**
  62268. * Emissivie texture used to self-illuminate the model.
  62269. */
  62270. emissiveTexture: BaseTexture;
  62271. /**
  62272. * Occlusion Channel Strenght.
  62273. */
  62274. occlusionStrength: number;
  62275. /**
  62276. * Occlusion Texture of the material (adding extra occlusion effects).
  62277. */
  62278. occlusionTexture: BaseTexture;
  62279. /**
  62280. * Defines the alpha limits in alpha test mode.
  62281. */
  62282. alphaCutOff: number;
  62283. /**
  62284. * Gets the current double sided mode.
  62285. */
  62286. get doubleSided(): boolean;
  62287. /**
  62288. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  62289. */
  62290. set doubleSided(value: boolean);
  62291. /**
  62292. * Stores the pre-calculated light information of a mesh in a texture.
  62293. */
  62294. lightmapTexture: BaseTexture;
  62295. /**
  62296. * If true, the light map contains occlusion information instead of lighting info.
  62297. */
  62298. useLightmapAsShadowmap: boolean;
  62299. /**
  62300. * Instantiates a new PBRMaterial instance.
  62301. *
  62302. * @param name The material name
  62303. * @param scene The scene the material will be use in.
  62304. */
  62305. constructor(name: string, scene: Scene);
  62306. getClassName(): string;
  62307. }
  62308. }
  62309. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  62310. import { Scene } from "babylonjs/scene";
  62311. import { Color3 } from "babylonjs/Maths/math.color";
  62312. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  62313. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  62314. /**
  62315. * The PBR material of BJS following the metal roughness convention.
  62316. *
  62317. * This fits to the PBR convention in the GLTF definition:
  62318. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  62319. */
  62320. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  62321. /**
  62322. * The base color has two different interpretations depending on the value of metalness.
  62323. * When the material is a metal, the base color is the specific measured reflectance value
  62324. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  62325. * of the material.
  62326. */
  62327. baseColor: Color3;
  62328. /**
  62329. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  62330. * well as opacity information in the alpha channel.
  62331. */
  62332. baseTexture: BaseTexture;
  62333. /**
  62334. * Specifies the metallic scalar value of the material.
  62335. * Can also be used to scale the metalness values of the metallic texture.
  62336. */
  62337. metallic: number;
  62338. /**
  62339. * Specifies the roughness scalar value of the material.
  62340. * Can also be used to scale the roughness values of the metallic texture.
  62341. */
  62342. roughness: number;
  62343. /**
  62344. * Texture containing both the metallic value in the B channel and the
  62345. * roughness value in the G channel to keep better precision.
  62346. */
  62347. metallicRoughnessTexture: BaseTexture;
  62348. /**
  62349. * Instantiates a new PBRMetalRoughnessMaterial instance.
  62350. *
  62351. * @param name The material name
  62352. * @param scene The scene the material will be use in.
  62353. */
  62354. constructor(name: string, scene: Scene);
  62355. /**
  62356. * Return the currrent class name of the material.
  62357. */
  62358. getClassName(): string;
  62359. /**
  62360. * Makes a duplicate of the current material.
  62361. * @param name - name to use for the new material.
  62362. */
  62363. clone(name: string): PBRMetallicRoughnessMaterial;
  62364. /**
  62365. * Serialize the material to a parsable JSON object.
  62366. */
  62367. serialize(): any;
  62368. /**
  62369. * Parses a JSON object correponding to the serialize function.
  62370. */
  62371. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  62372. }
  62373. }
  62374. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  62375. import { Scene } from "babylonjs/scene";
  62376. import { Color3 } from "babylonjs/Maths/math.color";
  62377. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  62378. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  62379. /**
  62380. * The PBR material of BJS following the specular glossiness convention.
  62381. *
  62382. * This fits to the PBR convention in the GLTF definition:
  62383. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  62384. */
  62385. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  62386. /**
  62387. * Specifies the diffuse color of the material.
  62388. */
  62389. diffuseColor: Color3;
  62390. /**
  62391. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  62392. * channel.
  62393. */
  62394. diffuseTexture: BaseTexture;
  62395. /**
  62396. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  62397. */
  62398. specularColor: Color3;
  62399. /**
  62400. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  62401. */
  62402. glossiness: number;
  62403. /**
  62404. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  62405. */
  62406. specularGlossinessTexture: BaseTexture;
  62407. /**
  62408. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  62409. *
  62410. * @param name The material name
  62411. * @param scene The scene the material will be use in.
  62412. */
  62413. constructor(name: string, scene: Scene);
  62414. /**
  62415. * Return the currrent class name of the material.
  62416. */
  62417. getClassName(): string;
  62418. /**
  62419. * Makes a duplicate of the current material.
  62420. * @param name - name to use for the new material.
  62421. */
  62422. clone(name: string): PBRSpecularGlossinessMaterial;
  62423. /**
  62424. * Serialize the material to a parsable JSON object.
  62425. */
  62426. serialize(): any;
  62427. /**
  62428. * Parses a JSON object correponding to the serialize function.
  62429. */
  62430. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  62431. }
  62432. }
  62433. declare module "babylonjs/Materials/PBR/index" {
  62434. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  62435. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  62436. export * from "babylonjs/Materials/PBR/pbrMaterial";
  62437. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  62438. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  62439. }
  62440. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  62441. import { Nullable } from "babylonjs/types";
  62442. import { Scene } from "babylonjs/scene";
  62443. import { Matrix } from "babylonjs/Maths/math.vector";
  62444. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  62445. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  62446. import "babylonjs/Engines/Extensions/engine.rawTexture";
  62447. /**
  62448. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  62449. * It can help converting any input color in a desired output one. This can then be used to create effects
  62450. * from sepia, black and white to sixties or futuristic rendering...
  62451. *
  62452. * The only supported format is currently 3dl.
  62453. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  62454. */
  62455. export class ColorGradingTexture extends BaseTexture {
  62456. /**
  62457. * The texture URL.
  62458. */
  62459. url: string;
  62460. /**
  62461. * Empty line regex stored for GC.
  62462. */
  62463. private static _noneEmptyLineRegex;
  62464. private _textureMatrix;
  62465. private _onLoad;
  62466. /**
  62467. * Instantiates a ColorGradingTexture from the following parameters.
  62468. *
  62469. * @param url The location of the color gradind data (currently only supporting 3dl)
  62470. * @param sceneOrEngine The scene or engine the texture will be used in
  62471. * @param onLoad defines a callback triggered when the texture has been loaded
  62472. */
  62473. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  62474. /**
  62475. * Fires the onload event from the constructor if requested.
  62476. */
  62477. private _triggerOnLoad;
  62478. /**
  62479. * Returns the texture matrix used in most of the material.
  62480. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  62481. */
  62482. getTextureMatrix(): Matrix;
  62483. /**
  62484. * Occurs when the file being loaded is a .3dl LUT file.
  62485. */
  62486. private load3dlTexture;
  62487. /**
  62488. * Starts the loading process of the texture.
  62489. */
  62490. private loadTexture;
  62491. /**
  62492. * Clones the color gradind texture.
  62493. */
  62494. clone(): ColorGradingTexture;
  62495. /**
  62496. * Called during delayed load for textures.
  62497. */
  62498. delayLoad(): void;
  62499. /**
  62500. * Parses a color grading texture serialized by Babylon.
  62501. * @param parsedTexture The texture information being parsedTexture
  62502. * @param scene The scene to load the texture in
  62503. * @param rootUrl The root url of the data assets to load
  62504. * @return A color gradind texture
  62505. */
  62506. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  62507. /**
  62508. * Serializes the LUT texture to json format.
  62509. */
  62510. serialize(): any;
  62511. }
  62512. }
  62513. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  62514. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  62515. import { Scene } from "babylonjs/scene";
  62516. import { Nullable } from "babylonjs/types";
  62517. import "babylonjs/Engines/Extensions/engine.rawTexture";
  62518. /**
  62519. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  62520. */
  62521. export class EquiRectangularCubeTexture extends BaseTexture {
  62522. /** The six faces of the cube. */
  62523. private static _FacesMapping;
  62524. private _noMipmap;
  62525. private _onLoad;
  62526. private _onError;
  62527. /** The size of the cubemap. */
  62528. private _size;
  62529. /** The buffer of the image. */
  62530. private _buffer;
  62531. /** The width of the input image. */
  62532. private _width;
  62533. /** The height of the input image. */
  62534. private _height;
  62535. /** The URL to the image. */
  62536. url: string;
  62537. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  62538. coordinatesMode: number;
  62539. /**
  62540. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  62541. * @param url The location of the image
  62542. * @param scene The scene the texture will be used in
  62543. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  62544. * @param noMipmap Forces to not generate the mipmap if true
  62545. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  62546. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  62547. * @param onLoad — defines a callback called when texture is loaded
  62548. * @param onError — defines a callback called if there is an error
  62549. */
  62550. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  62551. /**
  62552. * Load the image data, by putting the image on a canvas and extracting its buffer.
  62553. */
  62554. private loadImage;
  62555. /**
  62556. * Convert the image buffer into a cubemap and create a CubeTexture.
  62557. */
  62558. private loadTexture;
  62559. /**
  62560. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  62561. * @param buffer The ArrayBuffer that should be converted.
  62562. * @returns The buffer as Float32Array.
  62563. */
  62564. private getFloat32ArrayFromArrayBuffer;
  62565. /**
  62566. * Get the current class name of the texture useful for serialization or dynamic coding.
  62567. * @returns "EquiRectangularCubeTexture"
  62568. */
  62569. getClassName(): string;
  62570. /**
  62571. * Create a clone of the current EquiRectangularCubeTexture and return it.
  62572. * @returns A clone of the current EquiRectangularCubeTexture.
  62573. */
  62574. clone(): EquiRectangularCubeTexture;
  62575. }
  62576. }
  62577. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  62578. import { Nullable } from "babylonjs/types";
  62579. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  62580. import { Matrix } from "babylonjs/Maths/math.vector";
  62581. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  62582. import "babylonjs/Engines/Extensions/engine.videoTexture";
  62583. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  62584. import { Scene } from "babylonjs/scene";
  62585. /**
  62586. * Defines the options related to the creation of an HtmlElementTexture
  62587. */
  62588. export interface IHtmlElementTextureOptions {
  62589. /**
  62590. * Defines wether mip maps should be created or not.
  62591. */
  62592. generateMipMaps?: boolean;
  62593. /**
  62594. * Defines the sampling mode of the texture.
  62595. */
  62596. samplingMode?: number;
  62597. /**
  62598. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  62599. */
  62600. engine: Nullable<ThinEngine>;
  62601. /**
  62602. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  62603. */
  62604. scene: Nullable<Scene>;
  62605. }
  62606. /**
  62607. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  62608. * To be as efficient as possible depending on your constraints nothing aside the first upload
  62609. * is automatically managed.
  62610. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  62611. * in your application.
  62612. *
  62613. * As the update is not automatic, you need to call them manually.
  62614. */
  62615. export class HtmlElementTexture extends BaseTexture {
  62616. /**
  62617. * The texture URL.
  62618. */
  62619. element: HTMLVideoElement | HTMLCanvasElement;
  62620. private static readonly DefaultOptions;
  62621. private _textureMatrix;
  62622. private _isVideo;
  62623. private _generateMipMaps;
  62624. private _samplingMode;
  62625. /**
  62626. * Instantiates a HtmlElementTexture from the following parameters.
  62627. *
  62628. * @param name Defines the name of the texture
  62629. * @param element Defines the video or canvas the texture is filled with
  62630. * @param options Defines the other none mandatory texture creation options
  62631. */
  62632. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  62633. private _createInternalTexture;
  62634. /**
  62635. * Returns the texture matrix used in most of the material.
  62636. */
  62637. getTextureMatrix(): Matrix;
  62638. /**
  62639. * Updates the content of the texture.
  62640. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  62641. */
  62642. update(invertY?: Nullable<boolean>): void;
  62643. }
  62644. }
  62645. declare module "babylonjs/Misc/tga" {
  62646. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  62647. /**
  62648. * Based on jsTGALoader - Javascript loader for TGA file
  62649. * By Vincent Thibault
  62650. * @see http://blog.robrowser.com/javascript-tga-loader.html
  62651. */
  62652. export class TGATools {
  62653. private static _TYPE_INDEXED;
  62654. private static _TYPE_RGB;
  62655. private static _TYPE_GREY;
  62656. private static _TYPE_RLE_INDEXED;
  62657. private static _TYPE_RLE_RGB;
  62658. private static _TYPE_RLE_GREY;
  62659. private static _ORIGIN_MASK;
  62660. private static _ORIGIN_SHIFT;
  62661. private static _ORIGIN_BL;
  62662. private static _ORIGIN_BR;
  62663. private static _ORIGIN_UL;
  62664. private static _ORIGIN_UR;
  62665. /**
  62666. * Gets the header of a TGA file
  62667. * @param data defines the TGA data
  62668. * @returns the header
  62669. */
  62670. static GetTGAHeader(data: Uint8Array): any;
  62671. /**
  62672. * Uploads TGA content to a Babylon Texture
  62673. * @hidden
  62674. */
  62675. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  62676. /** @hidden */
  62677. 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;
  62678. /** @hidden */
  62679. 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;
  62680. /** @hidden */
  62681. 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;
  62682. /** @hidden */
  62683. 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;
  62684. /** @hidden */
  62685. 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;
  62686. /** @hidden */
  62687. 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;
  62688. }
  62689. }
  62690. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  62691. import { Nullable } from "babylonjs/types";
  62692. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  62693. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  62694. /**
  62695. * Implementation of the TGA Texture Loader.
  62696. * @hidden
  62697. */
  62698. export class _TGATextureLoader implements IInternalTextureLoader {
  62699. /**
  62700. * Defines wether the loader supports cascade loading the different faces.
  62701. */
  62702. readonly supportCascades: boolean;
  62703. /**
  62704. * This returns if the loader support the current file information.
  62705. * @param extension defines the file extension of the file being loaded
  62706. * @returns true if the loader can load the specified file
  62707. */
  62708. canLoad(extension: string): boolean;
  62709. /**
  62710. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  62711. * @param data contains the texture data
  62712. * @param texture defines the BabylonJS internal texture
  62713. * @param createPolynomials will be true if polynomials have been requested
  62714. * @param onLoad defines the callback to trigger once the texture is ready
  62715. * @param onError defines the callback to trigger in case of error
  62716. */
  62717. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  62718. /**
  62719. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  62720. * @param data contains the texture data
  62721. * @param texture defines the BabylonJS internal texture
  62722. * @param callback defines the method to call once ready to upload
  62723. */
  62724. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  62725. }
  62726. }
  62727. declare module "babylonjs/Misc/basis" {
  62728. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  62729. /**
  62730. * Info about the .basis files
  62731. */
  62732. class BasisFileInfo {
  62733. /**
  62734. * If the file has alpha
  62735. */
  62736. hasAlpha: boolean;
  62737. /**
  62738. * Info about each image of the basis file
  62739. */
  62740. images: Array<{
  62741. levels: Array<{
  62742. width: number;
  62743. height: number;
  62744. transcodedPixels: ArrayBufferView;
  62745. }>;
  62746. }>;
  62747. }
  62748. /**
  62749. * Result of transcoding a basis file
  62750. */
  62751. class TranscodeResult {
  62752. /**
  62753. * Info about the .basis file
  62754. */
  62755. fileInfo: BasisFileInfo;
  62756. /**
  62757. * Format to use when loading the file
  62758. */
  62759. format: number;
  62760. }
  62761. /**
  62762. * Configuration options for the Basis transcoder
  62763. */
  62764. export class BasisTranscodeConfiguration {
  62765. /**
  62766. * Supported compression formats used to determine the supported output format of the transcoder
  62767. */
  62768. supportedCompressionFormats?: {
  62769. /**
  62770. * etc1 compression format
  62771. */
  62772. etc1?: boolean;
  62773. /**
  62774. * s3tc compression format
  62775. */
  62776. s3tc?: boolean;
  62777. /**
  62778. * pvrtc compression format
  62779. */
  62780. pvrtc?: boolean;
  62781. /**
  62782. * etc2 compression format
  62783. */
  62784. etc2?: boolean;
  62785. };
  62786. /**
  62787. * If mipmap levels should be loaded for transcoded images (Default: true)
  62788. */
  62789. loadMipmapLevels?: boolean;
  62790. /**
  62791. * Index of a single image to load (Default: all images)
  62792. */
  62793. loadSingleImage?: number;
  62794. }
  62795. /**
  62796. * Used to load .Basis files
  62797. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  62798. */
  62799. export class BasisTools {
  62800. private static _IgnoreSupportedFormats;
  62801. /**
  62802. * URL to use when loading the basis transcoder
  62803. */
  62804. static JSModuleURL: string;
  62805. /**
  62806. * URL to use when loading the wasm module for the transcoder
  62807. */
  62808. static WasmModuleURL: string;
  62809. /**
  62810. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  62811. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  62812. * @returns internal format corresponding to the Basis format
  62813. */
  62814. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  62815. private static _WorkerPromise;
  62816. private static _Worker;
  62817. private static _actionId;
  62818. private static _CreateWorkerAsync;
  62819. /**
  62820. * Transcodes a loaded image file to compressed pixel data
  62821. * @param data image data to transcode
  62822. * @param config configuration options for the transcoding
  62823. * @returns a promise resulting in the transcoded image
  62824. */
  62825. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  62826. /**
  62827. * Loads a texture from the transcode result
  62828. * @param texture texture load to
  62829. * @param transcodeResult the result of transcoding the basis file to load from
  62830. */
  62831. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  62832. }
  62833. }
  62834. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  62835. import { Nullable } from "babylonjs/types";
  62836. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  62837. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  62838. /**
  62839. * Loader for .basis file format
  62840. */
  62841. export class _BasisTextureLoader implements IInternalTextureLoader {
  62842. /**
  62843. * Defines whether the loader supports cascade loading the different faces.
  62844. */
  62845. readonly supportCascades: boolean;
  62846. /**
  62847. * This returns if the loader support the current file information.
  62848. * @param extension defines the file extension of the file being loaded
  62849. * @returns true if the loader can load the specified file
  62850. */
  62851. canLoad(extension: string): boolean;
  62852. /**
  62853. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  62854. * @param data contains the texture data
  62855. * @param texture defines the BabylonJS internal texture
  62856. * @param createPolynomials will be true if polynomials have been requested
  62857. * @param onLoad defines the callback to trigger once the texture is ready
  62858. * @param onError defines the callback to trigger in case of error
  62859. */
  62860. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  62861. /**
  62862. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  62863. * @param data contains the texture data
  62864. * @param texture defines the BabylonJS internal texture
  62865. * @param callback defines the method to call once ready to upload
  62866. */
  62867. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  62868. }
  62869. }
  62870. declare module "babylonjs/Materials/Textures/Loaders/index" {
  62871. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  62872. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  62873. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  62874. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  62875. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  62876. }
  62877. declare module "babylonjs/Materials/Textures/Packer/frame" {
  62878. import { Vector2 } from "babylonjs/Maths/math.vector";
  62879. /**
  62880. * Defines the basic options interface of a TexturePacker Frame
  62881. */
  62882. export interface ITexturePackerFrame {
  62883. /**
  62884. * The frame ID
  62885. */
  62886. id: number;
  62887. /**
  62888. * The frames Scale
  62889. */
  62890. scale: Vector2;
  62891. /**
  62892. * The Frames offset
  62893. */
  62894. offset: Vector2;
  62895. }
  62896. /**
  62897. * This is a support class for frame Data on texture packer sets.
  62898. */
  62899. export class TexturePackerFrame implements ITexturePackerFrame {
  62900. /**
  62901. * The frame ID
  62902. */
  62903. id: number;
  62904. /**
  62905. * The frames Scale
  62906. */
  62907. scale: Vector2;
  62908. /**
  62909. * The Frames offset
  62910. */
  62911. offset: Vector2;
  62912. /**
  62913. * Initializes a texture package frame.
  62914. * @param id The numerical frame identifier
  62915. * @param scale Scalar Vector2 for UV frame
  62916. * @param offset Vector2 for the frame position in UV units.
  62917. * @returns TexturePackerFrame
  62918. */
  62919. constructor(id: number, scale: Vector2, offset: Vector2);
  62920. }
  62921. }
  62922. declare module "babylonjs/Materials/Textures/Packer/packer" {
  62923. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62924. import { Scene } from "babylonjs/scene";
  62925. import { Nullable } from "babylonjs/types";
  62926. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  62927. import { TexturePackerFrame } from "babylonjs/Materials/Textures/Packer/frame";
  62928. /**
  62929. * Defines the basic options interface of a TexturePacker
  62930. */
  62931. export interface ITexturePackerOptions {
  62932. /**
  62933. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  62934. */
  62935. map?: string[];
  62936. /**
  62937. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  62938. */
  62939. uvsIn?: string;
  62940. /**
  62941. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  62942. */
  62943. uvsOut?: string;
  62944. /**
  62945. * number representing the layout style. Defaults to LAYOUT_STRIP
  62946. */
  62947. layout?: number;
  62948. /**
  62949. * number of columns if using custom column count layout(2). This defaults to 4.
  62950. */
  62951. colnum?: number;
  62952. /**
  62953. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  62954. */
  62955. updateInputMeshes?: boolean;
  62956. /**
  62957. * boolean flag to dispose all the source textures. Defaults to true.
  62958. */
  62959. disposeSources?: boolean;
  62960. /**
  62961. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  62962. */
  62963. fillBlanks?: boolean;
  62964. /**
  62965. * string value representing the context fill style color. Defaults to 'black'.
  62966. */
  62967. customFillColor?: string;
  62968. /**
  62969. * Width and Height Value of each Frame in the TexturePacker Sets
  62970. */
  62971. frameSize?: number;
  62972. /**
  62973. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  62974. */
  62975. paddingRatio?: number;
  62976. /**
  62977. * Number that declares the fill method for the padding gutter.
  62978. */
  62979. paddingMode?: number;
  62980. /**
  62981. * If in SUBUV_COLOR padding mode what color to use.
  62982. */
  62983. paddingColor?: Color3 | Color4;
  62984. }
  62985. /**
  62986. * Defines the basic interface of a TexturePacker JSON File
  62987. */
  62988. export interface ITexturePackerJSON {
  62989. /**
  62990. * The frame ID
  62991. */
  62992. name: string;
  62993. /**
  62994. * The base64 channel data
  62995. */
  62996. sets: any;
  62997. /**
  62998. * The options of the Packer
  62999. */
  63000. options: ITexturePackerOptions;
  63001. /**
  63002. * The frame data of the Packer
  63003. */
  63004. frames: Array<number>;
  63005. }
  63006. /**
  63007. * This is a support class that generates a series of packed texture sets.
  63008. * @see https://doc.babylonjs.com/babylon101/materials
  63009. */
  63010. export class TexturePacker {
  63011. /** Packer Layout Constant 0 */
  63012. static readonly LAYOUT_STRIP: number;
  63013. /** Packer Layout Constant 1 */
  63014. static readonly LAYOUT_POWER2: number;
  63015. /** Packer Layout Constant 2 */
  63016. static readonly LAYOUT_COLNUM: number;
  63017. /** Packer Layout Constant 0 */
  63018. static readonly SUBUV_WRAP: number;
  63019. /** Packer Layout Constant 1 */
  63020. static readonly SUBUV_EXTEND: number;
  63021. /** Packer Layout Constant 2 */
  63022. static readonly SUBUV_COLOR: number;
  63023. /** The Name of the Texture Package */
  63024. name: string;
  63025. /** The scene scope of the TexturePacker */
  63026. scene: Scene;
  63027. /** The Meshes to target */
  63028. meshes: AbstractMesh[];
  63029. /** Arguments passed with the Constructor */
  63030. options: ITexturePackerOptions;
  63031. /** The promise that is started upon initialization */
  63032. promise: Nullable<Promise<TexturePacker | string>>;
  63033. /** The Container object for the channel sets that are generated */
  63034. sets: object;
  63035. /** The Container array for the frames that are generated */
  63036. frames: TexturePackerFrame[];
  63037. /** The expected number of textures the system is parsing. */
  63038. private _expecting;
  63039. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  63040. private _paddingValue;
  63041. /**
  63042. * Initializes a texture package series from an array of meshes or a single mesh.
  63043. * @param name The name of the package
  63044. * @param meshes The target meshes to compose the package from
  63045. * @param options The arguments that texture packer should follow while building.
  63046. * @param scene The scene which the textures are scoped to.
  63047. * @returns TexturePacker
  63048. */
  63049. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  63050. /**
  63051. * Starts the package process
  63052. * @param resolve The promises resolution function
  63053. * @returns TexturePacker
  63054. */
  63055. private _createFrames;
  63056. /**
  63057. * Calculates the Size of the Channel Sets
  63058. * @returns Vector2
  63059. */
  63060. private _calculateSize;
  63061. /**
  63062. * Calculates the UV data for the frames.
  63063. * @param baseSize the base frameSize
  63064. * @param padding the base frame padding
  63065. * @param dtSize size of the Dynamic Texture for that channel
  63066. * @param dtUnits is 1/dtSize
  63067. * @param update flag to update the input meshes
  63068. */
  63069. private _calculateMeshUVFrames;
  63070. /**
  63071. * Calculates the frames Offset.
  63072. * @param index of the frame
  63073. * @returns Vector2
  63074. */
  63075. private _getFrameOffset;
  63076. /**
  63077. * Updates a Mesh to the frame data
  63078. * @param mesh that is the target
  63079. * @param frameID or the frame index
  63080. */
  63081. private _updateMeshUV;
  63082. /**
  63083. * Updates a Meshes materials to use the texture packer channels
  63084. * @param m is the mesh to target
  63085. * @param force all channels on the packer to be set.
  63086. */
  63087. private _updateTextureReferences;
  63088. /**
  63089. * Public method to set a Mesh to a frame
  63090. * @param m that is the target
  63091. * @param frameID or the frame index
  63092. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  63093. */
  63094. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  63095. /**
  63096. * Starts the async promise to compile the texture packer.
  63097. * @returns Promise<void>
  63098. */
  63099. processAsync(): Promise<void>;
  63100. /**
  63101. * Disposes all textures associated with this packer
  63102. */
  63103. dispose(): void;
  63104. /**
  63105. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  63106. * @param imageType is the image type to use.
  63107. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  63108. */
  63109. download(imageType?: string, quality?: number): void;
  63110. /**
  63111. * Public method to load a texturePacker JSON file.
  63112. * @param data of the JSON file in string format.
  63113. */
  63114. updateFromJSON(data: string): void;
  63115. }
  63116. }
  63117. declare module "babylonjs/Materials/Textures/Packer/index" {
  63118. export * from "babylonjs/Materials/Textures/Packer/packer";
  63119. export * from "babylonjs/Materials/Textures/Packer/frame";
  63120. }
  63121. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  63122. import { Scene } from "babylonjs/scene";
  63123. import { Texture } from "babylonjs/Materials/Textures/texture";
  63124. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  63125. /**
  63126. * 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.
  63127. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  63128. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  63129. */
  63130. export class CustomProceduralTexture extends ProceduralTexture {
  63131. private _animate;
  63132. private _time;
  63133. private _config;
  63134. private _texturePath;
  63135. /**
  63136. * Instantiates a new Custom Procedural Texture.
  63137. * 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.
  63138. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  63139. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  63140. * @param name Define the name of the texture
  63141. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  63142. * @param size Define the size of the texture to create
  63143. * @param scene Define the scene the texture belongs to
  63144. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  63145. * @param generateMipMaps Define if the texture should creates mip maps or not
  63146. */
  63147. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  63148. private _loadJson;
  63149. /**
  63150. * Is the texture ready to be used ? (rendered at least once)
  63151. * @returns true if ready, otherwise, false.
  63152. */
  63153. isReady(): boolean;
  63154. /**
  63155. * Render the texture to its associated render target.
  63156. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  63157. */
  63158. render(useCameraPostProcess?: boolean): void;
  63159. /**
  63160. * Update the list of dependant textures samplers in the shader.
  63161. */
  63162. updateTextures(): void;
  63163. /**
  63164. * Update the uniform values of the procedural texture in the shader.
  63165. */
  63166. updateShaderUniforms(): void;
  63167. /**
  63168. * Define if the texture animates or not.
  63169. */
  63170. get animate(): boolean;
  63171. set animate(value: boolean);
  63172. }
  63173. }
  63174. declare module "babylonjs/Shaders/noise.fragment" {
  63175. /** @hidden */
  63176. export var noisePixelShader: {
  63177. name: string;
  63178. shader: string;
  63179. };
  63180. }
  63181. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  63182. import { Nullable } from "babylonjs/types";
  63183. import { Scene } from "babylonjs/scene";
  63184. import { Texture } from "babylonjs/Materials/Textures/texture";
  63185. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  63186. import "babylonjs/Shaders/noise.fragment";
  63187. /**
  63188. * Class used to generate noise procedural textures
  63189. */
  63190. export class NoiseProceduralTexture extends ProceduralTexture {
  63191. private _time;
  63192. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  63193. brightness: number;
  63194. /** Defines the number of octaves to process */
  63195. octaves: number;
  63196. /** Defines the level of persistence (0.8 by default) */
  63197. persistence: number;
  63198. /** Gets or sets animation speed factor (default is 1) */
  63199. animationSpeedFactor: number;
  63200. /**
  63201. * Creates a new NoiseProceduralTexture
  63202. * @param name defines the name fo the texture
  63203. * @param size defines the size of the texture (default is 256)
  63204. * @param scene defines the hosting scene
  63205. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  63206. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  63207. */
  63208. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  63209. private _updateShaderUniforms;
  63210. protected _getDefines(): string;
  63211. /** Generate the current state of the procedural texture */
  63212. render(useCameraPostProcess?: boolean): void;
  63213. /**
  63214. * Serializes this noise procedural texture
  63215. * @returns a serialized noise procedural texture object
  63216. */
  63217. serialize(): any;
  63218. /**
  63219. * Clone the texture.
  63220. * @returns the cloned texture
  63221. */
  63222. clone(): NoiseProceduralTexture;
  63223. /**
  63224. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  63225. * @param parsedTexture defines parsed texture data
  63226. * @param scene defines the current scene
  63227. * @param rootUrl defines the root URL containing noise procedural texture information
  63228. * @returns a parsed NoiseProceduralTexture
  63229. */
  63230. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  63231. }
  63232. }
  63233. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  63234. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  63235. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  63236. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  63237. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  63238. }
  63239. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  63240. import { Nullable } from "babylonjs/types";
  63241. import { Scene } from "babylonjs/scene";
  63242. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  63243. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  63244. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  63245. import "babylonjs/Engines/Extensions/engine.rawTexture";
  63246. /**
  63247. * Raw cube texture where the raw buffers are passed in
  63248. */
  63249. export class RawCubeTexture extends CubeTexture {
  63250. /**
  63251. * Creates a cube texture where the raw buffers are passed in.
  63252. * @param scene defines the scene the texture is attached to
  63253. * @param data defines the array of data to use to create each face
  63254. * @param size defines the size of the textures
  63255. * @param format defines the format of the data
  63256. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  63257. * @param generateMipMaps defines if the engine should generate the mip levels
  63258. * @param invertY defines if data must be stored with Y axis inverted
  63259. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  63260. * @param compression defines the compression used (null by default)
  63261. */
  63262. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  63263. /**
  63264. * Updates the raw cube texture.
  63265. * @param data defines the data to store
  63266. * @param format defines the data format
  63267. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  63268. * @param invertY defines if data must be stored with Y axis inverted
  63269. * @param compression defines the compression used (null by default)
  63270. * @param level defines which level of the texture to update
  63271. */
  63272. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  63273. /**
  63274. * Updates a raw cube texture with RGBD encoded data.
  63275. * @param data defines the array of data [mipmap][face] to use to create each face
  63276. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  63277. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  63278. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  63279. * @returns a promsie that resolves when the operation is complete
  63280. */
  63281. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  63282. /**
  63283. * Clones the raw cube texture.
  63284. * @return a new cube texture
  63285. */
  63286. clone(): CubeTexture;
  63287. /** @hidden */
  63288. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  63289. }
  63290. }
  63291. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  63292. import { Scene } from "babylonjs/scene";
  63293. import { Texture } from "babylonjs/Materials/Textures/texture";
  63294. import "babylonjs/Engines/Extensions/engine.rawTexture";
  63295. /**
  63296. * Class used to store 2D array textures containing user data
  63297. */
  63298. export class RawTexture2DArray extends Texture {
  63299. /** Gets or sets the texture format to use */
  63300. format: number;
  63301. /**
  63302. * Create a new RawTexture2DArray
  63303. * @param data defines the data of the texture
  63304. * @param width defines the width of the texture
  63305. * @param height defines the height of the texture
  63306. * @param depth defines the number of layers of the texture
  63307. * @param format defines the texture format to use
  63308. * @param scene defines the hosting scene
  63309. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  63310. * @param invertY defines if texture must be stored with Y axis inverted
  63311. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  63312. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  63313. */
  63314. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  63315. /** Gets or sets the texture format to use */
  63316. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  63317. /**
  63318. * Update the texture with new data
  63319. * @param data defines the data to store in the texture
  63320. */
  63321. update(data: ArrayBufferView): void;
  63322. }
  63323. }
  63324. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  63325. import { Scene } from "babylonjs/scene";
  63326. import { Texture } from "babylonjs/Materials/Textures/texture";
  63327. import "babylonjs/Engines/Extensions/engine.rawTexture";
  63328. /**
  63329. * Class used to store 3D textures containing user data
  63330. */
  63331. export class RawTexture3D extends Texture {
  63332. /** Gets or sets the texture format to use */
  63333. format: number;
  63334. /**
  63335. * Create a new RawTexture3D
  63336. * @param data defines the data of the texture
  63337. * @param width defines the width of the texture
  63338. * @param height defines the height of the texture
  63339. * @param depth defines the depth of the texture
  63340. * @param format defines the texture format to use
  63341. * @param scene defines the hosting scene
  63342. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  63343. * @param invertY defines if texture must be stored with Y axis inverted
  63344. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  63345. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  63346. */
  63347. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  63348. /** Gets or sets the texture format to use */
  63349. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  63350. /**
  63351. * Update the texture with new data
  63352. * @param data defines the data to store in the texture
  63353. */
  63354. update(data: ArrayBufferView): void;
  63355. }
  63356. }
  63357. declare module "babylonjs/Materials/Textures/refractionTexture" {
  63358. import { Scene } from "babylonjs/scene";
  63359. import { Plane } from "babylonjs/Maths/math.plane";
  63360. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63361. /**
  63362. * Creates a refraction texture used by refraction channel of the standard material.
  63363. * It is like a mirror but to see through a material.
  63364. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  63365. */
  63366. export class RefractionTexture extends RenderTargetTexture {
  63367. /**
  63368. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  63369. * 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.
  63370. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  63371. */
  63372. refractionPlane: Plane;
  63373. /**
  63374. * Define how deep under the surface we should see.
  63375. */
  63376. depth: number;
  63377. /**
  63378. * Creates a refraction texture used by refraction channel of the standard material.
  63379. * It is like a mirror but to see through a material.
  63380. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  63381. * @param name Define the texture name
  63382. * @param size Define the size of the underlying texture
  63383. * @param scene Define the scene the refraction belongs to
  63384. * @param generateMipMaps Define if we need to generate mips level for the refraction
  63385. */
  63386. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  63387. /**
  63388. * Clone the refraction texture.
  63389. * @returns the cloned texture
  63390. */
  63391. clone(): RefractionTexture;
  63392. /**
  63393. * Serialize the texture to a JSON representation you could use in Parse later on
  63394. * @returns the serialized JSON representation
  63395. */
  63396. serialize(): any;
  63397. }
  63398. }
  63399. declare module "babylonjs/Materials/Textures/index" {
  63400. export * from "babylonjs/Materials/Textures/baseTexture";
  63401. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  63402. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  63403. export * from "babylonjs/Materials/Textures/cubeTexture";
  63404. export * from "babylonjs/Materials/Textures/dynamicTexture";
  63405. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  63406. export * from "babylonjs/Materials/Textures/Filtering/hdrFiltering";
  63407. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  63408. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  63409. export * from "babylonjs/Materials/Textures/internalTexture";
  63410. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  63411. export * from "babylonjs/Materials/Textures/Loaders/index";
  63412. export * from "babylonjs/Materials/Textures/mirrorTexture";
  63413. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  63414. export * from "babylonjs/Materials/Textures/Packer/index";
  63415. export * from "babylonjs/Materials/Textures/Procedurals/index";
  63416. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  63417. export * from "babylonjs/Materials/Textures/rawTexture";
  63418. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  63419. export * from "babylonjs/Materials/Textures/rawTexture3D";
  63420. export * from "babylonjs/Materials/Textures/refractionTexture";
  63421. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  63422. export * from "babylonjs/Materials/Textures/texture";
  63423. export * from "babylonjs/Materials/Textures/videoTexture";
  63424. }
  63425. declare module "babylonjs/Materials/Node/Enums/index" {
  63426. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  63427. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  63428. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  63429. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  63430. export * from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  63431. }
  63432. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  63433. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63434. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63435. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63436. import { Mesh } from "babylonjs/Meshes/mesh";
  63437. import { Effect } from "babylonjs/Materials/effect";
  63438. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63439. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  63440. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  63441. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  63442. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  63443. /**
  63444. * Block used to add support for vertex skinning (bones)
  63445. */
  63446. export class BonesBlock extends NodeMaterialBlock {
  63447. /**
  63448. * Creates a new BonesBlock
  63449. * @param name defines the block name
  63450. */
  63451. constructor(name: string);
  63452. /**
  63453. * Initialize the block and prepare the context for build
  63454. * @param state defines the state that will be used for the build
  63455. */
  63456. initialize(state: NodeMaterialBuildState): void;
  63457. /**
  63458. * Gets the current class name
  63459. * @returns the class name
  63460. */
  63461. getClassName(): string;
  63462. /**
  63463. * Gets the matrix indices input component
  63464. */
  63465. get matricesIndices(): NodeMaterialConnectionPoint;
  63466. /**
  63467. * Gets the matrix weights input component
  63468. */
  63469. get matricesWeights(): NodeMaterialConnectionPoint;
  63470. /**
  63471. * Gets the extra matrix indices input component
  63472. */
  63473. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  63474. /**
  63475. * Gets the extra matrix weights input component
  63476. */
  63477. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  63478. /**
  63479. * Gets the world input component
  63480. */
  63481. get world(): NodeMaterialConnectionPoint;
  63482. /**
  63483. * Gets the output component
  63484. */
  63485. get output(): NodeMaterialConnectionPoint;
  63486. autoConfigure(material: NodeMaterial): void;
  63487. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  63488. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63489. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63490. protected _buildBlock(state: NodeMaterialBuildState): this;
  63491. }
  63492. }
  63493. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  63494. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63495. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63496. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63497. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63498. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  63499. /**
  63500. * Block used to add support for instances
  63501. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  63502. */
  63503. export class InstancesBlock extends NodeMaterialBlock {
  63504. /**
  63505. * Creates a new InstancesBlock
  63506. * @param name defines the block name
  63507. */
  63508. constructor(name: string);
  63509. /**
  63510. * Gets the current class name
  63511. * @returns the class name
  63512. */
  63513. getClassName(): string;
  63514. /**
  63515. * Gets the first world row input component
  63516. */
  63517. get world0(): NodeMaterialConnectionPoint;
  63518. /**
  63519. * Gets the second world row input component
  63520. */
  63521. get world1(): NodeMaterialConnectionPoint;
  63522. /**
  63523. * Gets the third world row input component
  63524. */
  63525. get world2(): NodeMaterialConnectionPoint;
  63526. /**
  63527. * Gets the forth world row input component
  63528. */
  63529. get world3(): NodeMaterialConnectionPoint;
  63530. /**
  63531. * Gets the world input component
  63532. */
  63533. get world(): NodeMaterialConnectionPoint;
  63534. /**
  63535. * Gets the output component
  63536. */
  63537. get output(): NodeMaterialConnectionPoint;
  63538. /**
  63539. * Gets the isntanceID component
  63540. */
  63541. get instanceID(): NodeMaterialConnectionPoint;
  63542. autoConfigure(material: NodeMaterial): void;
  63543. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  63544. protected _buildBlock(state: NodeMaterialBuildState): this;
  63545. }
  63546. }
  63547. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  63548. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63549. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63550. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63551. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63552. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  63553. import { Effect } from "babylonjs/Materials/effect";
  63554. import { Mesh } from "babylonjs/Meshes/mesh";
  63555. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  63556. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  63557. /**
  63558. * Block used to add morph targets support to vertex shader
  63559. */
  63560. export class MorphTargetsBlock extends NodeMaterialBlock {
  63561. private _repeatableContentAnchor;
  63562. /**
  63563. * Create a new MorphTargetsBlock
  63564. * @param name defines the block name
  63565. */
  63566. constructor(name: string);
  63567. /**
  63568. * Gets the current class name
  63569. * @returns the class name
  63570. */
  63571. getClassName(): string;
  63572. /**
  63573. * Gets the position input component
  63574. */
  63575. get position(): NodeMaterialConnectionPoint;
  63576. /**
  63577. * Gets the normal input component
  63578. */
  63579. get normal(): NodeMaterialConnectionPoint;
  63580. /**
  63581. * Gets the tangent input component
  63582. */
  63583. get tangent(): NodeMaterialConnectionPoint;
  63584. /**
  63585. * Gets the tangent input component
  63586. */
  63587. get uv(): NodeMaterialConnectionPoint;
  63588. /**
  63589. * Gets the position output component
  63590. */
  63591. get positionOutput(): NodeMaterialConnectionPoint;
  63592. /**
  63593. * Gets the normal output component
  63594. */
  63595. get normalOutput(): NodeMaterialConnectionPoint;
  63596. /**
  63597. * Gets the tangent output component
  63598. */
  63599. get tangentOutput(): NodeMaterialConnectionPoint;
  63600. /**
  63601. * Gets the tangent output component
  63602. */
  63603. get uvOutput(): NodeMaterialConnectionPoint;
  63604. initialize(state: NodeMaterialBuildState): void;
  63605. autoConfigure(material: NodeMaterial): void;
  63606. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63607. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63608. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  63609. protected _buildBlock(state: NodeMaterialBuildState): this;
  63610. }
  63611. }
  63612. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  63613. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63614. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63615. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63616. import { Nullable } from "babylonjs/types";
  63617. import { Scene } from "babylonjs/scene";
  63618. import { Effect } from "babylonjs/Materials/effect";
  63619. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  63620. import { Mesh } from "babylonjs/Meshes/mesh";
  63621. import { Light } from "babylonjs/Lights/light";
  63622. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63623. /**
  63624. * Block used to get data information from a light
  63625. */
  63626. export class LightInformationBlock extends NodeMaterialBlock {
  63627. private _lightDataUniformName;
  63628. private _lightColorUniformName;
  63629. private _lightTypeDefineName;
  63630. /**
  63631. * Gets or sets the light associated with this block
  63632. */
  63633. light: Nullable<Light>;
  63634. /**
  63635. * Creates a new LightInformationBlock
  63636. * @param name defines the block name
  63637. */
  63638. constructor(name: string);
  63639. /**
  63640. * Gets the current class name
  63641. * @returns the class name
  63642. */
  63643. getClassName(): string;
  63644. /**
  63645. * Gets the world position input component
  63646. */
  63647. get worldPosition(): NodeMaterialConnectionPoint;
  63648. /**
  63649. * Gets the direction output component
  63650. */
  63651. get direction(): NodeMaterialConnectionPoint;
  63652. /**
  63653. * Gets the direction output component
  63654. */
  63655. get color(): NodeMaterialConnectionPoint;
  63656. /**
  63657. * Gets the direction output component
  63658. */
  63659. get intensity(): NodeMaterialConnectionPoint;
  63660. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63661. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63662. protected _buildBlock(state: NodeMaterialBuildState): this;
  63663. serialize(): any;
  63664. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63665. }
  63666. }
  63667. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  63668. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  63669. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  63670. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  63671. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  63672. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  63673. }
  63674. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  63675. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63676. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63677. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63678. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63679. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  63680. import { Effect } from "babylonjs/Materials/effect";
  63681. import { Mesh } from "babylonjs/Meshes/mesh";
  63682. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  63683. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  63684. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  63685. /**
  63686. * Block used to add image processing support to fragment shader
  63687. */
  63688. export class ImageProcessingBlock extends NodeMaterialBlock {
  63689. /**
  63690. * Create a new ImageProcessingBlock
  63691. * @param name defines the block name
  63692. */
  63693. constructor(name: string);
  63694. /**
  63695. * Gets the current class name
  63696. * @returns the class name
  63697. */
  63698. getClassName(): string;
  63699. /**
  63700. * Gets the color input component
  63701. */
  63702. get color(): NodeMaterialConnectionPoint;
  63703. /**
  63704. * Gets the output component
  63705. */
  63706. get output(): NodeMaterialConnectionPoint;
  63707. /**
  63708. * Initialize the block and prepare the context for build
  63709. * @param state defines the state that will be used for the build
  63710. */
  63711. initialize(state: NodeMaterialBuildState): void;
  63712. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  63713. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63714. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63715. protected _buildBlock(state: NodeMaterialBuildState): this;
  63716. }
  63717. }
  63718. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  63719. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63720. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63721. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63722. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  63723. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63724. import { Effect } from "babylonjs/Materials/effect";
  63725. import { Mesh } from "babylonjs/Meshes/mesh";
  63726. import { Scene } from "babylonjs/scene";
  63727. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  63728. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  63729. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  63730. /**
  63731. * Block used to pertub normals based on a normal map
  63732. */
  63733. export class PerturbNormalBlock extends NodeMaterialBlock {
  63734. private _tangentSpaceParameterName;
  63735. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  63736. invertX: boolean;
  63737. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  63738. invertY: boolean;
  63739. /**
  63740. * Create a new PerturbNormalBlock
  63741. * @param name defines the block name
  63742. */
  63743. constructor(name: string);
  63744. /**
  63745. * Gets the current class name
  63746. * @returns the class name
  63747. */
  63748. getClassName(): string;
  63749. /**
  63750. * Gets the world position input component
  63751. */
  63752. get worldPosition(): NodeMaterialConnectionPoint;
  63753. /**
  63754. * Gets the world normal input component
  63755. */
  63756. get worldNormal(): NodeMaterialConnectionPoint;
  63757. /**
  63758. * Gets the world tangent input component
  63759. */
  63760. get worldTangent(): NodeMaterialConnectionPoint;
  63761. /**
  63762. * Gets the uv input component
  63763. */
  63764. get uv(): NodeMaterialConnectionPoint;
  63765. /**
  63766. * Gets the normal map color input component
  63767. */
  63768. get normalMapColor(): NodeMaterialConnectionPoint;
  63769. /**
  63770. * Gets the strength input component
  63771. */
  63772. get strength(): NodeMaterialConnectionPoint;
  63773. /**
  63774. * Gets the output component
  63775. */
  63776. get output(): NodeMaterialConnectionPoint;
  63777. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63778. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63779. autoConfigure(material: NodeMaterial): void;
  63780. protected _buildBlock(state: NodeMaterialBuildState): this;
  63781. protected _dumpPropertiesCode(): string;
  63782. serialize(): any;
  63783. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63784. }
  63785. }
  63786. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  63787. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63788. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63789. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63790. /**
  63791. * Block used to discard a pixel if a value is smaller than a cutoff
  63792. */
  63793. export class DiscardBlock extends NodeMaterialBlock {
  63794. /**
  63795. * Create a new DiscardBlock
  63796. * @param name defines the block name
  63797. */
  63798. constructor(name: string);
  63799. /**
  63800. * Gets the current class name
  63801. * @returns the class name
  63802. */
  63803. getClassName(): string;
  63804. /**
  63805. * Gets the color input component
  63806. */
  63807. get value(): NodeMaterialConnectionPoint;
  63808. /**
  63809. * Gets the cutoff input component
  63810. */
  63811. get cutoff(): NodeMaterialConnectionPoint;
  63812. protected _buildBlock(state: NodeMaterialBuildState): this;
  63813. }
  63814. }
  63815. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  63816. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63817. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63818. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63819. /**
  63820. * Block used to test if the fragment shader is front facing
  63821. */
  63822. export class FrontFacingBlock extends NodeMaterialBlock {
  63823. /**
  63824. * Creates a new FrontFacingBlock
  63825. * @param name defines the block name
  63826. */
  63827. constructor(name: string);
  63828. /**
  63829. * Gets the current class name
  63830. * @returns the class name
  63831. */
  63832. getClassName(): string;
  63833. /**
  63834. * Gets the output component
  63835. */
  63836. get output(): NodeMaterialConnectionPoint;
  63837. protected _buildBlock(state: NodeMaterialBuildState): this;
  63838. }
  63839. }
  63840. declare module "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock" {
  63841. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63842. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63843. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63844. /**
  63845. * Block used to get the derivative value on x and y of a given input
  63846. */
  63847. export class DerivativeBlock extends NodeMaterialBlock {
  63848. /**
  63849. * Create a new DerivativeBlock
  63850. * @param name defines the block name
  63851. */
  63852. constructor(name: string);
  63853. /**
  63854. * Gets the current class name
  63855. * @returns the class name
  63856. */
  63857. getClassName(): string;
  63858. /**
  63859. * Gets the input component
  63860. */
  63861. get input(): NodeMaterialConnectionPoint;
  63862. /**
  63863. * Gets the derivative output on x
  63864. */
  63865. get dx(): NodeMaterialConnectionPoint;
  63866. /**
  63867. * Gets the derivative output on y
  63868. */
  63869. get dy(): NodeMaterialConnectionPoint;
  63870. protected _buildBlock(state: NodeMaterialBuildState): this;
  63871. }
  63872. }
  63873. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  63874. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  63875. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  63876. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  63877. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  63878. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  63879. export * from "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock";
  63880. }
  63881. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  63882. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63883. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63884. import { Mesh } from "babylonjs/Meshes/mesh";
  63885. import { Effect } from "babylonjs/Materials/effect";
  63886. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63887. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63888. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  63889. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  63890. /**
  63891. * Block used to add support for scene fog
  63892. */
  63893. export class FogBlock extends NodeMaterialBlock {
  63894. private _fogDistanceName;
  63895. private _fogParameters;
  63896. /**
  63897. * Create a new FogBlock
  63898. * @param name defines the block name
  63899. */
  63900. constructor(name: string);
  63901. /**
  63902. * Gets the current class name
  63903. * @returns the class name
  63904. */
  63905. getClassName(): string;
  63906. /**
  63907. * Gets the world position input component
  63908. */
  63909. get worldPosition(): NodeMaterialConnectionPoint;
  63910. /**
  63911. * Gets the view input component
  63912. */
  63913. get view(): NodeMaterialConnectionPoint;
  63914. /**
  63915. * Gets the color input component
  63916. */
  63917. get input(): NodeMaterialConnectionPoint;
  63918. /**
  63919. * Gets the fog color input component
  63920. */
  63921. get fogColor(): NodeMaterialConnectionPoint;
  63922. /**
  63923. * Gets the output component
  63924. */
  63925. get output(): NodeMaterialConnectionPoint;
  63926. autoConfigure(material: NodeMaterial): void;
  63927. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63928. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63929. protected _buildBlock(state: NodeMaterialBuildState): this;
  63930. }
  63931. }
  63932. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  63933. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63934. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63935. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63936. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63937. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  63938. import { Effect } from "babylonjs/Materials/effect";
  63939. import { Mesh } from "babylonjs/Meshes/mesh";
  63940. import { Light } from "babylonjs/Lights/light";
  63941. import { Nullable } from "babylonjs/types";
  63942. import { Scene } from "babylonjs/scene";
  63943. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  63944. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  63945. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  63946. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  63947. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  63948. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  63949. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  63950. /**
  63951. * Block used to add light in the fragment shader
  63952. */
  63953. export class LightBlock extends NodeMaterialBlock {
  63954. private _lightId;
  63955. /**
  63956. * Gets or sets the light associated with this block
  63957. */
  63958. light: Nullable<Light>;
  63959. /**
  63960. * Create a new LightBlock
  63961. * @param name defines the block name
  63962. */
  63963. constructor(name: string);
  63964. /**
  63965. * Gets the current class name
  63966. * @returns the class name
  63967. */
  63968. getClassName(): string;
  63969. /**
  63970. * Gets the world position input component
  63971. */
  63972. get worldPosition(): NodeMaterialConnectionPoint;
  63973. /**
  63974. * Gets the world normal input component
  63975. */
  63976. get worldNormal(): NodeMaterialConnectionPoint;
  63977. /**
  63978. * Gets the camera (or eye) position component
  63979. */
  63980. get cameraPosition(): NodeMaterialConnectionPoint;
  63981. /**
  63982. * Gets the glossiness component
  63983. */
  63984. get glossiness(): NodeMaterialConnectionPoint;
  63985. /**
  63986. * Gets the glossinness power component
  63987. */
  63988. get glossPower(): NodeMaterialConnectionPoint;
  63989. /**
  63990. * Gets the diffuse color component
  63991. */
  63992. get diffuseColor(): NodeMaterialConnectionPoint;
  63993. /**
  63994. * Gets the specular color component
  63995. */
  63996. get specularColor(): NodeMaterialConnectionPoint;
  63997. /**
  63998. * Gets the diffuse output component
  63999. */
  64000. get diffuseOutput(): NodeMaterialConnectionPoint;
  64001. /**
  64002. * Gets the specular output component
  64003. */
  64004. get specularOutput(): NodeMaterialConnectionPoint;
  64005. /**
  64006. * Gets the shadow output component
  64007. */
  64008. get shadow(): NodeMaterialConnectionPoint;
  64009. autoConfigure(material: NodeMaterial): void;
  64010. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64011. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  64012. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64013. private _injectVertexCode;
  64014. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  64015. serialize(): any;
  64016. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64017. }
  64018. }
  64019. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  64020. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64021. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64022. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  64023. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  64024. /**
  64025. * Block used to read a reflection texture from a sampler
  64026. */
  64027. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  64028. /**
  64029. * Create a new ReflectionTextureBlock
  64030. * @param name defines the block name
  64031. */
  64032. constructor(name: string);
  64033. /**
  64034. * Gets the current class name
  64035. * @returns the class name
  64036. */
  64037. getClassName(): string;
  64038. /**
  64039. * Gets the world position input component
  64040. */
  64041. get position(): NodeMaterialConnectionPoint;
  64042. /**
  64043. * Gets the world position input component
  64044. */
  64045. get worldPosition(): NodeMaterialConnectionPoint;
  64046. /**
  64047. * Gets the world normal input component
  64048. */
  64049. get worldNormal(): NodeMaterialConnectionPoint;
  64050. /**
  64051. * Gets the world input component
  64052. */
  64053. get world(): NodeMaterialConnectionPoint;
  64054. /**
  64055. * Gets the camera (or eye) position component
  64056. */
  64057. get cameraPosition(): NodeMaterialConnectionPoint;
  64058. /**
  64059. * Gets the view input component
  64060. */
  64061. get view(): NodeMaterialConnectionPoint;
  64062. /**
  64063. * Gets the rgb output component
  64064. */
  64065. get rgb(): NodeMaterialConnectionPoint;
  64066. /**
  64067. * Gets the r output component
  64068. */
  64069. get r(): NodeMaterialConnectionPoint;
  64070. /**
  64071. * Gets the g output component
  64072. */
  64073. get g(): NodeMaterialConnectionPoint;
  64074. /**
  64075. * Gets the b output component
  64076. */
  64077. get b(): NodeMaterialConnectionPoint;
  64078. autoConfigure(material: NodeMaterial): void;
  64079. protected _buildBlock(state: NodeMaterialBuildState): this;
  64080. }
  64081. }
  64082. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  64083. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  64084. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  64085. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  64086. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  64087. export * from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  64088. }
  64089. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  64090. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  64091. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  64092. }
  64093. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  64094. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64095. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64096. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64097. /**
  64098. * Block used to add 2 vectors
  64099. */
  64100. export class AddBlock extends NodeMaterialBlock {
  64101. /**
  64102. * Creates a new AddBlock
  64103. * @param name defines the block name
  64104. */
  64105. constructor(name: string);
  64106. /**
  64107. * Gets the current class name
  64108. * @returns the class name
  64109. */
  64110. getClassName(): string;
  64111. /**
  64112. * Gets the left operand input component
  64113. */
  64114. get left(): NodeMaterialConnectionPoint;
  64115. /**
  64116. * Gets the right operand input component
  64117. */
  64118. get right(): NodeMaterialConnectionPoint;
  64119. /**
  64120. * Gets the output component
  64121. */
  64122. get output(): NodeMaterialConnectionPoint;
  64123. protected _buildBlock(state: NodeMaterialBuildState): this;
  64124. }
  64125. }
  64126. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  64127. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64128. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64129. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64130. /**
  64131. * Block used to scale a vector by a float
  64132. */
  64133. export class ScaleBlock extends NodeMaterialBlock {
  64134. /**
  64135. * Creates a new ScaleBlock
  64136. * @param name defines the block name
  64137. */
  64138. constructor(name: string);
  64139. /**
  64140. * Gets the current class name
  64141. * @returns the class name
  64142. */
  64143. getClassName(): string;
  64144. /**
  64145. * Gets the input component
  64146. */
  64147. get input(): NodeMaterialConnectionPoint;
  64148. /**
  64149. * Gets the factor input component
  64150. */
  64151. get factor(): NodeMaterialConnectionPoint;
  64152. /**
  64153. * Gets the output component
  64154. */
  64155. get output(): NodeMaterialConnectionPoint;
  64156. protected _buildBlock(state: NodeMaterialBuildState): this;
  64157. }
  64158. }
  64159. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  64160. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64161. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64162. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64163. import { Scene } from "babylonjs/scene";
  64164. /**
  64165. * Block used to clamp a float
  64166. */
  64167. export class ClampBlock extends NodeMaterialBlock {
  64168. /** Gets or sets the minimum range */
  64169. minimum: number;
  64170. /** Gets or sets the maximum range */
  64171. maximum: number;
  64172. /**
  64173. * Creates a new ClampBlock
  64174. * @param name defines the block name
  64175. */
  64176. constructor(name: string);
  64177. /**
  64178. * Gets the current class name
  64179. * @returns the class name
  64180. */
  64181. getClassName(): string;
  64182. /**
  64183. * Gets the value input component
  64184. */
  64185. get value(): NodeMaterialConnectionPoint;
  64186. /**
  64187. * Gets the output component
  64188. */
  64189. get output(): NodeMaterialConnectionPoint;
  64190. protected _buildBlock(state: NodeMaterialBuildState): this;
  64191. protected _dumpPropertiesCode(): string;
  64192. serialize(): any;
  64193. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64194. }
  64195. }
  64196. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  64197. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64198. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64199. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64200. /**
  64201. * Block used to apply a cross product between 2 vectors
  64202. */
  64203. export class CrossBlock extends NodeMaterialBlock {
  64204. /**
  64205. * Creates a new CrossBlock
  64206. * @param name defines the block name
  64207. */
  64208. constructor(name: string);
  64209. /**
  64210. * Gets the current class name
  64211. * @returns the class name
  64212. */
  64213. getClassName(): string;
  64214. /**
  64215. * Gets the left operand input component
  64216. */
  64217. get left(): NodeMaterialConnectionPoint;
  64218. /**
  64219. * Gets the right operand input component
  64220. */
  64221. get right(): NodeMaterialConnectionPoint;
  64222. /**
  64223. * Gets the output component
  64224. */
  64225. get output(): NodeMaterialConnectionPoint;
  64226. protected _buildBlock(state: NodeMaterialBuildState): this;
  64227. }
  64228. }
  64229. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  64230. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64231. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64232. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64233. /**
  64234. * Block used to apply a dot product between 2 vectors
  64235. */
  64236. export class DotBlock extends NodeMaterialBlock {
  64237. /**
  64238. * Creates a new DotBlock
  64239. * @param name defines the block name
  64240. */
  64241. constructor(name: string);
  64242. /**
  64243. * Gets the current class name
  64244. * @returns the class name
  64245. */
  64246. getClassName(): string;
  64247. /**
  64248. * Gets the left operand input component
  64249. */
  64250. get left(): NodeMaterialConnectionPoint;
  64251. /**
  64252. * Gets the right operand input component
  64253. */
  64254. get right(): NodeMaterialConnectionPoint;
  64255. /**
  64256. * Gets the output component
  64257. */
  64258. get output(): NodeMaterialConnectionPoint;
  64259. protected _buildBlock(state: NodeMaterialBuildState): this;
  64260. }
  64261. }
  64262. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  64263. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64264. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64265. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64266. /**
  64267. * Block used to normalize a vector
  64268. */
  64269. export class NormalizeBlock extends NodeMaterialBlock {
  64270. /**
  64271. * Creates a new NormalizeBlock
  64272. * @param name defines the block name
  64273. */
  64274. constructor(name: string);
  64275. /**
  64276. * Gets the current class name
  64277. * @returns the class name
  64278. */
  64279. getClassName(): string;
  64280. /**
  64281. * Gets the input component
  64282. */
  64283. get input(): NodeMaterialConnectionPoint;
  64284. /**
  64285. * Gets the output component
  64286. */
  64287. get output(): NodeMaterialConnectionPoint;
  64288. protected _buildBlock(state: NodeMaterialBuildState): this;
  64289. }
  64290. }
  64291. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  64292. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64293. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64294. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64295. import { Scene } from "babylonjs/scene";
  64296. /**
  64297. * Operations supported by the Trigonometry block
  64298. */
  64299. export enum TrigonometryBlockOperations {
  64300. /** Cos */
  64301. Cos = 0,
  64302. /** Sin */
  64303. Sin = 1,
  64304. /** Abs */
  64305. Abs = 2,
  64306. /** Exp */
  64307. Exp = 3,
  64308. /** Exp2 */
  64309. Exp2 = 4,
  64310. /** Round */
  64311. Round = 5,
  64312. /** Floor */
  64313. Floor = 6,
  64314. /** Ceiling */
  64315. Ceiling = 7,
  64316. /** Square root */
  64317. Sqrt = 8,
  64318. /** Log */
  64319. Log = 9,
  64320. /** Tangent */
  64321. Tan = 10,
  64322. /** Arc tangent */
  64323. ArcTan = 11,
  64324. /** Arc cosinus */
  64325. ArcCos = 12,
  64326. /** Arc sinus */
  64327. ArcSin = 13,
  64328. /** Fraction */
  64329. Fract = 14,
  64330. /** Sign */
  64331. Sign = 15,
  64332. /** To radians (from degrees) */
  64333. Radians = 16,
  64334. /** To degrees (from radians) */
  64335. Degrees = 17
  64336. }
  64337. /**
  64338. * Block used to apply trigonometry operation to floats
  64339. */
  64340. export class TrigonometryBlock extends NodeMaterialBlock {
  64341. /**
  64342. * Gets or sets the operation applied by the block
  64343. */
  64344. operation: TrigonometryBlockOperations;
  64345. /**
  64346. * Creates a new TrigonometryBlock
  64347. * @param name defines the block name
  64348. */
  64349. constructor(name: string);
  64350. /**
  64351. * Gets the current class name
  64352. * @returns the class name
  64353. */
  64354. getClassName(): string;
  64355. /**
  64356. * Gets the input component
  64357. */
  64358. get input(): NodeMaterialConnectionPoint;
  64359. /**
  64360. * Gets the output component
  64361. */
  64362. get output(): NodeMaterialConnectionPoint;
  64363. protected _buildBlock(state: NodeMaterialBuildState): this;
  64364. serialize(): any;
  64365. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64366. protected _dumpPropertiesCode(): string;
  64367. }
  64368. }
  64369. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  64370. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64371. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64372. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64373. /**
  64374. * Block used to create a Color3/4 out of individual inputs (one for each component)
  64375. */
  64376. export class ColorMergerBlock extends NodeMaterialBlock {
  64377. /**
  64378. * Create a new ColorMergerBlock
  64379. * @param name defines the block name
  64380. */
  64381. constructor(name: string);
  64382. /**
  64383. * Gets the current class name
  64384. * @returns the class name
  64385. */
  64386. getClassName(): string;
  64387. /**
  64388. * Gets the rgb component (input)
  64389. */
  64390. get rgbIn(): NodeMaterialConnectionPoint;
  64391. /**
  64392. * Gets the r component (input)
  64393. */
  64394. get r(): NodeMaterialConnectionPoint;
  64395. /**
  64396. * Gets the g component (input)
  64397. */
  64398. get g(): NodeMaterialConnectionPoint;
  64399. /**
  64400. * Gets the b component (input)
  64401. */
  64402. get b(): NodeMaterialConnectionPoint;
  64403. /**
  64404. * Gets the a component (input)
  64405. */
  64406. get a(): NodeMaterialConnectionPoint;
  64407. /**
  64408. * Gets the rgba component (output)
  64409. */
  64410. get rgba(): NodeMaterialConnectionPoint;
  64411. /**
  64412. * Gets the rgb component (output)
  64413. */
  64414. get rgbOut(): NodeMaterialConnectionPoint;
  64415. /**
  64416. * Gets the rgb component (output)
  64417. * @deprecated Please use rgbOut instead.
  64418. */
  64419. get rgb(): NodeMaterialConnectionPoint;
  64420. protected _buildBlock(state: NodeMaterialBuildState): this;
  64421. }
  64422. }
  64423. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  64424. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64425. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64426. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64427. /**
  64428. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  64429. */
  64430. export class VectorSplitterBlock extends NodeMaterialBlock {
  64431. /**
  64432. * Create a new VectorSplitterBlock
  64433. * @param name defines the block name
  64434. */
  64435. constructor(name: string);
  64436. /**
  64437. * Gets the current class name
  64438. * @returns the class name
  64439. */
  64440. getClassName(): string;
  64441. /**
  64442. * Gets the xyzw component (input)
  64443. */
  64444. get xyzw(): NodeMaterialConnectionPoint;
  64445. /**
  64446. * Gets the xyz component (input)
  64447. */
  64448. get xyzIn(): NodeMaterialConnectionPoint;
  64449. /**
  64450. * Gets the xy component (input)
  64451. */
  64452. get xyIn(): NodeMaterialConnectionPoint;
  64453. /**
  64454. * Gets the xyz component (output)
  64455. */
  64456. get xyzOut(): NodeMaterialConnectionPoint;
  64457. /**
  64458. * Gets the xy component (output)
  64459. */
  64460. get xyOut(): NodeMaterialConnectionPoint;
  64461. /**
  64462. * Gets the x component (output)
  64463. */
  64464. get x(): NodeMaterialConnectionPoint;
  64465. /**
  64466. * Gets the y component (output)
  64467. */
  64468. get y(): NodeMaterialConnectionPoint;
  64469. /**
  64470. * Gets the z component (output)
  64471. */
  64472. get z(): NodeMaterialConnectionPoint;
  64473. /**
  64474. * Gets the w component (output)
  64475. */
  64476. get w(): NodeMaterialConnectionPoint;
  64477. protected _inputRename(name: string): string;
  64478. protected _outputRename(name: string): string;
  64479. protected _buildBlock(state: NodeMaterialBuildState): this;
  64480. }
  64481. }
  64482. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  64483. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64484. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64485. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64486. /**
  64487. * Block used to lerp between 2 values
  64488. */
  64489. export class LerpBlock extends NodeMaterialBlock {
  64490. /**
  64491. * Creates a new LerpBlock
  64492. * @param name defines the block name
  64493. */
  64494. constructor(name: string);
  64495. /**
  64496. * Gets the current class name
  64497. * @returns the class name
  64498. */
  64499. getClassName(): string;
  64500. /**
  64501. * Gets the left operand input component
  64502. */
  64503. get left(): NodeMaterialConnectionPoint;
  64504. /**
  64505. * Gets the right operand input component
  64506. */
  64507. get right(): NodeMaterialConnectionPoint;
  64508. /**
  64509. * Gets the gradient operand input component
  64510. */
  64511. get gradient(): NodeMaterialConnectionPoint;
  64512. /**
  64513. * Gets the output component
  64514. */
  64515. get output(): NodeMaterialConnectionPoint;
  64516. protected _buildBlock(state: NodeMaterialBuildState): this;
  64517. }
  64518. }
  64519. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  64520. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64521. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64522. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64523. /**
  64524. * Block used to divide 2 vectors
  64525. */
  64526. export class DivideBlock extends NodeMaterialBlock {
  64527. /**
  64528. * Creates a new DivideBlock
  64529. * @param name defines the block name
  64530. */
  64531. constructor(name: string);
  64532. /**
  64533. * Gets the current class name
  64534. * @returns the class name
  64535. */
  64536. getClassName(): string;
  64537. /**
  64538. * Gets the left operand input component
  64539. */
  64540. get left(): NodeMaterialConnectionPoint;
  64541. /**
  64542. * Gets the right operand input component
  64543. */
  64544. get right(): NodeMaterialConnectionPoint;
  64545. /**
  64546. * Gets the output component
  64547. */
  64548. get output(): NodeMaterialConnectionPoint;
  64549. protected _buildBlock(state: NodeMaterialBuildState): this;
  64550. }
  64551. }
  64552. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  64553. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64554. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64555. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64556. /**
  64557. * Block used to subtract 2 vectors
  64558. */
  64559. export class SubtractBlock extends NodeMaterialBlock {
  64560. /**
  64561. * Creates a new SubtractBlock
  64562. * @param name defines the block name
  64563. */
  64564. constructor(name: string);
  64565. /**
  64566. * Gets the current class name
  64567. * @returns the class name
  64568. */
  64569. getClassName(): string;
  64570. /**
  64571. * Gets the left operand input component
  64572. */
  64573. get left(): NodeMaterialConnectionPoint;
  64574. /**
  64575. * Gets the right operand input component
  64576. */
  64577. get right(): NodeMaterialConnectionPoint;
  64578. /**
  64579. * Gets the output component
  64580. */
  64581. get output(): NodeMaterialConnectionPoint;
  64582. protected _buildBlock(state: NodeMaterialBuildState): this;
  64583. }
  64584. }
  64585. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  64586. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64587. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64588. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64589. /**
  64590. * Block used to step a value
  64591. */
  64592. export class StepBlock extends NodeMaterialBlock {
  64593. /**
  64594. * Creates a new StepBlock
  64595. * @param name defines the block name
  64596. */
  64597. constructor(name: string);
  64598. /**
  64599. * Gets the current class name
  64600. * @returns the class name
  64601. */
  64602. getClassName(): string;
  64603. /**
  64604. * Gets the value operand input component
  64605. */
  64606. get value(): NodeMaterialConnectionPoint;
  64607. /**
  64608. * Gets the edge operand input component
  64609. */
  64610. get edge(): NodeMaterialConnectionPoint;
  64611. /**
  64612. * Gets the output component
  64613. */
  64614. get output(): NodeMaterialConnectionPoint;
  64615. protected _buildBlock(state: NodeMaterialBuildState): this;
  64616. }
  64617. }
  64618. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  64619. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64620. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64621. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64622. /**
  64623. * Block used to get the opposite (1 - x) of a value
  64624. */
  64625. export class OneMinusBlock extends NodeMaterialBlock {
  64626. /**
  64627. * Creates a new OneMinusBlock
  64628. * @param name defines the block name
  64629. */
  64630. constructor(name: string);
  64631. /**
  64632. * Gets the current class name
  64633. * @returns the class name
  64634. */
  64635. getClassName(): string;
  64636. /**
  64637. * Gets the input component
  64638. */
  64639. get input(): NodeMaterialConnectionPoint;
  64640. /**
  64641. * Gets the output component
  64642. */
  64643. get output(): NodeMaterialConnectionPoint;
  64644. protected _buildBlock(state: NodeMaterialBuildState): this;
  64645. }
  64646. }
  64647. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  64648. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64649. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64650. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64651. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  64652. /**
  64653. * Block used to get the view direction
  64654. */
  64655. export class ViewDirectionBlock extends NodeMaterialBlock {
  64656. /**
  64657. * Creates a new ViewDirectionBlock
  64658. * @param name defines the block name
  64659. */
  64660. constructor(name: string);
  64661. /**
  64662. * Gets the current class name
  64663. * @returns the class name
  64664. */
  64665. getClassName(): string;
  64666. /**
  64667. * Gets the world position component
  64668. */
  64669. get worldPosition(): NodeMaterialConnectionPoint;
  64670. /**
  64671. * Gets the camera position component
  64672. */
  64673. get cameraPosition(): NodeMaterialConnectionPoint;
  64674. /**
  64675. * Gets the output component
  64676. */
  64677. get output(): NodeMaterialConnectionPoint;
  64678. autoConfigure(material: NodeMaterial): void;
  64679. protected _buildBlock(state: NodeMaterialBuildState): this;
  64680. }
  64681. }
  64682. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  64683. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64684. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64685. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64686. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  64687. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  64688. /**
  64689. * Block used to compute fresnel value
  64690. */
  64691. export class FresnelBlock extends NodeMaterialBlock {
  64692. /**
  64693. * Create a new FresnelBlock
  64694. * @param name defines the block name
  64695. */
  64696. constructor(name: string);
  64697. /**
  64698. * Gets the current class name
  64699. * @returns the class name
  64700. */
  64701. getClassName(): string;
  64702. /**
  64703. * Gets the world normal input component
  64704. */
  64705. get worldNormal(): NodeMaterialConnectionPoint;
  64706. /**
  64707. * Gets the view direction input component
  64708. */
  64709. get viewDirection(): NodeMaterialConnectionPoint;
  64710. /**
  64711. * Gets the bias input component
  64712. */
  64713. get bias(): NodeMaterialConnectionPoint;
  64714. /**
  64715. * Gets the camera (or eye) position component
  64716. */
  64717. get power(): NodeMaterialConnectionPoint;
  64718. /**
  64719. * Gets the fresnel output component
  64720. */
  64721. get fresnel(): NodeMaterialConnectionPoint;
  64722. autoConfigure(material: NodeMaterial): void;
  64723. protected _buildBlock(state: NodeMaterialBuildState): this;
  64724. }
  64725. }
  64726. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  64727. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64728. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64729. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64730. /**
  64731. * Block used to get the max of 2 values
  64732. */
  64733. export class MaxBlock extends NodeMaterialBlock {
  64734. /**
  64735. * Creates a new MaxBlock
  64736. * @param name defines the block name
  64737. */
  64738. constructor(name: string);
  64739. /**
  64740. * Gets the current class name
  64741. * @returns the class name
  64742. */
  64743. getClassName(): string;
  64744. /**
  64745. * Gets the left operand input component
  64746. */
  64747. get left(): NodeMaterialConnectionPoint;
  64748. /**
  64749. * Gets the right operand input component
  64750. */
  64751. get right(): NodeMaterialConnectionPoint;
  64752. /**
  64753. * Gets the output component
  64754. */
  64755. get output(): NodeMaterialConnectionPoint;
  64756. protected _buildBlock(state: NodeMaterialBuildState): this;
  64757. }
  64758. }
  64759. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  64760. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64761. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64762. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64763. /**
  64764. * Block used to get the min of 2 values
  64765. */
  64766. export class MinBlock extends NodeMaterialBlock {
  64767. /**
  64768. * Creates a new MinBlock
  64769. * @param name defines the block name
  64770. */
  64771. constructor(name: string);
  64772. /**
  64773. * Gets the current class name
  64774. * @returns the class name
  64775. */
  64776. getClassName(): string;
  64777. /**
  64778. * Gets the left operand input component
  64779. */
  64780. get left(): NodeMaterialConnectionPoint;
  64781. /**
  64782. * Gets the right operand input component
  64783. */
  64784. get right(): NodeMaterialConnectionPoint;
  64785. /**
  64786. * Gets the output component
  64787. */
  64788. get output(): NodeMaterialConnectionPoint;
  64789. protected _buildBlock(state: NodeMaterialBuildState): this;
  64790. }
  64791. }
  64792. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  64793. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64794. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64795. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64796. /**
  64797. * Block used to get the distance between 2 values
  64798. */
  64799. export class DistanceBlock extends NodeMaterialBlock {
  64800. /**
  64801. * Creates a new DistanceBlock
  64802. * @param name defines the block name
  64803. */
  64804. constructor(name: string);
  64805. /**
  64806. * Gets the current class name
  64807. * @returns the class name
  64808. */
  64809. getClassName(): string;
  64810. /**
  64811. * Gets the left operand input component
  64812. */
  64813. get left(): NodeMaterialConnectionPoint;
  64814. /**
  64815. * Gets the right operand input component
  64816. */
  64817. get right(): NodeMaterialConnectionPoint;
  64818. /**
  64819. * Gets the output component
  64820. */
  64821. get output(): NodeMaterialConnectionPoint;
  64822. protected _buildBlock(state: NodeMaterialBuildState): this;
  64823. }
  64824. }
  64825. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  64826. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64827. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64828. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64829. /**
  64830. * Block used to get the length of a vector
  64831. */
  64832. export class LengthBlock extends NodeMaterialBlock {
  64833. /**
  64834. * Creates a new LengthBlock
  64835. * @param name defines the block name
  64836. */
  64837. constructor(name: string);
  64838. /**
  64839. * Gets the current class name
  64840. * @returns the class name
  64841. */
  64842. getClassName(): string;
  64843. /**
  64844. * Gets the value input component
  64845. */
  64846. get value(): NodeMaterialConnectionPoint;
  64847. /**
  64848. * Gets the output component
  64849. */
  64850. get output(): NodeMaterialConnectionPoint;
  64851. protected _buildBlock(state: NodeMaterialBuildState): this;
  64852. }
  64853. }
  64854. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  64855. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64856. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64857. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64858. /**
  64859. * Block used to get negative version of a value (i.e. x * -1)
  64860. */
  64861. export class NegateBlock extends NodeMaterialBlock {
  64862. /**
  64863. * Creates a new NegateBlock
  64864. * @param name defines the block name
  64865. */
  64866. constructor(name: string);
  64867. /**
  64868. * Gets the current class name
  64869. * @returns the class name
  64870. */
  64871. getClassName(): string;
  64872. /**
  64873. * Gets the value input component
  64874. */
  64875. get value(): NodeMaterialConnectionPoint;
  64876. /**
  64877. * Gets the output component
  64878. */
  64879. get output(): NodeMaterialConnectionPoint;
  64880. protected _buildBlock(state: NodeMaterialBuildState): this;
  64881. }
  64882. }
  64883. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  64884. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64885. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64886. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64887. /**
  64888. * Block used to get the value of the first parameter raised to the power of the second
  64889. */
  64890. export class PowBlock extends NodeMaterialBlock {
  64891. /**
  64892. * Creates a new PowBlock
  64893. * @param name defines the block name
  64894. */
  64895. constructor(name: string);
  64896. /**
  64897. * Gets the current class name
  64898. * @returns the class name
  64899. */
  64900. getClassName(): string;
  64901. /**
  64902. * Gets the value operand input component
  64903. */
  64904. get value(): NodeMaterialConnectionPoint;
  64905. /**
  64906. * Gets the power operand input component
  64907. */
  64908. get power(): NodeMaterialConnectionPoint;
  64909. /**
  64910. * Gets the output component
  64911. */
  64912. get output(): NodeMaterialConnectionPoint;
  64913. protected _buildBlock(state: NodeMaterialBuildState): this;
  64914. }
  64915. }
  64916. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  64917. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64918. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64919. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64920. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  64921. /**
  64922. * Block used to get a random number
  64923. */
  64924. export class RandomNumberBlock extends NodeMaterialBlock {
  64925. /**
  64926. * Creates a new RandomNumberBlock
  64927. * @param name defines the block name
  64928. */
  64929. constructor(name: string);
  64930. /**
  64931. * Gets the current class name
  64932. * @returns the class name
  64933. */
  64934. getClassName(): string;
  64935. /**
  64936. * Gets the seed input component
  64937. */
  64938. get seed(): NodeMaterialConnectionPoint;
  64939. /**
  64940. * Gets the output component
  64941. */
  64942. get output(): NodeMaterialConnectionPoint;
  64943. protected _buildBlock(state: NodeMaterialBuildState): this;
  64944. }
  64945. }
  64946. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  64947. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64948. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64949. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64950. /**
  64951. * Block used to compute arc tangent of 2 values
  64952. */
  64953. export class ArcTan2Block extends NodeMaterialBlock {
  64954. /**
  64955. * Creates a new ArcTan2Block
  64956. * @param name defines the block name
  64957. */
  64958. constructor(name: string);
  64959. /**
  64960. * Gets the current class name
  64961. * @returns the class name
  64962. */
  64963. getClassName(): string;
  64964. /**
  64965. * Gets the x operand input component
  64966. */
  64967. get x(): NodeMaterialConnectionPoint;
  64968. /**
  64969. * Gets the y operand input component
  64970. */
  64971. get y(): NodeMaterialConnectionPoint;
  64972. /**
  64973. * Gets the output component
  64974. */
  64975. get output(): NodeMaterialConnectionPoint;
  64976. protected _buildBlock(state: NodeMaterialBuildState): this;
  64977. }
  64978. }
  64979. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  64980. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64981. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64982. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64983. /**
  64984. * Block used to smooth step a value
  64985. */
  64986. export class SmoothStepBlock extends NodeMaterialBlock {
  64987. /**
  64988. * Creates a new SmoothStepBlock
  64989. * @param name defines the block name
  64990. */
  64991. constructor(name: string);
  64992. /**
  64993. * Gets the current class name
  64994. * @returns the class name
  64995. */
  64996. getClassName(): string;
  64997. /**
  64998. * Gets the value operand input component
  64999. */
  65000. get value(): NodeMaterialConnectionPoint;
  65001. /**
  65002. * Gets the first edge operand input component
  65003. */
  65004. get edge0(): NodeMaterialConnectionPoint;
  65005. /**
  65006. * Gets the second edge operand input component
  65007. */
  65008. get edge1(): NodeMaterialConnectionPoint;
  65009. /**
  65010. * Gets the output component
  65011. */
  65012. get output(): NodeMaterialConnectionPoint;
  65013. protected _buildBlock(state: NodeMaterialBuildState): this;
  65014. }
  65015. }
  65016. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  65017. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65018. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65019. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65020. /**
  65021. * Block used to get the reciprocal (1 / x) of a value
  65022. */
  65023. export class ReciprocalBlock extends NodeMaterialBlock {
  65024. /**
  65025. * Creates a new ReciprocalBlock
  65026. * @param name defines the block name
  65027. */
  65028. constructor(name: string);
  65029. /**
  65030. * Gets the current class name
  65031. * @returns the class name
  65032. */
  65033. getClassName(): string;
  65034. /**
  65035. * Gets the input component
  65036. */
  65037. get input(): NodeMaterialConnectionPoint;
  65038. /**
  65039. * Gets the output component
  65040. */
  65041. get output(): NodeMaterialConnectionPoint;
  65042. protected _buildBlock(state: NodeMaterialBuildState): this;
  65043. }
  65044. }
  65045. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  65046. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65047. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65048. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65049. /**
  65050. * Block used to replace a color by another one
  65051. */
  65052. export class ReplaceColorBlock extends NodeMaterialBlock {
  65053. /**
  65054. * Creates a new ReplaceColorBlock
  65055. * @param name defines the block name
  65056. */
  65057. constructor(name: string);
  65058. /**
  65059. * Gets the current class name
  65060. * @returns the class name
  65061. */
  65062. getClassName(): string;
  65063. /**
  65064. * Gets the value input component
  65065. */
  65066. get value(): NodeMaterialConnectionPoint;
  65067. /**
  65068. * Gets the reference input component
  65069. */
  65070. get reference(): NodeMaterialConnectionPoint;
  65071. /**
  65072. * Gets the distance input component
  65073. */
  65074. get distance(): NodeMaterialConnectionPoint;
  65075. /**
  65076. * Gets the replacement input component
  65077. */
  65078. get replacement(): NodeMaterialConnectionPoint;
  65079. /**
  65080. * Gets the output component
  65081. */
  65082. get output(): NodeMaterialConnectionPoint;
  65083. protected _buildBlock(state: NodeMaterialBuildState): this;
  65084. }
  65085. }
  65086. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  65087. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65088. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65089. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65090. /**
  65091. * Block used to posterize a value
  65092. * @see https://en.wikipedia.org/wiki/Posterization
  65093. */
  65094. export class PosterizeBlock extends NodeMaterialBlock {
  65095. /**
  65096. * Creates a new PosterizeBlock
  65097. * @param name defines the block name
  65098. */
  65099. constructor(name: string);
  65100. /**
  65101. * Gets the current class name
  65102. * @returns the class name
  65103. */
  65104. getClassName(): string;
  65105. /**
  65106. * Gets the value input component
  65107. */
  65108. get value(): NodeMaterialConnectionPoint;
  65109. /**
  65110. * Gets the steps input component
  65111. */
  65112. get steps(): NodeMaterialConnectionPoint;
  65113. /**
  65114. * Gets the output component
  65115. */
  65116. get output(): NodeMaterialConnectionPoint;
  65117. protected _buildBlock(state: NodeMaterialBuildState): this;
  65118. }
  65119. }
  65120. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  65121. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65122. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65123. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65124. import { Scene } from "babylonjs/scene";
  65125. /**
  65126. * Operations supported by the Wave block
  65127. */
  65128. export enum WaveBlockKind {
  65129. /** SawTooth */
  65130. SawTooth = 0,
  65131. /** Square */
  65132. Square = 1,
  65133. /** Triangle */
  65134. Triangle = 2
  65135. }
  65136. /**
  65137. * Block used to apply wave operation to floats
  65138. */
  65139. export class WaveBlock extends NodeMaterialBlock {
  65140. /**
  65141. * Gets or sets the kibnd of wave to be applied by the block
  65142. */
  65143. kind: WaveBlockKind;
  65144. /**
  65145. * Creates a new WaveBlock
  65146. * @param name defines the block name
  65147. */
  65148. constructor(name: string);
  65149. /**
  65150. * Gets the current class name
  65151. * @returns the class name
  65152. */
  65153. getClassName(): string;
  65154. /**
  65155. * Gets the input component
  65156. */
  65157. get input(): NodeMaterialConnectionPoint;
  65158. /**
  65159. * Gets the output component
  65160. */
  65161. get output(): NodeMaterialConnectionPoint;
  65162. protected _buildBlock(state: NodeMaterialBuildState): this;
  65163. serialize(): any;
  65164. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65165. }
  65166. }
  65167. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  65168. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65169. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65170. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65171. import { Color3 } from "babylonjs/Maths/math.color";
  65172. import { Scene } from "babylonjs/scene";
  65173. /**
  65174. * Class used to store a color step for the GradientBlock
  65175. */
  65176. export class GradientBlockColorStep {
  65177. /**
  65178. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  65179. */
  65180. step: number;
  65181. /**
  65182. * Gets or sets the color associated with this step
  65183. */
  65184. color: Color3;
  65185. /**
  65186. * Creates a new GradientBlockColorStep
  65187. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  65188. * @param color defines the color associated with this step
  65189. */
  65190. constructor(
  65191. /**
  65192. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  65193. */
  65194. step: number,
  65195. /**
  65196. * Gets or sets the color associated with this step
  65197. */
  65198. color: Color3);
  65199. }
  65200. /**
  65201. * Block used to return a color from a gradient based on an input value between 0 and 1
  65202. */
  65203. export class GradientBlock extends NodeMaterialBlock {
  65204. /**
  65205. * Gets or sets the list of color steps
  65206. */
  65207. colorSteps: GradientBlockColorStep[];
  65208. /**
  65209. * Creates a new GradientBlock
  65210. * @param name defines the block name
  65211. */
  65212. constructor(name: string);
  65213. /**
  65214. * Gets the current class name
  65215. * @returns the class name
  65216. */
  65217. getClassName(): string;
  65218. /**
  65219. * Gets the gradient input component
  65220. */
  65221. get gradient(): NodeMaterialConnectionPoint;
  65222. /**
  65223. * Gets the output component
  65224. */
  65225. get output(): NodeMaterialConnectionPoint;
  65226. private _writeColorConstant;
  65227. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  65228. serialize(): any;
  65229. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65230. protected _dumpPropertiesCode(): string;
  65231. }
  65232. }
  65233. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  65234. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65235. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65236. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65237. /**
  65238. * Block used to normalize lerp between 2 values
  65239. */
  65240. export class NLerpBlock extends NodeMaterialBlock {
  65241. /**
  65242. * Creates a new NLerpBlock
  65243. * @param name defines the block name
  65244. */
  65245. constructor(name: string);
  65246. /**
  65247. * Gets the current class name
  65248. * @returns the class name
  65249. */
  65250. getClassName(): string;
  65251. /**
  65252. * Gets the left operand input component
  65253. */
  65254. get left(): NodeMaterialConnectionPoint;
  65255. /**
  65256. * Gets the right operand input component
  65257. */
  65258. get right(): NodeMaterialConnectionPoint;
  65259. /**
  65260. * Gets the gradient operand input component
  65261. */
  65262. get gradient(): NodeMaterialConnectionPoint;
  65263. /**
  65264. * Gets the output component
  65265. */
  65266. get output(): NodeMaterialConnectionPoint;
  65267. protected _buildBlock(state: NodeMaterialBuildState): this;
  65268. }
  65269. }
  65270. declare module "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock" {
  65271. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65272. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65273. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65274. import { Scene } from "babylonjs/scene";
  65275. /**
  65276. * block used to Generate a Worley Noise 3D Noise Pattern
  65277. */
  65278. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  65279. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  65280. manhattanDistance: boolean;
  65281. /**
  65282. * Creates a new WorleyNoise3DBlock
  65283. * @param name defines the block name
  65284. */
  65285. constructor(name: string);
  65286. /**
  65287. * Gets the current class name
  65288. * @returns the class name
  65289. */
  65290. getClassName(): string;
  65291. /**
  65292. * Gets the seed input component
  65293. */
  65294. get seed(): NodeMaterialConnectionPoint;
  65295. /**
  65296. * Gets the jitter input component
  65297. */
  65298. get jitter(): NodeMaterialConnectionPoint;
  65299. /**
  65300. * Gets the output component
  65301. */
  65302. get output(): NodeMaterialConnectionPoint;
  65303. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  65304. /**
  65305. * Exposes the properties to the UI?
  65306. */
  65307. protected _dumpPropertiesCode(): string;
  65308. /**
  65309. * Exposes the properties to the Seralize?
  65310. */
  65311. serialize(): any;
  65312. /**
  65313. * Exposes the properties to the deseralize?
  65314. */
  65315. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65316. }
  65317. }
  65318. declare module "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock" {
  65319. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65320. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65321. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65322. /**
  65323. * block used to Generate a Simplex Perlin 3d Noise Pattern
  65324. */
  65325. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  65326. /**
  65327. * Creates a new SimplexPerlin3DBlock
  65328. * @param name defines the block name
  65329. */
  65330. constructor(name: string);
  65331. /**
  65332. * Gets the current class name
  65333. * @returns the class name
  65334. */
  65335. getClassName(): string;
  65336. /**
  65337. * Gets the seed operand input component
  65338. */
  65339. get seed(): NodeMaterialConnectionPoint;
  65340. /**
  65341. * Gets the output component
  65342. */
  65343. get output(): NodeMaterialConnectionPoint;
  65344. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  65345. }
  65346. }
  65347. declare module "babylonjs/Materials/Node/Blocks/normalBlendBlock" {
  65348. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65349. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65350. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65351. /**
  65352. * Block used to blend normals
  65353. */
  65354. export class NormalBlendBlock extends NodeMaterialBlock {
  65355. /**
  65356. * Creates a new NormalBlendBlock
  65357. * @param name defines the block name
  65358. */
  65359. constructor(name: string);
  65360. /**
  65361. * Gets the current class name
  65362. * @returns the class name
  65363. */
  65364. getClassName(): string;
  65365. /**
  65366. * Gets the first input component
  65367. */
  65368. get normalMap0(): NodeMaterialConnectionPoint;
  65369. /**
  65370. * Gets the second input component
  65371. */
  65372. get normalMap1(): NodeMaterialConnectionPoint;
  65373. /**
  65374. * Gets the output component
  65375. */
  65376. get output(): NodeMaterialConnectionPoint;
  65377. protected _buildBlock(state: NodeMaterialBuildState): this;
  65378. }
  65379. }
  65380. declare module "babylonjs/Materials/Node/Blocks/rotate2dBlock" {
  65381. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65382. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65383. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65384. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  65385. /**
  65386. * Block used to rotate a 2d vector by a given angle
  65387. */
  65388. export class Rotate2dBlock extends NodeMaterialBlock {
  65389. /**
  65390. * Creates a new Rotate2dBlock
  65391. * @param name defines the block name
  65392. */
  65393. constructor(name: string);
  65394. /**
  65395. * Gets the current class name
  65396. * @returns the class name
  65397. */
  65398. getClassName(): string;
  65399. /**
  65400. * Gets the input vector
  65401. */
  65402. get input(): NodeMaterialConnectionPoint;
  65403. /**
  65404. * Gets the input angle
  65405. */
  65406. get angle(): NodeMaterialConnectionPoint;
  65407. /**
  65408. * Gets the output component
  65409. */
  65410. get output(): NodeMaterialConnectionPoint;
  65411. autoConfigure(material: NodeMaterial): void;
  65412. protected _buildBlock(state: NodeMaterialBuildState): this;
  65413. }
  65414. }
  65415. declare module "babylonjs/Materials/Node/Blocks/reflectBlock" {
  65416. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65417. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65418. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65419. /**
  65420. * Block used to get the reflected vector from a direction and a normal
  65421. */
  65422. export class ReflectBlock extends NodeMaterialBlock {
  65423. /**
  65424. * Creates a new ReflectBlock
  65425. * @param name defines the block name
  65426. */
  65427. constructor(name: string);
  65428. /**
  65429. * Gets the current class name
  65430. * @returns the class name
  65431. */
  65432. getClassName(): string;
  65433. /**
  65434. * Gets the incident component
  65435. */
  65436. get incident(): NodeMaterialConnectionPoint;
  65437. /**
  65438. * Gets the normal component
  65439. */
  65440. get normal(): NodeMaterialConnectionPoint;
  65441. /**
  65442. * Gets the output component
  65443. */
  65444. get output(): NodeMaterialConnectionPoint;
  65445. protected _buildBlock(state: NodeMaterialBuildState): this;
  65446. }
  65447. }
  65448. declare module "babylonjs/Materials/Node/Blocks/refractBlock" {
  65449. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65450. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65451. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65452. /**
  65453. * Block used to get the refracted vector from a direction and a normal
  65454. */
  65455. export class RefractBlock extends NodeMaterialBlock {
  65456. /**
  65457. * Creates a new RefractBlock
  65458. * @param name defines the block name
  65459. */
  65460. constructor(name: string);
  65461. /**
  65462. * Gets the current class name
  65463. * @returns the class name
  65464. */
  65465. getClassName(): string;
  65466. /**
  65467. * Gets the incident component
  65468. */
  65469. get incident(): NodeMaterialConnectionPoint;
  65470. /**
  65471. * Gets the normal component
  65472. */
  65473. get normal(): NodeMaterialConnectionPoint;
  65474. /**
  65475. * Gets the index of refraction component
  65476. */
  65477. get ior(): 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/desaturateBlock" {
  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 desaturate a color
  65491. */
  65492. export class DesaturateBlock extends NodeMaterialBlock {
  65493. /**
  65494. * Creates a new DesaturateBlock
  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 color operand input component
  65505. */
  65506. get color(): NodeMaterialConnectionPoint;
  65507. /**
  65508. * Gets the level operand input component
  65509. */
  65510. get level(): 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/PBR/ambientOcclusionBlock" {
  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 { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65523. import { Nullable } from "babylonjs/types";
  65524. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65525. import { Scene } from "babylonjs/scene";
  65526. /**
  65527. * Block used to implement the ambient occlusion module of the PBR material
  65528. */
  65529. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  65530. /**
  65531. * Create a new AmbientOcclusionBlock
  65532. * @param name defines the block name
  65533. */
  65534. constructor(name: string);
  65535. /**
  65536. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  65537. */
  65538. useAmbientInGrayScale: boolean;
  65539. /**
  65540. * Initialize the block and prepare the context for build
  65541. * @param state defines the state that will be used for the build
  65542. */
  65543. initialize(state: NodeMaterialBuildState): void;
  65544. /**
  65545. * Gets the current class name
  65546. * @returns the class name
  65547. */
  65548. getClassName(): string;
  65549. /**
  65550. * Gets the texture input component
  65551. */
  65552. get texture(): NodeMaterialConnectionPoint;
  65553. /**
  65554. * Gets the texture intensity component
  65555. */
  65556. get intensity(): NodeMaterialConnectionPoint;
  65557. /**
  65558. * Gets the direct light intensity input component
  65559. */
  65560. get directLightIntensity(): NodeMaterialConnectionPoint;
  65561. /**
  65562. * Gets the ambient occlusion object output component
  65563. */
  65564. get ambientOcclusion(): NodeMaterialConnectionPoint;
  65565. /**
  65566. * Gets the main code of the block (fragment side)
  65567. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  65568. * @returns the shader code
  65569. */
  65570. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  65571. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65572. protected _buildBlock(state: NodeMaterialBuildState): this;
  65573. protected _dumpPropertiesCode(): string;
  65574. serialize(): any;
  65575. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65576. }
  65577. }
  65578. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock" {
  65579. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65580. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65581. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65582. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  65583. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65584. import { Nullable } from "babylonjs/types";
  65585. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  65586. import { Mesh } from "babylonjs/Meshes/mesh";
  65587. import { SubMesh } from "babylonjs/Meshes/subMesh";
  65588. import { Effect } from "babylonjs/Materials/effect";
  65589. import { Scene } from "babylonjs/scene";
  65590. /**
  65591. * Block used to implement the reflection module of the PBR material
  65592. */
  65593. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  65594. /** @hidden */
  65595. _defineLODReflectionAlpha: string;
  65596. /** @hidden */
  65597. _defineLinearSpecularReflection: string;
  65598. private _vEnvironmentIrradianceName;
  65599. /** @hidden */
  65600. _vReflectionMicrosurfaceInfosName: string;
  65601. /** @hidden */
  65602. _vReflectionInfosName: string;
  65603. private _scene;
  65604. /**
  65605. * The three properties below are set by the main PBR block prior to calling methods of this class.
  65606. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  65607. * It's less burden on the user side in the editor part.
  65608. */
  65609. /** @hidden */
  65610. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  65611. /** @hidden */
  65612. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  65613. /** @hidden */
  65614. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  65615. /**
  65616. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  65617. * diffuse part of the IBL.
  65618. */
  65619. useSphericalHarmonics: boolean;
  65620. /**
  65621. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  65622. */
  65623. forceIrradianceInFragment: boolean;
  65624. /**
  65625. * Create a new ReflectionBlock
  65626. * @param name defines the block name
  65627. */
  65628. constructor(name: string);
  65629. /**
  65630. * Gets the current class name
  65631. * @returns the class name
  65632. */
  65633. getClassName(): string;
  65634. /**
  65635. * Gets the position input component
  65636. */
  65637. get position(): NodeMaterialConnectionPoint;
  65638. /**
  65639. * Gets the world position input component
  65640. */
  65641. get worldPosition(): NodeMaterialConnectionPoint;
  65642. /**
  65643. * Gets the world normal input component
  65644. */
  65645. get worldNormal(): NodeMaterialConnectionPoint;
  65646. /**
  65647. * Gets the world input component
  65648. */
  65649. get world(): NodeMaterialConnectionPoint;
  65650. /**
  65651. * Gets the camera (or eye) position component
  65652. */
  65653. get cameraPosition(): NodeMaterialConnectionPoint;
  65654. /**
  65655. * Gets the view input component
  65656. */
  65657. get view(): NodeMaterialConnectionPoint;
  65658. /**
  65659. * Gets the color input component
  65660. */
  65661. get color(): NodeMaterialConnectionPoint;
  65662. /**
  65663. * Gets the reflection object output component
  65664. */
  65665. get reflection(): NodeMaterialConnectionPoint;
  65666. /**
  65667. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  65668. */
  65669. get hasTexture(): boolean;
  65670. /**
  65671. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  65672. */
  65673. get reflectionColor(): string;
  65674. protected _getTexture(): Nullable<BaseTexture>;
  65675. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65676. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  65677. /**
  65678. * Gets the code to inject in the vertex shader
  65679. * @param state current state of the node material building
  65680. * @returns the shader code
  65681. */
  65682. handleVertexSide(state: NodeMaterialBuildState): string;
  65683. /**
  65684. * Gets the main code of the block (fragment side)
  65685. * @param state current state of the node material building
  65686. * @param normalVarName name of the existing variable corresponding to the normal
  65687. * @returns the shader code
  65688. */
  65689. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  65690. protected _buildBlock(state: NodeMaterialBuildState): this;
  65691. protected _dumpPropertiesCode(): string;
  65692. serialize(): any;
  65693. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65694. }
  65695. }
  65696. declare module "babylonjs/Materials/Node/Blocks/PBR/sheenBlock" {
  65697. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65698. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65699. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65700. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65701. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65702. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  65703. import { Scene } from "babylonjs/scene";
  65704. import { Nullable } from "babylonjs/types";
  65705. /**
  65706. * Block used to implement the sheen module of the PBR material
  65707. */
  65708. export class SheenBlock extends NodeMaterialBlock {
  65709. /**
  65710. * Create a new SheenBlock
  65711. * @param name defines the block name
  65712. */
  65713. constructor(name: string);
  65714. /**
  65715. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  65716. * It allows the strength of the sheen effect to not depend on the base color of the material,
  65717. * making it easier to setup and tweak the effect
  65718. */
  65719. albedoScaling: boolean;
  65720. /**
  65721. * Defines if the sheen is linked to the sheen color.
  65722. */
  65723. linkSheenWithAlbedo: boolean;
  65724. /**
  65725. * Initialize the block and prepare the context for build
  65726. * @param state defines the state that will be used for the build
  65727. */
  65728. initialize(state: NodeMaterialBuildState): void;
  65729. /**
  65730. * Gets the current class name
  65731. * @returns the class name
  65732. */
  65733. getClassName(): string;
  65734. /**
  65735. * Gets the intensity input component
  65736. */
  65737. get intensity(): NodeMaterialConnectionPoint;
  65738. /**
  65739. * Gets the color input component
  65740. */
  65741. get color(): NodeMaterialConnectionPoint;
  65742. /**
  65743. * Gets the roughness input component
  65744. */
  65745. get roughness(): NodeMaterialConnectionPoint;
  65746. /**
  65747. * Gets the texture input component
  65748. */
  65749. get texture(): NodeMaterialConnectionPoint;
  65750. /**
  65751. * Gets the sheen object output component
  65752. */
  65753. get sheen(): NodeMaterialConnectionPoint;
  65754. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65755. /**
  65756. * Gets the main code of the block (fragment side)
  65757. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  65758. * @returns the shader code
  65759. */
  65760. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  65761. protected _buildBlock(state: NodeMaterialBuildState): this;
  65762. protected _dumpPropertiesCode(): string;
  65763. serialize(): any;
  65764. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65765. }
  65766. }
  65767. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectivityBlock" {
  65768. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65769. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65770. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65771. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65772. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65773. import { Scene } from "babylonjs/scene";
  65774. /**
  65775. * Block used to implement the reflectivity module of the PBR material
  65776. */
  65777. export class ReflectivityBlock extends NodeMaterialBlock {
  65778. /**
  65779. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  65780. */
  65781. useAmbientOcclusionFromMetallicTextureRed: boolean;
  65782. /**
  65783. * Specifies if the metallic texture contains the metallness information in its blue channel.
  65784. */
  65785. useMetallnessFromMetallicTextureBlue: boolean;
  65786. /**
  65787. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  65788. */
  65789. useRoughnessFromMetallicTextureAlpha: boolean;
  65790. /**
  65791. * Specifies if the metallic texture contains the roughness information in its green channel.
  65792. */
  65793. useRoughnessFromMetallicTextureGreen: boolean;
  65794. /**
  65795. * Create a new ReflectivityBlock
  65796. * @param name defines the block name
  65797. */
  65798. constructor(name: string);
  65799. /**
  65800. * Initialize the block and prepare the context for build
  65801. * @param state defines the state that will be used for the build
  65802. */
  65803. initialize(state: NodeMaterialBuildState): void;
  65804. /**
  65805. * Gets the current class name
  65806. * @returns the class name
  65807. */
  65808. getClassName(): string;
  65809. /**
  65810. * Gets the metallic input component
  65811. */
  65812. get metallic(): NodeMaterialConnectionPoint;
  65813. /**
  65814. * Gets the roughness input component
  65815. */
  65816. get roughness(): NodeMaterialConnectionPoint;
  65817. /**
  65818. * Gets the texture input component
  65819. */
  65820. get texture(): NodeMaterialConnectionPoint;
  65821. /**
  65822. * Gets the reflectivity object output component
  65823. */
  65824. get reflectivity(): NodeMaterialConnectionPoint;
  65825. /**
  65826. * Gets the main code of the block (fragment side)
  65827. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  65828. * @returns the shader code
  65829. */
  65830. getCode(aoIntensityVarName: string): string;
  65831. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65832. protected _buildBlock(state: NodeMaterialBuildState): this;
  65833. protected _dumpPropertiesCode(): string;
  65834. serialize(): any;
  65835. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65836. }
  65837. }
  65838. declare module "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock" {
  65839. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65840. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65841. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65842. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65843. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65844. /**
  65845. * Block used to implement the anisotropy module of the PBR material
  65846. */
  65847. export class AnisotropyBlock extends NodeMaterialBlock {
  65848. /**
  65849. * The two properties below are set by the main PBR block prior to calling methods of this class.
  65850. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  65851. * It's less burden on the user side in the editor part.
  65852. */
  65853. /** @hidden */
  65854. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  65855. /** @hidden */
  65856. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  65857. /**
  65858. * Create a new AnisotropyBlock
  65859. * @param name defines the block name
  65860. */
  65861. constructor(name: string);
  65862. /**
  65863. * Initialize the block and prepare the context for build
  65864. * @param state defines the state that will be used for the build
  65865. */
  65866. initialize(state: NodeMaterialBuildState): void;
  65867. /**
  65868. * Gets the current class name
  65869. * @returns the class name
  65870. */
  65871. getClassName(): string;
  65872. /**
  65873. * Gets the intensity input component
  65874. */
  65875. get intensity(): NodeMaterialConnectionPoint;
  65876. /**
  65877. * Gets the direction input component
  65878. */
  65879. get direction(): NodeMaterialConnectionPoint;
  65880. /**
  65881. * Gets the texture input component
  65882. */
  65883. get texture(): NodeMaterialConnectionPoint;
  65884. /**
  65885. * Gets the uv input component
  65886. */
  65887. get uv(): NodeMaterialConnectionPoint;
  65888. /**
  65889. * Gets the worldTangent input component
  65890. */
  65891. get worldTangent(): NodeMaterialConnectionPoint;
  65892. /**
  65893. * Gets the anisotropy object output component
  65894. */
  65895. get anisotropy(): NodeMaterialConnectionPoint;
  65896. private _generateTBNSpace;
  65897. /**
  65898. * Gets the main code of the block (fragment side)
  65899. * @param state current state of the node material building
  65900. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  65901. * @returns the shader code
  65902. */
  65903. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  65904. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65905. protected _buildBlock(state: NodeMaterialBuildState): this;
  65906. }
  65907. }
  65908. declare module "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock" {
  65909. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65910. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65911. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65912. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65913. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65914. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  65915. import { Nullable } from "babylonjs/types";
  65916. import { Mesh } from "babylonjs/Meshes/mesh";
  65917. import { SubMesh } from "babylonjs/Meshes/subMesh";
  65918. import { Effect } from "babylonjs/Materials/effect";
  65919. /**
  65920. * Block used to implement the clear coat module of the PBR material
  65921. */
  65922. export class ClearCoatBlock extends NodeMaterialBlock {
  65923. private _scene;
  65924. /**
  65925. * Create a new ClearCoatBlock
  65926. * @param name defines the block name
  65927. */
  65928. constructor(name: string);
  65929. /**
  65930. * Initialize the block and prepare the context for build
  65931. * @param state defines the state that will be used for the build
  65932. */
  65933. initialize(state: NodeMaterialBuildState): void;
  65934. /**
  65935. * Gets the current class name
  65936. * @returns the class name
  65937. */
  65938. getClassName(): string;
  65939. /**
  65940. * Gets the intensity input component
  65941. */
  65942. get intensity(): NodeMaterialConnectionPoint;
  65943. /**
  65944. * Gets the roughness input component
  65945. */
  65946. get roughness(): NodeMaterialConnectionPoint;
  65947. /**
  65948. * Gets the ior input component
  65949. */
  65950. get ior(): NodeMaterialConnectionPoint;
  65951. /**
  65952. * Gets the texture input component
  65953. */
  65954. get texture(): NodeMaterialConnectionPoint;
  65955. /**
  65956. * Gets the bump texture input component
  65957. */
  65958. get bumpTexture(): NodeMaterialConnectionPoint;
  65959. /**
  65960. * Gets the uv input component
  65961. */
  65962. get uv(): NodeMaterialConnectionPoint;
  65963. /**
  65964. * Gets the tint color input component
  65965. */
  65966. get tintColor(): NodeMaterialConnectionPoint;
  65967. /**
  65968. * Gets the tint "at distance" input component
  65969. */
  65970. get tintAtDistance(): NodeMaterialConnectionPoint;
  65971. /**
  65972. * Gets the tint thickness input component
  65973. */
  65974. get tintThickness(): NodeMaterialConnectionPoint;
  65975. /**
  65976. * Gets the tint texture input component
  65977. */
  65978. get tintTexture(): NodeMaterialConnectionPoint;
  65979. /**
  65980. * Gets the world tangent input component
  65981. */
  65982. get worldTangent(): NodeMaterialConnectionPoint;
  65983. /**
  65984. * Gets the clear coat object output component
  65985. */
  65986. get clearcoat(): NodeMaterialConnectionPoint;
  65987. autoConfigure(material: NodeMaterial): void;
  65988. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65989. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  65990. private _generateTBNSpace;
  65991. /**
  65992. * Gets the main code of the block (fragment side)
  65993. * @param state current state of the node material building
  65994. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  65995. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  65996. * @param worldPosVarName name of the variable holding the world position
  65997. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  65998. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  65999. * @param worldNormalVarName name of the variable holding the world normal
  66000. * @returns the shader code
  66001. */
  66002. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  66003. protected _buildBlock(state: NodeMaterialBuildState): this;
  66004. }
  66005. }
  66006. declare module "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock" {
  66007. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66008. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66009. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66010. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66011. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66012. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  66013. import { Nullable } from "babylonjs/types";
  66014. /**
  66015. * Block used to implement the sub surface module of the PBR material
  66016. */
  66017. export class SubSurfaceBlock extends NodeMaterialBlock {
  66018. /**
  66019. * Create a new SubSurfaceBlock
  66020. * @param name defines the block name
  66021. */
  66022. constructor(name: string);
  66023. /**
  66024. * Stores the intensity of the different subsurface effects in the thickness texture.
  66025. * * the green channel is the translucency intensity.
  66026. * * the blue channel is the scattering intensity.
  66027. * * the alpha channel is the refraction intensity.
  66028. */
  66029. useMaskFromThicknessTexture: boolean;
  66030. /**
  66031. * Initialize the block and prepare the context for build
  66032. * @param state defines the state that will be used for the build
  66033. */
  66034. initialize(state: NodeMaterialBuildState): void;
  66035. /**
  66036. * Gets the current class name
  66037. * @returns the class name
  66038. */
  66039. getClassName(): string;
  66040. /**
  66041. * Gets the min thickness input component
  66042. */
  66043. get minThickness(): NodeMaterialConnectionPoint;
  66044. /**
  66045. * Gets the max thickness input component
  66046. */
  66047. get maxThickness(): NodeMaterialConnectionPoint;
  66048. /**
  66049. * Gets the thickness texture component
  66050. */
  66051. get thicknessTexture(): NodeMaterialConnectionPoint;
  66052. /**
  66053. * Gets the tint color input component
  66054. */
  66055. get tintColor(): NodeMaterialConnectionPoint;
  66056. /**
  66057. * Gets the translucency intensity input component
  66058. */
  66059. get translucencyIntensity(): NodeMaterialConnectionPoint;
  66060. /**
  66061. * Gets the translucency diffusion distance input component
  66062. */
  66063. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  66064. /**
  66065. * Gets the refraction object parameters
  66066. */
  66067. get refraction(): NodeMaterialConnectionPoint;
  66068. /**
  66069. * Gets the sub surface object output component
  66070. */
  66071. get subsurface(): NodeMaterialConnectionPoint;
  66072. autoConfigure(material: NodeMaterial): void;
  66073. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66074. /**
  66075. * Gets the main code of the block (fragment side)
  66076. * @param state current state of the node material building
  66077. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  66078. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  66079. * @param worldPosVarName name of the variable holding the world position
  66080. * @returns the shader code
  66081. */
  66082. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  66083. protected _buildBlock(state: NodeMaterialBuildState): this;
  66084. }
  66085. }
  66086. declare module "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock" {
  66087. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66088. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66089. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66090. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66091. import { Light } from "babylonjs/Lights/light";
  66092. import { Nullable } from "babylonjs/types";
  66093. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66094. import { Effect } from "babylonjs/Materials/effect";
  66095. import { Mesh } from "babylonjs/Meshes/mesh";
  66096. import { Scene } from "babylonjs/scene";
  66097. /**
  66098. * Block used to implement the PBR metallic/roughness model
  66099. */
  66100. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  66101. /**
  66102. * Gets or sets the light associated with this block
  66103. */
  66104. light: Nullable<Light>;
  66105. private _lightId;
  66106. private _scene;
  66107. private _environmentBRDFTexture;
  66108. private _environmentBrdfSamplerName;
  66109. private _vNormalWName;
  66110. private _invertNormalName;
  66111. /**
  66112. * Create a new ReflectionBlock
  66113. * @param name defines the block name
  66114. */
  66115. constructor(name: string);
  66116. /**
  66117. * Intensity of the direct lights e.g. the four lights available in your scene.
  66118. * This impacts both the direct diffuse and specular highlights.
  66119. */
  66120. directIntensity: number;
  66121. /**
  66122. * Intensity of the environment e.g. how much the environment will light the object
  66123. * either through harmonics for rough material or through the refelction for shiny ones.
  66124. */
  66125. environmentIntensity: number;
  66126. /**
  66127. * This is a special control allowing the reduction of the specular highlights coming from the
  66128. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  66129. */
  66130. specularIntensity: number;
  66131. /**
  66132. * Defines the falloff type used in this material.
  66133. * It by default is Physical.
  66134. */
  66135. lightFalloff: number;
  66136. /**
  66137. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  66138. */
  66139. useAlphaFromAlbedoTexture: boolean;
  66140. /**
  66141. * Specifies that alpha test should be used
  66142. */
  66143. useAlphaTest: boolean;
  66144. /**
  66145. * Defines the alpha limits in alpha test mode.
  66146. */
  66147. alphaTestCutoff: number;
  66148. /**
  66149. * Specifies that alpha blending should be used
  66150. */
  66151. useAlphaBlending: boolean;
  66152. /**
  66153. * Defines if the alpha value should be determined via the rgb values.
  66154. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  66155. */
  66156. opacityRGB: boolean;
  66157. /**
  66158. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  66159. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  66160. */
  66161. useRadianceOverAlpha: boolean;
  66162. /**
  66163. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  66164. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  66165. */
  66166. useSpecularOverAlpha: boolean;
  66167. /**
  66168. * Enables specular anti aliasing in the PBR shader.
  66169. * It will both interacts on the Geometry for analytical and IBL lighting.
  66170. * It also prefilter the roughness map based on the bump values.
  66171. */
  66172. enableSpecularAntiAliasing: boolean;
  66173. /**
  66174. * Defines if the material uses energy conservation.
  66175. */
  66176. useEnergyConservation: boolean;
  66177. /**
  66178. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  66179. * too much the area relying on ambient texture to define their ambient occlusion.
  66180. */
  66181. useRadianceOcclusion: boolean;
  66182. /**
  66183. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  66184. * makes the reflect vector face the model (under horizon).
  66185. */
  66186. useHorizonOcclusion: boolean;
  66187. /**
  66188. * If set to true, no lighting calculations will be applied.
  66189. */
  66190. unlit: boolean;
  66191. /**
  66192. * Force normal to face away from face.
  66193. */
  66194. forceNormalForward: boolean;
  66195. /**
  66196. * Defines the material debug mode.
  66197. * It helps seeing only some components of the material while troubleshooting.
  66198. */
  66199. debugMode: number;
  66200. /**
  66201. * Specify from where on screen the debug mode should start.
  66202. * The value goes from -1 (full screen) to 1 (not visible)
  66203. * It helps with side by side comparison against the final render
  66204. * This defaults to 0
  66205. */
  66206. debugLimit: number;
  66207. /**
  66208. * As the default viewing range might not be enough (if the ambient is really small for instance)
  66209. * You can use the factor to better multiply the final value.
  66210. */
  66211. debugFactor: number;
  66212. /**
  66213. * Initialize the block and prepare the context for build
  66214. * @param state defines the state that will be used for the build
  66215. */
  66216. initialize(state: NodeMaterialBuildState): void;
  66217. /**
  66218. * Gets the current class name
  66219. * @returns the class name
  66220. */
  66221. getClassName(): string;
  66222. /**
  66223. * Gets the world position input component
  66224. */
  66225. get worldPosition(): NodeMaterialConnectionPoint;
  66226. /**
  66227. * Gets the world normal input component
  66228. */
  66229. get worldNormal(): NodeMaterialConnectionPoint;
  66230. /**
  66231. * Gets the perturbed normal input component
  66232. */
  66233. get perturbedNormal(): NodeMaterialConnectionPoint;
  66234. /**
  66235. * Gets the camera position input component
  66236. */
  66237. get cameraPosition(): NodeMaterialConnectionPoint;
  66238. /**
  66239. * Gets the base color input component
  66240. */
  66241. get baseColor(): NodeMaterialConnectionPoint;
  66242. /**
  66243. * Gets the base texture input component
  66244. */
  66245. get baseTexture(): NodeMaterialConnectionPoint;
  66246. /**
  66247. * Gets the opacity texture input component
  66248. */
  66249. get opacityTexture(): NodeMaterialConnectionPoint;
  66250. /**
  66251. * Gets the ambient color input component
  66252. */
  66253. get ambientColor(): NodeMaterialConnectionPoint;
  66254. /**
  66255. * Gets the reflectivity object parameters
  66256. */
  66257. get reflectivity(): NodeMaterialConnectionPoint;
  66258. /**
  66259. * Gets the ambient occlusion object parameters
  66260. */
  66261. get ambientOcclusion(): NodeMaterialConnectionPoint;
  66262. /**
  66263. * Gets the reflection object parameters
  66264. */
  66265. get reflection(): NodeMaterialConnectionPoint;
  66266. /**
  66267. * Gets the sheen object parameters
  66268. */
  66269. get sheen(): NodeMaterialConnectionPoint;
  66270. /**
  66271. * Gets the clear coat object parameters
  66272. */
  66273. get clearcoat(): NodeMaterialConnectionPoint;
  66274. /**
  66275. * Gets the sub surface object parameters
  66276. */
  66277. get subsurface(): NodeMaterialConnectionPoint;
  66278. /**
  66279. * Gets the anisotropy object parameters
  66280. */
  66281. get anisotropy(): NodeMaterialConnectionPoint;
  66282. /**
  66283. * Gets the ambient output component
  66284. */
  66285. get ambient(): NodeMaterialConnectionPoint;
  66286. /**
  66287. * Gets the diffuse output component
  66288. */
  66289. get diffuse(): NodeMaterialConnectionPoint;
  66290. /**
  66291. * Gets the specular output component
  66292. */
  66293. get specular(): NodeMaterialConnectionPoint;
  66294. /**
  66295. * Gets the sheen output component
  66296. */
  66297. get sheenDir(): NodeMaterialConnectionPoint;
  66298. /**
  66299. * Gets the clear coat output component
  66300. */
  66301. get clearcoatDir(): NodeMaterialConnectionPoint;
  66302. /**
  66303. * Gets the indirect diffuse output component
  66304. */
  66305. get diffuseIndirect(): NodeMaterialConnectionPoint;
  66306. /**
  66307. * Gets the indirect specular output component
  66308. */
  66309. get specularIndirect(): NodeMaterialConnectionPoint;
  66310. /**
  66311. * Gets the indirect sheen output component
  66312. */
  66313. get sheenIndirect(): NodeMaterialConnectionPoint;
  66314. /**
  66315. * Gets the indirect clear coat output component
  66316. */
  66317. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  66318. /**
  66319. * Gets the refraction output component
  66320. */
  66321. get refraction(): NodeMaterialConnectionPoint;
  66322. /**
  66323. * Gets the global lighting output component
  66324. */
  66325. get lighting(): NodeMaterialConnectionPoint;
  66326. /**
  66327. * Gets the shadow output component
  66328. */
  66329. get shadow(): NodeMaterialConnectionPoint;
  66330. /**
  66331. * Gets the alpha output component
  66332. */
  66333. get alpha(): NodeMaterialConnectionPoint;
  66334. autoConfigure(material: NodeMaterial): void;
  66335. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66336. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  66337. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66338. private _injectVertexCode;
  66339. /**
  66340. * Gets the code corresponding to the albedo/opacity module
  66341. * @returns the shader code
  66342. */
  66343. getAlbedoOpacityCode(): string;
  66344. protected _buildBlock(state: NodeMaterialBuildState): this;
  66345. protected _dumpPropertiesCode(): string;
  66346. serialize(): any;
  66347. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66348. }
  66349. }
  66350. declare module "babylonjs/Materials/Node/Blocks/PBR/index" {
  66351. export * from "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock";
  66352. export * from "babylonjs/Materials/Node/Blocks/PBR/sheenBlock";
  66353. export * from "babylonjs/Materials/Node/Blocks/PBR/ambientOcclusionBlock";
  66354. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectivityBlock";
  66355. export * from "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock";
  66356. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  66357. export * from "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock";
  66358. export * from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  66359. export * from "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock";
  66360. }
  66361. declare module "babylonjs/Materials/Node/Blocks/Particle/index" {
  66362. export * from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  66363. export * from "babylonjs/Materials/Node/Blocks/Particle/particleRampGradientBlock";
  66364. export * from "babylonjs/Materials/Node/Blocks/Particle/particleBlendMultiplyBlock";
  66365. }
  66366. declare module "babylonjs/Materials/Node/Blocks/modBlock" {
  66367. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66368. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66369. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66370. /**
  66371. * Block used to compute value of one parameter modulo another
  66372. */
  66373. export class ModBlock extends NodeMaterialBlock {
  66374. /**
  66375. * Creates a new ModBlock
  66376. * @param name defines the block name
  66377. */
  66378. constructor(name: string);
  66379. /**
  66380. * Gets the current class name
  66381. * @returns the class name
  66382. */
  66383. getClassName(): string;
  66384. /**
  66385. * Gets the left operand input component
  66386. */
  66387. get left(): NodeMaterialConnectionPoint;
  66388. /**
  66389. * Gets the right operand input component
  66390. */
  66391. get right(): NodeMaterialConnectionPoint;
  66392. /**
  66393. * Gets the output component
  66394. */
  66395. get output(): NodeMaterialConnectionPoint;
  66396. protected _buildBlock(state: NodeMaterialBuildState): this;
  66397. }
  66398. }
  66399. declare module "babylonjs/Materials/Node/Blocks/index" {
  66400. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  66401. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  66402. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  66403. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  66404. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  66405. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  66406. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  66407. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  66408. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  66409. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  66410. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  66411. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  66412. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  66413. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  66414. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  66415. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  66416. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  66417. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  66418. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  66419. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  66420. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  66421. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  66422. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  66423. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  66424. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  66425. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  66426. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  66427. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  66428. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  66429. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  66430. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  66431. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  66432. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  66433. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  66434. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  66435. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  66436. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  66437. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  66438. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  66439. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  66440. export * from "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock";
  66441. export * from "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock";
  66442. export * from "babylonjs/Materials/Node/Blocks/normalBlendBlock";
  66443. export * from "babylonjs/Materials/Node/Blocks/rotate2dBlock";
  66444. export * from "babylonjs/Materials/Node/Blocks/reflectBlock";
  66445. export * from "babylonjs/Materials/Node/Blocks/refractBlock";
  66446. export * from "babylonjs/Materials/Node/Blocks/desaturateBlock";
  66447. export * from "babylonjs/Materials/Node/Blocks/PBR/index";
  66448. export * from "babylonjs/Materials/Node/Blocks/Particle/index";
  66449. export * from "babylonjs/Materials/Node/Blocks/modBlock";
  66450. }
  66451. declare module "babylonjs/Materials/Node/Optimizers/index" {
  66452. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  66453. }
  66454. declare module "babylonjs/Materials/Node/index" {
  66455. export * from "babylonjs/Materials/Node/Enums/index";
  66456. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66457. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  66458. export * from "babylonjs/Materials/Node/nodeMaterial";
  66459. export * from "babylonjs/Materials/Node/Blocks/index";
  66460. export * from "babylonjs/Materials/Node/Optimizers/index";
  66461. export * from "babylonjs/Materials/Node/nodeMaterialDecorator";
  66462. }
  66463. declare module "babylonjs/Materials/index" {
  66464. export * from "babylonjs/Materials/Background/index";
  66465. export * from "babylonjs/Materials/colorCurves";
  66466. export * from "babylonjs/Materials/iEffectFallbacks";
  66467. export * from "babylonjs/Materials/effectFallbacks";
  66468. export * from "babylonjs/Materials/effect";
  66469. export * from "babylonjs/Materials/fresnelParameters";
  66470. export * from "babylonjs/Materials/imageProcessingConfiguration";
  66471. export * from "babylonjs/Materials/material";
  66472. export * from "babylonjs/Materials/materialDefines";
  66473. export * from "babylonjs/Materials/materialHelper";
  66474. export * from "babylonjs/Materials/multiMaterial";
  66475. export * from "babylonjs/Materials/PBR/index";
  66476. export * from "babylonjs/Materials/pushMaterial";
  66477. export * from "babylonjs/Materials/shaderMaterial";
  66478. export * from "babylonjs/Materials/standardMaterial";
  66479. export * from "babylonjs/Materials/Textures/index";
  66480. export * from "babylonjs/Materials/uniformBuffer";
  66481. export * from "babylonjs/Materials/materialFlags";
  66482. export * from "babylonjs/Materials/Node/index";
  66483. export * from "babylonjs/Materials/effectRenderer";
  66484. export * from "babylonjs/Materials/shadowDepthWrapper";
  66485. }
  66486. declare module "babylonjs/Maths/index" {
  66487. export * from "babylonjs/Maths/math.scalar";
  66488. export * from "babylonjs/Maths/math";
  66489. export * from "babylonjs/Maths/sphericalPolynomial";
  66490. }
  66491. declare module "babylonjs/Misc/workerPool" {
  66492. import { IDisposable } from "babylonjs/scene";
  66493. /**
  66494. * Helper class to push actions to a pool of workers.
  66495. */
  66496. export class WorkerPool implements IDisposable {
  66497. private _workerInfos;
  66498. private _pendingActions;
  66499. /**
  66500. * Constructor
  66501. * @param workers Array of workers to use for actions
  66502. */
  66503. constructor(workers: Array<Worker>);
  66504. /**
  66505. * Terminates all workers and clears any pending actions.
  66506. */
  66507. dispose(): void;
  66508. /**
  66509. * Pushes an action to the worker pool. If all the workers are active, the action will be
  66510. * pended until a worker has completed its action.
  66511. * @param action The action to perform. Call onComplete when the action is complete.
  66512. */
  66513. push(action: (worker: Worker, onComplete: () => void) => void): void;
  66514. private _execute;
  66515. }
  66516. }
  66517. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  66518. import { IDisposable } from "babylonjs/scene";
  66519. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  66520. /**
  66521. * Configuration for Draco compression
  66522. */
  66523. export interface IDracoCompressionConfiguration {
  66524. /**
  66525. * Configuration for the decoder.
  66526. */
  66527. decoder: {
  66528. /**
  66529. * The url to the WebAssembly module.
  66530. */
  66531. wasmUrl?: string;
  66532. /**
  66533. * The url to the WebAssembly binary.
  66534. */
  66535. wasmBinaryUrl?: string;
  66536. /**
  66537. * The url to the fallback JavaScript module.
  66538. */
  66539. fallbackUrl?: string;
  66540. };
  66541. }
  66542. /**
  66543. * Draco compression (https://google.github.io/draco/)
  66544. *
  66545. * This class wraps the Draco module.
  66546. *
  66547. * **Encoder**
  66548. *
  66549. * The encoder is not currently implemented.
  66550. *
  66551. * **Decoder**
  66552. *
  66553. * 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.
  66554. *
  66555. * To update the configuration, use the following code:
  66556. * ```javascript
  66557. * DracoCompression.Configuration = {
  66558. * decoder: {
  66559. * wasmUrl: "<url to the WebAssembly library>",
  66560. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  66561. * fallbackUrl: "<url to the fallback JavaScript library>",
  66562. * }
  66563. * };
  66564. * ```
  66565. *
  66566. * 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.
  66567. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  66568. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  66569. *
  66570. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  66571. * ```javascript
  66572. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  66573. * ```
  66574. *
  66575. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  66576. */
  66577. export class DracoCompression implements IDisposable {
  66578. private _workerPoolPromise?;
  66579. private _decoderModulePromise?;
  66580. /**
  66581. * The configuration. Defaults to the following urls:
  66582. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  66583. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  66584. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  66585. */
  66586. static Configuration: IDracoCompressionConfiguration;
  66587. /**
  66588. * Returns true if the decoder configuration is available.
  66589. */
  66590. static get DecoderAvailable(): boolean;
  66591. /**
  66592. * Default number of workers to create when creating the draco compression object.
  66593. */
  66594. static DefaultNumWorkers: number;
  66595. private static GetDefaultNumWorkers;
  66596. private static _Default;
  66597. /**
  66598. * Default instance for the draco compression object.
  66599. */
  66600. static get Default(): DracoCompression;
  66601. /**
  66602. * Constructor
  66603. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  66604. */
  66605. constructor(numWorkers?: number);
  66606. /**
  66607. * Stop all async operations and release resources.
  66608. */
  66609. dispose(): void;
  66610. /**
  66611. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  66612. * @returns a promise that resolves when ready
  66613. */
  66614. whenReadyAsync(): Promise<void>;
  66615. /**
  66616. * Decode Draco compressed mesh data to vertex data.
  66617. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  66618. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  66619. * @returns A promise that resolves with the decoded vertex data
  66620. */
  66621. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  66622. [kind: string]: number;
  66623. }): Promise<VertexData>;
  66624. }
  66625. }
  66626. declare module "babylonjs/Meshes/Compression/index" {
  66627. export * from "babylonjs/Meshes/Compression/dracoCompression";
  66628. }
  66629. declare module "babylonjs/Meshes/csg" {
  66630. import { Nullable } from "babylonjs/types";
  66631. import { Scene } from "babylonjs/scene";
  66632. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  66633. import { Mesh } from "babylonjs/Meshes/mesh";
  66634. import { Material } from "babylonjs/Materials/material";
  66635. /**
  66636. * Class for building Constructive Solid Geometry
  66637. */
  66638. export class CSG {
  66639. private polygons;
  66640. /**
  66641. * The world matrix
  66642. */
  66643. matrix: Matrix;
  66644. /**
  66645. * Stores the position
  66646. */
  66647. position: Vector3;
  66648. /**
  66649. * Stores the rotation
  66650. */
  66651. rotation: Vector3;
  66652. /**
  66653. * Stores the rotation quaternion
  66654. */
  66655. rotationQuaternion: Nullable<Quaternion>;
  66656. /**
  66657. * Stores the scaling vector
  66658. */
  66659. scaling: Vector3;
  66660. /**
  66661. * Convert the Mesh to CSG
  66662. * @param mesh The Mesh to convert to CSG
  66663. * @returns A new CSG from the Mesh
  66664. */
  66665. static FromMesh(mesh: Mesh): CSG;
  66666. /**
  66667. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  66668. * @param polygons Polygons used to construct a CSG solid
  66669. */
  66670. private static FromPolygons;
  66671. /**
  66672. * Clones, or makes a deep copy, of the CSG
  66673. * @returns A new CSG
  66674. */
  66675. clone(): CSG;
  66676. /**
  66677. * Unions this CSG with another CSG
  66678. * @param csg The CSG to union against this CSG
  66679. * @returns The unioned CSG
  66680. */
  66681. union(csg: CSG): CSG;
  66682. /**
  66683. * Unions this CSG with another CSG in place
  66684. * @param csg The CSG to union against this CSG
  66685. */
  66686. unionInPlace(csg: CSG): void;
  66687. /**
  66688. * Subtracts this CSG with another CSG
  66689. * @param csg The CSG to subtract against this CSG
  66690. * @returns A new CSG
  66691. */
  66692. subtract(csg: CSG): CSG;
  66693. /**
  66694. * Subtracts this CSG with another CSG in place
  66695. * @param csg The CSG to subtact against this CSG
  66696. */
  66697. subtractInPlace(csg: CSG): void;
  66698. /**
  66699. * Intersect this CSG with another CSG
  66700. * @param csg The CSG to intersect against this CSG
  66701. * @returns A new CSG
  66702. */
  66703. intersect(csg: CSG): CSG;
  66704. /**
  66705. * Intersects this CSG with another CSG in place
  66706. * @param csg The CSG to intersect against this CSG
  66707. */
  66708. intersectInPlace(csg: CSG): void;
  66709. /**
  66710. * Return a new CSG solid with solid and empty space switched. This solid is
  66711. * not modified.
  66712. * @returns A new CSG solid with solid and empty space switched
  66713. */
  66714. inverse(): CSG;
  66715. /**
  66716. * Inverses the CSG in place
  66717. */
  66718. inverseInPlace(): void;
  66719. /**
  66720. * This is used to keep meshes transformations so they can be restored
  66721. * when we build back a Babylon Mesh
  66722. * NB : All CSG operations are performed in world coordinates
  66723. * @param csg The CSG to copy the transform attributes from
  66724. * @returns This CSG
  66725. */
  66726. copyTransformAttributes(csg: CSG): CSG;
  66727. /**
  66728. * Build Raw mesh from CSG
  66729. * Coordinates here are in world space
  66730. * @param name The name of the mesh geometry
  66731. * @param scene The Scene
  66732. * @param keepSubMeshes Specifies if the submeshes should be kept
  66733. * @returns A new Mesh
  66734. */
  66735. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  66736. /**
  66737. * Build Mesh from CSG taking material and transforms into account
  66738. * @param name The name of the Mesh
  66739. * @param material The material of the Mesh
  66740. * @param scene The Scene
  66741. * @param keepSubMeshes Specifies if submeshes should be kept
  66742. * @returns The new Mesh
  66743. */
  66744. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  66745. }
  66746. }
  66747. declare module "babylonjs/Meshes/trailMesh" {
  66748. import { Mesh } from "babylonjs/Meshes/mesh";
  66749. import { Scene } from "babylonjs/scene";
  66750. import { TransformNode } from "babylonjs/Meshes/transformNode";
  66751. /**
  66752. * Class used to create a trail following a mesh
  66753. */
  66754. export class TrailMesh extends Mesh {
  66755. private _generator;
  66756. private _autoStart;
  66757. private _running;
  66758. private _diameter;
  66759. private _length;
  66760. private _sectionPolygonPointsCount;
  66761. private _sectionVectors;
  66762. private _sectionNormalVectors;
  66763. private _beforeRenderObserver;
  66764. /**
  66765. * @constructor
  66766. * @param name The value used by scene.getMeshByName() to do a lookup.
  66767. * @param generator The mesh or transform node to generate a trail.
  66768. * @param scene The scene to add this mesh to.
  66769. * @param diameter Diameter of trailing mesh. Default is 1.
  66770. * @param length Length of trailing mesh. Default is 60.
  66771. * @param autoStart Automatically start trailing mesh. Default true.
  66772. */
  66773. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  66774. /**
  66775. * "TrailMesh"
  66776. * @returns "TrailMesh"
  66777. */
  66778. getClassName(): string;
  66779. private _createMesh;
  66780. /**
  66781. * Start trailing mesh.
  66782. */
  66783. start(): void;
  66784. /**
  66785. * Stop trailing mesh.
  66786. */
  66787. stop(): void;
  66788. /**
  66789. * Update trailing mesh geometry.
  66790. */
  66791. update(): void;
  66792. /**
  66793. * Returns a new TrailMesh object.
  66794. * @param name is a string, the name given to the new mesh
  66795. * @param newGenerator use new generator object for cloned trail mesh
  66796. * @returns a new mesh
  66797. */
  66798. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  66799. /**
  66800. * Serializes this trail mesh
  66801. * @param serializationObject object to write serialization to
  66802. */
  66803. serialize(serializationObject: any): void;
  66804. /**
  66805. * Parses a serialized trail mesh
  66806. * @param parsedMesh the serialized mesh
  66807. * @param scene the scene to create the trail mesh in
  66808. * @returns the created trail mesh
  66809. */
  66810. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  66811. }
  66812. }
  66813. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  66814. import { Nullable } from "babylonjs/types";
  66815. import { Scene } from "babylonjs/scene";
  66816. import { Vector4 } from "babylonjs/Maths/math.vector";
  66817. import { Color4 } from "babylonjs/Maths/math.color";
  66818. import { Mesh } from "babylonjs/Meshes/mesh";
  66819. /**
  66820. * Class containing static functions to help procedurally build meshes
  66821. */
  66822. export class TiledBoxBuilder {
  66823. /**
  66824. * Creates a box mesh
  66825. * 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)
  66826. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  66827. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66828. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  66829. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66830. * @param name defines the name of the mesh
  66831. * @param options defines the options used to create the mesh
  66832. * @param scene defines the hosting scene
  66833. * @returns the box mesh
  66834. */
  66835. static CreateTiledBox(name: string, options: {
  66836. pattern?: number;
  66837. width?: number;
  66838. height?: number;
  66839. depth?: number;
  66840. tileSize?: number;
  66841. tileWidth?: number;
  66842. tileHeight?: number;
  66843. alignHorizontal?: number;
  66844. alignVertical?: number;
  66845. faceUV?: Vector4[];
  66846. faceColors?: Color4[];
  66847. sideOrientation?: number;
  66848. updatable?: boolean;
  66849. }, scene?: Nullable<Scene>): Mesh;
  66850. }
  66851. }
  66852. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  66853. import { Vector4 } from "babylonjs/Maths/math.vector";
  66854. import { Mesh } from "babylonjs/Meshes/mesh";
  66855. /**
  66856. * Class containing static functions to help procedurally build meshes
  66857. */
  66858. export class TorusKnotBuilder {
  66859. /**
  66860. * Creates a torus knot mesh
  66861. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  66862. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  66863. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  66864. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  66865. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66866. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  66867. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66868. * @param name defines the name of the mesh
  66869. * @param options defines the options used to create the mesh
  66870. * @param scene defines the hosting scene
  66871. * @returns the torus knot mesh
  66872. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  66873. */
  66874. static CreateTorusKnot(name: string, options: {
  66875. radius?: number;
  66876. tube?: number;
  66877. radialSegments?: number;
  66878. tubularSegments?: number;
  66879. p?: number;
  66880. q?: number;
  66881. updatable?: boolean;
  66882. sideOrientation?: number;
  66883. frontUVs?: Vector4;
  66884. backUVs?: Vector4;
  66885. }, scene: any): Mesh;
  66886. }
  66887. }
  66888. declare module "babylonjs/Meshes/polygonMesh" {
  66889. import { Scene } from "babylonjs/scene";
  66890. import { Vector2 } from "babylonjs/Maths/math.vector";
  66891. import { Mesh } from "babylonjs/Meshes/mesh";
  66892. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  66893. import { Path2 } from "babylonjs/Maths/math.path";
  66894. /**
  66895. * Polygon
  66896. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  66897. */
  66898. export class Polygon {
  66899. /**
  66900. * Creates a rectangle
  66901. * @param xmin bottom X coord
  66902. * @param ymin bottom Y coord
  66903. * @param xmax top X coord
  66904. * @param ymax top Y coord
  66905. * @returns points that make the resulting rectation
  66906. */
  66907. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  66908. /**
  66909. * Creates a circle
  66910. * @param radius radius of circle
  66911. * @param cx scale in x
  66912. * @param cy scale in y
  66913. * @param numberOfSides number of sides that make up the circle
  66914. * @returns points that make the resulting circle
  66915. */
  66916. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  66917. /**
  66918. * Creates a polygon from input string
  66919. * @param input Input polygon data
  66920. * @returns the parsed points
  66921. */
  66922. static Parse(input: string): Vector2[];
  66923. /**
  66924. * Starts building a polygon from x and y coordinates
  66925. * @param x x coordinate
  66926. * @param y y coordinate
  66927. * @returns the started path2
  66928. */
  66929. static StartingAt(x: number, y: number): Path2;
  66930. }
  66931. /**
  66932. * Builds a polygon
  66933. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  66934. */
  66935. export class PolygonMeshBuilder {
  66936. private _points;
  66937. private _outlinepoints;
  66938. private _holes;
  66939. private _name;
  66940. private _scene;
  66941. private _epoints;
  66942. private _eholes;
  66943. private _addToepoint;
  66944. /**
  66945. * Babylon reference to the earcut plugin.
  66946. */
  66947. bjsEarcut: any;
  66948. /**
  66949. * Creates a PolygonMeshBuilder
  66950. * @param name name of the builder
  66951. * @param contours Path of the polygon
  66952. * @param scene scene to add to when creating the mesh
  66953. * @param earcutInjection can be used to inject your own earcut reference
  66954. */
  66955. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  66956. /**
  66957. * Adds a whole within the polygon
  66958. * @param hole Array of points defining the hole
  66959. * @returns this
  66960. */
  66961. addHole(hole: Vector2[]): PolygonMeshBuilder;
  66962. /**
  66963. * Creates the polygon
  66964. * @param updatable If the mesh should be updatable
  66965. * @param depth The depth of the mesh created
  66966. * @returns the created mesh
  66967. */
  66968. build(updatable?: boolean, depth?: number): Mesh;
  66969. /**
  66970. * Creates the polygon
  66971. * @param depth The depth of the mesh created
  66972. * @returns the created VertexData
  66973. */
  66974. buildVertexData(depth?: number): VertexData;
  66975. /**
  66976. * Adds a side to the polygon
  66977. * @param positions points that make the polygon
  66978. * @param normals normals of the polygon
  66979. * @param uvs uvs of the polygon
  66980. * @param indices indices of the polygon
  66981. * @param bounds bounds of the polygon
  66982. * @param points points of the polygon
  66983. * @param depth depth of the polygon
  66984. * @param flip flip of the polygon
  66985. */
  66986. private addSide;
  66987. }
  66988. }
  66989. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  66990. import { Scene } from "babylonjs/scene";
  66991. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  66992. import { Color4 } from "babylonjs/Maths/math.color";
  66993. import { Mesh } from "babylonjs/Meshes/mesh";
  66994. import { Nullable } from "babylonjs/types";
  66995. /**
  66996. * Class containing static functions to help procedurally build meshes
  66997. */
  66998. export class PolygonBuilder {
  66999. /**
  67000. * Creates a polygon mesh
  67001. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  67002. * * 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
  67003. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  67004. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67005. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  67006. * * Remember you can only change the shape positions, not their number when updating a polygon
  67007. * @param name defines the name of the mesh
  67008. * @param options defines the options used to create the mesh
  67009. * @param scene defines the hosting scene
  67010. * @param earcutInjection can be used to inject your own earcut reference
  67011. * @returns the polygon mesh
  67012. */
  67013. static CreatePolygon(name: string, options: {
  67014. shape: Vector3[];
  67015. holes?: Vector3[][];
  67016. depth?: number;
  67017. faceUV?: Vector4[];
  67018. faceColors?: Color4[];
  67019. updatable?: boolean;
  67020. sideOrientation?: number;
  67021. frontUVs?: Vector4;
  67022. backUVs?: Vector4;
  67023. wrap?: boolean;
  67024. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  67025. /**
  67026. * Creates an extruded polygon mesh, with depth in the Y direction.
  67027. * * 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)
  67028. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  67029. * @param name defines the name of the mesh
  67030. * @param options defines the options used to create the mesh
  67031. * @param scene defines the hosting scene
  67032. * @param earcutInjection can be used to inject your own earcut reference
  67033. * @returns the polygon mesh
  67034. */
  67035. static ExtrudePolygon(name: string, options: {
  67036. shape: Vector3[];
  67037. holes?: Vector3[][];
  67038. depth?: number;
  67039. faceUV?: Vector4[];
  67040. faceColors?: Color4[];
  67041. updatable?: boolean;
  67042. sideOrientation?: number;
  67043. frontUVs?: Vector4;
  67044. backUVs?: Vector4;
  67045. wrap?: boolean;
  67046. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  67047. }
  67048. }
  67049. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  67050. import { Scene } from "babylonjs/scene";
  67051. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  67052. import { Mesh } from "babylonjs/Meshes/mesh";
  67053. import { Nullable } from "babylonjs/types";
  67054. /**
  67055. * Class containing static functions to help procedurally build meshes
  67056. */
  67057. export class LatheBuilder {
  67058. /**
  67059. * Creates lathe mesh.
  67060. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  67061. * * 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
  67062. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  67063. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  67064. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  67065. * * 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
  67066. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  67067. * * 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
  67068. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67069. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67070. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  67071. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67072. * @param name defines the name of the mesh
  67073. * @param options defines the options used to create the mesh
  67074. * @param scene defines the hosting scene
  67075. * @returns the lathe mesh
  67076. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  67077. */
  67078. static CreateLathe(name: string, options: {
  67079. shape: Vector3[];
  67080. radius?: number;
  67081. tessellation?: number;
  67082. clip?: number;
  67083. arc?: number;
  67084. closed?: boolean;
  67085. updatable?: boolean;
  67086. sideOrientation?: number;
  67087. frontUVs?: Vector4;
  67088. backUVs?: Vector4;
  67089. cap?: number;
  67090. invertUV?: boolean;
  67091. }, scene?: Nullable<Scene>): Mesh;
  67092. }
  67093. }
  67094. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  67095. import { Nullable } from "babylonjs/types";
  67096. import { Scene } from "babylonjs/scene";
  67097. import { Vector4 } from "babylonjs/Maths/math.vector";
  67098. import { Mesh } from "babylonjs/Meshes/mesh";
  67099. /**
  67100. * Class containing static functions to help procedurally build meshes
  67101. */
  67102. export class TiledPlaneBuilder {
  67103. /**
  67104. * Creates a tiled plane mesh
  67105. * * The parameter `pattern` will, depending on value, do nothing or
  67106. * * * flip (reflect about central vertical) alternate tiles across and up
  67107. * * * flip every tile on alternate rows
  67108. * * * rotate (180 degs) alternate tiles across and up
  67109. * * * rotate every tile on alternate rows
  67110. * * * flip and rotate alternate tiles across and up
  67111. * * * flip and rotate every tile on alternate rows
  67112. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  67113. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  67114. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67115. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  67116. * * 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)
  67117. * * 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)
  67118. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  67119. * @param name defines the name of the mesh
  67120. * @param options defines the options used to create the mesh
  67121. * @param scene defines the hosting scene
  67122. * @returns the box mesh
  67123. */
  67124. static CreateTiledPlane(name: string, options: {
  67125. pattern?: number;
  67126. tileSize?: number;
  67127. tileWidth?: number;
  67128. tileHeight?: number;
  67129. size?: number;
  67130. width?: number;
  67131. height?: number;
  67132. alignHorizontal?: number;
  67133. alignVertical?: number;
  67134. sideOrientation?: number;
  67135. frontUVs?: Vector4;
  67136. backUVs?: Vector4;
  67137. updatable?: boolean;
  67138. }, scene?: Nullable<Scene>): Mesh;
  67139. }
  67140. }
  67141. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  67142. import { Nullable } from "babylonjs/types";
  67143. import { Scene } from "babylonjs/scene";
  67144. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  67145. import { Mesh } from "babylonjs/Meshes/mesh";
  67146. /**
  67147. * Class containing static functions to help procedurally build meshes
  67148. */
  67149. export class TubeBuilder {
  67150. /**
  67151. * Creates a tube mesh.
  67152. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  67153. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  67154. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  67155. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  67156. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  67157. * * 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)
  67158. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  67159. * * 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
  67160. * * 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
  67161. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67162. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67163. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  67164. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67165. * @param name defines the name of the mesh
  67166. * @param options defines the options used to create the mesh
  67167. * @param scene defines the hosting scene
  67168. * @returns the tube mesh
  67169. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  67170. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  67171. */
  67172. static CreateTube(name: string, options: {
  67173. path: Vector3[];
  67174. radius?: number;
  67175. tessellation?: number;
  67176. radiusFunction?: {
  67177. (i: number, distance: number): number;
  67178. };
  67179. cap?: number;
  67180. arc?: number;
  67181. updatable?: boolean;
  67182. sideOrientation?: number;
  67183. frontUVs?: Vector4;
  67184. backUVs?: Vector4;
  67185. instance?: Mesh;
  67186. invertUV?: boolean;
  67187. }, scene?: Nullable<Scene>): Mesh;
  67188. }
  67189. }
  67190. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  67191. import { Scene } from "babylonjs/scene";
  67192. import { Vector4 } from "babylonjs/Maths/math.vector";
  67193. import { Mesh } from "babylonjs/Meshes/mesh";
  67194. import { Nullable } from "babylonjs/types";
  67195. /**
  67196. * Class containing static functions to help procedurally build meshes
  67197. */
  67198. export class IcoSphereBuilder {
  67199. /**
  67200. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  67201. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  67202. * * 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`)
  67203. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  67204. * * 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
  67205. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67206. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67207. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67208. * @param name defines the name of the mesh
  67209. * @param options defines the options used to create the mesh
  67210. * @param scene defines the hosting scene
  67211. * @returns the icosahedron mesh
  67212. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  67213. */
  67214. static CreateIcoSphere(name: string, options: {
  67215. radius?: number;
  67216. radiusX?: number;
  67217. radiusY?: number;
  67218. radiusZ?: number;
  67219. flat?: boolean;
  67220. subdivisions?: number;
  67221. sideOrientation?: number;
  67222. frontUVs?: Vector4;
  67223. backUVs?: Vector4;
  67224. updatable?: boolean;
  67225. }, scene?: Nullable<Scene>): Mesh;
  67226. }
  67227. }
  67228. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  67229. import { Vector3 } from "babylonjs/Maths/math.vector";
  67230. import { Mesh } from "babylonjs/Meshes/mesh";
  67231. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67232. /**
  67233. * Class containing static functions to help procedurally build meshes
  67234. */
  67235. export class DecalBuilder {
  67236. /**
  67237. * Creates a decal mesh.
  67238. * 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
  67239. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  67240. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  67241. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  67242. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  67243. * @param name defines the name of the mesh
  67244. * @param sourceMesh defines the mesh where the decal must be applied
  67245. * @param options defines the options used to create the mesh
  67246. * @param scene defines the hosting scene
  67247. * @returns the decal mesh
  67248. * @see https://doc.babylonjs.com/how_to/decals
  67249. */
  67250. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  67251. position?: Vector3;
  67252. normal?: Vector3;
  67253. size?: Vector3;
  67254. angle?: number;
  67255. }): Mesh;
  67256. }
  67257. }
  67258. declare module "babylonjs/Meshes/meshBuilder" {
  67259. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  67260. import { Nullable } from "babylonjs/types";
  67261. import { Scene } from "babylonjs/scene";
  67262. import { Mesh } from "babylonjs/Meshes/mesh";
  67263. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  67264. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  67265. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67266. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  67267. import { Plane } from "babylonjs/Maths/math.plane";
  67268. /**
  67269. * Class containing static functions to help procedurally build meshes
  67270. */
  67271. export class MeshBuilder {
  67272. /**
  67273. * Creates a box mesh
  67274. * * The parameter `size` sets the size (float) of each box side (default 1)
  67275. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  67276. * * 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)
  67277. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  67278. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67279. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67280. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67281. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  67282. * @param name defines the name of the mesh
  67283. * @param options defines the options used to create the mesh
  67284. * @param scene defines the hosting scene
  67285. * @returns the box mesh
  67286. */
  67287. static CreateBox(name: string, options: {
  67288. size?: number;
  67289. width?: number;
  67290. height?: number;
  67291. depth?: number;
  67292. faceUV?: Vector4[];
  67293. faceColors?: Color4[];
  67294. sideOrientation?: number;
  67295. frontUVs?: Vector4;
  67296. backUVs?: Vector4;
  67297. wrap?: boolean;
  67298. topBaseAt?: number;
  67299. bottomBaseAt?: number;
  67300. updatable?: boolean;
  67301. }, scene?: Nullable<Scene>): Mesh;
  67302. /**
  67303. * Creates a tiled box mesh
  67304. * * faceTiles sets the pattern, tile size and number of tiles for a face
  67305. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67306. * @param name defines the name of the mesh
  67307. * @param options defines the options used to create the mesh
  67308. * @param scene defines the hosting scene
  67309. * @returns the tiled box mesh
  67310. */
  67311. static CreateTiledBox(name: string, options: {
  67312. pattern?: number;
  67313. size?: number;
  67314. width?: number;
  67315. height?: number;
  67316. depth: number;
  67317. tileSize?: number;
  67318. tileWidth?: number;
  67319. tileHeight?: number;
  67320. faceUV?: Vector4[];
  67321. faceColors?: Color4[];
  67322. alignHorizontal?: number;
  67323. alignVertical?: number;
  67324. sideOrientation?: number;
  67325. updatable?: boolean;
  67326. }, scene?: Nullable<Scene>): Mesh;
  67327. /**
  67328. * Creates a sphere mesh
  67329. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  67330. * * 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`)
  67331. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  67332. * * 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
  67333. * * 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)
  67334. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67335. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67336. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67337. * @param name defines the name of the mesh
  67338. * @param options defines the options used to create the mesh
  67339. * @param scene defines the hosting scene
  67340. * @returns the sphere mesh
  67341. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  67342. */
  67343. static CreateSphere(name: string, options: {
  67344. segments?: number;
  67345. diameter?: number;
  67346. diameterX?: number;
  67347. diameterY?: number;
  67348. diameterZ?: number;
  67349. arc?: number;
  67350. slice?: number;
  67351. sideOrientation?: number;
  67352. frontUVs?: Vector4;
  67353. backUVs?: Vector4;
  67354. updatable?: boolean;
  67355. }, scene?: Nullable<Scene>): Mesh;
  67356. /**
  67357. * Creates a plane polygonal mesh. By default, this is a disc
  67358. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  67359. * * 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
  67360. * * 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
  67361. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67362. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67363. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67364. * @param name defines the name of the mesh
  67365. * @param options defines the options used to create the mesh
  67366. * @param scene defines the hosting scene
  67367. * @returns the plane polygonal mesh
  67368. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  67369. */
  67370. static CreateDisc(name: string, options: {
  67371. radius?: number;
  67372. tessellation?: number;
  67373. arc?: number;
  67374. updatable?: boolean;
  67375. sideOrientation?: number;
  67376. frontUVs?: Vector4;
  67377. backUVs?: Vector4;
  67378. }, scene?: Nullable<Scene>): Mesh;
  67379. /**
  67380. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  67381. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  67382. * * 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`)
  67383. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  67384. * * 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
  67385. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67386. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67387. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67388. * @param name defines the name of the mesh
  67389. * @param options defines the options used to create the mesh
  67390. * @param scene defines the hosting scene
  67391. * @returns the icosahedron mesh
  67392. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  67393. */
  67394. static CreateIcoSphere(name: string, options: {
  67395. radius?: number;
  67396. radiusX?: number;
  67397. radiusY?: number;
  67398. radiusZ?: number;
  67399. flat?: boolean;
  67400. subdivisions?: number;
  67401. sideOrientation?: number;
  67402. frontUVs?: Vector4;
  67403. backUVs?: Vector4;
  67404. updatable?: boolean;
  67405. }, scene?: Nullable<Scene>): Mesh;
  67406. /**
  67407. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  67408. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  67409. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  67410. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  67411. * * 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
  67412. * * 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
  67413. * * 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
  67414. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67415. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67416. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  67417. * * 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
  67418. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  67419. * * 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
  67420. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  67421. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67422. * @param name defines the name of the mesh
  67423. * @param options defines the options used to create the mesh
  67424. * @param scene defines the hosting scene
  67425. * @returns the ribbon mesh
  67426. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  67427. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  67428. */
  67429. static CreateRibbon(name: string, options: {
  67430. pathArray: Vector3[][];
  67431. closeArray?: boolean;
  67432. closePath?: boolean;
  67433. offset?: number;
  67434. updatable?: boolean;
  67435. sideOrientation?: number;
  67436. frontUVs?: Vector4;
  67437. backUVs?: Vector4;
  67438. instance?: Mesh;
  67439. invertUV?: boolean;
  67440. uvs?: Vector2[];
  67441. colors?: Color4[];
  67442. }, scene?: Nullable<Scene>): Mesh;
  67443. /**
  67444. * Creates a cylinder or a cone mesh
  67445. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  67446. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  67447. * * 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.
  67448. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  67449. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  67450. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  67451. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  67452. * * 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).
  67453. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  67454. * * 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).
  67455. * * 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
  67456. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  67457. * * 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
  67458. * * 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.
  67459. * * If `enclose` is false, a ring surface is one element.
  67460. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  67461. * * 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
  67462. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67463. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67464. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67465. * @param name defines the name of the mesh
  67466. * @param options defines the options used to create the mesh
  67467. * @param scene defines the hosting scene
  67468. * @returns the cylinder mesh
  67469. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  67470. */
  67471. static CreateCylinder(name: string, options: {
  67472. height?: number;
  67473. diameterTop?: number;
  67474. diameterBottom?: number;
  67475. diameter?: number;
  67476. tessellation?: number;
  67477. subdivisions?: number;
  67478. arc?: number;
  67479. faceColors?: Color4[];
  67480. faceUV?: Vector4[];
  67481. updatable?: boolean;
  67482. hasRings?: boolean;
  67483. enclose?: boolean;
  67484. cap?: number;
  67485. sideOrientation?: number;
  67486. frontUVs?: Vector4;
  67487. backUVs?: Vector4;
  67488. }, scene?: Nullable<Scene>): Mesh;
  67489. /**
  67490. * Creates a torus mesh
  67491. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  67492. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  67493. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  67494. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67495. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67496. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67497. * @param name defines the name of the mesh
  67498. * @param options defines the options used to create the mesh
  67499. * @param scene defines the hosting scene
  67500. * @returns the torus mesh
  67501. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  67502. */
  67503. static CreateTorus(name: string, options: {
  67504. diameter?: number;
  67505. thickness?: number;
  67506. tessellation?: number;
  67507. updatable?: boolean;
  67508. sideOrientation?: number;
  67509. frontUVs?: Vector4;
  67510. backUVs?: Vector4;
  67511. }, scene?: Nullable<Scene>): Mesh;
  67512. /**
  67513. * Creates a torus knot mesh
  67514. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  67515. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  67516. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  67517. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  67518. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67519. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67520. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67521. * @param name defines the name of the mesh
  67522. * @param options defines the options used to create the mesh
  67523. * @param scene defines the hosting scene
  67524. * @returns the torus knot mesh
  67525. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  67526. */
  67527. static CreateTorusKnot(name: string, options: {
  67528. radius?: number;
  67529. tube?: number;
  67530. radialSegments?: number;
  67531. tubularSegments?: number;
  67532. p?: number;
  67533. q?: number;
  67534. updatable?: boolean;
  67535. sideOrientation?: number;
  67536. frontUVs?: Vector4;
  67537. backUVs?: Vector4;
  67538. }, scene?: Nullable<Scene>): Mesh;
  67539. /**
  67540. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  67541. * * 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
  67542. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  67543. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  67544. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  67545. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  67546. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  67547. * * 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
  67548. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  67549. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67550. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  67551. * @param name defines the name of the new line system
  67552. * @param options defines the options used to create the line system
  67553. * @param scene defines the hosting scene
  67554. * @returns a new line system mesh
  67555. */
  67556. static CreateLineSystem(name: string, options: {
  67557. lines: Vector3[][];
  67558. updatable?: boolean;
  67559. instance?: Nullable<LinesMesh>;
  67560. colors?: Nullable<Color4[][]>;
  67561. useVertexAlpha?: boolean;
  67562. }, scene: Nullable<Scene>): LinesMesh;
  67563. /**
  67564. * Creates a line mesh
  67565. * 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
  67566. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  67567. * * The parameter `points` is an array successive Vector3
  67568. * * 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
  67569. * * The optional parameter `colors` is an array of successive Color4, one per line point
  67570. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  67571. * * When updating an instance, remember that only point positions can change, not the number of points
  67572. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67573. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  67574. * @param name defines the name of the new line system
  67575. * @param options defines the options used to create the line system
  67576. * @param scene defines the hosting scene
  67577. * @returns a new line mesh
  67578. */
  67579. static CreateLines(name: string, options: {
  67580. points: Vector3[];
  67581. updatable?: boolean;
  67582. instance?: Nullable<LinesMesh>;
  67583. colors?: Color4[];
  67584. useVertexAlpha?: boolean;
  67585. }, scene?: Nullable<Scene>): LinesMesh;
  67586. /**
  67587. * Creates a dashed line mesh
  67588. * * 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
  67589. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  67590. * * The parameter `points` is an array successive Vector3
  67591. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  67592. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  67593. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  67594. * * 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
  67595. * * When updating an instance, remember that only point positions can change, not the number of points
  67596. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67597. * @param name defines the name of the mesh
  67598. * @param options defines the options used to create the mesh
  67599. * @param scene defines the hosting scene
  67600. * @returns the dashed line mesh
  67601. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  67602. */
  67603. static CreateDashedLines(name: string, options: {
  67604. points: Vector3[];
  67605. dashSize?: number;
  67606. gapSize?: number;
  67607. dashNb?: number;
  67608. updatable?: boolean;
  67609. instance?: LinesMesh;
  67610. }, scene?: Nullable<Scene>): LinesMesh;
  67611. /**
  67612. * 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.
  67613. * * 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.
  67614. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  67615. * * 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.
  67616. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  67617. * * 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
  67618. * * 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
  67619. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  67620. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67621. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67622. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  67623. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67624. * @param name defines the name of the mesh
  67625. * @param options defines the options used to create the mesh
  67626. * @param scene defines the hosting scene
  67627. * @returns the extruded shape mesh
  67628. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  67629. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  67630. */
  67631. static ExtrudeShape(name: string, options: {
  67632. shape: Vector3[];
  67633. path: Vector3[];
  67634. scale?: number;
  67635. rotation?: number;
  67636. cap?: number;
  67637. updatable?: boolean;
  67638. sideOrientation?: number;
  67639. frontUVs?: Vector4;
  67640. backUVs?: Vector4;
  67641. instance?: Mesh;
  67642. invertUV?: boolean;
  67643. }, scene?: Nullable<Scene>): Mesh;
  67644. /**
  67645. * Creates an custom extruded shape mesh.
  67646. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  67647. * * 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.
  67648. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  67649. * * 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
  67650. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  67651. * * 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
  67652. * * It must returns a float value that will be the scale value applied to the shape on each path point
  67653. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  67654. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  67655. * * 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
  67656. * * 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
  67657. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  67658. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67659. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67660. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  67661. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67662. * @param name defines the name of the mesh
  67663. * @param options defines the options used to create the mesh
  67664. * @param scene defines the hosting scene
  67665. * @returns the custom extruded shape mesh
  67666. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  67667. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  67668. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  67669. */
  67670. static ExtrudeShapeCustom(name: string, options: {
  67671. shape: Vector3[];
  67672. path: Vector3[];
  67673. scaleFunction?: any;
  67674. rotationFunction?: any;
  67675. ribbonCloseArray?: boolean;
  67676. ribbonClosePath?: boolean;
  67677. cap?: number;
  67678. updatable?: boolean;
  67679. sideOrientation?: number;
  67680. frontUVs?: Vector4;
  67681. backUVs?: Vector4;
  67682. instance?: Mesh;
  67683. invertUV?: boolean;
  67684. }, scene?: Nullable<Scene>): Mesh;
  67685. /**
  67686. * Creates lathe mesh.
  67687. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  67688. * * 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
  67689. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  67690. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  67691. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  67692. * * 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
  67693. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  67694. * * 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
  67695. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67696. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67697. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  67698. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67699. * @param name defines the name of the mesh
  67700. * @param options defines the options used to create the mesh
  67701. * @param scene defines the hosting scene
  67702. * @returns the lathe mesh
  67703. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  67704. */
  67705. static CreateLathe(name: string, options: {
  67706. shape: Vector3[];
  67707. radius?: number;
  67708. tessellation?: number;
  67709. clip?: number;
  67710. arc?: number;
  67711. closed?: boolean;
  67712. updatable?: boolean;
  67713. sideOrientation?: number;
  67714. frontUVs?: Vector4;
  67715. backUVs?: Vector4;
  67716. cap?: number;
  67717. invertUV?: boolean;
  67718. }, scene?: Nullable<Scene>): Mesh;
  67719. /**
  67720. * Creates a tiled plane mesh
  67721. * * You can set a limited pattern arrangement with the tiles
  67722. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67723. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67724. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67725. * @param name defines the name of the mesh
  67726. * @param options defines the options used to create the mesh
  67727. * @param scene defines the hosting scene
  67728. * @returns the plane mesh
  67729. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  67730. */
  67731. static CreateTiledPlane(name: string, options: {
  67732. pattern?: number;
  67733. tileSize?: number;
  67734. tileWidth?: number;
  67735. tileHeight?: number;
  67736. size?: number;
  67737. width?: number;
  67738. height?: number;
  67739. alignHorizontal?: number;
  67740. alignVertical?: number;
  67741. sideOrientation?: number;
  67742. frontUVs?: Vector4;
  67743. backUVs?: Vector4;
  67744. updatable?: boolean;
  67745. }, scene?: Nullable<Scene>): Mesh;
  67746. /**
  67747. * Creates a plane mesh
  67748. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  67749. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  67750. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  67751. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67752. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67753. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67754. * @param name defines the name of the mesh
  67755. * @param options defines the options used to create the mesh
  67756. * @param scene defines the hosting scene
  67757. * @returns the plane mesh
  67758. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  67759. */
  67760. static CreatePlane(name: string, options: {
  67761. size?: number;
  67762. width?: number;
  67763. height?: number;
  67764. sideOrientation?: number;
  67765. frontUVs?: Vector4;
  67766. backUVs?: Vector4;
  67767. updatable?: boolean;
  67768. sourcePlane?: Plane;
  67769. }, scene?: Nullable<Scene>): Mesh;
  67770. /**
  67771. * Creates a ground mesh
  67772. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  67773. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  67774. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67775. * @param name defines the name of the mesh
  67776. * @param options defines the options used to create the mesh
  67777. * @param scene defines the hosting scene
  67778. * @returns the ground mesh
  67779. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  67780. */
  67781. static CreateGround(name: string, options: {
  67782. width?: number;
  67783. height?: number;
  67784. subdivisions?: number;
  67785. subdivisionsX?: number;
  67786. subdivisionsY?: number;
  67787. updatable?: boolean;
  67788. }, scene?: Nullable<Scene>): Mesh;
  67789. /**
  67790. * Creates a tiled ground mesh
  67791. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  67792. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  67793. * * 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
  67794. * * 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
  67795. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67796. * @param name defines the name of the mesh
  67797. * @param options defines the options used to create the mesh
  67798. * @param scene defines the hosting scene
  67799. * @returns the tiled ground mesh
  67800. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  67801. */
  67802. static CreateTiledGround(name: string, options: {
  67803. xmin: number;
  67804. zmin: number;
  67805. xmax: number;
  67806. zmax: number;
  67807. subdivisions?: {
  67808. w: number;
  67809. h: number;
  67810. };
  67811. precision?: {
  67812. w: number;
  67813. h: number;
  67814. };
  67815. updatable?: boolean;
  67816. }, scene?: Nullable<Scene>): Mesh;
  67817. /**
  67818. * Creates a ground mesh from a height map
  67819. * * The parameter `url` sets the URL of the height map image resource.
  67820. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  67821. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  67822. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  67823. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  67824. * * 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.
  67825. * * 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).
  67826. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  67827. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67828. * @param name defines the name of the mesh
  67829. * @param url defines the url to the height map
  67830. * @param options defines the options used to create the mesh
  67831. * @param scene defines the hosting scene
  67832. * @returns the ground mesh
  67833. * @see https://doc.babylonjs.com/babylon101/height_map
  67834. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  67835. */
  67836. static CreateGroundFromHeightMap(name: string, url: string, options: {
  67837. width?: number;
  67838. height?: number;
  67839. subdivisions?: number;
  67840. minHeight?: number;
  67841. maxHeight?: number;
  67842. colorFilter?: Color3;
  67843. alphaFilter?: number;
  67844. updatable?: boolean;
  67845. onReady?: (mesh: GroundMesh) => void;
  67846. }, scene?: Nullable<Scene>): GroundMesh;
  67847. /**
  67848. * Creates a polygon mesh
  67849. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  67850. * * 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
  67851. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  67852. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67853. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  67854. * * Remember you can only change the shape positions, not their number when updating a polygon
  67855. * @param name defines the name of the mesh
  67856. * @param options defines the options used to create the mesh
  67857. * @param scene defines the hosting scene
  67858. * @param earcutInjection can be used to inject your own earcut reference
  67859. * @returns the polygon mesh
  67860. */
  67861. static CreatePolygon(name: string, options: {
  67862. shape: Vector3[];
  67863. holes?: Vector3[][];
  67864. depth?: number;
  67865. faceUV?: Vector4[];
  67866. faceColors?: Color4[];
  67867. updatable?: boolean;
  67868. sideOrientation?: number;
  67869. frontUVs?: Vector4;
  67870. backUVs?: Vector4;
  67871. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  67872. /**
  67873. * Creates an extruded polygon mesh, with depth in the Y direction.
  67874. * * 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)
  67875. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  67876. * @param name defines the name of the mesh
  67877. * @param options defines the options used to create the mesh
  67878. * @param scene defines the hosting scene
  67879. * @param earcutInjection can be used to inject your own earcut reference
  67880. * @returns the polygon mesh
  67881. */
  67882. static ExtrudePolygon(name: string, options: {
  67883. shape: Vector3[];
  67884. holes?: Vector3[][];
  67885. depth?: number;
  67886. faceUV?: Vector4[];
  67887. faceColors?: Color4[];
  67888. updatable?: boolean;
  67889. sideOrientation?: number;
  67890. frontUVs?: Vector4;
  67891. backUVs?: Vector4;
  67892. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  67893. /**
  67894. * Creates a tube mesh.
  67895. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  67896. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  67897. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  67898. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  67899. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  67900. * * 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)
  67901. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  67902. * * 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
  67903. * * 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
  67904. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67905. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67906. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  67907. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67908. * @param name defines the name of the mesh
  67909. * @param options defines the options used to create the mesh
  67910. * @param scene defines the hosting scene
  67911. * @returns the tube mesh
  67912. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  67913. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  67914. */
  67915. static CreateTube(name: string, options: {
  67916. path: Vector3[];
  67917. radius?: number;
  67918. tessellation?: number;
  67919. radiusFunction?: {
  67920. (i: number, distance: number): number;
  67921. };
  67922. cap?: number;
  67923. arc?: number;
  67924. updatable?: boolean;
  67925. sideOrientation?: number;
  67926. frontUVs?: Vector4;
  67927. backUVs?: Vector4;
  67928. instance?: Mesh;
  67929. invertUV?: boolean;
  67930. }, scene?: Nullable<Scene>): Mesh;
  67931. /**
  67932. * Creates a polyhedron mesh
  67933. * * 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
  67934. * * The parameter `size` (positive float, default 1) sets the polygon size
  67935. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  67936. * * 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`
  67937. * * 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
  67938. * * 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)`)
  67939. * * 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
  67940. * * 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
  67941. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67942. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67943. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67944. * @param name defines the name of the mesh
  67945. * @param options defines the options used to create the mesh
  67946. * @param scene defines the hosting scene
  67947. * @returns the polyhedron mesh
  67948. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  67949. */
  67950. static CreatePolyhedron(name: string, options: {
  67951. type?: number;
  67952. size?: number;
  67953. sizeX?: number;
  67954. sizeY?: number;
  67955. sizeZ?: number;
  67956. custom?: any;
  67957. faceUV?: Vector4[];
  67958. faceColors?: Color4[];
  67959. flat?: boolean;
  67960. updatable?: boolean;
  67961. sideOrientation?: number;
  67962. frontUVs?: Vector4;
  67963. backUVs?: Vector4;
  67964. }, scene?: Nullable<Scene>): Mesh;
  67965. /**
  67966. * Creates a decal mesh.
  67967. * 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
  67968. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  67969. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  67970. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  67971. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  67972. * @param name defines the name of the mesh
  67973. * @param sourceMesh defines the mesh where the decal must be applied
  67974. * @param options defines the options used to create the mesh
  67975. * @param scene defines the hosting scene
  67976. * @returns the decal mesh
  67977. * @see https://doc.babylonjs.com/how_to/decals
  67978. */
  67979. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  67980. position?: Vector3;
  67981. normal?: Vector3;
  67982. size?: Vector3;
  67983. angle?: number;
  67984. }): Mesh;
  67985. }
  67986. }
  67987. declare module "babylonjs/Meshes/meshSimplification" {
  67988. import { Mesh } from "babylonjs/Meshes/mesh";
  67989. /**
  67990. * A simplifier interface for future simplification implementations
  67991. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67992. */
  67993. export interface ISimplifier {
  67994. /**
  67995. * Simplification of a given mesh according to the given settings.
  67996. * Since this requires computation, it is assumed that the function runs async.
  67997. * @param settings The settings of the simplification, including quality and distance
  67998. * @param successCallback A callback that will be called after the mesh was simplified.
  67999. * @param errorCallback in case of an error, this callback will be called. optional.
  68000. */
  68001. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  68002. }
  68003. /**
  68004. * Expected simplification settings.
  68005. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  68006. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  68007. */
  68008. export interface ISimplificationSettings {
  68009. /**
  68010. * Gets or sets the expected quality
  68011. */
  68012. quality: number;
  68013. /**
  68014. * Gets or sets the distance when this optimized version should be used
  68015. */
  68016. distance: number;
  68017. /**
  68018. * Gets an already optimized mesh
  68019. */
  68020. optimizeMesh?: boolean;
  68021. }
  68022. /**
  68023. * Class used to specify simplification options
  68024. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  68025. */
  68026. export class SimplificationSettings implements ISimplificationSettings {
  68027. /** expected quality */
  68028. quality: number;
  68029. /** distance when this optimized version should be used */
  68030. distance: number;
  68031. /** already optimized mesh */
  68032. optimizeMesh?: boolean | undefined;
  68033. /**
  68034. * Creates a SimplificationSettings
  68035. * @param quality expected quality
  68036. * @param distance distance when this optimized version should be used
  68037. * @param optimizeMesh already optimized mesh
  68038. */
  68039. constructor(
  68040. /** expected quality */
  68041. quality: number,
  68042. /** distance when this optimized version should be used */
  68043. distance: number,
  68044. /** already optimized mesh */
  68045. optimizeMesh?: boolean | undefined);
  68046. }
  68047. /**
  68048. * Interface used to define a simplification task
  68049. */
  68050. export interface ISimplificationTask {
  68051. /**
  68052. * Array of settings
  68053. */
  68054. settings: Array<ISimplificationSettings>;
  68055. /**
  68056. * Simplification type
  68057. */
  68058. simplificationType: SimplificationType;
  68059. /**
  68060. * Mesh to simplify
  68061. */
  68062. mesh: Mesh;
  68063. /**
  68064. * Callback called on success
  68065. */
  68066. successCallback?: () => void;
  68067. /**
  68068. * Defines if parallel processing can be used
  68069. */
  68070. parallelProcessing: boolean;
  68071. }
  68072. /**
  68073. * Queue used to order the simplification tasks
  68074. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  68075. */
  68076. export class SimplificationQueue {
  68077. private _simplificationArray;
  68078. /**
  68079. * Gets a boolean indicating that the process is still running
  68080. */
  68081. running: boolean;
  68082. /**
  68083. * Creates a new queue
  68084. */
  68085. constructor();
  68086. /**
  68087. * Adds a new simplification task
  68088. * @param task defines a task to add
  68089. */
  68090. addTask(task: ISimplificationTask): void;
  68091. /**
  68092. * Execute next task
  68093. */
  68094. executeNext(): void;
  68095. /**
  68096. * Execute a simplification task
  68097. * @param task defines the task to run
  68098. */
  68099. runSimplification(task: ISimplificationTask): void;
  68100. private getSimplifier;
  68101. }
  68102. /**
  68103. * The implemented types of simplification
  68104. * At the moment only Quadratic Error Decimation is implemented
  68105. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  68106. */
  68107. export enum SimplificationType {
  68108. /** Quadratic error decimation */
  68109. QUADRATIC = 0
  68110. }
  68111. /**
  68112. * An implementation of the Quadratic Error simplification algorithm.
  68113. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  68114. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  68115. * @author RaananW
  68116. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  68117. */
  68118. export class QuadraticErrorSimplification implements ISimplifier {
  68119. private _mesh;
  68120. private triangles;
  68121. private vertices;
  68122. private references;
  68123. private _reconstructedMesh;
  68124. /** Gets or sets the number pf sync interations */
  68125. syncIterations: number;
  68126. /** Gets or sets the aggressiveness of the simplifier */
  68127. aggressiveness: number;
  68128. /** Gets or sets the number of allowed iterations for decimation */
  68129. decimationIterations: number;
  68130. /** Gets or sets the espilon to use for bounding box computation */
  68131. boundingBoxEpsilon: number;
  68132. /**
  68133. * Creates a new QuadraticErrorSimplification
  68134. * @param _mesh defines the target mesh
  68135. */
  68136. constructor(_mesh: Mesh);
  68137. /**
  68138. * Simplification of a given mesh according to the given settings.
  68139. * Since this requires computation, it is assumed that the function runs async.
  68140. * @param settings The settings of the simplification, including quality and distance
  68141. * @param successCallback A callback that will be called after the mesh was simplified.
  68142. */
  68143. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  68144. private runDecimation;
  68145. private initWithMesh;
  68146. private init;
  68147. private reconstructMesh;
  68148. private initDecimatedMesh;
  68149. private isFlipped;
  68150. private updateTriangles;
  68151. private identifyBorder;
  68152. private updateMesh;
  68153. private vertexError;
  68154. private calculateError;
  68155. }
  68156. }
  68157. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  68158. import { Scene } from "babylonjs/scene";
  68159. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  68160. import { ISceneComponent } from "babylonjs/sceneComponent";
  68161. module "babylonjs/scene" {
  68162. interface Scene {
  68163. /** @hidden (Backing field) */
  68164. _simplificationQueue: SimplificationQueue;
  68165. /**
  68166. * Gets or sets the simplification queue attached to the scene
  68167. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  68168. */
  68169. simplificationQueue: SimplificationQueue;
  68170. }
  68171. }
  68172. module "babylonjs/Meshes/mesh" {
  68173. interface Mesh {
  68174. /**
  68175. * Simplify the mesh according to the given array of settings.
  68176. * Function will return immediately and will simplify async
  68177. * @param settings a collection of simplification settings
  68178. * @param parallelProcessing should all levels calculate parallel or one after the other
  68179. * @param simplificationType the type of simplification to run
  68180. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  68181. * @returns the current mesh
  68182. */
  68183. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  68184. }
  68185. }
  68186. /**
  68187. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  68188. * created in a scene
  68189. */
  68190. export class SimplicationQueueSceneComponent implements ISceneComponent {
  68191. /**
  68192. * The component name helpfull to identify the component in the list of scene components.
  68193. */
  68194. readonly name: string;
  68195. /**
  68196. * The scene the component belongs to.
  68197. */
  68198. scene: Scene;
  68199. /**
  68200. * Creates a new instance of the component for the given scene
  68201. * @param scene Defines the scene to register the component in
  68202. */
  68203. constructor(scene: Scene);
  68204. /**
  68205. * Registers the component in a given scene
  68206. */
  68207. register(): void;
  68208. /**
  68209. * Rebuilds the elements related to this component in case of
  68210. * context lost for instance.
  68211. */
  68212. rebuild(): void;
  68213. /**
  68214. * Disposes the component and the associated ressources
  68215. */
  68216. dispose(): void;
  68217. private _beforeCameraUpdate;
  68218. }
  68219. }
  68220. declare module "babylonjs/Meshes/Builders/index" {
  68221. export * from "babylonjs/Meshes/Builders/boxBuilder";
  68222. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  68223. export * from "babylonjs/Meshes/Builders/discBuilder";
  68224. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  68225. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  68226. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  68227. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  68228. export * from "babylonjs/Meshes/Builders/torusBuilder";
  68229. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  68230. export * from "babylonjs/Meshes/Builders/linesBuilder";
  68231. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  68232. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  68233. export * from "babylonjs/Meshes/Builders/latheBuilder";
  68234. export * from "babylonjs/Meshes/Builders/planeBuilder";
  68235. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  68236. export * from "babylonjs/Meshes/Builders/groundBuilder";
  68237. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  68238. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  68239. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  68240. export * from "babylonjs/Meshes/Builders/decalBuilder";
  68241. }
  68242. declare module "babylonjs/Meshes/index" {
  68243. export * from "babylonjs/Meshes/abstractMesh";
  68244. export * from "babylonjs/Meshes/buffer";
  68245. export * from "babylonjs/Meshes/Compression/index";
  68246. export * from "babylonjs/Meshes/csg";
  68247. export * from "babylonjs/Meshes/geometry";
  68248. export * from "babylonjs/Meshes/groundMesh";
  68249. export * from "babylonjs/Meshes/trailMesh";
  68250. export * from "babylonjs/Meshes/instancedMesh";
  68251. export * from "babylonjs/Meshes/linesMesh";
  68252. export * from "babylonjs/Meshes/mesh";
  68253. export * from "babylonjs/Meshes/mesh.vertexData";
  68254. export * from "babylonjs/Meshes/meshBuilder";
  68255. export * from "babylonjs/Meshes/meshSimplification";
  68256. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  68257. export * from "babylonjs/Meshes/polygonMesh";
  68258. export * from "babylonjs/Meshes/subMesh";
  68259. export * from "babylonjs/Meshes/meshLODLevel";
  68260. export * from "babylonjs/Meshes/transformNode";
  68261. export * from "babylonjs/Meshes/Builders/index";
  68262. export * from "babylonjs/Meshes/dataBuffer";
  68263. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  68264. }
  68265. declare module "babylonjs/Morph/index" {
  68266. export * from "babylonjs/Morph/morphTarget";
  68267. export * from "babylonjs/Morph/morphTargetManager";
  68268. }
  68269. declare module "babylonjs/Navigation/INavigationEngine" {
  68270. import { TransformNode } from "babylonjs/Meshes/transformNode";
  68271. import { Vector3 } from "babylonjs/Maths/math";
  68272. import { Mesh } from "babylonjs/Meshes/mesh";
  68273. import { Scene } from "babylonjs/scene";
  68274. /**
  68275. * Navigation plugin interface to add navigation constrained by a navigation mesh
  68276. */
  68277. export interface INavigationEnginePlugin {
  68278. /**
  68279. * plugin name
  68280. */
  68281. name: string;
  68282. /**
  68283. * Creates a navigation mesh
  68284. * @param meshes array of all the geometry used to compute the navigatio mesh
  68285. * @param parameters bunch of parameters used to filter geometry
  68286. */
  68287. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  68288. /**
  68289. * Create a navigation mesh debug mesh
  68290. * @param scene is where the mesh will be added
  68291. * @returns debug display mesh
  68292. */
  68293. createDebugNavMesh(scene: Scene): Mesh;
  68294. /**
  68295. * Get a navigation mesh constrained position, closest to the parameter position
  68296. * @param position world position
  68297. * @returns the closest point to position constrained by the navigation mesh
  68298. */
  68299. getClosestPoint(position: Vector3): Vector3;
  68300. /**
  68301. * Get a navigation mesh constrained position, closest to the parameter position
  68302. * @param position world position
  68303. * @param result output the closest point to position constrained by the navigation mesh
  68304. */
  68305. getClosestPointToRef(position: Vector3, result: Vector3): void;
  68306. /**
  68307. * Get a navigation mesh constrained position, within a particular radius
  68308. * @param position world position
  68309. * @param maxRadius the maximum distance to the constrained world position
  68310. * @returns the closest point to position constrained by the navigation mesh
  68311. */
  68312. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  68313. /**
  68314. * Get a navigation mesh constrained position, within a particular radius
  68315. * @param position world position
  68316. * @param maxRadius the maximum distance to the constrained world position
  68317. * @param result output the closest point to position constrained by the navigation mesh
  68318. */
  68319. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  68320. /**
  68321. * Compute the final position from a segment made of destination-position
  68322. * @param position world position
  68323. * @param destination world position
  68324. * @returns the resulting point along the navmesh
  68325. */
  68326. moveAlong(position: Vector3, destination: Vector3): Vector3;
  68327. /**
  68328. * Compute the final position from a segment made of destination-position
  68329. * @param position world position
  68330. * @param destination world position
  68331. * @param result output the resulting point along the navmesh
  68332. */
  68333. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  68334. /**
  68335. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  68336. * @param start world position
  68337. * @param end world position
  68338. * @returns array containing world position composing the path
  68339. */
  68340. computePath(start: Vector3, end: Vector3): Vector3[];
  68341. /**
  68342. * If this plugin is supported
  68343. * @returns true if plugin is supported
  68344. */
  68345. isSupported(): boolean;
  68346. /**
  68347. * Create a new Crowd so you can add agents
  68348. * @param maxAgents the maximum agent count in the crowd
  68349. * @param maxAgentRadius the maximum radius an agent can have
  68350. * @param scene to attach the crowd to
  68351. * @returns the crowd you can add agents to
  68352. */
  68353. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  68354. /**
  68355. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  68356. * The queries will try to find a solution within those bounds
  68357. * default is (1,1,1)
  68358. * @param extent x,y,z value that define the extent around the queries point of reference
  68359. */
  68360. setDefaultQueryExtent(extent: Vector3): void;
  68361. /**
  68362. * Get the Bounding box extent specified by setDefaultQueryExtent
  68363. * @returns the box extent values
  68364. */
  68365. getDefaultQueryExtent(): Vector3;
  68366. /**
  68367. * build the navmesh from a previously saved state using getNavmeshData
  68368. * @param data the Uint8Array returned by getNavmeshData
  68369. */
  68370. buildFromNavmeshData(data: Uint8Array): void;
  68371. /**
  68372. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  68373. * @returns data the Uint8Array that can be saved and reused
  68374. */
  68375. getNavmeshData(): Uint8Array;
  68376. /**
  68377. * Get the Bounding box extent result specified by setDefaultQueryExtent
  68378. * @param result output the box extent values
  68379. */
  68380. getDefaultQueryExtentToRef(result: Vector3): void;
  68381. /**
  68382. * Release all resources
  68383. */
  68384. dispose(): void;
  68385. }
  68386. /**
  68387. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  68388. */
  68389. export interface ICrowd {
  68390. /**
  68391. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  68392. * You can attach anything to that node. The node position is updated in the scene update tick.
  68393. * @param pos world position that will be constrained by the navigation mesh
  68394. * @param parameters agent parameters
  68395. * @param transform hooked to the agent that will be update by the scene
  68396. * @returns agent index
  68397. */
  68398. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  68399. /**
  68400. * Returns the agent position in world space
  68401. * @param index agent index returned by addAgent
  68402. * @returns world space position
  68403. */
  68404. getAgentPosition(index: number): Vector3;
  68405. /**
  68406. * Gets the agent position result in world space
  68407. * @param index agent index returned by addAgent
  68408. * @param result output world space position
  68409. */
  68410. getAgentPositionToRef(index: number, result: Vector3): void;
  68411. /**
  68412. * Gets the agent velocity in world space
  68413. * @param index agent index returned by addAgent
  68414. * @returns world space velocity
  68415. */
  68416. getAgentVelocity(index: number): Vector3;
  68417. /**
  68418. * Gets the agent velocity result in world space
  68419. * @param index agent index returned by addAgent
  68420. * @param result output world space velocity
  68421. */
  68422. getAgentVelocityToRef(index: number, result: Vector3): void;
  68423. /**
  68424. * remove a particular agent previously created
  68425. * @param index agent index returned by addAgent
  68426. */
  68427. removeAgent(index: number): void;
  68428. /**
  68429. * get the list of all agents attached to this crowd
  68430. * @returns list of agent indices
  68431. */
  68432. getAgents(): number[];
  68433. /**
  68434. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  68435. * @param deltaTime in seconds
  68436. */
  68437. update(deltaTime: number): void;
  68438. /**
  68439. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  68440. * @param index agent index returned by addAgent
  68441. * @param destination targeted world position
  68442. */
  68443. agentGoto(index: number, destination: Vector3): void;
  68444. /**
  68445. * Teleport the agent to a new position
  68446. * @param index agent index returned by addAgent
  68447. * @param destination targeted world position
  68448. */
  68449. agentTeleport(index: number, destination: Vector3): void;
  68450. /**
  68451. * Update agent parameters
  68452. * @param index agent index returned by addAgent
  68453. * @param parameters agent parameters
  68454. */
  68455. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  68456. /**
  68457. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  68458. * The queries will try to find a solution within those bounds
  68459. * default is (1,1,1)
  68460. * @param extent x,y,z value that define the extent around the queries point of reference
  68461. */
  68462. setDefaultQueryExtent(extent: Vector3): void;
  68463. /**
  68464. * Get the Bounding box extent specified by setDefaultQueryExtent
  68465. * @returns the box extent values
  68466. */
  68467. getDefaultQueryExtent(): Vector3;
  68468. /**
  68469. * Get the Bounding box extent result specified by setDefaultQueryExtent
  68470. * @param result output the box extent values
  68471. */
  68472. getDefaultQueryExtentToRef(result: Vector3): void;
  68473. /**
  68474. * Release all resources
  68475. */
  68476. dispose(): void;
  68477. }
  68478. /**
  68479. * Configures an agent
  68480. */
  68481. export interface IAgentParameters {
  68482. /**
  68483. * Agent radius. [Limit: >= 0]
  68484. */
  68485. radius: number;
  68486. /**
  68487. * Agent height. [Limit: > 0]
  68488. */
  68489. height: number;
  68490. /**
  68491. * Maximum allowed acceleration. [Limit: >= 0]
  68492. */
  68493. maxAcceleration: number;
  68494. /**
  68495. * Maximum allowed speed. [Limit: >= 0]
  68496. */
  68497. maxSpeed: number;
  68498. /**
  68499. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  68500. */
  68501. collisionQueryRange: number;
  68502. /**
  68503. * The path visibility optimization range. [Limit: > 0]
  68504. */
  68505. pathOptimizationRange: number;
  68506. /**
  68507. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  68508. */
  68509. separationWeight: number;
  68510. }
  68511. /**
  68512. * Configures the navigation mesh creation
  68513. */
  68514. export interface INavMeshParameters {
  68515. /**
  68516. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  68517. */
  68518. cs: number;
  68519. /**
  68520. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  68521. */
  68522. ch: number;
  68523. /**
  68524. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  68525. */
  68526. walkableSlopeAngle: number;
  68527. /**
  68528. * Minimum floor to 'ceiling' height that will still allow the floor area to
  68529. * be considered walkable. [Limit: >= 3] [Units: vx]
  68530. */
  68531. walkableHeight: number;
  68532. /**
  68533. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  68534. */
  68535. walkableClimb: number;
  68536. /**
  68537. * The distance to erode/shrink the walkable area of the heightfield away from
  68538. * obstructions. [Limit: >=0] [Units: vx]
  68539. */
  68540. walkableRadius: number;
  68541. /**
  68542. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  68543. */
  68544. maxEdgeLen: number;
  68545. /**
  68546. * The maximum distance a simplfied contour's border edges should deviate
  68547. * the original raw contour. [Limit: >=0] [Units: vx]
  68548. */
  68549. maxSimplificationError: number;
  68550. /**
  68551. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  68552. */
  68553. minRegionArea: number;
  68554. /**
  68555. * Any regions with a span count smaller than this value will, if possible,
  68556. * be merged with larger regions. [Limit: >=0] [Units: vx]
  68557. */
  68558. mergeRegionArea: number;
  68559. /**
  68560. * The maximum number of vertices allowed for polygons generated during the
  68561. * contour to polygon conversion process. [Limit: >= 3]
  68562. */
  68563. maxVertsPerPoly: number;
  68564. /**
  68565. * Sets the sampling distance to use when generating the detail mesh.
  68566. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  68567. */
  68568. detailSampleDist: number;
  68569. /**
  68570. * The maximum distance the detail mesh surface should deviate from heightfield
  68571. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  68572. */
  68573. detailSampleMaxError: number;
  68574. }
  68575. }
  68576. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  68577. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  68578. import { Mesh } from "babylonjs/Meshes/mesh";
  68579. import { Scene } from "babylonjs/scene";
  68580. import { Vector3 } from "babylonjs/Maths/math";
  68581. import { TransformNode } from "babylonjs/Meshes/transformNode";
  68582. /**
  68583. * RecastJS navigation plugin
  68584. */
  68585. export class RecastJSPlugin implements INavigationEnginePlugin {
  68586. /**
  68587. * Reference to the Recast library
  68588. */
  68589. bjsRECAST: any;
  68590. /**
  68591. * plugin name
  68592. */
  68593. name: string;
  68594. /**
  68595. * the first navmesh created. We might extend this to support multiple navmeshes
  68596. */
  68597. navMesh: any;
  68598. /**
  68599. * Initializes the recastJS plugin
  68600. * @param recastInjection can be used to inject your own recast reference
  68601. */
  68602. constructor(recastInjection?: any);
  68603. /**
  68604. * Creates a navigation mesh
  68605. * @param meshes array of all the geometry used to compute the navigatio mesh
  68606. * @param parameters bunch of parameters used to filter geometry
  68607. */
  68608. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  68609. /**
  68610. * Create a navigation mesh debug mesh
  68611. * @param scene is where the mesh will be added
  68612. * @returns debug display mesh
  68613. */
  68614. createDebugNavMesh(scene: Scene): Mesh;
  68615. /**
  68616. * Get a navigation mesh constrained position, closest to the parameter position
  68617. * @param position world position
  68618. * @returns the closest point to position constrained by the navigation mesh
  68619. */
  68620. getClosestPoint(position: Vector3): Vector3;
  68621. /**
  68622. * Get a navigation mesh constrained position, closest to the parameter position
  68623. * @param position world position
  68624. * @param result output the closest point to position constrained by the navigation mesh
  68625. */
  68626. getClosestPointToRef(position: Vector3, result: Vector3): void;
  68627. /**
  68628. * Get a navigation mesh constrained position, within a particular radius
  68629. * @param position world position
  68630. * @param maxRadius the maximum distance to the constrained world position
  68631. * @returns the closest point to position constrained by the navigation mesh
  68632. */
  68633. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  68634. /**
  68635. * Get a navigation mesh constrained position, within a particular radius
  68636. * @param position world position
  68637. * @param maxRadius the maximum distance to the constrained world position
  68638. * @param result output the closest point to position constrained by the navigation mesh
  68639. */
  68640. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  68641. /**
  68642. * Compute the final position from a segment made of destination-position
  68643. * @param position world position
  68644. * @param destination world position
  68645. * @returns the resulting point along the navmesh
  68646. */
  68647. moveAlong(position: Vector3, destination: Vector3): Vector3;
  68648. /**
  68649. * Compute the final position from a segment made of destination-position
  68650. * @param position world position
  68651. * @param destination world position
  68652. * @param result output the resulting point along the navmesh
  68653. */
  68654. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  68655. /**
  68656. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  68657. * @param start world position
  68658. * @param end world position
  68659. * @returns array containing world position composing the path
  68660. */
  68661. computePath(start: Vector3, end: Vector3): Vector3[];
  68662. /**
  68663. * Create a new Crowd so you can add agents
  68664. * @param maxAgents the maximum agent count in the crowd
  68665. * @param maxAgentRadius the maximum radius an agent can have
  68666. * @param scene to attach the crowd to
  68667. * @returns the crowd you can add agents to
  68668. */
  68669. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  68670. /**
  68671. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  68672. * The queries will try to find a solution within those bounds
  68673. * default is (1,1,1)
  68674. * @param extent x,y,z value that define the extent around the queries point of reference
  68675. */
  68676. setDefaultQueryExtent(extent: Vector3): void;
  68677. /**
  68678. * Get the Bounding box extent specified by setDefaultQueryExtent
  68679. * @returns the box extent values
  68680. */
  68681. getDefaultQueryExtent(): Vector3;
  68682. /**
  68683. * build the navmesh from a previously saved state using getNavmeshData
  68684. * @param data the Uint8Array returned by getNavmeshData
  68685. */
  68686. buildFromNavmeshData(data: Uint8Array): void;
  68687. /**
  68688. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  68689. * @returns data the Uint8Array that can be saved and reused
  68690. */
  68691. getNavmeshData(): Uint8Array;
  68692. /**
  68693. * Get the Bounding box extent result specified by setDefaultQueryExtent
  68694. * @param result output the box extent values
  68695. */
  68696. getDefaultQueryExtentToRef(result: Vector3): void;
  68697. /**
  68698. * Disposes
  68699. */
  68700. dispose(): void;
  68701. /**
  68702. * If this plugin is supported
  68703. * @returns true if plugin is supported
  68704. */
  68705. isSupported(): boolean;
  68706. }
  68707. /**
  68708. * Recast detour crowd implementation
  68709. */
  68710. export class RecastJSCrowd implements ICrowd {
  68711. /**
  68712. * Recast/detour plugin
  68713. */
  68714. bjsRECASTPlugin: RecastJSPlugin;
  68715. /**
  68716. * Link to the detour crowd
  68717. */
  68718. recastCrowd: any;
  68719. /**
  68720. * One transform per agent
  68721. */
  68722. transforms: TransformNode[];
  68723. /**
  68724. * All agents created
  68725. */
  68726. agents: number[];
  68727. /**
  68728. * Link to the scene is kept to unregister the crowd from the scene
  68729. */
  68730. private _scene;
  68731. /**
  68732. * Observer for crowd updates
  68733. */
  68734. private _onBeforeAnimationsObserver;
  68735. /**
  68736. * Constructor
  68737. * @param plugin recastJS plugin
  68738. * @param maxAgents the maximum agent count in the crowd
  68739. * @param maxAgentRadius the maximum radius an agent can have
  68740. * @param scene to attach the crowd to
  68741. * @returns the crowd you can add agents to
  68742. */
  68743. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  68744. /**
  68745. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  68746. * You can attach anything to that node. The node position is updated in the scene update tick.
  68747. * @param pos world position that will be constrained by the navigation mesh
  68748. * @param parameters agent parameters
  68749. * @param transform hooked to the agent that will be update by the scene
  68750. * @returns agent index
  68751. */
  68752. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  68753. /**
  68754. * Returns the agent position in world space
  68755. * @param index agent index returned by addAgent
  68756. * @returns world space position
  68757. */
  68758. getAgentPosition(index: number): Vector3;
  68759. /**
  68760. * Returns the agent position result in world space
  68761. * @param index agent index returned by addAgent
  68762. * @param result output world space position
  68763. */
  68764. getAgentPositionToRef(index: number, result: Vector3): void;
  68765. /**
  68766. * Returns the agent velocity in world space
  68767. * @param index agent index returned by addAgent
  68768. * @returns world space velocity
  68769. */
  68770. getAgentVelocity(index: number): Vector3;
  68771. /**
  68772. * Returns the agent velocity result in world space
  68773. * @param index agent index returned by addAgent
  68774. * @param result output world space velocity
  68775. */
  68776. getAgentVelocityToRef(index: number, result: Vector3): void;
  68777. /**
  68778. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  68779. * @param index agent index returned by addAgent
  68780. * @param destination targeted world position
  68781. */
  68782. agentGoto(index: number, destination: Vector3): void;
  68783. /**
  68784. * Teleport the agent to a new position
  68785. * @param index agent index returned by addAgent
  68786. * @param destination targeted world position
  68787. */
  68788. agentTeleport(index: number, destination: Vector3): void;
  68789. /**
  68790. * Update agent parameters
  68791. * @param index agent index returned by addAgent
  68792. * @param parameters agent parameters
  68793. */
  68794. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  68795. /**
  68796. * remove a particular agent previously created
  68797. * @param index agent index returned by addAgent
  68798. */
  68799. removeAgent(index: number): void;
  68800. /**
  68801. * get the list of all agents attached to this crowd
  68802. * @returns list of agent indices
  68803. */
  68804. getAgents(): number[];
  68805. /**
  68806. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  68807. * @param deltaTime in seconds
  68808. */
  68809. update(deltaTime: number): void;
  68810. /**
  68811. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  68812. * The queries will try to find a solution within those bounds
  68813. * default is (1,1,1)
  68814. * @param extent x,y,z value that define the extent around the queries point of reference
  68815. */
  68816. setDefaultQueryExtent(extent: Vector3): void;
  68817. /**
  68818. * Get the Bounding box extent specified by setDefaultQueryExtent
  68819. * @returns the box extent values
  68820. */
  68821. getDefaultQueryExtent(): Vector3;
  68822. /**
  68823. * Get the Bounding box extent result specified by setDefaultQueryExtent
  68824. * @param result output the box extent values
  68825. */
  68826. getDefaultQueryExtentToRef(result: Vector3): void;
  68827. /**
  68828. * Release all resources
  68829. */
  68830. dispose(): void;
  68831. }
  68832. }
  68833. declare module "babylonjs/Navigation/Plugins/index" {
  68834. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  68835. }
  68836. declare module "babylonjs/Navigation/index" {
  68837. export * from "babylonjs/Navigation/INavigationEngine";
  68838. export * from "babylonjs/Navigation/Plugins/index";
  68839. }
  68840. declare module "babylonjs/Offline/database" {
  68841. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  68842. /**
  68843. * Class used to enable access to IndexedDB
  68844. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  68845. */
  68846. export class Database implements IOfflineProvider {
  68847. private _callbackManifestChecked;
  68848. private _currentSceneUrl;
  68849. private _db;
  68850. private _enableSceneOffline;
  68851. private _enableTexturesOffline;
  68852. private _manifestVersionFound;
  68853. private _mustUpdateRessources;
  68854. private _hasReachedQuota;
  68855. private _isSupported;
  68856. private _idbFactory;
  68857. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  68858. private static IsUASupportingBlobStorage;
  68859. /**
  68860. * Gets a boolean indicating if Database storate is enabled (off by default)
  68861. */
  68862. static IDBStorageEnabled: boolean;
  68863. /**
  68864. * Gets a boolean indicating if scene must be saved in the database
  68865. */
  68866. get enableSceneOffline(): boolean;
  68867. /**
  68868. * Gets a boolean indicating if textures must be saved in the database
  68869. */
  68870. get enableTexturesOffline(): boolean;
  68871. /**
  68872. * Creates a new Database
  68873. * @param urlToScene defines the url to load the scene
  68874. * @param callbackManifestChecked defines the callback to use when manifest is checked
  68875. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  68876. */
  68877. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  68878. private static _ParseURL;
  68879. private static _ReturnFullUrlLocation;
  68880. private _checkManifestFile;
  68881. /**
  68882. * Open the database and make it available
  68883. * @param successCallback defines the callback to call on success
  68884. * @param errorCallback defines the callback to call on error
  68885. */
  68886. open(successCallback: () => void, errorCallback: () => void): void;
  68887. /**
  68888. * Loads an image from the database
  68889. * @param url defines the url to load from
  68890. * @param image defines the target DOM image
  68891. */
  68892. loadImage(url: string, image: HTMLImageElement): void;
  68893. private _loadImageFromDBAsync;
  68894. private _saveImageIntoDBAsync;
  68895. private _checkVersionFromDB;
  68896. private _loadVersionFromDBAsync;
  68897. private _saveVersionIntoDBAsync;
  68898. /**
  68899. * Loads a file from database
  68900. * @param url defines the URL to load from
  68901. * @param sceneLoaded defines a callback to call on success
  68902. * @param progressCallBack defines a callback to call when progress changed
  68903. * @param errorCallback defines a callback to call on error
  68904. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  68905. */
  68906. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  68907. private _loadFileAsync;
  68908. private _saveFileAsync;
  68909. /**
  68910. * Validates if xhr data is correct
  68911. * @param xhr defines the request to validate
  68912. * @param dataType defines the expected data type
  68913. * @returns true if data is correct
  68914. */
  68915. private static _ValidateXHRData;
  68916. }
  68917. }
  68918. declare module "babylonjs/Offline/index" {
  68919. export * from "babylonjs/Offline/database";
  68920. export * from "babylonjs/Offline/IOfflineProvider";
  68921. }
  68922. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  68923. /** @hidden */
  68924. export var gpuUpdateParticlesPixelShader: {
  68925. name: string;
  68926. shader: string;
  68927. };
  68928. }
  68929. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  68930. /** @hidden */
  68931. export var gpuUpdateParticlesVertexShader: {
  68932. name: string;
  68933. shader: string;
  68934. };
  68935. }
  68936. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  68937. /** @hidden */
  68938. export var clipPlaneFragmentDeclaration2: {
  68939. name: string;
  68940. shader: string;
  68941. };
  68942. }
  68943. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  68944. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  68945. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  68946. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  68947. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  68948. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  68949. /** @hidden */
  68950. export var gpuRenderParticlesPixelShader: {
  68951. name: string;
  68952. shader: string;
  68953. };
  68954. }
  68955. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  68956. /** @hidden */
  68957. export var clipPlaneVertexDeclaration2: {
  68958. name: string;
  68959. shader: string;
  68960. };
  68961. }
  68962. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  68963. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  68964. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  68965. /** @hidden */
  68966. export var gpuRenderParticlesVertexShader: {
  68967. name: string;
  68968. shader: string;
  68969. };
  68970. }
  68971. declare module "babylonjs/Particles/gpuParticleSystem" {
  68972. import { Nullable } from "babylonjs/types";
  68973. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  68974. import { Observable } from "babylonjs/Misc/observable";
  68975. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  68976. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  68977. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  68978. import { Scene, IDisposable } from "babylonjs/scene";
  68979. import { Effect } from "babylonjs/Materials/effect";
  68980. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  68981. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  68982. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  68983. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  68984. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  68985. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  68986. /**
  68987. * This represents a GPU particle system in Babylon
  68988. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  68989. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  68990. */
  68991. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  68992. /**
  68993. * The layer mask we are rendering the particles through.
  68994. */
  68995. layerMask: number;
  68996. private _capacity;
  68997. private _activeCount;
  68998. private _currentActiveCount;
  68999. private _accumulatedCount;
  69000. private _renderEffect;
  69001. private _updateEffect;
  69002. private _buffer0;
  69003. private _buffer1;
  69004. private _spriteBuffer;
  69005. private _updateVAO;
  69006. private _renderVAO;
  69007. private _targetIndex;
  69008. private _sourceBuffer;
  69009. private _targetBuffer;
  69010. private _engine;
  69011. private _currentRenderId;
  69012. private _started;
  69013. private _stopped;
  69014. private _timeDelta;
  69015. private _randomTexture;
  69016. private _randomTexture2;
  69017. private _attributesStrideSize;
  69018. private _updateEffectOptions;
  69019. private _randomTextureSize;
  69020. private _actualFrame;
  69021. private _customEffect;
  69022. private readonly _rawTextureWidth;
  69023. /**
  69024. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  69025. */
  69026. static get IsSupported(): boolean;
  69027. /**
  69028. * An event triggered when the system is disposed.
  69029. */
  69030. onDisposeObservable: Observable<IParticleSystem>;
  69031. /**
  69032. * Gets the maximum number of particles active at the same time.
  69033. * @returns The max number of active particles.
  69034. */
  69035. getCapacity(): number;
  69036. /**
  69037. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  69038. * to override the particles.
  69039. */
  69040. forceDepthWrite: boolean;
  69041. /**
  69042. * Gets or set the number of active particles
  69043. */
  69044. get activeParticleCount(): number;
  69045. set activeParticleCount(value: number);
  69046. private _preWarmDone;
  69047. /**
  69048. * Specifies if the particles are updated in emitter local space or world space.
  69049. */
  69050. isLocal: boolean;
  69051. /**
  69052. * Is this system ready to be used/rendered
  69053. * @return true if the system is ready
  69054. */
  69055. isReady(): boolean;
  69056. /**
  69057. * Gets if the system has been started. (Note: this will still be true after stop is called)
  69058. * @returns True if it has been started, otherwise false.
  69059. */
  69060. isStarted(): boolean;
  69061. /**
  69062. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  69063. * @returns True if it has been stopped, otherwise false.
  69064. */
  69065. isStopped(): boolean;
  69066. /**
  69067. * Gets a boolean indicating that the system is stopping
  69068. * @returns true if the system is currently stopping
  69069. */
  69070. isStopping(): boolean;
  69071. /**
  69072. * Gets the number of particles active at the same time.
  69073. * @returns The number of active particles.
  69074. */
  69075. getActiveCount(): number;
  69076. /**
  69077. * Starts the particle system and begins to emit
  69078. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  69079. */
  69080. start(delay?: number): void;
  69081. /**
  69082. * Stops the particle system.
  69083. */
  69084. stop(): void;
  69085. /**
  69086. * Remove all active particles
  69087. */
  69088. reset(): void;
  69089. /**
  69090. * Returns the string "GPUParticleSystem"
  69091. * @returns a string containing the class name
  69092. */
  69093. getClassName(): string;
  69094. /**
  69095. * Gets the custom effect used to render the particles
  69096. * @param blendMode Blend mode for which the effect should be retrieved
  69097. * @returns The effect
  69098. */
  69099. getCustomEffect(blendMode?: number): Nullable<Effect>;
  69100. /**
  69101. * Sets the custom effect used to render the particles
  69102. * @param effect The effect to set
  69103. * @param blendMode Blend mode for which the effect should be set
  69104. */
  69105. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  69106. /** @hidden */
  69107. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  69108. /**
  69109. * Observable that will be called just before the particles are drawn
  69110. */
  69111. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  69112. /**
  69113. * Gets the name of the particle vertex shader
  69114. */
  69115. get vertexShaderName(): string;
  69116. private _colorGradientsTexture;
  69117. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  69118. /**
  69119. * Adds a new color gradient
  69120. * @param gradient defines the gradient to use (between 0 and 1)
  69121. * @param color1 defines the color to affect to the specified gradient
  69122. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  69123. * @returns the current particle system
  69124. */
  69125. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  69126. private _refreshColorGradient;
  69127. /** Force the system to rebuild all gradients that need to be resync */
  69128. forceRefreshGradients(): void;
  69129. /**
  69130. * Remove a specific color gradient
  69131. * @param gradient defines the gradient to remove
  69132. * @returns the current particle system
  69133. */
  69134. removeColorGradient(gradient: number): GPUParticleSystem;
  69135. private _angularSpeedGradientsTexture;
  69136. private _sizeGradientsTexture;
  69137. private _velocityGradientsTexture;
  69138. private _limitVelocityGradientsTexture;
  69139. private _dragGradientsTexture;
  69140. private _addFactorGradient;
  69141. /**
  69142. * Adds a new size gradient
  69143. * @param gradient defines the gradient to use (between 0 and 1)
  69144. * @param factor defines the size factor to affect to the specified gradient
  69145. * @returns the current particle system
  69146. */
  69147. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  69148. /**
  69149. * Remove a specific size gradient
  69150. * @param gradient defines the gradient to remove
  69151. * @returns the current particle system
  69152. */
  69153. removeSizeGradient(gradient: number): GPUParticleSystem;
  69154. private _refreshFactorGradient;
  69155. /**
  69156. * Adds a new angular speed gradient
  69157. * @param gradient defines the gradient to use (between 0 and 1)
  69158. * @param factor defines the angular speed to affect to the specified gradient
  69159. * @returns the current particle system
  69160. */
  69161. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  69162. /**
  69163. * Remove a specific angular speed gradient
  69164. * @param gradient defines the gradient to remove
  69165. * @returns the current particle system
  69166. */
  69167. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  69168. /**
  69169. * Adds a new velocity gradient
  69170. * @param gradient defines the gradient to use (between 0 and 1)
  69171. * @param factor defines the velocity to affect to the specified gradient
  69172. * @returns the current particle system
  69173. */
  69174. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  69175. /**
  69176. * Remove a specific velocity gradient
  69177. * @param gradient defines the gradient to remove
  69178. * @returns the current particle system
  69179. */
  69180. removeVelocityGradient(gradient: number): GPUParticleSystem;
  69181. /**
  69182. * Adds a new limit velocity gradient
  69183. * @param gradient defines the gradient to use (between 0 and 1)
  69184. * @param factor defines the limit velocity value to affect to the specified gradient
  69185. * @returns the current particle system
  69186. */
  69187. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  69188. /**
  69189. * Remove a specific limit velocity gradient
  69190. * @param gradient defines the gradient to remove
  69191. * @returns the current particle system
  69192. */
  69193. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  69194. /**
  69195. * Adds a new drag gradient
  69196. * @param gradient defines the gradient to use (between 0 and 1)
  69197. * @param factor defines the drag value to affect to the specified gradient
  69198. * @returns the current particle system
  69199. */
  69200. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  69201. /**
  69202. * Remove a specific drag gradient
  69203. * @param gradient defines the gradient to remove
  69204. * @returns the current particle system
  69205. */
  69206. removeDragGradient(gradient: number): GPUParticleSystem;
  69207. /**
  69208. * Not supported by GPUParticleSystem
  69209. * @param gradient defines the gradient to use (between 0 and 1)
  69210. * @param factor defines the emit rate value to affect to the specified gradient
  69211. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  69212. * @returns the current particle system
  69213. */
  69214. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  69215. /**
  69216. * Not supported by GPUParticleSystem
  69217. * @param gradient defines the gradient to remove
  69218. * @returns the current particle system
  69219. */
  69220. removeEmitRateGradient(gradient: number): IParticleSystem;
  69221. /**
  69222. * Not supported by GPUParticleSystem
  69223. * @param gradient defines the gradient to use (between 0 and 1)
  69224. * @param factor defines the start size value to affect to the specified gradient
  69225. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  69226. * @returns the current particle system
  69227. */
  69228. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  69229. /**
  69230. * Not supported by GPUParticleSystem
  69231. * @param gradient defines the gradient to remove
  69232. * @returns the current particle system
  69233. */
  69234. removeStartSizeGradient(gradient: number): IParticleSystem;
  69235. /**
  69236. * Not supported by GPUParticleSystem
  69237. * @param gradient defines the gradient to use (between 0 and 1)
  69238. * @param min defines the color remap minimal range
  69239. * @param max defines the color remap maximal range
  69240. * @returns the current particle system
  69241. */
  69242. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  69243. /**
  69244. * Not supported by GPUParticleSystem
  69245. * @param gradient defines the gradient to remove
  69246. * @returns the current particle system
  69247. */
  69248. removeColorRemapGradient(): IParticleSystem;
  69249. /**
  69250. * Not supported by GPUParticleSystem
  69251. * @param gradient defines the gradient to use (between 0 and 1)
  69252. * @param min defines the alpha remap minimal range
  69253. * @param max defines the alpha remap maximal range
  69254. * @returns the current particle system
  69255. */
  69256. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  69257. /**
  69258. * Not supported by GPUParticleSystem
  69259. * @param gradient defines the gradient to remove
  69260. * @returns the current particle system
  69261. */
  69262. removeAlphaRemapGradient(): IParticleSystem;
  69263. /**
  69264. * Not supported by GPUParticleSystem
  69265. * @param gradient defines the gradient to use (between 0 and 1)
  69266. * @param color defines the color to affect to the specified gradient
  69267. * @returns the current particle system
  69268. */
  69269. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  69270. /**
  69271. * Not supported by GPUParticleSystem
  69272. * @param gradient defines the gradient to remove
  69273. * @returns the current particle system
  69274. */
  69275. removeRampGradient(): IParticleSystem;
  69276. /**
  69277. * Not supported by GPUParticleSystem
  69278. * @returns the list of ramp gradients
  69279. */
  69280. getRampGradients(): Nullable<Array<Color3Gradient>>;
  69281. /**
  69282. * Not supported by GPUParticleSystem
  69283. * Gets or sets a boolean indicating that ramp gradients must be used
  69284. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  69285. */
  69286. get useRampGradients(): boolean;
  69287. set useRampGradients(value: boolean);
  69288. /**
  69289. * Not supported by GPUParticleSystem
  69290. * @param gradient defines the gradient to use (between 0 and 1)
  69291. * @param factor defines the life time factor to affect to the specified gradient
  69292. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  69293. * @returns the current particle system
  69294. */
  69295. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  69296. /**
  69297. * Not supported by GPUParticleSystem
  69298. * @param gradient defines the gradient to remove
  69299. * @returns the current particle system
  69300. */
  69301. removeLifeTimeGradient(gradient: number): IParticleSystem;
  69302. /**
  69303. * Instantiates a GPU particle system.
  69304. * 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.
  69305. * @param name The name of the particle system
  69306. * @param options The options used to create the system
  69307. * @param scene The scene the particle system belongs to
  69308. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  69309. * @param customEffect a custom effect used to change the way particles are rendered by default
  69310. */
  69311. constructor(name: string, options: Partial<{
  69312. capacity: number;
  69313. randomTextureSize: number;
  69314. }>, scene: Scene, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  69315. protected _reset(): void;
  69316. private _createUpdateVAO;
  69317. private _createRenderVAO;
  69318. private _initialize;
  69319. /** @hidden */
  69320. _recreateUpdateEffect(): void;
  69321. private _getEffect;
  69322. /**
  69323. * Fill the defines array according to the current settings of the particle system
  69324. * @param defines Array to be updated
  69325. * @param blendMode blend mode to take into account when updating the array
  69326. */
  69327. fillDefines(defines: Array<string>, blendMode?: number): void;
  69328. /**
  69329. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  69330. * @param uniforms Uniforms array to fill
  69331. * @param attributes Attributes array to fill
  69332. * @param samplers Samplers array to fill
  69333. */
  69334. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  69335. /** @hidden */
  69336. _recreateRenderEffect(): Effect;
  69337. /**
  69338. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  69339. * @param preWarm defines if we are in the pre-warmimg phase
  69340. */
  69341. animate(preWarm?: boolean): void;
  69342. private _createFactorGradientTexture;
  69343. private _createSizeGradientTexture;
  69344. private _createAngularSpeedGradientTexture;
  69345. private _createVelocityGradientTexture;
  69346. private _createLimitVelocityGradientTexture;
  69347. private _createDragGradientTexture;
  69348. private _createColorGradientTexture;
  69349. /**
  69350. * Renders the particle system in its current state
  69351. * @param preWarm defines if the system should only update the particles but not render them
  69352. * @returns the current number of particles
  69353. */
  69354. render(preWarm?: boolean): number;
  69355. /**
  69356. * Rebuilds the particle system
  69357. */
  69358. rebuild(): void;
  69359. private _releaseBuffers;
  69360. private _releaseVAOs;
  69361. /**
  69362. * Disposes the particle system and free the associated resources
  69363. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  69364. */
  69365. dispose(disposeTexture?: boolean): void;
  69366. /**
  69367. * Clones the particle system.
  69368. * @param name The name of the cloned object
  69369. * @param newEmitter The new emitter to use
  69370. * @returns the cloned particle system
  69371. */
  69372. clone(name: string, newEmitter: any): GPUParticleSystem;
  69373. /**
  69374. * Serializes the particle system to a JSON object
  69375. * @param serializeTexture defines if the texture must be serialized as well
  69376. * @returns the JSON object
  69377. */
  69378. serialize(serializeTexture?: boolean): any;
  69379. /**
  69380. * Parses a JSON object to create a GPU particle system.
  69381. * @param parsedParticleSystem The JSON object to parse
  69382. * @param scene The scene to create the particle system in
  69383. * @param rootUrl The root url to use to load external dependencies like texture
  69384. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  69385. * @returns the parsed GPU particle system
  69386. */
  69387. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  69388. }
  69389. }
  69390. declare module "babylonjs/Particles/particleSystemSet" {
  69391. import { Nullable } from "babylonjs/types";
  69392. import { Color3 } from "babylonjs/Maths/math.color";
  69393. import { TransformNode } from "babylonjs/Meshes/transformNode";
  69394. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69395. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  69396. import { Scene, IDisposable } from "babylonjs/scene";
  69397. /**
  69398. * Represents a set of particle systems working together to create a specific effect
  69399. */
  69400. export class ParticleSystemSet implements IDisposable {
  69401. /**
  69402. * Gets or sets base Assets URL
  69403. */
  69404. static BaseAssetsUrl: string;
  69405. private _emitterCreationOptions;
  69406. private _emitterNode;
  69407. /**
  69408. * Gets the particle system list
  69409. */
  69410. systems: IParticleSystem[];
  69411. /**
  69412. * Gets the emitter node used with this set
  69413. */
  69414. get emitterNode(): Nullable<TransformNode>;
  69415. /**
  69416. * Creates a new emitter mesh as a sphere
  69417. * @param options defines the options used to create the sphere
  69418. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  69419. * @param scene defines the hosting scene
  69420. */
  69421. setEmitterAsSphere(options: {
  69422. diameter: number;
  69423. segments: number;
  69424. color: Color3;
  69425. }, renderingGroupId: number, scene: Scene): void;
  69426. /**
  69427. * Starts all particle systems of the set
  69428. * @param emitter defines an optional mesh to use as emitter for the particle systems
  69429. */
  69430. start(emitter?: AbstractMesh): void;
  69431. /**
  69432. * Release all associated resources
  69433. */
  69434. dispose(): void;
  69435. /**
  69436. * Serialize the set into a JSON compatible object
  69437. * @param serializeTexture defines if the texture must be serialized as well
  69438. * @returns a JSON compatible representation of the set
  69439. */
  69440. serialize(serializeTexture?: boolean): any;
  69441. /**
  69442. * Parse a new ParticleSystemSet from a serialized source
  69443. * @param data defines a JSON compatible representation of the set
  69444. * @param scene defines the hosting scene
  69445. * @param gpu defines if we want GPU particles or CPU particles
  69446. * @returns a new ParticleSystemSet
  69447. */
  69448. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  69449. }
  69450. }
  69451. declare module "babylonjs/Particles/particleHelper" {
  69452. import { Nullable } from "babylonjs/types";
  69453. import { Scene } from "babylonjs/scene";
  69454. import { Vector3 } from "babylonjs/Maths/math.vector";
  69455. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69456. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  69457. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  69458. /**
  69459. * This class is made for on one-liner static method to help creating particle system set.
  69460. */
  69461. export class ParticleHelper {
  69462. /**
  69463. * Gets or sets base Assets URL
  69464. */
  69465. static BaseAssetsUrl: string;
  69466. /** Define the Url to load snippets */
  69467. static SnippetUrl: string;
  69468. /**
  69469. * Create a default particle system that you can tweak
  69470. * @param emitter defines the emitter to use
  69471. * @param capacity defines the system capacity (default is 500 particles)
  69472. * @param scene defines the hosting scene
  69473. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  69474. * @returns the new Particle system
  69475. */
  69476. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  69477. /**
  69478. * This is the main static method (one-liner) of this helper to create different particle systems
  69479. * @param type This string represents the type to the particle system to create
  69480. * @param scene The scene where the particle system should live
  69481. * @param gpu If the system will use gpu
  69482. * @returns the ParticleSystemSet created
  69483. */
  69484. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  69485. /**
  69486. * Static function used to export a particle system to a ParticleSystemSet variable.
  69487. * Please note that the emitter shape is not exported
  69488. * @param systems defines the particle systems to export
  69489. * @returns the created particle system set
  69490. */
  69491. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  69492. /**
  69493. * Creates a particle system from a snippet saved in a remote file
  69494. * @param name defines the name of the particle system to create
  69495. * @param url defines the url to load from
  69496. * @param scene defines the hosting scene
  69497. * @param gpu If the system will use gpu
  69498. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  69499. * @returns a promise that will resolve to the new particle system
  69500. */
  69501. static ParseFromFileAsync(name: string, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  69502. /**
  69503. * Creates a particle system from a snippet saved by the particle system editor
  69504. * @param snippetId defines the snippet to load
  69505. * @param scene defines the hosting scene
  69506. * @param gpu If the system will use gpu
  69507. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  69508. * @returns a promise that will resolve to the new particle system
  69509. */
  69510. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  69511. }
  69512. }
  69513. declare module "babylonjs/Particles/particleSystemComponent" {
  69514. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  69515. import { Effect } from "babylonjs/Materials/effect";
  69516. import "babylonjs/Shaders/particles.vertex";
  69517. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  69518. module "babylonjs/Engines/engine" {
  69519. interface Engine {
  69520. /**
  69521. * Create an effect to use with particle systems.
  69522. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  69523. * the particle system for which you want to create a custom effect in the last parameter
  69524. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  69525. * @param uniformsNames defines a list of attribute names
  69526. * @param samplers defines an array of string used to represent textures
  69527. * @param defines defines the string containing the defines to use to compile the shaders
  69528. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  69529. * @param onCompiled defines a function to call when the effect creation is successful
  69530. * @param onError defines a function to call when the effect creation has failed
  69531. * @param particleSystem the particle system you want to create the effect for
  69532. * @returns the new Effect
  69533. */
  69534. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  69535. }
  69536. }
  69537. module "babylonjs/Meshes/mesh" {
  69538. interface Mesh {
  69539. /**
  69540. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  69541. * @returns an array of IParticleSystem
  69542. */
  69543. getEmittedParticleSystems(): IParticleSystem[];
  69544. /**
  69545. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  69546. * @returns an array of IParticleSystem
  69547. */
  69548. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  69549. }
  69550. }
  69551. /**
  69552. * @hidden
  69553. */
  69554. export var _IDoNeedToBeInTheBuild: number;
  69555. }
  69556. declare module "babylonjs/Particles/pointsCloudSystem" {
  69557. import { Color4 } from "babylonjs/Maths/math";
  69558. import { Mesh } from "babylonjs/Meshes/mesh";
  69559. import { Scene, IDisposable } from "babylonjs/scene";
  69560. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  69561. /** Defines the 4 color options */
  69562. export enum PointColor {
  69563. /** color value */
  69564. Color = 2,
  69565. /** uv value */
  69566. UV = 1,
  69567. /** random value */
  69568. Random = 0,
  69569. /** stated value */
  69570. Stated = 3
  69571. }
  69572. /**
  69573. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  69574. * 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.
  69575. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  69576. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  69577. *
  69578. * Full documentation here : TO BE ENTERED
  69579. */
  69580. export class PointsCloudSystem implements IDisposable {
  69581. /**
  69582. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  69583. * Example : var p = SPS.particles[i];
  69584. */
  69585. particles: CloudPoint[];
  69586. /**
  69587. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  69588. */
  69589. nbParticles: number;
  69590. /**
  69591. * This a counter for your own usage. It's not set by any SPS functions.
  69592. */
  69593. counter: number;
  69594. /**
  69595. * The PCS name. This name is also given to the underlying mesh.
  69596. */
  69597. name: string;
  69598. /**
  69599. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  69600. */
  69601. mesh: Mesh;
  69602. /**
  69603. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  69604. * Please read :
  69605. */
  69606. vars: any;
  69607. /**
  69608. * @hidden
  69609. */
  69610. _size: number;
  69611. private _scene;
  69612. private _promises;
  69613. private _positions;
  69614. private _indices;
  69615. private _normals;
  69616. private _colors;
  69617. private _uvs;
  69618. private _indices32;
  69619. private _positions32;
  69620. private _colors32;
  69621. private _uvs32;
  69622. private _updatable;
  69623. private _isVisibilityBoxLocked;
  69624. private _alwaysVisible;
  69625. private _groups;
  69626. private _groupCounter;
  69627. private _computeParticleColor;
  69628. private _computeParticleTexture;
  69629. private _computeParticleRotation;
  69630. private _computeBoundingBox;
  69631. private _isReady;
  69632. /**
  69633. * Creates a PCS (Points Cloud System) object
  69634. * @param name (String) is the PCS name, this will be the underlying mesh name
  69635. * @param pointSize (number) is the size for each point
  69636. * @param scene (Scene) is the scene in which the PCS is added
  69637. * @param options defines the options of the PCS e.g.
  69638. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  69639. */
  69640. constructor(name: string, pointSize: number, scene: Scene, options?: {
  69641. updatable?: boolean;
  69642. });
  69643. /**
  69644. * Builds the PCS underlying mesh. Returns a standard Mesh.
  69645. * If no points were added to the PCS, the returned mesh is just a single point.
  69646. * @returns a promise for the created mesh
  69647. */
  69648. buildMeshAsync(): Promise<Mesh>;
  69649. /**
  69650. * @hidden
  69651. */
  69652. private _buildMesh;
  69653. private _addParticle;
  69654. private _randomUnitVector;
  69655. private _getColorIndicesForCoord;
  69656. private _setPointsColorOrUV;
  69657. private _colorFromTexture;
  69658. private _calculateDensity;
  69659. /**
  69660. * Adds points to the PCS in random positions within a unit sphere
  69661. * @param nb (positive integer) the number of particles to be created from this model
  69662. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  69663. * @returns the number of groups in the system
  69664. */
  69665. addPoints(nb: number, pointFunction?: any): number;
  69666. /**
  69667. * Adds points to the PCS from the surface of the model shape
  69668. * @param mesh is any Mesh object that will be used as a surface model for the points
  69669. * @param nb (positive integer) the number of particles to be created from this model
  69670. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  69671. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  69672. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  69673. * @returns the number of groups in the system
  69674. */
  69675. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  69676. /**
  69677. * Adds points to the PCS inside the model shape
  69678. * @param mesh is any Mesh object that will be used as a surface model for the points
  69679. * @param nb (positive integer) the number of particles to be created from this model
  69680. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  69681. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  69682. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  69683. * @returns the number of groups in the system
  69684. */
  69685. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  69686. /**
  69687. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  69688. * This method calls `updateParticle()` for each particle of the SPS.
  69689. * For an animated SPS, it is usually called within the render loop.
  69690. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  69691. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  69692. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  69693. * @returns the PCS.
  69694. */
  69695. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  69696. /**
  69697. * Disposes the PCS.
  69698. */
  69699. dispose(): void;
  69700. /**
  69701. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  69702. * doc :
  69703. * @returns the PCS.
  69704. */
  69705. refreshVisibleSize(): PointsCloudSystem;
  69706. /**
  69707. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  69708. * @param size the size (float) of the visibility box
  69709. * note : this doesn't lock the PCS mesh bounding box.
  69710. * doc :
  69711. */
  69712. setVisibilityBox(size: number): void;
  69713. /**
  69714. * Gets whether the PCS is always visible or not
  69715. * doc :
  69716. */
  69717. get isAlwaysVisible(): boolean;
  69718. /**
  69719. * Sets the PCS as always visible or not
  69720. * doc :
  69721. */
  69722. set isAlwaysVisible(val: boolean);
  69723. /**
  69724. * Tells to `setParticles()` to compute the particle rotations or not
  69725. * Default value : false. The PCS is faster when it's set to false
  69726. * Note : particle rotations are only applied to parent particles
  69727. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  69728. */
  69729. set computeParticleRotation(val: boolean);
  69730. /**
  69731. * Tells to `setParticles()` to compute the particle colors or not.
  69732. * Default value : true. The PCS is faster when it's set to false.
  69733. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  69734. */
  69735. set computeParticleColor(val: boolean);
  69736. set computeParticleTexture(val: boolean);
  69737. /**
  69738. * Gets if `setParticles()` computes the particle colors or not.
  69739. * Default value : false. The PCS is faster when it's set to false.
  69740. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  69741. */
  69742. get computeParticleColor(): boolean;
  69743. /**
  69744. * Gets if `setParticles()` computes the particle textures or not.
  69745. * Default value : false. The PCS is faster when it's set to false.
  69746. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  69747. */
  69748. get computeParticleTexture(): boolean;
  69749. /**
  69750. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  69751. */
  69752. set computeBoundingBox(val: boolean);
  69753. /**
  69754. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  69755. */
  69756. get computeBoundingBox(): boolean;
  69757. /**
  69758. * This function does nothing. It may be overwritten to set all the particle first values.
  69759. * The PCS doesn't call this function, you may have to call it by your own.
  69760. * doc :
  69761. */
  69762. initParticles(): void;
  69763. /**
  69764. * This function does nothing. It may be overwritten to recycle a particle
  69765. * The PCS doesn't call this function, you can to call it
  69766. * doc :
  69767. * @param particle The particle to recycle
  69768. * @returns the recycled particle
  69769. */
  69770. recycleParticle(particle: CloudPoint): CloudPoint;
  69771. /**
  69772. * Updates a particle : this function should be overwritten by the user.
  69773. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  69774. * doc :
  69775. * @example : just set a particle position or velocity and recycle conditions
  69776. * @param particle The particle to update
  69777. * @returns the updated particle
  69778. */
  69779. updateParticle(particle: CloudPoint): CloudPoint;
  69780. /**
  69781. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  69782. * This does nothing and may be overwritten by the user.
  69783. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  69784. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  69785. * @param update the boolean update value actually passed to setParticles()
  69786. */
  69787. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  69788. /**
  69789. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  69790. * This will be passed three parameters.
  69791. * This does nothing and may be overwritten by the user.
  69792. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  69793. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  69794. * @param update the boolean update value actually passed to setParticles()
  69795. */
  69796. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  69797. }
  69798. }
  69799. declare module "babylonjs/Particles/cloudPoint" {
  69800. import { Nullable } from "babylonjs/types";
  69801. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  69802. import { Mesh } from "babylonjs/Meshes/mesh";
  69803. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  69804. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  69805. /**
  69806. * Represents one particle of a points cloud system.
  69807. */
  69808. export class CloudPoint {
  69809. /**
  69810. * particle global index
  69811. */
  69812. idx: number;
  69813. /**
  69814. * The color of the particle
  69815. */
  69816. color: Nullable<Color4>;
  69817. /**
  69818. * The world space position of the particle.
  69819. */
  69820. position: Vector3;
  69821. /**
  69822. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  69823. */
  69824. rotation: Vector3;
  69825. /**
  69826. * The world space rotation quaternion of the particle.
  69827. */
  69828. rotationQuaternion: Nullable<Quaternion>;
  69829. /**
  69830. * The uv of the particle.
  69831. */
  69832. uv: Nullable<Vector2>;
  69833. /**
  69834. * The current speed of the particle.
  69835. */
  69836. velocity: Vector3;
  69837. /**
  69838. * The pivot point in the particle local space.
  69839. */
  69840. pivot: Vector3;
  69841. /**
  69842. * Must the particle be translated from its pivot point in its local space ?
  69843. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  69844. * Default : false
  69845. */
  69846. translateFromPivot: boolean;
  69847. /**
  69848. * Index of this particle in the global "positions" array (Internal use)
  69849. * @hidden
  69850. */
  69851. _pos: number;
  69852. /**
  69853. * @hidden Index of this particle in the global "indices" array (Internal use)
  69854. */
  69855. _ind: number;
  69856. /**
  69857. * Group this particle belongs to
  69858. */
  69859. _group: PointsGroup;
  69860. /**
  69861. * Group id of this particle
  69862. */
  69863. groupId: number;
  69864. /**
  69865. * Index of the particle in its group id (Internal use)
  69866. */
  69867. idxInGroup: number;
  69868. /**
  69869. * @hidden Particle BoundingInfo object (Internal use)
  69870. */
  69871. _boundingInfo: BoundingInfo;
  69872. /**
  69873. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  69874. */
  69875. _pcs: PointsCloudSystem;
  69876. /**
  69877. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  69878. */
  69879. _stillInvisible: boolean;
  69880. /**
  69881. * @hidden Last computed particle rotation matrix
  69882. */
  69883. _rotationMatrix: number[];
  69884. /**
  69885. * Parent particle Id, if any.
  69886. * Default null.
  69887. */
  69888. parentId: Nullable<number>;
  69889. /**
  69890. * @hidden Internal global position in the PCS.
  69891. */
  69892. _globalPosition: Vector3;
  69893. /**
  69894. * Creates a Point Cloud object.
  69895. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  69896. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  69897. * @param group (PointsGroup) is the group the particle belongs to
  69898. * @param groupId (integer) is the group identifier in the PCS.
  69899. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  69900. * @param pcs defines the PCS it is associated to
  69901. */
  69902. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  69903. /**
  69904. * get point size
  69905. */
  69906. get size(): Vector3;
  69907. /**
  69908. * Set point size
  69909. */
  69910. set size(scale: Vector3);
  69911. /**
  69912. * Legacy support, changed quaternion to rotationQuaternion
  69913. */
  69914. get quaternion(): Nullable<Quaternion>;
  69915. /**
  69916. * Legacy support, changed quaternion to rotationQuaternion
  69917. */
  69918. set quaternion(q: Nullable<Quaternion>);
  69919. /**
  69920. * Returns a boolean. True if the particle intersects a mesh, else false
  69921. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  69922. * @param target is the object (point or mesh) what the intersection is computed against
  69923. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  69924. * @returns true if it intersects
  69925. */
  69926. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  69927. /**
  69928. * get the rotation matrix of the particle
  69929. * @hidden
  69930. */
  69931. getRotationMatrix(m: Matrix): void;
  69932. }
  69933. /**
  69934. * Represents a group of points in a points cloud system
  69935. * * PCS internal tool, don't use it manually.
  69936. */
  69937. export class PointsGroup {
  69938. /**
  69939. * The group id
  69940. * @hidden
  69941. */
  69942. groupID: number;
  69943. /**
  69944. * image data for group (internal use)
  69945. * @hidden
  69946. */
  69947. _groupImageData: Nullable<ArrayBufferView>;
  69948. /**
  69949. * Image Width (internal use)
  69950. * @hidden
  69951. */
  69952. _groupImgWidth: number;
  69953. /**
  69954. * Image Height (internal use)
  69955. * @hidden
  69956. */
  69957. _groupImgHeight: number;
  69958. /**
  69959. * Custom position function (internal use)
  69960. * @hidden
  69961. */
  69962. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  69963. /**
  69964. * density per facet for surface points
  69965. * @hidden
  69966. */
  69967. _groupDensity: number[];
  69968. /**
  69969. * Only when points are colored by texture carries pointer to texture list array
  69970. * @hidden
  69971. */
  69972. _textureNb: number;
  69973. /**
  69974. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  69975. * PCS internal tool, don't use it manually.
  69976. * @hidden
  69977. */
  69978. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  69979. }
  69980. }
  69981. declare module "babylonjs/Particles/index" {
  69982. export * from "babylonjs/Particles/baseParticleSystem";
  69983. export * from "babylonjs/Particles/EmitterTypes/index";
  69984. export * from "babylonjs/Particles/gpuParticleSystem";
  69985. export * from "babylonjs/Particles/IParticleSystem";
  69986. export * from "babylonjs/Particles/particle";
  69987. export * from "babylonjs/Particles/particleHelper";
  69988. export * from "babylonjs/Particles/particleSystem";
  69989. export * from "babylonjs/Particles/particleSystemComponent";
  69990. export * from "babylonjs/Particles/particleSystemSet";
  69991. export * from "babylonjs/Particles/solidParticle";
  69992. export * from "babylonjs/Particles/solidParticleSystem";
  69993. export * from "babylonjs/Particles/cloudPoint";
  69994. export * from "babylonjs/Particles/pointsCloudSystem";
  69995. export * from "babylonjs/Particles/subEmitter";
  69996. }
  69997. declare module "babylonjs/Physics/physicsEngineComponent" {
  69998. import { Nullable } from "babylonjs/types";
  69999. import { Observable, Observer } from "babylonjs/Misc/observable";
  70000. import { Vector3 } from "babylonjs/Maths/math.vector";
  70001. import { Mesh } from "babylonjs/Meshes/mesh";
  70002. import { ISceneComponent } from "babylonjs/sceneComponent";
  70003. import { Scene } from "babylonjs/scene";
  70004. import { Node } from "babylonjs/node";
  70005. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  70006. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  70007. module "babylonjs/scene" {
  70008. interface Scene {
  70009. /** @hidden (Backing field) */
  70010. _physicsEngine: Nullable<IPhysicsEngine>;
  70011. /** @hidden */
  70012. _physicsTimeAccumulator: number;
  70013. /**
  70014. * Gets the current physics engine
  70015. * @returns a IPhysicsEngine or null if none attached
  70016. */
  70017. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  70018. /**
  70019. * Enables physics to the current scene
  70020. * @param gravity defines the scene's gravity for the physics engine
  70021. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  70022. * @return a boolean indicating if the physics engine was initialized
  70023. */
  70024. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  70025. /**
  70026. * Disables and disposes the physics engine associated with the scene
  70027. */
  70028. disablePhysicsEngine(): void;
  70029. /**
  70030. * Gets a boolean indicating if there is an active physics engine
  70031. * @returns a boolean indicating if there is an active physics engine
  70032. */
  70033. isPhysicsEnabled(): boolean;
  70034. /**
  70035. * Deletes a physics compound impostor
  70036. * @param compound defines the compound to delete
  70037. */
  70038. deleteCompoundImpostor(compound: any): void;
  70039. /**
  70040. * An event triggered when physic simulation is about to be run
  70041. */
  70042. onBeforePhysicsObservable: Observable<Scene>;
  70043. /**
  70044. * An event triggered when physic simulation has been done
  70045. */
  70046. onAfterPhysicsObservable: Observable<Scene>;
  70047. }
  70048. }
  70049. module "babylonjs/Meshes/abstractMesh" {
  70050. interface AbstractMesh {
  70051. /** @hidden */
  70052. _physicsImpostor: Nullable<PhysicsImpostor>;
  70053. /**
  70054. * Gets or sets impostor used for physic simulation
  70055. * @see http://doc.babylonjs.com/features/physics_engine
  70056. */
  70057. physicsImpostor: Nullable<PhysicsImpostor>;
  70058. /**
  70059. * Gets the current physics impostor
  70060. * @see http://doc.babylonjs.com/features/physics_engine
  70061. * @returns a physics impostor or null
  70062. */
  70063. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  70064. /** Apply a physic impulse to the mesh
  70065. * @param force defines the force to apply
  70066. * @param contactPoint defines where to apply the force
  70067. * @returns the current mesh
  70068. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  70069. */
  70070. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  70071. /**
  70072. * Creates a physic joint between two meshes
  70073. * @param otherMesh defines the other mesh to use
  70074. * @param pivot1 defines the pivot to use on this mesh
  70075. * @param pivot2 defines the pivot to use on the other mesh
  70076. * @param options defines additional options (can be plugin dependent)
  70077. * @returns the current mesh
  70078. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  70079. */
  70080. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  70081. /** @hidden */
  70082. _disposePhysicsObserver: Nullable<Observer<Node>>;
  70083. }
  70084. }
  70085. /**
  70086. * Defines the physics engine scene component responsible to manage a physics engine
  70087. */
  70088. export class PhysicsEngineSceneComponent implements ISceneComponent {
  70089. /**
  70090. * The component name helpful to identify the component in the list of scene components.
  70091. */
  70092. readonly name: string;
  70093. /**
  70094. * The scene the component belongs to.
  70095. */
  70096. scene: Scene;
  70097. /**
  70098. * Creates a new instance of the component for the given scene
  70099. * @param scene Defines the scene to register the component in
  70100. */
  70101. constructor(scene: Scene);
  70102. /**
  70103. * Registers the component in a given scene
  70104. */
  70105. register(): void;
  70106. /**
  70107. * Rebuilds the elements related to this component in case of
  70108. * context lost for instance.
  70109. */
  70110. rebuild(): void;
  70111. /**
  70112. * Disposes the component and the associated ressources
  70113. */
  70114. dispose(): void;
  70115. }
  70116. }
  70117. declare module "babylonjs/Physics/physicsHelper" {
  70118. import { Nullable } from "babylonjs/types";
  70119. import { Vector3 } from "babylonjs/Maths/math.vector";
  70120. import { Mesh } from "babylonjs/Meshes/mesh";
  70121. import { Scene } from "babylonjs/scene";
  70122. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  70123. /**
  70124. * A helper for physics simulations
  70125. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70126. */
  70127. export class PhysicsHelper {
  70128. private _scene;
  70129. private _physicsEngine;
  70130. /**
  70131. * Initializes the Physics helper
  70132. * @param scene Babylon.js scene
  70133. */
  70134. constructor(scene: Scene);
  70135. /**
  70136. * Applies a radial explosion impulse
  70137. * @param origin the origin of the explosion
  70138. * @param radiusOrEventOptions the radius or the options of radial explosion
  70139. * @param strength the explosion strength
  70140. * @param falloff possible options: Constant & Linear. Defaults to Constant
  70141. * @returns A physics radial explosion event, or null
  70142. */
  70143. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  70144. /**
  70145. * Applies a radial explosion force
  70146. * @param origin the origin of the explosion
  70147. * @param radiusOrEventOptions the radius or the options of radial explosion
  70148. * @param strength the explosion strength
  70149. * @param falloff possible options: Constant & Linear. Defaults to Constant
  70150. * @returns A physics radial explosion event, or null
  70151. */
  70152. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  70153. /**
  70154. * Creates a gravitational field
  70155. * @param origin the origin of the explosion
  70156. * @param radiusOrEventOptions the radius or the options of radial explosion
  70157. * @param strength the explosion strength
  70158. * @param falloff possible options: Constant & Linear. Defaults to Constant
  70159. * @returns A physics gravitational field event, or null
  70160. */
  70161. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  70162. /**
  70163. * Creates a physics updraft event
  70164. * @param origin the origin of the updraft
  70165. * @param radiusOrEventOptions the radius or the options of the updraft
  70166. * @param strength the strength of the updraft
  70167. * @param height the height of the updraft
  70168. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  70169. * @returns A physics updraft event, or null
  70170. */
  70171. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  70172. /**
  70173. * Creates a physics vortex event
  70174. * @param origin the of the vortex
  70175. * @param radiusOrEventOptions the radius or the options of the vortex
  70176. * @param strength the strength of the vortex
  70177. * @param height the height of the vortex
  70178. * @returns a Physics vortex event, or null
  70179. * A physics vortex event or null
  70180. */
  70181. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  70182. }
  70183. /**
  70184. * Represents a physics radial explosion event
  70185. */
  70186. class PhysicsRadialExplosionEvent {
  70187. private _scene;
  70188. private _options;
  70189. private _sphere;
  70190. private _dataFetched;
  70191. /**
  70192. * Initializes a radial explosioin event
  70193. * @param _scene BabylonJS scene
  70194. * @param _options The options for the vortex event
  70195. */
  70196. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  70197. /**
  70198. * Returns the data related to the radial explosion event (sphere).
  70199. * @returns The radial explosion event data
  70200. */
  70201. getData(): PhysicsRadialExplosionEventData;
  70202. /**
  70203. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  70204. * @param impostor A physics imposter
  70205. * @param origin the origin of the explosion
  70206. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  70207. */
  70208. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  70209. /**
  70210. * Triggers affecterd impostors callbacks
  70211. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  70212. */
  70213. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  70214. /**
  70215. * Disposes the sphere.
  70216. * @param force Specifies if the sphere should be disposed by force
  70217. */
  70218. dispose(force?: boolean): void;
  70219. /*** Helpers ***/
  70220. private _prepareSphere;
  70221. private _intersectsWithSphere;
  70222. }
  70223. /**
  70224. * Represents a gravitational field event
  70225. */
  70226. class PhysicsGravitationalFieldEvent {
  70227. private _physicsHelper;
  70228. private _scene;
  70229. private _origin;
  70230. private _options;
  70231. private _tickCallback;
  70232. private _sphere;
  70233. private _dataFetched;
  70234. /**
  70235. * Initializes the physics gravitational field event
  70236. * @param _physicsHelper A physics helper
  70237. * @param _scene BabylonJS scene
  70238. * @param _origin The origin position of the gravitational field event
  70239. * @param _options The options for the vortex event
  70240. */
  70241. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  70242. /**
  70243. * Returns the data related to the gravitational field event (sphere).
  70244. * @returns A gravitational field event
  70245. */
  70246. getData(): PhysicsGravitationalFieldEventData;
  70247. /**
  70248. * Enables the gravitational field.
  70249. */
  70250. enable(): void;
  70251. /**
  70252. * Disables the gravitational field.
  70253. */
  70254. disable(): void;
  70255. /**
  70256. * Disposes the sphere.
  70257. * @param force The force to dispose from the gravitational field event
  70258. */
  70259. dispose(force?: boolean): void;
  70260. private _tick;
  70261. }
  70262. /**
  70263. * Represents a physics updraft event
  70264. */
  70265. class PhysicsUpdraftEvent {
  70266. private _scene;
  70267. private _origin;
  70268. private _options;
  70269. private _physicsEngine;
  70270. private _originTop;
  70271. private _originDirection;
  70272. private _tickCallback;
  70273. private _cylinder;
  70274. private _cylinderPosition;
  70275. private _dataFetched;
  70276. /**
  70277. * Initializes the physics updraft event
  70278. * @param _scene BabylonJS scene
  70279. * @param _origin The origin position of the updraft
  70280. * @param _options The options for the updraft event
  70281. */
  70282. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  70283. /**
  70284. * Returns the data related to the updraft event (cylinder).
  70285. * @returns A physics updraft event
  70286. */
  70287. getData(): PhysicsUpdraftEventData;
  70288. /**
  70289. * Enables the updraft.
  70290. */
  70291. enable(): void;
  70292. /**
  70293. * Disables the updraft.
  70294. */
  70295. disable(): void;
  70296. /**
  70297. * Disposes the cylinder.
  70298. * @param force Specifies if the updraft should be disposed by force
  70299. */
  70300. dispose(force?: boolean): void;
  70301. private getImpostorHitData;
  70302. private _tick;
  70303. /*** Helpers ***/
  70304. private _prepareCylinder;
  70305. private _intersectsWithCylinder;
  70306. }
  70307. /**
  70308. * Represents a physics vortex event
  70309. */
  70310. class PhysicsVortexEvent {
  70311. private _scene;
  70312. private _origin;
  70313. private _options;
  70314. private _physicsEngine;
  70315. private _originTop;
  70316. private _tickCallback;
  70317. private _cylinder;
  70318. private _cylinderPosition;
  70319. private _dataFetched;
  70320. /**
  70321. * Initializes the physics vortex event
  70322. * @param _scene The BabylonJS scene
  70323. * @param _origin The origin position of the vortex
  70324. * @param _options The options for the vortex event
  70325. */
  70326. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  70327. /**
  70328. * Returns the data related to the vortex event (cylinder).
  70329. * @returns The physics vortex event data
  70330. */
  70331. getData(): PhysicsVortexEventData;
  70332. /**
  70333. * Enables the vortex.
  70334. */
  70335. enable(): void;
  70336. /**
  70337. * Disables the cortex.
  70338. */
  70339. disable(): void;
  70340. /**
  70341. * Disposes the sphere.
  70342. * @param force
  70343. */
  70344. dispose(force?: boolean): void;
  70345. private getImpostorHitData;
  70346. private _tick;
  70347. /*** Helpers ***/
  70348. private _prepareCylinder;
  70349. private _intersectsWithCylinder;
  70350. }
  70351. /**
  70352. * Options fot the radial explosion event
  70353. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70354. */
  70355. export class PhysicsRadialExplosionEventOptions {
  70356. /**
  70357. * The radius of the sphere for the radial explosion.
  70358. */
  70359. radius: number;
  70360. /**
  70361. * The strenth of the explosion.
  70362. */
  70363. strength: number;
  70364. /**
  70365. * The strenght of the force in correspondence to the distance of the affected object
  70366. */
  70367. falloff: PhysicsRadialImpulseFalloff;
  70368. /**
  70369. * Sphere options for the radial explosion.
  70370. */
  70371. sphere: {
  70372. segments: number;
  70373. diameter: number;
  70374. };
  70375. /**
  70376. * Sphere options for the radial explosion.
  70377. */
  70378. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  70379. }
  70380. /**
  70381. * Options fot the updraft event
  70382. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70383. */
  70384. export class PhysicsUpdraftEventOptions {
  70385. /**
  70386. * The radius of the cylinder for the vortex
  70387. */
  70388. radius: number;
  70389. /**
  70390. * The strenth of the updraft.
  70391. */
  70392. strength: number;
  70393. /**
  70394. * The height of the cylinder for the updraft.
  70395. */
  70396. height: number;
  70397. /**
  70398. * The mode for the the updraft.
  70399. */
  70400. updraftMode: PhysicsUpdraftMode;
  70401. }
  70402. /**
  70403. * Options fot the vortex event
  70404. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70405. */
  70406. export class PhysicsVortexEventOptions {
  70407. /**
  70408. * The radius of the cylinder for the vortex
  70409. */
  70410. radius: number;
  70411. /**
  70412. * The strenth of the vortex.
  70413. */
  70414. strength: number;
  70415. /**
  70416. * The height of the cylinder for the vortex.
  70417. */
  70418. height: number;
  70419. /**
  70420. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  70421. */
  70422. centripetalForceThreshold: number;
  70423. /**
  70424. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  70425. */
  70426. centripetalForceMultiplier: number;
  70427. /**
  70428. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  70429. */
  70430. centrifugalForceMultiplier: number;
  70431. /**
  70432. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  70433. */
  70434. updraftForceMultiplier: number;
  70435. }
  70436. /**
  70437. * The strenght of the force in correspondence to the distance of the affected object
  70438. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70439. */
  70440. export enum PhysicsRadialImpulseFalloff {
  70441. /** Defines that impulse is constant in strength across it's whole radius */
  70442. Constant = 0,
  70443. /** Defines that impulse gets weaker if it's further from the origin */
  70444. Linear = 1
  70445. }
  70446. /**
  70447. * The strength of the force in correspondence to the distance of the affected object
  70448. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70449. */
  70450. export enum PhysicsUpdraftMode {
  70451. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  70452. Center = 0,
  70453. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  70454. Perpendicular = 1
  70455. }
  70456. /**
  70457. * Interface for a physics hit data
  70458. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70459. */
  70460. export interface PhysicsHitData {
  70461. /**
  70462. * The force applied at the contact point
  70463. */
  70464. force: Vector3;
  70465. /**
  70466. * The contact point
  70467. */
  70468. contactPoint: Vector3;
  70469. /**
  70470. * The distance from the origin to the contact point
  70471. */
  70472. distanceFromOrigin: number;
  70473. }
  70474. /**
  70475. * Interface for radial explosion event data
  70476. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70477. */
  70478. export interface PhysicsRadialExplosionEventData {
  70479. /**
  70480. * A sphere used for the radial explosion event
  70481. */
  70482. sphere: Mesh;
  70483. }
  70484. /**
  70485. * Interface for gravitational field event data
  70486. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70487. */
  70488. export interface PhysicsGravitationalFieldEventData {
  70489. /**
  70490. * A sphere mesh used for the gravitational field event
  70491. */
  70492. sphere: Mesh;
  70493. }
  70494. /**
  70495. * Interface for updraft event data
  70496. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70497. */
  70498. export interface PhysicsUpdraftEventData {
  70499. /**
  70500. * A cylinder used for the updraft event
  70501. */
  70502. cylinder: Mesh;
  70503. }
  70504. /**
  70505. * Interface for vortex event data
  70506. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70507. */
  70508. export interface PhysicsVortexEventData {
  70509. /**
  70510. * A cylinder used for the vortex event
  70511. */
  70512. cylinder: Mesh;
  70513. }
  70514. /**
  70515. * Interface for an affected physics impostor
  70516. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70517. */
  70518. export interface PhysicsAffectedImpostorWithData {
  70519. /**
  70520. * The impostor affected by the effect
  70521. */
  70522. impostor: PhysicsImpostor;
  70523. /**
  70524. * The data about the hit/horce from the explosion
  70525. */
  70526. hitData: PhysicsHitData;
  70527. }
  70528. }
  70529. declare module "babylonjs/Physics/Plugins/index" {
  70530. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  70531. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  70532. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  70533. }
  70534. declare module "babylonjs/Physics/index" {
  70535. export * from "babylonjs/Physics/IPhysicsEngine";
  70536. export * from "babylonjs/Physics/physicsEngine";
  70537. export * from "babylonjs/Physics/physicsEngineComponent";
  70538. export * from "babylonjs/Physics/physicsHelper";
  70539. export * from "babylonjs/Physics/physicsImpostor";
  70540. export * from "babylonjs/Physics/physicsJoint";
  70541. export * from "babylonjs/Physics/Plugins/index";
  70542. }
  70543. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  70544. /** @hidden */
  70545. export var blackAndWhitePixelShader: {
  70546. name: string;
  70547. shader: string;
  70548. };
  70549. }
  70550. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  70551. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  70552. import { Camera } from "babylonjs/Cameras/camera";
  70553. import { Engine } from "babylonjs/Engines/engine";
  70554. import "babylonjs/Shaders/blackAndWhite.fragment";
  70555. /**
  70556. * Post process used to render in black and white
  70557. */
  70558. export class BlackAndWhitePostProcess extends PostProcess {
  70559. /**
  70560. * Linear about to convert he result to black and white (default: 1)
  70561. */
  70562. degree: number;
  70563. /**
  70564. * Creates a black and white post process
  70565. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  70566. * @param name The name of the effect.
  70567. * @param options The required width/height ratio to downsize to before computing the render pass.
  70568. * @param camera The camera to apply the render pass to.
  70569. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70570. * @param engine The engine which the post process will be applied. (default: current engine)
  70571. * @param reusable If the post process can be reused on the same frame. (default: false)
  70572. */
  70573. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70574. }
  70575. }
  70576. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  70577. import { Nullable } from "babylonjs/types";
  70578. import { Camera } from "babylonjs/Cameras/camera";
  70579. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  70580. import { Engine } from "babylonjs/Engines/engine";
  70581. /**
  70582. * This represents a set of one or more post processes in Babylon.
  70583. * A post process can be used to apply a shader to a texture after it is rendered.
  70584. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70585. */
  70586. export class PostProcessRenderEffect {
  70587. private _postProcesses;
  70588. private _getPostProcesses;
  70589. private _singleInstance;
  70590. private _cameras;
  70591. private _indicesForCamera;
  70592. /**
  70593. * Name of the effect
  70594. * @hidden
  70595. */
  70596. _name: string;
  70597. /**
  70598. * Instantiates a post process render effect.
  70599. * A post process can be used to apply a shader to a texture after it is rendered.
  70600. * @param engine The engine the effect is tied to
  70601. * @param name The name of the effect
  70602. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  70603. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  70604. */
  70605. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  70606. /**
  70607. * Checks if all the post processes in the effect are supported.
  70608. */
  70609. get isSupported(): boolean;
  70610. /**
  70611. * Updates the current state of the effect
  70612. * @hidden
  70613. */
  70614. _update(): void;
  70615. /**
  70616. * Attaches the effect on cameras
  70617. * @param cameras The camera to attach to.
  70618. * @hidden
  70619. */
  70620. _attachCameras(cameras: Camera): void;
  70621. /**
  70622. * Attaches the effect on cameras
  70623. * @param cameras The camera to attach to.
  70624. * @hidden
  70625. */
  70626. _attachCameras(cameras: Camera[]): void;
  70627. /**
  70628. * Detaches the effect on cameras
  70629. * @param cameras The camera to detatch from.
  70630. * @hidden
  70631. */
  70632. _detachCameras(cameras: Camera): void;
  70633. /**
  70634. * Detatches the effect on cameras
  70635. * @param cameras The camera to detatch from.
  70636. * @hidden
  70637. */
  70638. _detachCameras(cameras: Camera[]): void;
  70639. /**
  70640. * Enables the effect on given cameras
  70641. * @param cameras The camera to enable.
  70642. * @hidden
  70643. */
  70644. _enable(cameras: Camera): void;
  70645. /**
  70646. * Enables the effect on given cameras
  70647. * @param cameras The camera to enable.
  70648. * @hidden
  70649. */
  70650. _enable(cameras: Nullable<Camera[]>): void;
  70651. /**
  70652. * Disables the effect on the given cameras
  70653. * @param cameras The camera to disable.
  70654. * @hidden
  70655. */
  70656. _disable(cameras: Camera): void;
  70657. /**
  70658. * Disables the effect on the given cameras
  70659. * @param cameras The camera to disable.
  70660. * @hidden
  70661. */
  70662. _disable(cameras: Nullable<Camera[]>): void;
  70663. /**
  70664. * Gets a list of the post processes contained in the effect.
  70665. * @param camera The camera to get the post processes on.
  70666. * @returns The list of the post processes in the effect.
  70667. */
  70668. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  70669. }
  70670. }
  70671. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  70672. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  70673. /** @hidden */
  70674. export var extractHighlightsPixelShader: {
  70675. name: string;
  70676. shader: string;
  70677. };
  70678. }
  70679. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  70680. import { Nullable } from "babylonjs/types";
  70681. import { Camera } from "babylonjs/Cameras/camera";
  70682. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  70683. import { Engine } from "babylonjs/Engines/engine";
  70684. import "babylonjs/Shaders/extractHighlights.fragment";
  70685. /**
  70686. * 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.
  70687. */
  70688. export class ExtractHighlightsPostProcess extends PostProcess {
  70689. /**
  70690. * The luminance threshold, pixels below this value will be set to black.
  70691. */
  70692. threshold: number;
  70693. /** @hidden */
  70694. _exposure: number;
  70695. /**
  70696. * Post process which has the input texture to be used when performing highlight extraction
  70697. * @hidden
  70698. */
  70699. _inputPostProcess: Nullable<PostProcess>;
  70700. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70701. }
  70702. }
  70703. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  70704. /** @hidden */
  70705. export var bloomMergePixelShader: {
  70706. name: string;
  70707. shader: string;
  70708. };
  70709. }
  70710. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  70711. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  70712. import { Nullable } from "babylonjs/types";
  70713. import { Engine } from "babylonjs/Engines/engine";
  70714. import { Camera } from "babylonjs/Cameras/camera";
  70715. import "babylonjs/Shaders/bloomMerge.fragment";
  70716. /**
  70717. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  70718. */
  70719. export class BloomMergePostProcess extends PostProcess {
  70720. /** Weight of the bloom to be added to the original input. */
  70721. weight: number;
  70722. /**
  70723. * Creates a new instance of @see BloomMergePostProcess
  70724. * @param name The name of the effect.
  70725. * @param originalFromInput Post process which's input will be used for the merge.
  70726. * @param blurred Blurred highlights post process which's output will be used.
  70727. * @param weight Weight of the bloom to be added to the original input.
  70728. * @param options The required width/height ratio to downsize to before computing the render pass.
  70729. * @param camera The camera to apply the render pass to.
  70730. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70731. * @param engine The engine which the post process will be applied. (default: current engine)
  70732. * @param reusable If the post process can be reused on the same frame. (default: false)
  70733. * @param textureType Type of textures used when performing the post process. (default: 0)
  70734. * @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)
  70735. */
  70736. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  70737. /** Weight of the bloom to be added to the original input. */
  70738. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70739. }
  70740. }
  70741. declare module "babylonjs/PostProcesses/bloomEffect" {
  70742. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  70743. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  70744. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  70745. import { Camera } from "babylonjs/Cameras/camera";
  70746. import { Scene } from "babylonjs/scene";
  70747. /**
  70748. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  70749. */
  70750. export class BloomEffect extends PostProcessRenderEffect {
  70751. private bloomScale;
  70752. /**
  70753. * @hidden Internal
  70754. */
  70755. _effects: Array<PostProcess>;
  70756. /**
  70757. * @hidden Internal
  70758. */
  70759. _downscale: ExtractHighlightsPostProcess;
  70760. private _blurX;
  70761. private _blurY;
  70762. private _merge;
  70763. /**
  70764. * The luminance threshold to find bright areas of the image to bloom.
  70765. */
  70766. get threshold(): number;
  70767. set threshold(value: number);
  70768. /**
  70769. * The strength of the bloom.
  70770. */
  70771. get weight(): number;
  70772. set weight(value: number);
  70773. /**
  70774. * Specifies the size of the bloom blur kernel, relative to the final output size
  70775. */
  70776. get kernel(): number;
  70777. set kernel(value: number);
  70778. /**
  70779. * Creates a new instance of @see BloomEffect
  70780. * @param scene The scene the effect belongs to.
  70781. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  70782. * @param bloomKernel The size of the kernel to be used when applying the blur.
  70783. * @param bloomWeight The the strength of bloom.
  70784. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  70785. * @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)
  70786. */
  70787. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  70788. /**
  70789. * Disposes each of the internal effects for a given camera.
  70790. * @param camera The camera to dispose the effect on.
  70791. */
  70792. disposeEffects(camera: Camera): void;
  70793. /**
  70794. * @hidden Internal
  70795. */
  70796. _updateEffects(): void;
  70797. /**
  70798. * Internal
  70799. * @returns if all the contained post processes are ready.
  70800. * @hidden
  70801. */
  70802. _isReady(): boolean;
  70803. }
  70804. }
  70805. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  70806. /** @hidden */
  70807. export var chromaticAberrationPixelShader: {
  70808. name: string;
  70809. shader: string;
  70810. };
  70811. }
  70812. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  70813. import { Vector2 } from "babylonjs/Maths/math.vector";
  70814. import { Nullable } from "babylonjs/types";
  70815. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  70816. import { Camera } from "babylonjs/Cameras/camera";
  70817. import { Engine } from "babylonjs/Engines/engine";
  70818. import "babylonjs/Shaders/chromaticAberration.fragment";
  70819. /**
  70820. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  70821. */
  70822. export class ChromaticAberrationPostProcess extends PostProcess {
  70823. /**
  70824. * The amount of seperation of rgb channels (default: 30)
  70825. */
  70826. aberrationAmount: number;
  70827. /**
  70828. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  70829. */
  70830. radialIntensity: number;
  70831. /**
  70832. * 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))
  70833. */
  70834. direction: Vector2;
  70835. /**
  70836. * 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))
  70837. */
  70838. centerPosition: Vector2;
  70839. /**
  70840. * Creates a new instance ChromaticAberrationPostProcess
  70841. * @param name The name of the effect.
  70842. * @param screenWidth The width of the screen to apply the effect on.
  70843. * @param screenHeight The height of the screen to apply the effect on.
  70844. * @param options The required width/height ratio to downsize to before computing the render pass.
  70845. * @param camera The camera to apply the render pass to.
  70846. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70847. * @param engine The engine which the post process will be applied. (default: current engine)
  70848. * @param reusable If the post process can be reused on the same frame. (default: false)
  70849. * @param textureType Type of textures used when performing the post process. (default: 0)
  70850. * @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)
  70851. */
  70852. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70853. }
  70854. }
  70855. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  70856. /** @hidden */
  70857. export var circleOfConfusionPixelShader: {
  70858. name: string;
  70859. shader: string;
  70860. };
  70861. }
  70862. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  70863. import { Nullable } from "babylonjs/types";
  70864. import { Engine } from "babylonjs/Engines/engine";
  70865. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  70866. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  70867. import { Camera } from "babylonjs/Cameras/camera";
  70868. import "babylonjs/Shaders/circleOfConfusion.fragment";
  70869. /**
  70870. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  70871. */
  70872. export class CircleOfConfusionPostProcess extends PostProcess {
  70873. /**
  70874. * 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.
  70875. */
  70876. lensSize: number;
  70877. /**
  70878. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  70879. */
  70880. fStop: number;
  70881. /**
  70882. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  70883. */
  70884. focusDistance: number;
  70885. /**
  70886. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  70887. */
  70888. focalLength: number;
  70889. private _depthTexture;
  70890. /**
  70891. * Creates a new instance CircleOfConfusionPostProcess
  70892. * @param name The name of the effect.
  70893. * @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.
  70894. * @param options The required width/height ratio to downsize to before computing the render pass.
  70895. * @param camera The camera to apply the render pass to.
  70896. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70897. * @param engine The engine which the post process will be applied. (default: current engine)
  70898. * @param reusable If the post process can be reused on the same frame. (default: false)
  70899. * @param textureType Type of textures used when performing the post process. (default: 0)
  70900. * @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)
  70901. */
  70902. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70903. /**
  70904. * 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.
  70905. */
  70906. set depthTexture(value: RenderTargetTexture);
  70907. }
  70908. }
  70909. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  70910. /** @hidden */
  70911. export var colorCorrectionPixelShader: {
  70912. name: string;
  70913. shader: string;
  70914. };
  70915. }
  70916. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  70917. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  70918. import { Engine } from "babylonjs/Engines/engine";
  70919. import { Camera } from "babylonjs/Cameras/camera";
  70920. import "babylonjs/Shaders/colorCorrection.fragment";
  70921. /**
  70922. *
  70923. * This post-process allows the modification of rendered colors by using
  70924. * a 'look-up table' (LUT). This effect is also called Color Grading.
  70925. *
  70926. * The object needs to be provided an url to a texture containing the color
  70927. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  70928. * Use an image editing software to tweak the LUT to match your needs.
  70929. *
  70930. * For an example of a color LUT, see here:
  70931. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  70932. * For explanations on color grading, see here:
  70933. * @see http://udn.epicgames.com/Three/ColorGrading.html
  70934. *
  70935. */
  70936. export class ColorCorrectionPostProcess extends PostProcess {
  70937. private _colorTableTexture;
  70938. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70939. }
  70940. }
  70941. declare module "babylonjs/Shaders/convolution.fragment" {
  70942. /** @hidden */
  70943. export var convolutionPixelShader: {
  70944. name: string;
  70945. shader: string;
  70946. };
  70947. }
  70948. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  70949. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  70950. import { Nullable } from "babylonjs/types";
  70951. import { Camera } from "babylonjs/Cameras/camera";
  70952. import { Engine } from "babylonjs/Engines/engine";
  70953. import "babylonjs/Shaders/convolution.fragment";
  70954. /**
  70955. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  70956. * input texture to perform effects such as edge detection or sharpening
  70957. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  70958. */
  70959. export class ConvolutionPostProcess extends PostProcess {
  70960. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  70961. kernel: number[];
  70962. /**
  70963. * Creates a new instance ConvolutionPostProcess
  70964. * @param name The name of the effect.
  70965. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  70966. * @param options The required width/height ratio to downsize to before computing the render pass.
  70967. * @param camera The camera to apply the render pass to.
  70968. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70969. * @param engine The engine which the post process will be applied. (default: current engine)
  70970. * @param reusable If the post process can be reused on the same frame. (default: false)
  70971. * @param textureType Type of textures used when performing the post process. (default: 0)
  70972. */
  70973. constructor(name: string,
  70974. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  70975. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  70976. /**
  70977. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70978. */
  70979. static EdgeDetect0Kernel: number[];
  70980. /**
  70981. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70982. */
  70983. static EdgeDetect1Kernel: number[];
  70984. /**
  70985. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70986. */
  70987. static EdgeDetect2Kernel: number[];
  70988. /**
  70989. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70990. */
  70991. static SharpenKernel: number[];
  70992. /**
  70993. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70994. */
  70995. static EmbossKernel: number[];
  70996. /**
  70997. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70998. */
  70999. static GaussianKernel: number[];
  71000. }
  71001. }
  71002. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  71003. import { Nullable } from "babylonjs/types";
  71004. import { Vector2 } from "babylonjs/Maths/math.vector";
  71005. import { Camera } from "babylonjs/Cameras/camera";
  71006. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71007. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  71008. import { Engine } from "babylonjs/Engines/engine";
  71009. import { Scene } from "babylonjs/scene";
  71010. /**
  71011. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  71012. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  71013. * based on samples that have a large difference in distance than the center pixel.
  71014. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  71015. */
  71016. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  71017. direction: Vector2;
  71018. /**
  71019. * Creates a new instance CircleOfConfusionPostProcess
  71020. * @param name The name of the effect.
  71021. * @param scene The scene the effect belongs to.
  71022. * @param direction The direction the blur should be applied.
  71023. * @param kernel The size of the kernel used to blur.
  71024. * @param options The required width/height ratio to downsize to before computing the render pass.
  71025. * @param camera The camera to apply the render pass to.
  71026. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  71027. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  71028. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71029. * @param engine The engine which the post process will be applied. (default: current engine)
  71030. * @param reusable If the post process can be reused on the same frame. (default: false)
  71031. * @param textureType Type of textures used when performing the post process. (default: 0)
  71032. * @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)
  71033. */
  71034. 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);
  71035. }
  71036. }
  71037. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  71038. /** @hidden */
  71039. export var depthOfFieldMergePixelShader: {
  71040. name: string;
  71041. shader: string;
  71042. };
  71043. }
  71044. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  71045. import { Nullable } from "babylonjs/types";
  71046. import { Camera } from "babylonjs/Cameras/camera";
  71047. import { Effect } from "babylonjs/Materials/effect";
  71048. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71049. import { Engine } from "babylonjs/Engines/engine";
  71050. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  71051. /**
  71052. * Options to be set when merging outputs from the default pipeline.
  71053. */
  71054. export class DepthOfFieldMergePostProcessOptions {
  71055. /**
  71056. * The original image to merge on top of
  71057. */
  71058. originalFromInput: PostProcess;
  71059. /**
  71060. * Parameters to perform the merge of the depth of field effect
  71061. */
  71062. depthOfField?: {
  71063. circleOfConfusion: PostProcess;
  71064. blurSteps: Array<PostProcess>;
  71065. };
  71066. /**
  71067. * Parameters to perform the merge of bloom effect
  71068. */
  71069. bloom?: {
  71070. blurred: PostProcess;
  71071. weight: number;
  71072. };
  71073. }
  71074. /**
  71075. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  71076. */
  71077. export class DepthOfFieldMergePostProcess extends PostProcess {
  71078. private blurSteps;
  71079. /**
  71080. * Creates a new instance of DepthOfFieldMergePostProcess
  71081. * @param name The name of the effect.
  71082. * @param originalFromInput Post process which's input will be used for the merge.
  71083. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  71084. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  71085. * @param options The required width/height ratio to downsize to before computing the render pass.
  71086. * @param camera The camera to apply the render pass to.
  71087. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71088. * @param engine The engine which the post process will be applied. (default: current engine)
  71089. * @param reusable If the post process can be reused on the same frame. (default: false)
  71090. * @param textureType Type of textures used when performing the post process. (default: 0)
  71091. * @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)
  71092. */
  71093. 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);
  71094. /**
  71095. * Updates the effect with the current post process compile time values and recompiles the shader.
  71096. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  71097. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  71098. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  71099. * @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
  71100. * @param onCompiled Called when the shader has been compiled.
  71101. * @param onError Called if there is an error when compiling a shader.
  71102. */
  71103. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  71104. }
  71105. }
  71106. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  71107. import { Nullable } from "babylonjs/types";
  71108. import { Camera } from "babylonjs/Cameras/camera";
  71109. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  71110. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  71111. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  71112. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  71113. import { Scene } from "babylonjs/scene";
  71114. /**
  71115. * Specifies the level of max blur that should be applied when using the depth of field effect
  71116. */
  71117. export enum DepthOfFieldEffectBlurLevel {
  71118. /**
  71119. * Subtle blur
  71120. */
  71121. Low = 0,
  71122. /**
  71123. * Medium blur
  71124. */
  71125. Medium = 1,
  71126. /**
  71127. * Large blur
  71128. */
  71129. High = 2
  71130. }
  71131. /**
  71132. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  71133. */
  71134. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  71135. private _circleOfConfusion;
  71136. /**
  71137. * @hidden Internal, blurs from high to low
  71138. */
  71139. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  71140. private _depthOfFieldBlurY;
  71141. private _dofMerge;
  71142. /**
  71143. * @hidden Internal post processes in depth of field effect
  71144. */
  71145. _effects: Array<PostProcess>;
  71146. /**
  71147. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  71148. */
  71149. set focalLength(value: number);
  71150. get focalLength(): number;
  71151. /**
  71152. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  71153. */
  71154. set fStop(value: number);
  71155. get fStop(): number;
  71156. /**
  71157. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  71158. */
  71159. set focusDistance(value: number);
  71160. get focusDistance(): number;
  71161. /**
  71162. * 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.
  71163. */
  71164. set lensSize(value: number);
  71165. get lensSize(): number;
  71166. /**
  71167. * Creates a new instance DepthOfFieldEffect
  71168. * @param scene The scene the effect belongs to.
  71169. * @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.
  71170. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  71171. * @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)
  71172. */
  71173. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  71174. /**
  71175. * Get the current class name of the current effet
  71176. * @returns "DepthOfFieldEffect"
  71177. */
  71178. getClassName(): string;
  71179. /**
  71180. * 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.
  71181. */
  71182. set depthTexture(value: RenderTargetTexture);
  71183. /**
  71184. * Disposes each of the internal effects for a given camera.
  71185. * @param camera The camera to dispose the effect on.
  71186. */
  71187. disposeEffects(camera: Camera): void;
  71188. /**
  71189. * @hidden Internal
  71190. */
  71191. _updateEffects(): void;
  71192. /**
  71193. * Internal
  71194. * @returns if all the contained post processes are ready.
  71195. * @hidden
  71196. */
  71197. _isReady(): boolean;
  71198. }
  71199. }
  71200. declare module "babylonjs/Shaders/displayPass.fragment" {
  71201. /** @hidden */
  71202. export var displayPassPixelShader: {
  71203. name: string;
  71204. shader: string;
  71205. };
  71206. }
  71207. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  71208. import { Nullable } from "babylonjs/types";
  71209. import { Camera } from "babylonjs/Cameras/camera";
  71210. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71211. import { Engine } from "babylonjs/Engines/engine";
  71212. import "babylonjs/Shaders/displayPass.fragment";
  71213. /**
  71214. * DisplayPassPostProcess which produces an output the same as it's input
  71215. */
  71216. export class DisplayPassPostProcess extends PostProcess {
  71217. /**
  71218. * Creates the DisplayPassPostProcess
  71219. * @param name The name of the effect.
  71220. * @param options The required width/height ratio to downsize to before computing the render pass.
  71221. * @param camera The camera to apply the render pass to.
  71222. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71223. * @param engine The engine which the post process will be applied. (default: current engine)
  71224. * @param reusable If the post process can be reused on the same frame. (default: false)
  71225. */
  71226. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  71227. }
  71228. }
  71229. declare module "babylonjs/Shaders/filter.fragment" {
  71230. /** @hidden */
  71231. export var filterPixelShader: {
  71232. name: string;
  71233. shader: string;
  71234. };
  71235. }
  71236. declare module "babylonjs/PostProcesses/filterPostProcess" {
  71237. import { Nullable } from "babylonjs/types";
  71238. import { Matrix } from "babylonjs/Maths/math.vector";
  71239. import { Camera } from "babylonjs/Cameras/camera";
  71240. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71241. import { Engine } from "babylonjs/Engines/engine";
  71242. import "babylonjs/Shaders/filter.fragment";
  71243. /**
  71244. * Applies a kernel filter to the image
  71245. */
  71246. export class FilterPostProcess extends PostProcess {
  71247. /** The matrix to be applied to the image */
  71248. kernelMatrix: Matrix;
  71249. /**
  71250. *
  71251. * @param name The name of the effect.
  71252. * @param kernelMatrix The matrix to be applied to the image
  71253. * @param options The required width/height ratio to downsize to before computing the render pass.
  71254. * @param camera The camera to apply the render pass to.
  71255. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71256. * @param engine The engine which the post process will be applied. (default: current engine)
  71257. * @param reusable If the post process can be reused on the same frame. (default: false)
  71258. */
  71259. constructor(name: string,
  71260. /** The matrix to be applied to the image */
  71261. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  71262. }
  71263. }
  71264. declare module "babylonjs/Shaders/fxaa.fragment" {
  71265. /** @hidden */
  71266. export var fxaaPixelShader: {
  71267. name: string;
  71268. shader: string;
  71269. };
  71270. }
  71271. declare module "babylonjs/Shaders/fxaa.vertex" {
  71272. /** @hidden */
  71273. export var fxaaVertexShader: {
  71274. name: string;
  71275. shader: string;
  71276. };
  71277. }
  71278. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  71279. import { Nullable } from "babylonjs/types";
  71280. import { Camera } from "babylonjs/Cameras/camera";
  71281. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71282. import { Engine } from "babylonjs/Engines/engine";
  71283. import "babylonjs/Shaders/fxaa.fragment";
  71284. import "babylonjs/Shaders/fxaa.vertex";
  71285. /**
  71286. * Fxaa post process
  71287. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  71288. */
  71289. export class FxaaPostProcess extends PostProcess {
  71290. /** @hidden */
  71291. texelWidth: number;
  71292. /** @hidden */
  71293. texelHeight: number;
  71294. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  71295. private _getDefines;
  71296. }
  71297. }
  71298. declare module "babylonjs/Shaders/grain.fragment" {
  71299. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  71300. /** @hidden */
  71301. export var grainPixelShader: {
  71302. name: string;
  71303. shader: string;
  71304. };
  71305. }
  71306. declare module "babylonjs/PostProcesses/grainPostProcess" {
  71307. import { Nullable } from "babylonjs/types";
  71308. import { Camera } from "babylonjs/Cameras/camera";
  71309. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71310. import { Engine } from "babylonjs/Engines/engine";
  71311. import "babylonjs/Shaders/grain.fragment";
  71312. /**
  71313. * The GrainPostProcess adds noise to the image at mid luminance levels
  71314. */
  71315. export class GrainPostProcess extends PostProcess {
  71316. /**
  71317. * The intensity of the grain added (default: 30)
  71318. */
  71319. intensity: number;
  71320. /**
  71321. * If the grain should be randomized on every frame
  71322. */
  71323. animated: boolean;
  71324. /**
  71325. * Creates a new instance of @see GrainPostProcess
  71326. * @param name The name of the effect.
  71327. * @param options The required width/height ratio to downsize to before computing the render pass.
  71328. * @param camera The camera to apply the render pass to.
  71329. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71330. * @param engine The engine which the post process will be applied. (default: current engine)
  71331. * @param reusable If the post process can be reused on the same frame. (default: false)
  71332. * @param textureType Type of textures used when performing the post process. (default: 0)
  71333. * @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)
  71334. */
  71335. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71336. }
  71337. }
  71338. declare module "babylonjs/Shaders/highlights.fragment" {
  71339. /** @hidden */
  71340. export var highlightsPixelShader: {
  71341. name: string;
  71342. shader: string;
  71343. };
  71344. }
  71345. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  71346. import { Nullable } from "babylonjs/types";
  71347. import { Camera } from "babylonjs/Cameras/camera";
  71348. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71349. import { Engine } from "babylonjs/Engines/engine";
  71350. import "babylonjs/Shaders/highlights.fragment";
  71351. /**
  71352. * Extracts highlights from the image
  71353. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  71354. */
  71355. export class HighlightsPostProcess extends PostProcess {
  71356. /**
  71357. * Extracts highlights from the image
  71358. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  71359. * @param name The name of the effect.
  71360. * @param options The required width/height ratio to downsize to before computing the render pass.
  71361. * @param camera The camera to apply the render pass to.
  71362. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71363. * @param engine The engine which the post process will be applied. (default: current engine)
  71364. * @param reusable If the post process can be reused on the same frame. (default: false)
  71365. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  71366. */
  71367. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  71368. }
  71369. }
  71370. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  71371. /** @hidden */
  71372. export var mrtFragmentDeclaration: {
  71373. name: string;
  71374. shader: string;
  71375. };
  71376. }
  71377. declare module "babylonjs/Shaders/geometry.fragment" {
  71378. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  71379. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  71380. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  71381. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  71382. /** @hidden */
  71383. export var geometryPixelShader: {
  71384. name: string;
  71385. shader: string;
  71386. };
  71387. }
  71388. declare module "babylonjs/Shaders/geometry.vertex" {
  71389. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  71390. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  71391. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  71392. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  71393. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  71394. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  71395. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  71396. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  71397. /** @hidden */
  71398. export var geometryVertexShader: {
  71399. name: string;
  71400. shader: string;
  71401. };
  71402. }
  71403. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  71404. import { Matrix } from "babylonjs/Maths/math.vector";
  71405. import { SubMesh } from "babylonjs/Meshes/subMesh";
  71406. import { Mesh } from "babylonjs/Meshes/mesh";
  71407. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  71408. import { Effect } from "babylonjs/Materials/effect";
  71409. import { Scene } from "babylonjs/scene";
  71410. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  71411. import "babylonjs/Shaders/geometry.fragment";
  71412. import "babylonjs/Shaders/geometry.vertex";
  71413. /** @hidden */
  71414. interface ISavedTransformationMatrix {
  71415. world: Matrix;
  71416. viewProjection: Matrix;
  71417. }
  71418. /**
  71419. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  71420. */
  71421. export class GeometryBufferRenderer {
  71422. /**
  71423. * Constant used to retrieve the position texture index in the G-Buffer textures array
  71424. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  71425. */
  71426. static readonly POSITION_TEXTURE_TYPE: number;
  71427. /**
  71428. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  71429. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  71430. */
  71431. static readonly VELOCITY_TEXTURE_TYPE: number;
  71432. /**
  71433. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  71434. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  71435. */
  71436. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  71437. /**
  71438. * Dictionary used to store the previous transformation matrices of each rendered mesh
  71439. * in order to compute objects velocities when enableVelocity is set to "true"
  71440. * @hidden
  71441. */
  71442. _previousTransformationMatrices: {
  71443. [index: number]: ISavedTransformationMatrix;
  71444. };
  71445. /**
  71446. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  71447. * in order to compute objects velocities when enableVelocity is set to "true"
  71448. * @hidden
  71449. */
  71450. _previousBonesTransformationMatrices: {
  71451. [index: number]: Float32Array;
  71452. };
  71453. /**
  71454. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  71455. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  71456. */
  71457. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  71458. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  71459. renderTransparentMeshes: boolean;
  71460. private _scene;
  71461. private _multiRenderTarget;
  71462. private _ratio;
  71463. private _enablePosition;
  71464. private _enableVelocity;
  71465. private _enableReflectivity;
  71466. private _positionIndex;
  71467. private _velocityIndex;
  71468. private _reflectivityIndex;
  71469. protected _effect: Effect;
  71470. protected _cachedDefines: string;
  71471. /**
  71472. * Set the render list (meshes to be rendered) used in the G buffer.
  71473. */
  71474. set renderList(meshes: Mesh[]);
  71475. /**
  71476. * Gets wether or not G buffer are supported by the running hardware.
  71477. * This requires draw buffer supports
  71478. */
  71479. get isSupported(): boolean;
  71480. /**
  71481. * Returns the index of the given texture type in the G-Buffer textures array
  71482. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  71483. * @returns the index of the given texture type in the G-Buffer textures array
  71484. */
  71485. getTextureIndex(textureType: number): number;
  71486. /**
  71487. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  71488. */
  71489. get enablePosition(): boolean;
  71490. /**
  71491. * Sets whether or not objects positions are enabled for the G buffer.
  71492. */
  71493. set enablePosition(enable: boolean);
  71494. /**
  71495. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  71496. */
  71497. get enableVelocity(): boolean;
  71498. /**
  71499. * Sets wether or not objects velocities are enabled for the G buffer.
  71500. */
  71501. set enableVelocity(enable: boolean);
  71502. /**
  71503. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  71504. */
  71505. get enableReflectivity(): boolean;
  71506. /**
  71507. * Sets wether or not objects roughness are enabled for the G buffer.
  71508. */
  71509. set enableReflectivity(enable: boolean);
  71510. /**
  71511. * Gets the scene associated with the buffer.
  71512. */
  71513. get scene(): Scene;
  71514. /**
  71515. * Gets the ratio used by the buffer during its creation.
  71516. * How big is the buffer related to the main canvas.
  71517. */
  71518. get ratio(): number;
  71519. /** @hidden */
  71520. static _SceneComponentInitialization: (scene: Scene) => void;
  71521. /**
  71522. * Creates a new G Buffer for the scene
  71523. * @param scene The scene the buffer belongs to
  71524. * @param ratio How big is the buffer related to the main canvas.
  71525. */
  71526. constructor(scene: Scene, ratio?: number);
  71527. /**
  71528. * Checks wether everything is ready to render a submesh to the G buffer.
  71529. * @param subMesh the submesh to check readiness for
  71530. * @param useInstances is the mesh drawn using instance or not
  71531. * @returns true if ready otherwise false
  71532. */
  71533. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  71534. /**
  71535. * Gets the current underlying G Buffer.
  71536. * @returns the buffer
  71537. */
  71538. getGBuffer(): MultiRenderTarget;
  71539. /**
  71540. * Gets the number of samples used to render the buffer (anti aliasing).
  71541. */
  71542. get samples(): number;
  71543. /**
  71544. * Sets the number of samples used to render the buffer (anti aliasing).
  71545. */
  71546. set samples(value: number);
  71547. /**
  71548. * Disposes the renderer and frees up associated resources.
  71549. */
  71550. dispose(): void;
  71551. protected _createRenderTargets(): void;
  71552. private _copyBonesTransformationMatrices;
  71553. }
  71554. }
  71555. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  71556. import { Nullable } from "babylonjs/types";
  71557. import { Scene } from "babylonjs/scene";
  71558. import { ISceneComponent } from "babylonjs/sceneComponent";
  71559. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  71560. module "babylonjs/scene" {
  71561. interface Scene {
  71562. /** @hidden (Backing field) */
  71563. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  71564. /**
  71565. * Gets or Sets the current geometry buffer associated to the scene.
  71566. */
  71567. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  71568. /**
  71569. * Enables a GeometryBufferRender and associates it with the scene
  71570. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  71571. * @returns the GeometryBufferRenderer
  71572. */
  71573. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  71574. /**
  71575. * Disables the GeometryBufferRender associated with the scene
  71576. */
  71577. disableGeometryBufferRenderer(): void;
  71578. }
  71579. }
  71580. /**
  71581. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  71582. * in several rendering techniques.
  71583. */
  71584. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  71585. /**
  71586. * The component name helpful to identify the component in the list of scene components.
  71587. */
  71588. readonly name: string;
  71589. /**
  71590. * The scene the component belongs to.
  71591. */
  71592. scene: Scene;
  71593. /**
  71594. * Creates a new instance of the component for the given scene
  71595. * @param scene Defines the scene to register the component in
  71596. */
  71597. constructor(scene: Scene);
  71598. /**
  71599. * Registers the component in a given scene
  71600. */
  71601. register(): void;
  71602. /**
  71603. * Rebuilds the elements related to this component in case of
  71604. * context lost for instance.
  71605. */
  71606. rebuild(): void;
  71607. /**
  71608. * Disposes the component and the associated ressources
  71609. */
  71610. dispose(): void;
  71611. private _gatherRenderTargets;
  71612. }
  71613. }
  71614. declare module "babylonjs/Shaders/motionBlur.fragment" {
  71615. /** @hidden */
  71616. export var motionBlurPixelShader: {
  71617. name: string;
  71618. shader: string;
  71619. };
  71620. }
  71621. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  71622. import { Nullable } from "babylonjs/types";
  71623. import { Camera } from "babylonjs/Cameras/camera";
  71624. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71625. import { Scene } from "babylonjs/scene";
  71626. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  71627. import "babylonjs/Animations/animatable";
  71628. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  71629. import "babylonjs/Shaders/motionBlur.fragment";
  71630. import { Engine } from "babylonjs/Engines/engine";
  71631. /**
  71632. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  71633. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  71634. * As an example, all you have to do is to create the post-process:
  71635. * var mb = new BABYLON.MotionBlurPostProcess(
  71636. * 'mb', // The name of the effect.
  71637. * scene, // The scene containing the objects to blur according to their velocity.
  71638. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  71639. * camera // The camera to apply the render pass to.
  71640. * );
  71641. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  71642. */
  71643. export class MotionBlurPostProcess extends PostProcess {
  71644. /**
  71645. * Defines how much the image is blurred by the movement. Default value is equal to 1
  71646. */
  71647. motionStrength: number;
  71648. /**
  71649. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  71650. */
  71651. get motionBlurSamples(): number;
  71652. /**
  71653. * Sets the number of iterations to be used for motion blur quality
  71654. */
  71655. set motionBlurSamples(samples: number);
  71656. private _motionBlurSamples;
  71657. private _geometryBufferRenderer;
  71658. /**
  71659. * Creates a new instance MotionBlurPostProcess
  71660. * @param name The name of the effect.
  71661. * @param scene The scene containing the objects to blur according to their velocity.
  71662. * @param options The required width/height ratio to downsize to before computing the render pass.
  71663. * @param camera The camera to apply the render pass to.
  71664. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71665. * @param engine The engine which the post process will be applied. (default: current engine)
  71666. * @param reusable If the post process can be reused on the same frame. (default: false)
  71667. * @param textureType Type of textures used when performing the post process. (default: 0)
  71668. * @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)
  71669. */
  71670. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71671. /**
  71672. * Excludes the given skinned mesh from computing bones velocities.
  71673. * 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.
  71674. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  71675. */
  71676. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  71677. /**
  71678. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  71679. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  71680. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  71681. */
  71682. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  71683. /**
  71684. * Disposes the post process.
  71685. * @param camera The camera to dispose the post process on.
  71686. */
  71687. dispose(camera?: Camera): void;
  71688. }
  71689. }
  71690. declare module "babylonjs/Shaders/refraction.fragment" {
  71691. /** @hidden */
  71692. export var refractionPixelShader: {
  71693. name: string;
  71694. shader: string;
  71695. };
  71696. }
  71697. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  71698. import { Color3 } from "babylonjs/Maths/math.color";
  71699. import { Camera } from "babylonjs/Cameras/camera";
  71700. import { Texture } from "babylonjs/Materials/Textures/texture";
  71701. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71702. import { Engine } from "babylonjs/Engines/engine";
  71703. import "babylonjs/Shaders/refraction.fragment";
  71704. /**
  71705. * Post process which applies a refractin texture
  71706. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  71707. */
  71708. export class RefractionPostProcess extends PostProcess {
  71709. /** the base color of the refraction (used to taint the rendering) */
  71710. color: Color3;
  71711. /** simulated refraction depth */
  71712. depth: number;
  71713. /** the coefficient of the base color (0 to remove base color tainting) */
  71714. colorLevel: number;
  71715. private _refTexture;
  71716. private _ownRefractionTexture;
  71717. /**
  71718. * Gets or sets the refraction texture
  71719. * Please note that you are responsible for disposing the texture if you set it manually
  71720. */
  71721. get refractionTexture(): Texture;
  71722. set refractionTexture(value: Texture);
  71723. /**
  71724. * Initializes the RefractionPostProcess
  71725. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  71726. * @param name The name of the effect.
  71727. * @param refractionTextureUrl Url of the refraction texture to use
  71728. * @param color the base color of the refraction (used to taint the rendering)
  71729. * @param depth simulated refraction depth
  71730. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  71731. * @param camera The camera to apply the render pass to.
  71732. * @param options The required width/height ratio to downsize to before computing the render pass.
  71733. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71734. * @param engine The engine which the post process will be applied. (default: current engine)
  71735. * @param reusable If the post process can be reused on the same frame. (default: false)
  71736. */
  71737. constructor(name: string, refractionTextureUrl: string,
  71738. /** the base color of the refraction (used to taint the rendering) */
  71739. color: Color3,
  71740. /** simulated refraction depth */
  71741. depth: number,
  71742. /** the coefficient of the base color (0 to remove base color tainting) */
  71743. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  71744. /**
  71745. * Disposes of the post process
  71746. * @param camera Camera to dispose post process on
  71747. */
  71748. dispose(camera: Camera): void;
  71749. }
  71750. }
  71751. declare module "babylonjs/Shaders/sharpen.fragment" {
  71752. /** @hidden */
  71753. export var sharpenPixelShader: {
  71754. name: string;
  71755. shader: string;
  71756. };
  71757. }
  71758. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  71759. import { Nullable } from "babylonjs/types";
  71760. import { Camera } from "babylonjs/Cameras/camera";
  71761. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71762. import "babylonjs/Shaders/sharpen.fragment";
  71763. import { Engine } from "babylonjs/Engines/engine";
  71764. /**
  71765. * The SharpenPostProcess applies a sharpen kernel to every pixel
  71766. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  71767. */
  71768. export class SharpenPostProcess extends PostProcess {
  71769. /**
  71770. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  71771. */
  71772. colorAmount: number;
  71773. /**
  71774. * How much sharpness should be applied (default: 0.3)
  71775. */
  71776. edgeAmount: number;
  71777. /**
  71778. * Creates a new instance ConvolutionPostProcess
  71779. * @param name The name of the effect.
  71780. * @param options The required width/height ratio to downsize to before computing the render pass.
  71781. * @param camera The camera to apply the render pass to.
  71782. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71783. * @param engine The engine which the post process will be applied. (default: current engine)
  71784. * @param reusable If the post process can be reused on the same frame. (default: false)
  71785. * @param textureType Type of textures used when performing the post process. (default: 0)
  71786. * @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)
  71787. */
  71788. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71789. }
  71790. }
  71791. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  71792. import { Nullable } from "babylonjs/types";
  71793. import { Camera } from "babylonjs/Cameras/camera";
  71794. import { Engine } from "babylonjs/Engines/engine";
  71795. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  71796. import { IInspectable } from "babylonjs/Misc/iInspectable";
  71797. /**
  71798. * PostProcessRenderPipeline
  71799. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  71800. */
  71801. export class PostProcessRenderPipeline {
  71802. private engine;
  71803. private _renderEffects;
  71804. private _renderEffectsForIsolatedPass;
  71805. /**
  71806. * List of inspectable custom properties (used by the Inspector)
  71807. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  71808. */
  71809. inspectableCustomProperties: IInspectable[];
  71810. /**
  71811. * @hidden
  71812. */
  71813. protected _cameras: Camera[];
  71814. /** @hidden */
  71815. _name: string;
  71816. /**
  71817. * Gets pipeline name
  71818. */
  71819. get name(): string;
  71820. /** Gets the list of attached cameras */
  71821. get cameras(): Camera[];
  71822. /**
  71823. * Initializes a PostProcessRenderPipeline
  71824. * @param engine engine to add the pipeline to
  71825. * @param name name of the pipeline
  71826. */
  71827. constructor(engine: Engine, name: string);
  71828. /**
  71829. * Gets the class name
  71830. * @returns "PostProcessRenderPipeline"
  71831. */
  71832. getClassName(): string;
  71833. /**
  71834. * If all the render effects in the pipeline are supported
  71835. */
  71836. get isSupported(): boolean;
  71837. /**
  71838. * Adds an effect to the pipeline
  71839. * @param renderEffect the effect to add
  71840. */
  71841. addEffect(renderEffect: PostProcessRenderEffect): void;
  71842. /** @hidden */
  71843. _rebuild(): void;
  71844. /** @hidden */
  71845. _enableEffect(renderEffectName: string, cameras: Camera): void;
  71846. /** @hidden */
  71847. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  71848. /** @hidden */
  71849. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  71850. /** @hidden */
  71851. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  71852. /** @hidden */
  71853. _attachCameras(cameras: Camera, unique: boolean): void;
  71854. /** @hidden */
  71855. _attachCameras(cameras: Camera[], unique: boolean): void;
  71856. /** @hidden */
  71857. _detachCameras(cameras: Camera): void;
  71858. /** @hidden */
  71859. _detachCameras(cameras: Nullable<Camera[]>): void;
  71860. /** @hidden */
  71861. _update(): void;
  71862. /** @hidden */
  71863. _reset(): void;
  71864. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  71865. /**
  71866. * Disposes of the pipeline
  71867. */
  71868. dispose(): void;
  71869. }
  71870. }
  71871. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  71872. import { Camera } from "babylonjs/Cameras/camera";
  71873. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  71874. /**
  71875. * PostProcessRenderPipelineManager class
  71876. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  71877. */
  71878. export class PostProcessRenderPipelineManager {
  71879. private _renderPipelines;
  71880. /**
  71881. * Initializes a PostProcessRenderPipelineManager
  71882. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  71883. */
  71884. constructor();
  71885. /**
  71886. * Gets the list of supported render pipelines
  71887. */
  71888. get supportedPipelines(): PostProcessRenderPipeline[];
  71889. /**
  71890. * Adds a pipeline to the manager
  71891. * @param renderPipeline The pipeline to add
  71892. */
  71893. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  71894. /**
  71895. * Attaches a camera to the pipeline
  71896. * @param renderPipelineName The name of the pipeline to attach to
  71897. * @param cameras the camera to attach
  71898. * @param unique if the camera can be attached multiple times to the pipeline
  71899. */
  71900. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  71901. /**
  71902. * Detaches a camera from the pipeline
  71903. * @param renderPipelineName The name of the pipeline to detach from
  71904. * @param cameras the camera to detach
  71905. */
  71906. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  71907. /**
  71908. * Enables an effect by name on a pipeline
  71909. * @param renderPipelineName the name of the pipeline to enable the effect in
  71910. * @param renderEffectName the name of the effect to enable
  71911. * @param cameras the cameras that the effect should be enabled on
  71912. */
  71913. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  71914. /**
  71915. * Disables an effect by name on a pipeline
  71916. * @param renderPipelineName the name of the pipeline to disable the effect in
  71917. * @param renderEffectName the name of the effect to disable
  71918. * @param cameras the cameras that the effect should be disabled on
  71919. */
  71920. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  71921. /**
  71922. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  71923. */
  71924. update(): void;
  71925. /** @hidden */
  71926. _rebuild(): void;
  71927. /**
  71928. * Disposes of the manager and pipelines
  71929. */
  71930. dispose(): void;
  71931. }
  71932. }
  71933. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  71934. import { ISceneComponent } from "babylonjs/sceneComponent";
  71935. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  71936. import { Scene } from "babylonjs/scene";
  71937. module "babylonjs/scene" {
  71938. interface Scene {
  71939. /** @hidden (Backing field) */
  71940. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  71941. /**
  71942. * Gets the postprocess render pipeline manager
  71943. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  71944. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  71945. */
  71946. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  71947. }
  71948. }
  71949. /**
  71950. * Defines the Render Pipeline scene component responsible to rendering pipelines
  71951. */
  71952. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  71953. /**
  71954. * The component name helpfull to identify the component in the list of scene components.
  71955. */
  71956. readonly name: string;
  71957. /**
  71958. * The scene the component belongs to.
  71959. */
  71960. scene: Scene;
  71961. /**
  71962. * Creates a new instance of the component for the given scene
  71963. * @param scene Defines the scene to register the component in
  71964. */
  71965. constructor(scene: Scene);
  71966. /**
  71967. * Registers the component in a given scene
  71968. */
  71969. register(): void;
  71970. /**
  71971. * Rebuilds the elements related to this component in case of
  71972. * context lost for instance.
  71973. */
  71974. rebuild(): void;
  71975. /**
  71976. * Disposes the component and the associated ressources
  71977. */
  71978. dispose(): void;
  71979. private _gatherRenderTargets;
  71980. }
  71981. }
  71982. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  71983. import { Nullable } from "babylonjs/types";
  71984. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  71985. import { Camera } from "babylonjs/Cameras/camera";
  71986. import { IDisposable } from "babylonjs/scene";
  71987. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  71988. import { Scene } from "babylonjs/scene";
  71989. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  71990. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  71991. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  71992. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  71993. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  71994. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  71995. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  71996. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  71997. import { Animation } from "babylonjs/Animations/animation";
  71998. /**
  71999. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  72000. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  72001. */
  72002. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  72003. private _scene;
  72004. private _camerasToBeAttached;
  72005. /**
  72006. * ID of the sharpen post process,
  72007. */
  72008. private readonly SharpenPostProcessId;
  72009. /**
  72010. * @ignore
  72011. * ID of the image processing post process;
  72012. */
  72013. readonly ImageProcessingPostProcessId: string;
  72014. /**
  72015. * @ignore
  72016. * ID of the Fast Approximate Anti-Aliasing post process;
  72017. */
  72018. readonly FxaaPostProcessId: string;
  72019. /**
  72020. * ID of the chromatic aberration post process,
  72021. */
  72022. private readonly ChromaticAberrationPostProcessId;
  72023. /**
  72024. * ID of the grain post process
  72025. */
  72026. private readonly GrainPostProcessId;
  72027. /**
  72028. * Sharpen post process which will apply a sharpen convolution to enhance edges
  72029. */
  72030. sharpen: SharpenPostProcess;
  72031. private _sharpenEffect;
  72032. private bloom;
  72033. /**
  72034. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  72035. */
  72036. depthOfField: DepthOfFieldEffect;
  72037. /**
  72038. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  72039. */
  72040. fxaa: FxaaPostProcess;
  72041. /**
  72042. * Image post processing pass used to perform operations such as tone mapping or color grading.
  72043. */
  72044. imageProcessing: ImageProcessingPostProcess;
  72045. /**
  72046. * Chromatic aberration post process which will shift rgb colors in the image
  72047. */
  72048. chromaticAberration: ChromaticAberrationPostProcess;
  72049. private _chromaticAberrationEffect;
  72050. /**
  72051. * Grain post process which add noise to the image
  72052. */
  72053. grain: GrainPostProcess;
  72054. private _grainEffect;
  72055. /**
  72056. * Glow post process which adds a glow to emissive areas of the image
  72057. */
  72058. private _glowLayer;
  72059. /**
  72060. * Animations which can be used to tweak settings over a period of time
  72061. */
  72062. animations: Animation[];
  72063. private _imageProcessingConfigurationObserver;
  72064. private _sharpenEnabled;
  72065. private _bloomEnabled;
  72066. private _depthOfFieldEnabled;
  72067. private _depthOfFieldBlurLevel;
  72068. private _fxaaEnabled;
  72069. private _imageProcessingEnabled;
  72070. private _defaultPipelineTextureType;
  72071. private _bloomScale;
  72072. private _chromaticAberrationEnabled;
  72073. private _grainEnabled;
  72074. private _buildAllowed;
  72075. /**
  72076. * Gets active scene
  72077. */
  72078. get scene(): Scene;
  72079. /**
  72080. * Enable or disable the sharpen process from the pipeline
  72081. */
  72082. set sharpenEnabled(enabled: boolean);
  72083. get sharpenEnabled(): boolean;
  72084. private _resizeObserver;
  72085. private _hardwareScaleLevel;
  72086. private _bloomKernel;
  72087. /**
  72088. * Specifies the size of the bloom blur kernel, relative to the final output size
  72089. */
  72090. get bloomKernel(): number;
  72091. set bloomKernel(value: number);
  72092. /**
  72093. * Specifies the weight of the bloom in the final rendering
  72094. */
  72095. private _bloomWeight;
  72096. /**
  72097. * Specifies the luma threshold for the area that will be blurred by the bloom
  72098. */
  72099. private _bloomThreshold;
  72100. private _hdr;
  72101. /**
  72102. * The strength of the bloom.
  72103. */
  72104. set bloomWeight(value: number);
  72105. get bloomWeight(): number;
  72106. /**
  72107. * The strength of the bloom.
  72108. */
  72109. set bloomThreshold(value: number);
  72110. get bloomThreshold(): number;
  72111. /**
  72112. * The scale of the bloom, lower value will provide better performance.
  72113. */
  72114. set bloomScale(value: number);
  72115. get bloomScale(): number;
  72116. /**
  72117. * Enable or disable the bloom from the pipeline
  72118. */
  72119. set bloomEnabled(enabled: boolean);
  72120. get bloomEnabled(): boolean;
  72121. private _rebuildBloom;
  72122. /**
  72123. * If the depth of field is enabled.
  72124. */
  72125. get depthOfFieldEnabled(): boolean;
  72126. set depthOfFieldEnabled(enabled: boolean);
  72127. /**
  72128. * Blur level of the depth of field effect. (Higher blur will effect performance)
  72129. */
  72130. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  72131. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  72132. /**
  72133. * If the anti aliasing is enabled.
  72134. */
  72135. set fxaaEnabled(enabled: boolean);
  72136. get fxaaEnabled(): boolean;
  72137. private _samples;
  72138. /**
  72139. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  72140. */
  72141. set samples(sampleCount: number);
  72142. get samples(): number;
  72143. /**
  72144. * If image processing is enabled.
  72145. */
  72146. set imageProcessingEnabled(enabled: boolean);
  72147. get imageProcessingEnabled(): boolean;
  72148. /**
  72149. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  72150. */
  72151. set glowLayerEnabled(enabled: boolean);
  72152. get glowLayerEnabled(): boolean;
  72153. /**
  72154. * Gets the glow layer (or null if not defined)
  72155. */
  72156. get glowLayer(): Nullable<GlowLayer>;
  72157. /**
  72158. * Enable or disable the chromaticAberration process from the pipeline
  72159. */
  72160. set chromaticAberrationEnabled(enabled: boolean);
  72161. get chromaticAberrationEnabled(): boolean;
  72162. /**
  72163. * Enable or disable the grain process from the pipeline
  72164. */
  72165. set grainEnabled(enabled: boolean);
  72166. get grainEnabled(): boolean;
  72167. /**
  72168. * @constructor
  72169. * @param name - The rendering pipeline name (default: "")
  72170. * @param hdr - If high dynamic range textures should be used (default: true)
  72171. * @param scene - The scene linked to this pipeline (default: the last created scene)
  72172. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  72173. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  72174. */
  72175. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  72176. /**
  72177. * Get the class name
  72178. * @returns "DefaultRenderingPipeline"
  72179. */
  72180. getClassName(): string;
  72181. /**
  72182. * Force the compilation of the entire pipeline.
  72183. */
  72184. prepare(): void;
  72185. private _hasCleared;
  72186. private _prevPostProcess;
  72187. private _prevPrevPostProcess;
  72188. private _setAutoClearAndTextureSharing;
  72189. private _depthOfFieldSceneObserver;
  72190. private _buildPipeline;
  72191. private _disposePostProcesses;
  72192. /**
  72193. * Adds a camera to the pipeline
  72194. * @param camera the camera to be added
  72195. */
  72196. addCamera(camera: Camera): void;
  72197. /**
  72198. * Removes a camera from the pipeline
  72199. * @param camera the camera to remove
  72200. */
  72201. removeCamera(camera: Camera): void;
  72202. /**
  72203. * Dispose of the pipeline and stop all post processes
  72204. */
  72205. dispose(): void;
  72206. /**
  72207. * Serialize the rendering pipeline (Used when exporting)
  72208. * @returns the serialized object
  72209. */
  72210. serialize(): any;
  72211. /**
  72212. * Parse the serialized pipeline
  72213. * @param source Source pipeline.
  72214. * @param scene The scene to load the pipeline to.
  72215. * @param rootUrl The URL of the serialized pipeline.
  72216. * @returns An instantiated pipeline from the serialized object.
  72217. */
  72218. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  72219. }
  72220. }
  72221. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  72222. /** @hidden */
  72223. export var lensHighlightsPixelShader: {
  72224. name: string;
  72225. shader: string;
  72226. };
  72227. }
  72228. declare module "babylonjs/Shaders/depthOfField.fragment" {
  72229. /** @hidden */
  72230. export var depthOfFieldPixelShader: {
  72231. name: string;
  72232. shader: string;
  72233. };
  72234. }
  72235. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  72236. import { Camera } from "babylonjs/Cameras/camera";
  72237. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  72238. import { Scene } from "babylonjs/scene";
  72239. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  72240. import "babylonjs/Shaders/chromaticAberration.fragment";
  72241. import "babylonjs/Shaders/lensHighlights.fragment";
  72242. import "babylonjs/Shaders/depthOfField.fragment";
  72243. /**
  72244. * BABYLON.JS Chromatic Aberration GLSL Shader
  72245. * Author: Olivier Guyot
  72246. * Separates very slightly R, G and B colors on the edges of the screen
  72247. * Inspired by Francois Tarlier & Martins Upitis
  72248. */
  72249. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  72250. /**
  72251. * @ignore
  72252. * The chromatic aberration PostProcess id in the pipeline
  72253. */
  72254. LensChromaticAberrationEffect: string;
  72255. /**
  72256. * @ignore
  72257. * The highlights enhancing PostProcess id in the pipeline
  72258. */
  72259. HighlightsEnhancingEffect: string;
  72260. /**
  72261. * @ignore
  72262. * The depth-of-field PostProcess id in the pipeline
  72263. */
  72264. LensDepthOfFieldEffect: string;
  72265. private _scene;
  72266. private _depthTexture;
  72267. private _grainTexture;
  72268. private _chromaticAberrationPostProcess;
  72269. private _highlightsPostProcess;
  72270. private _depthOfFieldPostProcess;
  72271. private _edgeBlur;
  72272. private _grainAmount;
  72273. private _chromaticAberration;
  72274. private _distortion;
  72275. private _highlightsGain;
  72276. private _highlightsThreshold;
  72277. private _dofDistance;
  72278. private _dofAperture;
  72279. private _dofDarken;
  72280. private _dofPentagon;
  72281. private _blurNoise;
  72282. /**
  72283. * @constructor
  72284. *
  72285. * Effect parameters are as follow:
  72286. * {
  72287. * chromatic_aberration: number; // from 0 to x (1 for realism)
  72288. * edge_blur: number; // from 0 to x (1 for realism)
  72289. * distortion: number; // from 0 to x (1 for realism)
  72290. * grain_amount: number; // from 0 to 1
  72291. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  72292. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  72293. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  72294. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  72295. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  72296. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  72297. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  72298. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  72299. * }
  72300. * Note: if an effect parameter is unset, effect is disabled
  72301. *
  72302. * @param name The rendering pipeline name
  72303. * @param parameters - An object containing all parameters (see above)
  72304. * @param scene The scene linked to this pipeline
  72305. * @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)
  72306. * @param cameras The array of cameras that the rendering pipeline will be attached to
  72307. */
  72308. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  72309. /**
  72310. * Get the class name
  72311. * @returns "LensRenderingPipeline"
  72312. */
  72313. getClassName(): string;
  72314. /**
  72315. * Gets associated scene
  72316. */
  72317. get scene(): Scene;
  72318. /**
  72319. * Gets or sets the edge blur
  72320. */
  72321. get edgeBlur(): number;
  72322. set edgeBlur(value: number);
  72323. /**
  72324. * Gets or sets the grain amount
  72325. */
  72326. get grainAmount(): number;
  72327. set grainAmount(value: number);
  72328. /**
  72329. * Gets or sets the chromatic aberration amount
  72330. */
  72331. get chromaticAberration(): number;
  72332. set chromaticAberration(value: number);
  72333. /**
  72334. * Gets or sets the depth of field aperture
  72335. */
  72336. get dofAperture(): number;
  72337. set dofAperture(value: number);
  72338. /**
  72339. * Gets or sets the edge distortion
  72340. */
  72341. get edgeDistortion(): number;
  72342. set edgeDistortion(value: number);
  72343. /**
  72344. * Gets or sets the depth of field distortion
  72345. */
  72346. get dofDistortion(): number;
  72347. set dofDistortion(value: number);
  72348. /**
  72349. * Gets or sets the darken out of focus amount
  72350. */
  72351. get darkenOutOfFocus(): number;
  72352. set darkenOutOfFocus(value: number);
  72353. /**
  72354. * Gets or sets a boolean indicating if blur noise is enabled
  72355. */
  72356. get blurNoise(): boolean;
  72357. set blurNoise(value: boolean);
  72358. /**
  72359. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  72360. */
  72361. get pentagonBokeh(): boolean;
  72362. set pentagonBokeh(value: boolean);
  72363. /**
  72364. * Gets or sets the highlight grain amount
  72365. */
  72366. get highlightsGain(): number;
  72367. set highlightsGain(value: number);
  72368. /**
  72369. * Gets or sets the highlight threshold
  72370. */
  72371. get highlightsThreshold(): number;
  72372. set highlightsThreshold(value: number);
  72373. /**
  72374. * Sets the amount of blur at the edges
  72375. * @param amount blur amount
  72376. */
  72377. setEdgeBlur(amount: number): void;
  72378. /**
  72379. * Sets edge blur to 0
  72380. */
  72381. disableEdgeBlur(): void;
  72382. /**
  72383. * Sets the amout of grain
  72384. * @param amount Amount of grain
  72385. */
  72386. setGrainAmount(amount: number): void;
  72387. /**
  72388. * Set grain amount to 0
  72389. */
  72390. disableGrain(): void;
  72391. /**
  72392. * Sets the chromatic aberration amount
  72393. * @param amount amount of chromatic aberration
  72394. */
  72395. setChromaticAberration(amount: number): void;
  72396. /**
  72397. * Sets chromatic aberration amount to 0
  72398. */
  72399. disableChromaticAberration(): void;
  72400. /**
  72401. * Sets the EdgeDistortion amount
  72402. * @param amount amount of EdgeDistortion
  72403. */
  72404. setEdgeDistortion(amount: number): void;
  72405. /**
  72406. * Sets edge distortion to 0
  72407. */
  72408. disableEdgeDistortion(): void;
  72409. /**
  72410. * Sets the FocusDistance amount
  72411. * @param amount amount of FocusDistance
  72412. */
  72413. setFocusDistance(amount: number): void;
  72414. /**
  72415. * Disables depth of field
  72416. */
  72417. disableDepthOfField(): void;
  72418. /**
  72419. * Sets the Aperture amount
  72420. * @param amount amount of Aperture
  72421. */
  72422. setAperture(amount: number): void;
  72423. /**
  72424. * Sets the DarkenOutOfFocus amount
  72425. * @param amount amount of DarkenOutOfFocus
  72426. */
  72427. setDarkenOutOfFocus(amount: number): void;
  72428. private _pentagonBokehIsEnabled;
  72429. /**
  72430. * Creates a pentagon bokeh effect
  72431. */
  72432. enablePentagonBokeh(): void;
  72433. /**
  72434. * Disables the pentagon bokeh effect
  72435. */
  72436. disablePentagonBokeh(): void;
  72437. /**
  72438. * Enables noise blur
  72439. */
  72440. enableNoiseBlur(): void;
  72441. /**
  72442. * Disables noise blur
  72443. */
  72444. disableNoiseBlur(): void;
  72445. /**
  72446. * Sets the HighlightsGain amount
  72447. * @param amount amount of HighlightsGain
  72448. */
  72449. setHighlightsGain(amount: number): void;
  72450. /**
  72451. * Sets the HighlightsThreshold amount
  72452. * @param amount amount of HighlightsThreshold
  72453. */
  72454. setHighlightsThreshold(amount: number): void;
  72455. /**
  72456. * Disables highlights
  72457. */
  72458. disableHighlights(): void;
  72459. /**
  72460. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  72461. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  72462. */
  72463. dispose(disableDepthRender?: boolean): void;
  72464. private _createChromaticAberrationPostProcess;
  72465. private _createHighlightsPostProcess;
  72466. private _createDepthOfFieldPostProcess;
  72467. private _createGrainTexture;
  72468. }
  72469. }
  72470. declare module "babylonjs/Shaders/ssao2.fragment" {
  72471. /** @hidden */
  72472. export var ssao2PixelShader: {
  72473. name: string;
  72474. shader: string;
  72475. };
  72476. }
  72477. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  72478. /** @hidden */
  72479. export var ssaoCombinePixelShader: {
  72480. name: string;
  72481. shader: string;
  72482. };
  72483. }
  72484. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  72485. import { Camera } from "babylonjs/Cameras/camera";
  72486. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  72487. import { Scene } from "babylonjs/scene";
  72488. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  72489. import "babylonjs/Shaders/ssao2.fragment";
  72490. import "babylonjs/Shaders/ssaoCombine.fragment";
  72491. /**
  72492. * Render pipeline to produce ssao effect
  72493. */
  72494. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  72495. /**
  72496. * @ignore
  72497. * The PassPostProcess id in the pipeline that contains the original scene color
  72498. */
  72499. SSAOOriginalSceneColorEffect: string;
  72500. /**
  72501. * @ignore
  72502. * The SSAO PostProcess id in the pipeline
  72503. */
  72504. SSAORenderEffect: string;
  72505. /**
  72506. * @ignore
  72507. * The horizontal blur PostProcess id in the pipeline
  72508. */
  72509. SSAOBlurHRenderEffect: string;
  72510. /**
  72511. * @ignore
  72512. * The vertical blur PostProcess id in the pipeline
  72513. */
  72514. SSAOBlurVRenderEffect: string;
  72515. /**
  72516. * @ignore
  72517. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  72518. */
  72519. SSAOCombineRenderEffect: string;
  72520. /**
  72521. * The output strength of the SSAO post-process. Default value is 1.0.
  72522. */
  72523. totalStrength: number;
  72524. /**
  72525. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  72526. */
  72527. maxZ: number;
  72528. /**
  72529. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  72530. */
  72531. minZAspect: number;
  72532. private _samples;
  72533. /**
  72534. * Number of samples used for the SSAO calculations. Default value is 8
  72535. */
  72536. set samples(n: number);
  72537. get samples(): number;
  72538. private _textureSamples;
  72539. /**
  72540. * Number of samples to use for antialiasing
  72541. */
  72542. set textureSamples(n: number);
  72543. get textureSamples(): number;
  72544. /**
  72545. * Ratio object used for SSAO ratio and blur ratio
  72546. */
  72547. private _ratio;
  72548. /**
  72549. * Dynamically generated sphere sampler.
  72550. */
  72551. private _sampleSphere;
  72552. /**
  72553. * Blur filter offsets
  72554. */
  72555. private _samplerOffsets;
  72556. private _expensiveBlur;
  72557. /**
  72558. * If bilateral blur should be used
  72559. */
  72560. set expensiveBlur(b: boolean);
  72561. get expensiveBlur(): boolean;
  72562. /**
  72563. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  72564. */
  72565. radius: number;
  72566. /**
  72567. * The base color of the SSAO post-process
  72568. * The final result is "base + ssao" between [0, 1]
  72569. */
  72570. base: number;
  72571. /**
  72572. * Support test.
  72573. */
  72574. static get IsSupported(): boolean;
  72575. private _scene;
  72576. private _depthTexture;
  72577. private _normalTexture;
  72578. private _randomTexture;
  72579. private _originalColorPostProcess;
  72580. private _ssaoPostProcess;
  72581. private _blurHPostProcess;
  72582. private _blurVPostProcess;
  72583. private _ssaoCombinePostProcess;
  72584. /**
  72585. * Gets active scene
  72586. */
  72587. get scene(): Scene;
  72588. /**
  72589. * @constructor
  72590. * @param name The rendering pipeline name
  72591. * @param scene The scene linked to this pipeline
  72592. * @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 }
  72593. * @param cameras The array of cameras that the rendering pipeline will be attached to
  72594. */
  72595. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  72596. /**
  72597. * Get the class name
  72598. * @returns "SSAO2RenderingPipeline"
  72599. */
  72600. getClassName(): string;
  72601. /**
  72602. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  72603. */
  72604. dispose(disableGeometryBufferRenderer?: boolean): void;
  72605. private _createBlurPostProcess;
  72606. /** @hidden */
  72607. _rebuild(): void;
  72608. private _bits;
  72609. private _radicalInverse_VdC;
  72610. private _hammersley;
  72611. private _hemisphereSample_uniform;
  72612. private _generateHemisphere;
  72613. private _createSSAOPostProcess;
  72614. private _createSSAOCombinePostProcess;
  72615. private _createRandomTexture;
  72616. /**
  72617. * Serialize the rendering pipeline (Used when exporting)
  72618. * @returns the serialized object
  72619. */
  72620. serialize(): any;
  72621. /**
  72622. * Parse the serialized pipeline
  72623. * @param source Source pipeline.
  72624. * @param scene The scene to load the pipeline to.
  72625. * @param rootUrl The URL of the serialized pipeline.
  72626. * @returns An instantiated pipeline from the serialized object.
  72627. */
  72628. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  72629. }
  72630. }
  72631. declare module "babylonjs/Shaders/ssao.fragment" {
  72632. /** @hidden */
  72633. export var ssaoPixelShader: {
  72634. name: string;
  72635. shader: string;
  72636. };
  72637. }
  72638. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  72639. import { Camera } from "babylonjs/Cameras/camera";
  72640. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  72641. import { Scene } from "babylonjs/scene";
  72642. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  72643. import "babylonjs/Shaders/ssao.fragment";
  72644. import "babylonjs/Shaders/ssaoCombine.fragment";
  72645. /**
  72646. * Render pipeline to produce ssao effect
  72647. */
  72648. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  72649. /**
  72650. * @ignore
  72651. * The PassPostProcess id in the pipeline that contains the original scene color
  72652. */
  72653. SSAOOriginalSceneColorEffect: string;
  72654. /**
  72655. * @ignore
  72656. * The SSAO PostProcess id in the pipeline
  72657. */
  72658. SSAORenderEffect: string;
  72659. /**
  72660. * @ignore
  72661. * The horizontal blur PostProcess id in the pipeline
  72662. */
  72663. SSAOBlurHRenderEffect: string;
  72664. /**
  72665. * @ignore
  72666. * The vertical blur PostProcess id in the pipeline
  72667. */
  72668. SSAOBlurVRenderEffect: string;
  72669. /**
  72670. * @ignore
  72671. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  72672. */
  72673. SSAOCombineRenderEffect: string;
  72674. /**
  72675. * The output strength of the SSAO post-process. Default value is 1.0.
  72676. */
  72677. totalStrength: number;
  72678. /**
  72679. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  72680. */
  72681. radius: number;
  72682. /**
  72683. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  72684. * Must not be equal to fallOff and superior to fallOff.
  72685. * Default value is 0.0075
  72686. */
  72687. area: number;
  72688. /**
  72689. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  72690. * Must not be equal to area and inferior to area.
  72691. * Default value is 0.000001
  72692. */
  72693. fallOff: number;
  72694. /**
  72695. * The base color of the SSAO post-process
  72696. * The final result is "base + ssao" between [0, 1]
  72697. */
  72698. base: number;
  72699. private _scene;
  72700. private _depthTexture;
  72701. private _randomTexture;
  72702. private _originalColorPostProcess;
  72703. private _ssaoPostProcess;
  72704. private _blurHPostProcess;
  72705. private _blurVPostProcess;
  72706. private _ssaoCombinePostProcess;
  72707. private _firstUpdate;
  72708. /**
  72709. * Gets active scene
  72710. */
  72711. get scene(): Scene;
  72712. /**
  72713. * @constructor
  72714. * @param name - The rendering pipeline name
  72715. * @param scene - The scene linked to this pipeline
  72716. * @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 }
  72717. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  72718. */
  72719. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  72720. /**
  72721. * Get the class name
  72722. * @returns "SSAORenderingPipeline"
  72723. */
  72724. getClassName(): string;
  72725. /**
  72726. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  72727. */
  72728. dispose(disableDepthRender?: boolean): void;
  72729. private _createBlurPostProcess;
  72730. /** @hidden */
  72731. _rebuild(): void;
  72732. private _createSSAOPostProcess;
  72733. private _createSSAOCombinePostProcess;
  72734. private _createRandomTexture;
  72735. }
  72736. }
  72737. declare module "babylonjs/Shaders/screenSpaceReflection.fragment" {
  72738. /** @hidden */
  72739. export var screenSpaceReflectionPixelShader: {
  72740. name: string;
  72741. shader: string;
  72742. };
  72743. }
  72744. declare module "babylonjs/PostProcesses/screenSpaceReflectionPostProcess" {
  72745. import { Nullable } from "babylonjs/types";
  72746. import { Camera } from "babylonjs/Cameras/camera";
  72747. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72748. import { Scene } from "babylonjs/scene";
  72749. import "babylonjs/Shaders/screenSpaceReflection.fragment";
  72750. import { Engine } from "babylonjs/Engines/engine";
  72751. /**
  72752. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  72753. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  72754. */
  72755. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  72756. /**
  72757. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  72758. */
  72759. threshold: number;
  72760. /**
  72761. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  72762. */
  72763. strength: number;
  72764. /**
  72765. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  72766. */
  72767. reflectionSpecularFalloffExponent: number;
  72768. /**
  72769. * 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]
  72770. */
  72771. step: number;
  72772. /**
  72773. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  72774. */
  72775. roughnessFactor: number;
  72776. private _geometryBufferRenderer;
  72777. private _enableSmoothReflections;
  72778. private _reflectionSamples;
  72779. private _smoothSteps;
  72780. /**
  72781. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  72782. * @param name The name of the effect.
  72783. * @param scene The scene containing the objects to calculate reflections.
  72784. * @param options The required width/height ratio to downsize to before computing the render pass.
  72785. * @param camera The camera to apply the render pass to.
  72786. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72787. * @param engine The engine which the post process will be applied. (default: current engine)
  72788. * @param reusable If the post process can be reused on the same frame. (default: false)
  72789. * @param textureType Type of textures used when performing the post process. (default: 0)
  72790. * @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)
  72791. */
  72792. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72793. /**
  72794. * Gets wether or not smoothing reflections is enabled.
  72795. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  72796. */
  72797. get enableSmoothReflections(): boolean;
  72798. /**
  72799. * Sets wether or not smoothing reflections is enabled.
  72800. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  72801. */
  72802. set enableSmoothReflections(enabled: boolean);
  72803. /**
  72804. * Gets the number of samples taken while computing reflections. More samples count is high,
  72805. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  72806. */
  72807. get reflectionSamples(): number;
  72808. /**
  72809. * Sets the number of samples taken while computing reflections. More samples count is high,
  72810. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  72811. */
  72812. set reflectionSamples(samples: number);
  72813. /**
  72814. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  72815. * more the post-process will require GPU power and can generate a drop in FPS.
  72816. * Default value (5.0) work pretty well in all cases but can be adjusted.
  72817. */
  72818. get smoothSteps(): number;
  72819. set smoothSteps(steps: number);
  72820. private _updateEffectDefines;
  72821. }
  72822. }
  72823. declare module "babylonjs/Shaders/standard.fragment" {
  72824. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  72825. /** @hidden */
  72826. export var standardPixelShader: {
  72827. name: string;
  72828. shader: string;
  72829. };
  72830. }
  72831. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  72832. import { Nullable } from "babylonjs/types";
  72833. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  72834. import { Camera } from "babylonjs/Cameras/camera";
  72835. import { Texture } from "babylonjs/Materials/Textures/texture";
  72836. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  72837. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  72838. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  72839. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  72840. import { IDisposable } from "babylonjs/scene";
  72841. import { SpotLight } from "babylonjs/Lights/spotLight";
  72842. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  72843. import { Scene } from "babylonjs/scene";
  72844. import { ScreenSpaceReflectionPostProcess } from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  72845. import { Animation } from "babylonjs/Animations/animation";
  72846. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  72847. import "babylonjs/Shaders/standard.fragment";
  72848. /**
  72849. * Standard rendering pipeline
  72850. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  72851. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  72852. */
  72853. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  72854. /**
  72855. * Public members
  72856. */
  72857. /**
  72858. * Post-process which contains the original scene color before the pipeline applies all the effects
  72859. */
  72860. originalPostProcess: Nullable<PostProcess>;
  72861. /**
  72862. * Post-process used to down scale an image x4
  72863. */
  72864. downSampleX4PostProcess: Nullable<PostProcess>;
  72865. /**
  72866. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  72867. */
  72868. brightPassPostProcess: Nullable<PostProcess>;
  72869. /**
  72870. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  72871. */
  72872. blurHPostProcesses: PostProcess[];
  72873. /**
  72874. * Post-process array storing all the vertical blur post-processes used by the pipeline
  72875. */
  72876. blurVPostProcesses: PostProcess[];
  72877. /**
  72878. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  72879. */
  72880. textureAdderPostProcess: Nullable<PostProcess>;
  72881. /**
  72882. * Post-process used to create volumetric lighting effect
  72883. */
  72884. volumetricLightPostProcess: Nullable<PostProcess>;
  72885. /**
  72886. * Post-process used to smooth the previous volumetric light post-process on the X axis
  72887. */
  72888. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  72889. /**
  72890. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  72891. */
  72892. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  72893. /**
  72894. * Post-process used to merge the volumetric light effect and the real scene color
  72895. */
  72896. volumetricLightMergePostProces: Nullable<PostProcess>;
  72897. /**
  72898. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  72899. */
  72900. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  72901. /**
  72902. * Base post-process used to calculate the average luminance of the final image for HDR
  72903. */
  72904. luminancePostProcess: Nullable<PostProcess>;
  72905. /**
  72906. * Post-processes used to create down sample post-processes in order to get
  72907. * the average luminance of the final image for HDR
  72908. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  72909. */
  72910. luminanceDownSamplePostProcesses: PostProcess[];
  72911. /**
  72912. * Post-process used to create a HDR effect (light adaptation)
  72913. */
  72914. hdrPostProcess: Nullable<PostProcess>;
  72915. /**
  72916. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  72917. */
  72918. textureAdderFinalPostProcess: Nullable<PostProcess>;
  72919. /**
  72920. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  72921. */
  72922. lensFlareFinalPostProcess: Nullable<PostProcess>;
  72923. /**
  72924. * Post-process used to merge the final HDR post-process and the real scene color
  72925. */
  72926. hdrFinalPostProcess: Nullable<PostProcess>;
  72927. /**
  72928. * Post-process used to create a lens flare effect
  72929. */
  72930. lensFlarePostProcess: Nullable<PostProcess>;
  72931. /**
  72932. * Post-process that merges the result of the lens flare post-process and the real scene color
  72933. */
  72934. lensFlareComposePostProcess: Nullable<PostProcess>;
  72935. /**
  72936. * Post-process used to create a motion blur effect
  72937. */
  72938. motionBlurPostProcess: Nullable<PostProcess>;
  72939. /**
  72940. * Post-process used to create a depth of field effect
  72941. */
  72942. depthOfFieldPostProcess: Nullable<PostProcess>;
  72943. /**
  72944. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  72945. */
  72946. fxaaPostProcess: Nullable<FxaaPostProcess>;
  72947. /**
  72948. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  72949. */
  72950. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  72951. /**
  72952. * Represents the brightness threshold in order to configure the illuminated surfaces
  72953. */
  72954. brightThreshold: number;
  72955. /**
  72956. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  72957. */
  72958. blurWidth: number;
  72959. /**
  72960. * Sets if the blur for highlighted surfaces must be only horizontal
  72961. */
  72962. horizontalBlur: boolean;
  72963. /**
  72964. * Gets the overall exposure used by the pipeline
  72965. */
  72966. get exposure(): number;
  72967. /**
  72968. * Sets the overall exposure used by the pipeline
  72969. */
  72970. set exposure(value: number);
  72971. /**
  72972. * Texture used typically to simulate "dirty" on camera lens
  72973. */
  72974. lensTexture: Nullable<Texture>;
  72975. /**
  72976. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  72977. */
  72978. volumetricLightCoefficient: number;
  72979. /**
  72980. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  72981. */
  72982. volumetricLightPower: number;
  72983. /**
  72984. * Used the set the blur intensity to smooth the volumetric lights
  72985. */
  72986. volumetricLightBlurScale: number;
  72987. /**
  72988. * Light (spot or directional) used to generate the volumetric lights rays
  72989. * The source light must have a shadow generate so the pipeline can get its
  72990. * depth map
  72991. */
  72992. sourceLight: Nullable<SpotLight | DirectionalLight>;
  72993. /**
  72994. * For eye adaptation, represents the minimum luminance the eye can see
  72995. */
  72996. hdrMinimumLuminance: number;
  72997. /**
  72998. * For eye adaptation, represents the decrease luminance speed
  72999. */
  73000. hdrDecreaseRate: number;
  73001. /**
  73002. * For eye adaptation, represents the increase luminance speed
  73003. */
  73004. hdrIncreaseRate: number;
  73005. /**
  73006. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  73007. */
  73008. get hdrAutoExposure(): boolean;
  73009. /**
  73010. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  73011. */
  73012. set hdrAutoExposure(value: boolean);
  73013. /**
  73014. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  73015. */
  73016. lensColorTexture: Nullable<Texture>;
  73017. /**
  73018. * The overall strengh for the lens flare effect
  73019. */
  73020. lensFlareStrength: number;
  73021. /**
  73022. * Dispersion coefficient for lens flare ghosts
  73023. */
  73024. lensFlareGhostDispersal: number;
  73025. /**
  73026. * Main lens flare halo width
  73027. */
  73028. lensFlareHaloWidth: number;
  73029. /**
  73030. * Based on the lens distortion effect, defines how much the lens flare result
  73031. * is distorted
  73032. */
  73033. lensFlareDistortionStrength: number;
  73034. /**
  73035. * Configures the blur intensity used for for lens flare (halo)
  73036. */
  73037. lensFlareBlurWidth: number;
  73038. /**
  73039. * Lens star texture must be used to simulate rays on the flares and is available
  73040. * in the documentation
  73041. */
  73042. lensStarTexture: Nullable<Texture>;
  73043. /**
  73044. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  73045. * flare effect by taking account of the dirt texture
  73046. */
  73047. lensFlareDirtTexture: Nullable<Texture>;
  73048. /**
  73049. * Represents the focal length for the depth of field effect
  73050. */
  73051. depthOfFieldDistance: number;
  73052. /**
  73053. * Represents the blur intensity for the blurred part of the depth of field effect
  73054. */
  73055. depthOfFieldBlurWidth: number;
  73056. /**
  73057. * Gets how much the image is blurred by the movement while using the motion blur post-process
  73058. */
  73059. get motionStrength(): number;
  73060. /**
  73061. * Sets how much the image is blurred by the movement while using the motion blur post-process
  73062. */
  73063. set motionStrength(strength: number);
  73064. /**
  73065. * Gets wether or not the motion blur post-process is object based or screen based.
  73066. */
  73067. get objectBasedMotionBlur(): boolean;
  73068. /**
  73069. * Sets wether or not the motion blur post-process should be object based or screen based
  73070. */
  73071. set objectBasedMotionBlur(value: boolean);
  73072. /**
  73073. * List of animations for the pipeline (IAnimatable implementation)
  73074. */
  73075. animations: Animation[];
  73076. /**
  73077. * Private members
  73078. */
  73079. private _scene;
  73080. private _currentDepthOfFieldSource;
  73081. private _basePostProcess;
  73082. private _fixedExposure;
  73083. private _currentExposure;
  73084. private _hdrAutoExposure;
  73085. private _hdrCurrentLuminance;
  73086. private _motionStrength;
  73087. private _isObjectBasedMotionBlur;
  73088. private _floatTextureType;
  73089. private _camerasToBeAttached;
  73090. private _ratio;
  73091. private _bloomEnabled;
  73092. private _depthOfFieldEnabled;
  73093. private _vlsEnabled;
  73094. private _lensFlareEnabled;
  73095. private _hdrEnabled;
  73096. private _motionBlurEnabled;
  73097. private _fxaaEnabled;
  73098. private _screenSpaceReflectionsEnabled;
  73099. private _motionBlurSamples;
  73100. private _volumetricLightStepsCount;
  73101. private _samples;
  73102. /**
  73103. * @ignore
  73104. * Specifies if the bloom pipeline is enabled
  73105. */
  73106. get BloomEnabled(): boolean;
  73107. set BloomEnabled(enabled: boolean);
  73108. /**
  73109. * @ignore
  73110. * Specifies if the depth of field pipeline is enabed
  73111. */
  73112. get DepthOfFieldEnabled(): boolean;
  73113. set DepthOfFieldEnabled(enabled: boolean);
  73114. /**
  73115. * @ignore
  73116. * Specifies if the lens flare pipeline is enabed
  73117. */
  73118. get LensFlareEnabled(): boolean;
  73119. set LensFlareEnabled(enabled: boolean);
  73120. /**
  73121. * @ignore
  73122. * Specifies if the HDR pipeline is enabled
  73123. */
  73124. get HDREnabled(): boolean;
  73125. set HDREnabled(enabled: boolean);
  73126. /**
  73127. * @ignore
  73128. * Specifies if the volumetric lights scattering effect is enabled
  73129. */
  73130. get VLSEnabled(): boolean;
  73131. set VLSEnabled(enabled: boolean);
  73132. /**
  73133. * @ignore
  73134. * Specifies if the motion blur effect is enabled
  73135. */
  73136. get MotionBlurEnabled(): boolean;
  73137. set MotionBlurEnabled(enabled: boolean);
  73138. /**
  73139. * Specifies if anti-aliasing is enabled
  73140. */
  73141. get fxaaEnabled(): boolean;
  73142. set fxaaEnabled(enabled: boolean);
  73143. /**
  73144. * Specifies if screen space reflections are enabled.
  73145. */
  73146. get screenSpaceReflectionsEnabled(): boolean;
  73147. set screenSpaceReflectionsEnabled(enabled: boolean);
  73148. /**
  73149. * Specifies the number of steps used to calculate the volumetric lights
  73150. * Typically in interval [50, 200]
  73151. */
  73152. get volumetricLightStepsCount(): number;
  73153. set volumetricLightStepsCount(count: number);
  73154. /**
  73155. * Specifies the number of samples used for the motion blur effect
  73156. * Typically in interval [16, 64]
  73157. */
  73158. get motionBlurSamples(): number;
  73159. set motionBlurSamples(samples: number);
  73160. /**
  73161. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  73162. */
  73163. get samples(): number;
  73164. set samples(sampleCount: number);
  73165. /**
  73166. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  73167. * @constructor
  73168. * @param name The rendering pipeline name
  73169. * @param scene The scene linked to this pipeline
  73170. * @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)
  73171. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  73172. * @param cameras The array of cameras that the rendering pipeline will be attached to
  73173. */
  73174. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  73175. private _buildPipeline;
  73176. private _createDownSampleX4PostProcess;
  73177. private _createBrightPassPostProcess;
  73178. private _createBlurPostProcesses;
  73179. private _createTextureAdderPostProcess;
  73180. private _createVolumetricLightPostProcess;
  73181. private _createLuminancePostProcesses;
  73182. private _createHdrPostProcess;
  73183. private _createLensFlarePostProcess;
  73184. private _createDepthOfFieldPostProcess;
  73185. private _createMotionBlurPostProcess;
  73186. private _getDepthTexture;
  73187. private _disposePostProcesses;
  73188. /**
  73189. * Dispose of the pipeline and stop all post processes
  73190. */
  73191. dispose(): void;
  73192. /**
  73193. * Serialize the rendering pipeline (Used when exporting)
  73194. * @returns the serialized object
  73195. */
  73196. serialize(): any;
  73197. /**
  73198. * Parse the serialized pipeline
  73199. * @param source Source pipeline.
  73200. * @param scene The scene to load the pipeline to.
  73201. * @param rootUrl The URL of the serialized pipeline.
  73202. * @returns An instantiated pipeline from the serialized object.
  73203. */
  73204. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  73205. /**
  73206. * Luminance steps
  73207. */
  73208. static LuminanceSteps: number;
  73209. }
  73210. }
  73211. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  73212. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  73213. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  73214. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  73215. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  73216. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  73217. }
  73218. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  73219. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  73220. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  73221. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  73222. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  73223. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  73224. }
  73225. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  73226. /** @hidden */
  73227. export var stereoscopicInterlacePixelShader: {
  73228. name: string;
  73229. shader: string;
  73230. };
  73231. }
  73232. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  73233. import { Camera } from "babylonjs/Cameras/camera";
  73234. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  73235. import { Engine } from "babylonjs/Engines/engine";
  73236. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  73237. /**
  73238. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  73239. */
  73240. export class StereoscopicInterlacePostProcessI extends PostProcess {
  73241. private _stepSize;
  73242. private _passedProcess;
  73243. /**
  73244. * Initializes a StereoscopicInterlacePostProcessI
  73245. * @param name The name of the effect.
  73246. * @param rigCameras The rig cameras to be appled to the post process
  73247. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  73248. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  73249. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73250. * @param engine The engine which the post process will be applied. (default: current engine)
  73251. * @param reusable If the post process can be reused on the same frame. (default: false)
  73252. */
  73253. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73254. }
  73255. /**
  73256. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  73257. */
  73258. export class StereoscopicInterlacePostProcess extends PostProcess {
  73259. private _stepSize;
  73260. private _passedProcess;
  73261. /**
  73262. * Initializes a StereoscopicInterlacePostProcess
  73263. * @param name The name of the effect.
  73264. * @param rigCameras The rig cameras to be appled to the post process
  73265. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  73266. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73267. * @param engine The engine which the post process will be applied. (default: current engine)
  73268. * @param reusable If the post process can be reused on the same frame. (default: false)
  73269. */
  73270. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73271. }
  73272. }
  73273. declare module "babylonjs/Shaders/tonemap.fragment" {
  73274. /** @hidden */
  73275. export var tonemapPixelShader: {
  73276. name: string;
  73277. shader: string;
  73278. };
  73279. }
  73280. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  73281. import { Camera } from "babylonjs/Cameras/camera";
  73282. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  73283. import "babylonjs/Shaders/tonemap.fragment";
  73284. import { Engine } from "babylonjs/Engines/engine";
  73285. /** Defines operator used for tonemapping */
  73286. export enum TonemappingOperator {
  73287. /** Hable */
  73288. Hable = 0,
  73289. /** Reinhard */
  73290. Reinhard = 1,
  73291. /** HejiDawson */
  73292. HejiDawson = 2,
  73293. /** Photographic */
  73294. Photographic = 3
  73295. }
  73296. /**
  73297. * Defines a post process to apply tone mapping
  73298. */
  73299. export class TonemapPostProcess extends PostProcess {
  73300. private _operator;
  73301. /** Defines the required exposure adjustement */
  73302. exposureAdjustment: number;
  73303. /**
  73304. * Creates a new TonemapPostProcess
  73305. * @param name defines the name of the postprocess
  73306. * @param _operator defines the operator to use
  73307. * @param exposureAdjustment defines the required exposure adjustement
  73308. * @param camera defines the camera to use (can be null)
  73309. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  73310. * @param engine defines the hosting engine (can be ignore if camera is set)
  73311. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  73312. */
  73313. constructor(name: string, _operator: TonemappingOperator,
  73314. /** Defines the required exposure adjustement */
  73315. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  73316. }
  73317. }
  73318. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  73319. /** @hidden */
  73320. export var volumetricLightScatteringPixelShader: {
  73321. name: string;
  73322. shader: string;
  73323. };
  73324. }
  73325. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  73326. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  73327. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  73328. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  73329. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  73330. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  73331. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  73332. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  73333. /** @hidden */
  73334. export var volumetricLightScatteringPassVertexShader: {
  73335. name: string;
  73336. shader: string;
  73337. };
  73338. }
  73339. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  73340. /** @hidden */
  73341. export var volumetricLightScatteringPassPixelShader: {
  73342. name: string;
  73343. shader: string;
  73344. };
  73345. }
  73346. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  73347. import { Vector3 } from "babylonjs/Maths/math.vector";
  73348. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73349. import { Mesh } from "babylonjs/Meshes/mesh";
  73350. import { Camera } from "babylonjs/Cameras/camera";
  73351. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  73352. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  73353. import { Scene } from "babylonjs/scene";
  73354. import "babylonjs/Meshes/Builders/planeBuilder";
  73355. import "babylonjs/Shaders/depth.vertex";
  73356. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  73357. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  73358. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  73359. import { Engine } from "babylonjs/Engines/engine";
  73360. /**
  73361. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  73362. */
  73363. export class VolumetricLightScatteringPostProcess extends PostProcess {
  73364. private _volumetricLightScatteringPass;
  73365. private _volumetricLightScatteringRTT;
  73366. private _viewPort;
  73367. private _screenCoordinates;
  73368. private _cachedDefines;
  73369. /**
  73370. * If not undefined, the mesh position is computed from the attached node position
  73371. */
  73372. attachedNode: {
  73373. position: Vector3;
  73374. };
  73375. /**
  73376. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  73377. */
  73378. customMeshPosition: Vector3;
  73379. /**
  73380. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  73381. */
  73382. useCustomMeshPosition: boolean;
  73383. /**
  73384. * If the post-process should inverse the light scattering direction
  73385. */
  73386. invert: boolean;
  73387. /**
  73388. * The internal mesh used by the post-process
  73389. */
  73390. mesh: Mesh;
  73391. /**
  73392. * @hidden
  73393. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  73394. */
  73395. get useDiffuseColor(): boolean;
  73396. set useDiffuseColor(useDiffuseColor: boolean);
  73397. /**
  73398. * Array containing the excluded meshes not rendered in the internal pass
  73399. */
  73400. excludedMeshes: AbstractMesh[];
  73401. /**
  73402. * Controls the overall intensity of the post-process
  73403. */
  73404. exposure: number;
  73405. /**
  73406. * Dissipates each sample's contribution in range [0, 1]
  73407. */
  73408. decay: number;
  73409. /**
  73410. * Controls the overall intensity of each sample
  73411. */
  73412. weight: number;
  73413. /**
  73414. * Controls the density of each sample
  73415. */
  73416. density: number;
  73417. /**
  73418. * @constructor
  73419. * @param name The post-process name
  73420. * @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)
  73421. * @param camera The camera that the post-process will be attached to
  73422. * @param mesh The mesh used to create the light scattering
  73423. * @param samples The post-process quality, default 100
  73424. * @param samplingModeThe post-process filtering mode
  73425. * @param engine The babylon engine
  73426. * @param reusable If the post-process is reusable
  73427. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  73428. */
  73429. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  73430. /**
  73431. * Returns the string "VolumetricLightScatteringPostProcess"
  73432. * @returns "VolumetricLightScatteringPostProcess"
  73433. */
  73434. getClassName(): string;
  73435. private _isReady;
  73436. /**
  73437. * Sets the new light position for light scattering effect
  73438. * @param position The new custom light position
  73439. */
  73440. setCustomMeshPosition(position: Vector3): void;
  73441. /**
  73442. * Returns the light position for light scattering effect
  73443. * @return Vector3 The custom light position
  73444. */
  73445. getCustomMeshPosition(): Vector3;
  73446. /**
  73447. * Disposes the internal assets and detaches the post-process from the camera
  73448. */
  73449. dispose(camera: Camera): void;
  73450. /**
  73451. * Returns the render target texture used by the post-process
  73452. * @return the render target texture used by the post-process
  73453. */
  73454. getPass(): RenderTargetTexture;
  73455. private _meshExcluded;
  73456. private _createPass;
  73457. private _updateMeshScreenCoordinates;
  73458. /**
  73459. * Creates a default mesh for the Volumeric Light Scattering post-process
  73460. * @param name The mesh name
  73461. * @param scene The scene where to create the mesh
  73462. * @return the default mesh
  73463. */
  73464. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  73465. }
  73466. }
  73467. declare module "babylonjs/PostProcesses/index" {
  73468. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  73469. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  73470. export * from "babylonjs/PostProcesses/bloomEffect";
  73471. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  73472. export * from "babylonjs/PostProcesses/blurPostProcess";
  73473. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  73474. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  73475. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  73476. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  73477. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  73478. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  73479. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  73480. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  73481. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  73482. export * from "babylonjs/PostProcesses/filterPostProcess";
  73483. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  73484. export * from "babylonjs/PostProcesses/grainPostProcess";
  73485. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  73486. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  73487. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  73488. export * from "babylonjs/PostProcesses/passPostProcess";
  73489. export * from "babylonjs/PostProcesses/postProcess";
  73490. export * from "babylonjs/PostProcesses/postProcessManager";
  73491. export * from "babylonjs/PostProcesses/refractionPostProcess";
  73492. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  73493. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  73494. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  73495. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  73496. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  73497. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  73498. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  73499. export * from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  73500. }
  73501. declare module "babylonjs/Probes/index" {
  73502. export * from "babylonjs/Probes/reflectionProbe";
  73503. }
  73504. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  73505. import { Scene } from "babylonjs/scene";
  73506. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73507. import { SmartArray } from "babylonjs/Misc/smartArray";
  73508. import { ISceneComponent } from "babylonjs/sceneComponent";
  73509. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  73510. import "babylonjs/Meshes/Builders/boxBuilder";
  73511. import "babylonjs/Shaders/color.fragment";
  73512. import "babylonjs/Shaders/color.vertex";
  73513. import { Color3 } from "babylonjs/Maths/math.color";
  73514. import { Observable } from "babylonjs/Misc/observable";
  73515. module "babylonjs/scene" {
  73516. interface Scene {
  73517. /** @hidden (Backing field) */
  73518. _boundingBoxRenderer: BoundingBoxRenderer;
  73519. /** @hidden (Backing field) */
  73520. _forceShowBoundingBoxes: boolean;
  73521. /**
  73522. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  73523. */
  73524. forceShowBoundingBoxes: boolean;
  73525. /**
  73526. * Gets the bounding box renderer associated with the scene
  73527. * @returns a BoundingBoxRenderer
  73528. */
  73529. getBoundingBoxRenderer(): BoundingBoxRenderer;
  73530. }
  73531. }
  73532. module "babylonjs/Meshes/abstractMesh" {
  73533. interface AbstractMesh {
  73534. /** @hidden (Backing field) */
  73535. _showBoundingBox: boolean;
  73536. /**
  73537. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  73538. */
  73539. showBoundingBox: boolean;
  73540. }
  73541. }
  73542. /**
  73543. * Component responsible of rendering the bounding box of the meshes in a scene.
  73544. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  73545. */
  73546. export class BoundingBoxRenderer implements ISceneComponent {
  73547. /**
  73548. * The component name helpfull to identify the component in the list of scene components.
  73549. */
  73550. readonly name: string;
  73551. /**
  73552. * The scene the component belongs to.
  73553. */
  73554. scene: Scene;
  73555. /**
  73556. * Color of the bounding box lines placed in front of an object
  73557. */
  73558. frontColor: Color3;
  73559. /**
  73560. * Color of the bounding box lines placed behind an object
  73561. */
  73562. backColor: Color3;
  73563. /**
  73564. * Defines if the renderer should show the back lines or not
  73565. */
  73566. showBackLines: boolean;
  73567. /**
  73568. * Observable raised before rendering a bounding box
  73569. */
  73570. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  73571. /**
  73572. * Observable raised after rendering a bounding box
  73573. */
  73574. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  73575. /**
  73576. * @hidden
  73577. */
  73578. renderList: SmartArray<BoundingBox>;
  73579. private _colorShader;
  73580. private _vertexBuffers;
  73581. private _indexBuffer;
  73582. private _fillIndexBuffer;
  73583. private _fillIndexData;
  73584. /**
  73585. * Instantiates a new bounding box renderer in a scene.
  73586. * @param scene the scene the renderer renders in
  73587. */
  73588. constructor(scene: Scene);
  73589. /**
  73590. * Registers the component in a given scene
  73591. */
  73592. register(): void;
  73593. private _evaluateSubMesh;
  73594. private _activeMesh;
  73595. private _prepareRessources;
  73596. private _createIndexBuffer;
  73597. /**
  73598. * Rebuilds the elements related to this component in case of
  73599. * context lost for instance.
  73600. */
  73601. rebuild(): void;
  73602. /**
  73603. * @hidden
  73604. */
  73605. reset(): void;
  73606. /**
  73607. * Render the bounding boxes of a specific rendering group
  73608. * @param renderingGroupId defines the rendering group to render
  73609. */
  73610. render(renderingGroupId: number): void;
  73611. /**
  73612. * In case of occlusion queries, we can render the occlusion bounding box through this method
  73613. * @param mesh Define the mesh to render the occlusion bounding box for
  73614. */
  73615. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  73616. /**
  73617. * Dispose and release the resources attached to this renderer.
  73618. */
  73619. dispose(): void;
  73620. }
  73621. }
  73622. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  73623. import { Nullable } from "babylonjs/types";
  73624. import { Scene } from "babylonjs/scene";
  73625. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  73626. import { Camera } from "babylonjs/Cameras/camera";
  73627. import { ISceneComponent } from "babylonjs/sceneComponent";
  73628. module "babylonjs/scene" {
  73629. interface Scene {
  73630. /** @hidden (Backing field) */
  73631. _depthRenderer: {
  73632. [id: string]: DepthRenderer;
  73633. };
  73634. /**
  73635. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  73636. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  73637. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  73638. * @returns the created depth renderer
  73639. */
  73640. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  73641. /**
  73642. * Disables a depth renderer for a given camera
  73643. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  73644. */
  73645. disableDepthRenderer(camera?: Nullable<Camera>): void;
  73646. }
  73647. }
  73648. /**
  73649. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  73650. * in several rendering techniques.
  73651. */
  73652. export class DepthRendererSceneComponent implements ISceneComponent {
  73653. /**
  73654. * The component name helpfull to identify the component in the list of scene components.
  73655. */
  73656. readonly name: string;
  73657. /**
  73658. * The scene the component belongs to.
  73659. */
  73660. scene: Scene;
  73661. /**
  73662. * Creates a new instance of the component for the given scene
  73663. * @param scene Defines the scene to register the component in
  73664. */
  73665. constructor(scene: Scene);
  73666. /**
  73667. * Registers the component in a given scene
  73668. */
  73669. register(): void;
  73670. /**
  73671. * Rebuilds the elements related to this component in case of
  73672. * context lost for instance.
  73673. */
  73674. rebuild(): void;
  73675. /**
  73676. * Disposes the component and the associated ressources
  73677. */
  73678. dispose(): void;
  73679. private _gatherRenderTargets;
  73680. private _gatherActiveCameraRenderTargets;
  73681. }
  73682. }
  73683. declare module "babylonjs/Shaders/outline.fragment" {
  73684. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  73685. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  73686. /** @hidden */
  73687. export var outlinePixelShader: {
  73688. name: string;
  73689. shader: string;
  73690. };
  73691. }
  73692. declare module "babylonjs/Shaders/outline.vertex" {
  73693. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  73694. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  73695. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  73696. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  73697. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  73698. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  73699. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  73700. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  73701. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  73702. /** @hidden */
  73703. export var outlineVertexShader: {
  73704. name: string;
  73705. shader: string;
  73706. };
  73707. }
  73708. declare module "babylonjs/Rendering/outlineRenderer" {
  73709. import { SubMesh } from "babylonjs/Meshes/subMesh";
  73710. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  73711. import { Scene } from "babylonjs/scene";
  73712. import { ISceneComponent } from "babylonjs/sceneComponent";
  73713. import "babylonjs/Shaders/outline.fragment";
  73714. import "babylonjs/Shaders/outline.vertex";
  73715. module "babylonjs/scene" {
  73716. interface Scene {
  73717. /** @hidden */
  73718. _outlineRenderer: OutlineRenderer;
  73719. /**
  73720. * Gets the outline renderer associated with the scene
  73721. * @returns a OutlineRenderer
  73722. */
  73723. getOutlineRenderer(): OutlineRenderer;
  73724. }
  73725. }
  73726. module "babylonjs/Meshes/abstractMesh" {
  73727. interface AbstractMesh {
  73728. /** @hidden (Backing field) */
  73729. _renderOutline: boolean;
  73730. /**
  73731. * Gets or sets a boolean indicating if the outline must be rendered as well
  73732. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  73733. */
  73734. renderOutline: boolean;
  73735. /** @hidden (Backing field) */
  73736. _renderOverlay: boolean;
  73737. /**
  73738. * Gets or sets a boolean indicating if the overlay must be rendered as well
  73739. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  73740. */
  73741. renderOverlay: boolean;
  73742. }
  73743. }
  73744. /**
  73745. * This class is responsible to draw bothe outline/overlay of meshes.
  73746. * It should not be used directly but through the available method on mesh.
  73747. */
  73748. export class OutlineRenderer implements ISceneComponent {
  73749. /**
  73750. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  73751. */
  73752. private static _StencilReference;
  73753. /**
  73754. * The name of the component. Each component must have a unique name.
  73755. */
  73756. name: string;
  73757. /**
  73758. * The scene the component belongs to.
  73759. */
  73760. scene: Scene;
  73761. /**
  73762. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  73763. */
  73764. zOffset: number;
  73765. private _engine;
  73766. private _effect;
  73767. private _cachedDefines;
  73768. private _savedDepthWrite;
  73769. /**
  73770. * Instantiates a new outline renderer. (There could be only one per scene).
  73771. * @param scene Defines the scene it belongs to
  73772. */
  73773. constructor(scene: Scene);
  73774. /**
  73775. * Register the component to one instance of a scene.
  73776. */
  73777. register(): void;
  73778. /**
  73779. * Rebuilds the elements related to this component in case of
  73780. * context lost for instance.
  73781. */
  73782. rebuild(): void;
  73783. /**
  73784. * Disposes the component and the associated ressources.
  73785. */
  73786. dispose(): void;
  73787. /**
  73788. * Renders the outline in the canvas.
  73789. * @param subMesh Defines the sumesh to render
  73790. * @param batch Defines the batch of meshes in case of instances
  73791. * @param useOverlay Defines if the rendering is for the overlay or the outline
  73792. */
  73793. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  73794. /**
  73795. * Returns whether or not the outline renderer is ready for a given submesh.
  73796. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  73797. * @param subMesh Defines the submesh to check readyness for
  73798. * @param useInstances Defines wheter wee are trying to render instances or not
  73799. * @returns true if ready otherwise false
  73800. */
  73801. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  73802. private _beforeRenderingMesh;
  73803. private _afterRenderingMesh;
  73804. }
  73805. }
  73806. declare module "babylonjs/Rendering/index" {
  73807. export * from "babylonjs/Rendering/boundingBoxRenderer";
  73808. export * from "babylonjs/Rendering/depthRenderer";
  73809. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  73810. export * from "babylonjs/Rendering/edgesRenderer";
  73811. export * from "babylonjs/Rendering/geometryBufferRenderer";
  73812. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  73813. export * from "babylonjs/Rendering/outlineRenderer";
  73814. export * from "babylonjs/Rendering/renderingGroup";
  73815. export * from "babylonjs/Rendering/renderingManager";
  73816. export * from "babylonjs/Rendering/utilityLayerRenderer";
  73817. }
  73818. declare module "babylonjs/Sprites/ISprites" {
  73819. /**
  73820. * Defines the basic options interface of a Sprite Frame Source Size.
  73821. */
  73822. export interface ISpriteJSONSpriteSourceSize {
  73823. /**
  73824. * number of the original width of the Frame
  73825. */
  73826. w: number;
  73827. /**
  73828. * number of the original height of the Frame
  73829. */
  73830. h: number;
  73831. }
  73832. /**
  73833. * Defines the basic options interface of a Sprite Frame Data.
  73834. */
  73835. export interface ISpriteJSONSpriteFrameData {
  73836. /**
  73837. * number of the x offset of the Frame
  73838. */
  73839. x: number;
  73840. /**
  73841. * number of the y offset of the Frame
  73842. */
  73843. y: number;
  73844. /**
  73845. * number of the width of the Frame
  73846. */
  73847. w: number;
  73848. /**
  73849. * number of the height of the Frame
  73850. */
  73851. h: number;
  73852. }
  73853. /**
  73854. * Defines the basic options interface of a JSON Sprite.
  73855. */
  73856. export interface ISpriteJSONSprite {
  73857. /**
  73858. * string name of the Frame
  73859. */
  73860. filename: string;
  73861. /**
  73862. * ISpriteJSONSpriteFrame basic object of the frame data
  73863. */
  73864. frame: ISpriteJSONSpriteFrameData;
  73865. /**
  73866. * boolean to flag is the frame was rotated.
  73867. */
  73868. rotated: boolean;
  73869. /**
  73870. * boolean to flag is the frame was trimmed.
  73871. */
  73872. trimmed: boolean;
  73873. /**
  73874. * ISpriteJSONSpriteFrame basic object of the source data
  73875. */
  73876. spriteSourceSize: ISpriteJSONSpriteFrameData;
  73877. /**
  73878. * ISpriteJSONSpriteFrame basic object of the source data
  73879. */
  73880. sourceSize: ISpriteJSONSpriteSourceSize;
  73881. }
  73882. /**
  73883. * Defines the basic options interface of a JSON atlas.
  73884. */
  73885. export interface ISpriteJSONAtlas {
  73886. /**
  73887. * Array of objects that contain the frame data.
  73888. */
  73889. frames: Array<ISpriteJSONSprite>;
  73890. /**
  73891. * object basic object containing the sprite meta data.
  73892. */
  73893. meta?: object;
  73894. }
  73895. }
  73896. declare module "babylonjs/Shaders/spriteMap.fragment" {
  73897. /** @hidden */
  73898. export var spriteMapPixelShader: {
  73899. name: string;
  73900. shader: string;
  73901. };
  73902. }
  73903. declare module "babylonjs/Shaders/spriteMap.vertex" {
  73904. /** @hidden */
  73905. export var spriteMapVertexShader: {
  73906. name: string;
  73907. shader: string;
  73908. };
  73909. }
  73910. declare module "babylonjs/Sprites/spriteMap" {
  73911. import { IDisposable, Scene } from "babylonjs/scene";
  73912. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  73913. import { Texture } from "babylonjs/Materials/Textures/texture";
  73914. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  73915. import { ISpriteJSONSprite, ISpriteJSONAtlas } from "babylonjs/Sprites/ISprites";
  73916. import "babylonjs/Meshes/Builders/planeBuilder";
  73917. import "babylonjs/Shaders/spriteMap.fragment";
  73918. import "babylonjs/Shaders/spriteMap.vertex";
  73919. /**
  73920. * Defines the basic options interface of a SpriteMap
  73921. */
  73922. export interface ISpriteMapOptions {
  73923. /**
  73924. * Vector2 of the number of cells in the grid.
  73925. */
  73926. stageSize?: Vector2;
  73927. /**
  73928. * Vector2 of the size of the output plane in World Units.
  73929. */
  73930. outputSize?: Vector2;
  73931. /**
  73932. * Vector3 of the position of the output plane in World Units.
  73933. */
  73934. outputPosition?: Vector3;
  73935. /**
  73936. * Vector3 of the rotation of the output plane.
  73937. */
  73938. outputRotation?: Vector3;
  73939. /**
  73940. * number of layers that the system will reserve in resources.
  73941. */
  73942. layerCount?: number;
  73943. /**
  73944. * number of max animation frames a single cell will reserve in resources.
  73945. */
  73946. maxAnimationFrames?: number;
  73947. /**
  73948. * number cell index of the base tile when the system compiles.
  73949. */
  73950. baseTile?: number;
  73951. /**
  73952. * boolean flip the sprite after its been repositioned by the framing data.
  73953. */
  73954. flipU?: boolean;
  73955. /**
  73956. * Vector3 scalar of the global RGB values of the SpriteMap.
  73957. */
  73958. colorMultiply?: Vector3;
  73959. }
  73960. /**
  73961. * Defines the IDisposable interface in order to be cleanable from resources.
  73962. */
  73963. export interface ISpriteMap extends IDisposable {
  73964. /**
  73965. * String name of the SpriteMap.
  73966. */
  73967. name: string;
  73968. /**
  73969. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  73970. */
  73971. atlasJSON: ISpriteJSONAtlas;
  73972. /**
  73973. * Texture of the SpriteMap.
  73974. */
  73975. spriteSheet: Texture;
  73976. /**
  73977. * The parameters to initialize the SpriteMap with.
  73978. */
  73979. options: ISpriteMapOptions;
  73980. }
  73981. /**
  73982. * Class used to manage a grid restricted sprite deployment on an Output plane.
  73983. */
  73984. export class SpriteMap implements ISpriteMap {
  73985. /** The Name of the spriteMap */
  73986. name: string;
  73987. /** The JSON file with the frame and meta data */
  73988. atlasJSON: ISpriteJSONAtlas;
  73989. /** The systems Sprite Sheet Texture */
  73990. spriteSheet: Texture;
  73991. /** Arguments passed with the Constructor */
  73992. options: ISpriteMapOptions;
  73993. /** Public Sprite Storage array, parsed from atlasJSON */
  73994. sprites: Array<ISpriteJSONSprite>;
  73995. /** Returns the Number of Sprites in the System */
  73996. get spriteCount(): number;
  73997. /** Returns the Position of Output Plane*/
  73998. get position(): Vector3;
  73999. /** Returns the Position of Output Plane*/
  74000. set position(v: Vector3);
  74001. /** Returns the Rotation of Output Plane*/
  74002. get rotation(): Vector3;
  74003. /** Returns the Rotation of Output Plane*/
  74004. set rotation(v: Vector3);
  74005. /** Sets the AnimationMap*/
  74006. get animationMap(): RawTexture;
  74007. /** Sets the AnimationMap*/
  74008. set animationMap(v: RawTexture);
  74009. /** Scene that the SpriteMap was created in */
  74010. private _scene;
  74011. /** Texture Buffer of Float32 that holds tile frame data*/
  74012. private _frameMap;
  74013. /** Texture Buffers of Float32 that holds tileMap data*/
  74014. private _tileMaps;
  74015. /** Texture Buffer of Float32 that holds Animation Data*/
  74016. private _animationMap;
  74017. /** Custom ShaderMaterial Central to the System*/
  74018. private _material;
  74019. /** Custom ShaderMaterial Central to the System*/
  74020. private _output;
  74021. /** Systems Time Ticker*/
  74022. private _time;
  74023. /**
  74024. * Creates a new SpriteMap
  74025. * @param name defines the SpriteMaps Name
  74026. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  74027. * @param spriteSheet is the Texture that the Sprites are on.
  74028. * @param options a basic deployment configuration
  74029. * @param scene The Scene that the map is deployed on
  74030. */
  74031. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  74032. /**
  74033. * Returns tileID location
  74034. * @returns Vector2 the cell position ID
  74035. */
  74036. getTileID(): Vector2;
  74037. /**
  74038. * Gets the UV location of the mouse over the SpriteMap.
  74039. * @returns Vector2 the UV position of the mouse interaction
  74040. */
  74041. getMousePosition(): Vector2;
  74042. /**
  74043. * Creates the "frame" texture Buffer
  74044. * -------------------------------------
  74045. * Structure of frames
  74046. * "filename": "Falling-Water-2.png",
  74047. * "frame": {"x":69,"y":103,"w":24,"h":32},
  74048. * "rotated": true,
  74049. * "trimmed": true,
  74050. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  74051. * "sourceSize": {"w":32,"h":32}
  74052. * @returns RawTexture of the frameMap
  74053. */
  74054. private _createFrameBuffer;
  74055. /**
  74056. * Creates the tileMap texture Buffer
  74057. * @param buffer normally and array of numbers, or a false to generate from scratch
  74058. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  74059. * @returns RawTexture of the tileMap
  74060. */
  74061. private _createTileBuffer;
  74062. /**
  74063. * Modifies the data of the tileMaps
  74064. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  74065. * @param pos is the iVector2 Coordinates of the Tile
  74066. * @param tile The SpriteIndex of the new Tile
  74067. */
  74068. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  74069. /**
  74070. * Creates the animationMap texture Buffer
  74071. * @param buffer normally and array of numbers, or a false to generate from scratch
  74072. * @returns RawTexture of the animationMap
  74073. */
  74074. private _createTileAnimationBuffer;
  74075. /**
  74076. * Modifies the data of the animationMap
  74077. * @param cellID is the Index of the Sprite
  74078. * @param _frame is the target Animation frame
  74079. * @param toCell is the Target Index of the next frame of the animation
  74080. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  74081. * @param speed is a global scalar of the time variable on the map.
  74082. */
  74083. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  74084. /**
  74085. * Exports the .tilemaps file
  74086. */
  74087. saveTileMaps(): void;
  74088. /**
  74089. * Imports the .tilemaps file
  74090. * @param url of the .tilemaps file
  74091. */
  74092. loadTileMaps(url: string): void;
  74093. /**
  74094. * Release associated resources
  74095. */
  74096. dispose(): void;
  74097. }
  74098. }
  74099. declare module "babylonjs/Sprites/spritePackedManager" {
  74100. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  74101. import { Scene } from "babylonjs/scene";
  74102. /**
  74103. * Class used to manage multiple sprites of different sizes on the same spritesheet
  74104. * @see http://doc.babylonjs.com/babylon101/sprites
  74105. */
  74106. export class SpritePackedManager extends SpriteManager {
  74107. /** defines the packed manager's name */
  74108. name: string;
  74109. /**
  74110. * Creates a new sprite manager from a packed sprite sheet
  74111. * @param name defines the manager's name
  74112. * @param imgUrl defines the sprite sheet url
  74113. * @param capacity defines the maximum allowed number of sprites
  74114. * @param scene defines the hosting scene
  74115. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  74116. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  74117. * @param samplingMode defines the smapling mode to use with spritesheet
  74118. * @param fromPacked set to true; do not alter
  74119. */
  74120. constructor(
  74121. /** defines the packed manager's name */
  74122. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  74123. }
  74124. }
  74125. declare module "babylonjs/Sprites/index" {
  74126. export * from "babylonjs/Sprites/sprite";
  74127. export * from "babylonjs/Sprites/ISprites";
  74128. export * from "babylonjs/Sprites/spriteManager";
  74129. export * from "babylonjs/Sprites/spriteMap";
  74130. export * from "babylonjs/Sprites/spritePackedManager";
  74131. export * from "babylonjs/Sprites/spriteSceneComponent";
  74132. }
  74133. declare module "babylonjs/States/index" {
  74134. export * from "babylonjs/States/alphaCullingState";
  74135. export * from "babylonjs/States/depthCullingState";
  74136. export * from "babylonjs/States/stencilState";
  74137. }
  74138. declare module "babylonjs/Misc/assetsManager" {
  74139. import { Scene } from "babylonjs/scene";
  74140. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  74141. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  74142. import { Skeleton } from "babylonjs/Bones/skeleton";
  74143. import { Observable } from "babylonjs/Misc/observable";
  74144. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  74145. import { Texture } from "babylonjs/Materials/Textures/texture";
  74146. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  74147. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  74148. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  74149. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  74150. /**
  74151. * Defines the list of states available for a task inside a AssetsManager
  74152. */
  74153. export enum AssetTaskState {
  74154. /**
  74155. * Initialization
  74156. */
  74157. INIT = 0,
  74158. /**
  74159. * Running
  74160. */
  74161. RUNNING = 1,
  74162. /**
  74163. * Done
  74164. */
  74165. DONE = 2,
  74166. /**
  74167. * Error
  74168. */
  74169. ERROR = 3
  74170. }
  74171. /**
  74172. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  74173. */
  74174. export abstract class AbstractAssetTask {
  74175. /**
  74176. * Task name
  74177. */ name: string;
  74178. /**
  74179. * Callback called when the task is successful
  74180. */
  74181. onSuccess: (task: any) => void;
  74182. /**
  74183. * Callback called when the task is not successful
  74184. */
  74185. onError: (task: any, message?: string, exception?: any) => void;
  74186. /**
  74187. * Creates a new AssetsManager
  74188. * @param name defines the name of the task
  74189. */
  74190. constructor(
  74191. /**
  74192. * Task name
  74193. */ name: string);
  74194. private _isCompleted;
  74195. private _taskState;
  74196. private _errorObject;
  74197. /**
  74198. * Get if the task is completed
  74199. */
  74200. get isCompleted(): boolean;
  74201. /**
  74202. * Gets the current state of the task
  74203. */
  74204. get taskState(): AssetTaskState;
  74205. /**
  74206. * Gets the current error object (if task is in error)
  74207. */
  74208. get errorObject(): {
  74209. message?: string;
  74210. exception?: any;
  74211. };
  74212. /**
  74213. * Internal only
  74214. * @hidden
  74215. */
  74216. _setErrorObject(message?: string, exception?: any): void;
  74217. /**
  74218. * Execute the current task
  74219. * @param scene defines the scene where you want your assets to be loaded
  74220. * @param onSuccess is a callback called when the task is successfully executed
  74221. * @param onError is a callback called if an error occurs
  74222. */
  74223. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74224. /**
  74225. * Execute the current task
  74226. * @param scene defines the scene where you want your assets to be loaded
  74227. * @param onSuccess is a callback called when the task is successfully executed
  74228. * @param onError is a callback called if an error occurs
  74229. */
  74230. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74231. /**
  74232. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  74233. * This can be used with failed tasks that have the reason for failure fixed.
  74234. */
  74235. reset(): void;
  74236. private onErrorCallback;
  74237. private onDoneCallback;
  74238. }
  74239. /**
  74240. * Define the interface used by progress events raised during assets loading
  74241. */
  74242. export interface IAssetsProgressEvent {
  74243. /**
  74244. * Defines the number of remaining tasks to process
  74245. */
  74246. remainingCount: number;
  74247. /**
  74248. * Defines the total number of tasks
  74249. */
  74250. totalCount: number;
  74251. /**
  74252. * Defines the task that was just processed
  74253. */
  74254. task: AbstractAssetTask;
  74255. }
  74256. /**
  74257. * Class used to share progress information about assets loading
  74258. */
  74259. export class AssetsProgressEvent implements IAssetsProgressEvent {
  74260. /**
  74261. * Defines the number of remaining tasks to process
  74262. */
  74263. remainingCount: number;
  74264. /**
  74265. * Defines the total number of tasks
  74266. */
  74267. totalCount: number;
  74268. /**
  74269. * Defines the task that was just processed
  74270. */
  74271. task: AbstractAssetTask;
  74272. /**
  74273. * Creates a AssetsProgressEvent
  74274. * @param remainingCount defines the number of remaining tasks to process
  74275. * @param totalCount defines the total number of tasks
  74276. * @param task defines the task that was just processed
  74277. */
  74278. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  74279. }
  74280. /**
  74281. * Define a task used by AssetsManager to load meshes
  74282. */
  74283. export class MeshAssetTask extends AbstractAssetTask {
  74284. /**
  74285. * Defines the name of the task
  74286. */
  74287. name: string;
  74288. /**
  74289. * Defines the list of mesh's names you want to load
  74290. */
  74291. meshesNames: any;
  74292. /**
  74293. * Defines the root url to use as a base to load your meshes and associated resources
  74294. */
  74295. rootUrl: string;
  74296. /**
  74297. * Defines the filename or File of the scene to load from
  74298. */
  74299. sceneFilename: string | File;
  74300. /**
  74301. * Gets the list of loaded meshes
  74302. */
  74303. loadedMeshes: Array<AbstractMesh>;
  74304. /**
  74305. * Gets the list of loaded particle systems
  74306. */
  74307. loadedParticleSystems: Array<IParticleSystem>;
  74308. /**
  74309. * Gets the list of loaded skeletons
  74310. */
  74311. loadedSkeletons: Array<Skeleton>;
  74312. /**
  74313. * Gets the list of loaded animation groups
  74314. */
  74315. loadedAnimationGroups: Array<AnimationGroup>;
  74316. /**
  74317. * Callback called when the task is successful
  74318. */
  74319. onSuccess: (task: MeshAssetTask) => void;
  74320. /**
  74321. * Callback called when the task is successful
  74322. */
  74323. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  74324. /**
  74325. * Creates a new MeshAssetTask
  74326. * @param name defines the name of the task
  74327. * @param meshesNames defines the list of mesh's names you want to load
  74328. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  74329. * @param sceneFilename defines the filename or File of the scene to load from
  74330. */
  74331. constructor(
  74332. /**
  74333. * Defines the name of the task
  74334. */
  74335. name: string,
  74336. /**
  74337. * Defines the list of mesh's names you want to load
  74338. */
  74339. meshesNames: any,
  74340. /**
  74341. * Defines the root url to use as a base to load your meshes and associated resources
  74342. */
  74343. rootUrl: string,
  74344. /**
  74345. * Defines the filename or File of the scene to load from
  74346. */
  74347. sceneFilename: string | File);
  74348. /**
  74349. * Execute the current task
  74350. * @param scene defines the scene where you want your assets to be loaded
  74351. * @param onSuccess is a callback called when the task is successfully executed
  74352. * @param onError is a callback called if an error occurs
  74353. */
  74354. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74355. }
  74356. /**
  74357. * Define a task used by AssetsManager to load text content
  74358. */
  74359. export class TextFileAssetTask extends AbstractAssetTask {
  74360. /**
  74361. * Defines the name of the task
  74362. */
  74363. name: string;
  74364. /**
  74365. * Defines the location of the file to load
  74366. */
  74367. url: string;
  74368. /**
  74369. * Gets the loaded text string
  74370. */
  74371. text: string;
  74372. /**
  74373. * Callback called when the task is successful
  74374. */
  74375. onSuccess: (task: TextFileAssetTask) => void;
  74376. /**
  74377. * Callback called when the task is successful
  74378. */
  74379. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  74380. /**
  74381. * Creates a new TextFileAssetTask object
  74382. * @param name defines the name of the task
  74383. * @param url defines the location of the file to load
  74384. */
  74385. constructor(
  74386. /**
  74387. * Defines the name of the task
  74388. */
  74389. name: string,
  74390. /**
  74391. * Defines the location of the file to load
  74392. */
  74393. url: string);
  74394. /**
  74395. * Execute the current task
  74396. * @param scene defines the scene where you want your assets to be loaded
  74397. * @param onSuccess is a callback called when the task is successfully executed
  74398. * @param onError is a callback called if an error occurs
  74399. */
  74400. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74401. }
  74402. /**
  74403. * Define a task used by AssetsManager to load binary data
  74404. */
  74405. export class BinaryFileAssetTask extends AbstractAssetTask {
  74406. /**
  74407. * Defines the name of the task
  74408. */
  74409. name: string;
  74410. /**
  74411. * Defines the location of the file to load
  74412. */
  74413. url: string;
  74414. /**
  74415. * Gets the lodaded data (as an array buffer)
  74416. */
  74417. data: ArrayBuffer;
  74418. /**
  74419. * Callback called when the task is successful
  74420. */
  74421. onSuccess: (task: BinaryFileAssetTask) => void;
  74422. /**
  74423. * Callback called when the task is successful
  74424. */
  74425. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  74426. /**
  74427. * Creates a new BinaryFileAssetTask object
  74428. * @param name defines the name of the new task
  74429. * @param url defines the location of the file to load
  74430. */
  74431. constructor(
  74432. /**
  74433. * Defines the name of the task
  74434. */
  74435. name: string,
  74436. /**
  74437. * Defines the location of the file to load
  74438. */
  74439. url: string);
  74440. /**
  74441. * Execute the current task
  74442. * @param scene defines the scene where you want your assets to be loaded
  74443. * @param onSuccess is a callback called when the task is successfully executed
  74444. * @param onError is a callback called if an error occurs
  74445. */
  74446. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74447. }
  74448. /**
  74449. * Define a task used by AssetsManager to load images
  74450. */
  74451. export class ImageAssetTask extends AbstractAssetTask {
  74452. /**
  74453. * Defines the name of the task
  74454. */
  74455. name: string;
  74456. /**
  74457. * Defines the location of the image to load
  74458. */
  74459. url: string;
  74460. /**
  74461. * Gets the loaded images
  74462. */
  74463. image: HTMLImageElement;
  74464. /**
  74465. * Callback called when the task is successful
  74466. */
  74467. onSuccess: (task: ImageAssetTask) => void;
  74468. /**
  74469. * Callback called when the task is successful
  74470. */
  74471. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  74472. /**
  74473. * Creates a new ImageAssetTask
  74474. * @param name defines the name of the task
  74475. * @param url defines the location of the image to load
  74476. */
  74477. constructor(
  74478. /**
  74479. * Defines the name of the task
  74480. */
  74481. name: string,
  74482. /**
  74483. * Defines the location of the image to load
  74484. */
  74485. url: string);
  74486. /**
  74487. * Execute the current task
  74488. * @param scene defines the scene where you want your assets to be loaded
  74489. * @param onSuccess is a callback called when the task is successfully executed
  74490. * @param onError is a callback called if an error occurs
  74491. */
  74492. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74493. }
  74494. /**
  74495. * Defines the interface used by texture loading tasks
  74496. */
  74497. export interface ITextureAssetTask<TEX extends BaseTexture> {
  74498. /**
  74499. * Gets the loaded texture
  74500. */
  74501. texture: TEX;
  74502. }
  74503. /**
  74504. * Define a task used by AssetsManager to load 2D textures
  74505. */
  74506. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  74507. /**
  74508. * Defines the name of the task
  74509. */
  74510. name: string;
  74511. /**
  74512. * Defines the location of the file to load
  74513. */
  74514. url: string;
  74515. /**
  74516. * Defines if mipmap should not be generated (default is false)
  74517. */
  74518. noMipmap?: boolean | undefined;
  74519. /**
  74520. * Defines if texture must be inverted on Y axis (default is true)
  74521. */
  74522. invertY: boolean;
  74523. /**
  74524. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  74525. */
  74526. samplingMode: number;
  74527. /**
  74528. * Gets the loaded texture
  74529. */
  74530. texture: Texture;
  74531. /**
  74532. * Callback called when the task is successful
  74533. */
  74534. onSuccess: (task: TextureAssetTask) => void;
  74535. /**
  74536. * Callback called when the task is successful
  74537. */
  74538. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  74539. /**
  74540. * Creates a new TextureAssetTask object
  74541. * @param name defines the name of the task
  74542. * @param url defines the location of the file to load
  74543. * @param noMipmap defines if mipmap should not be generated (default is false)
  74544. * @param invertY defines if texture must be inverted on Y axis (default is true)
  74545. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  74546. */
  74547. constructor(
  74548. /**
  74549. * Defines the name of the task
  74550. */
  74551. name: string,
  74552. /**
  74553. * Defines the location of the file to load
  74554. */
  74555. url: string,
  74556. /**
  74557. * Defines if mipmap should not be generated (default is false)
  74558. */
  74559. noMipmap?: boolean | undefined,
  74560. /**
  74561. * Defines if texture must be inverted on Y axis (default is true)
  74562. */
  74563. invertY?: boolean,
  74564. /**
  74565. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  74566. */
  74567. samplingMode?: number);
  74568. /**
  74569. * Execute the current task
  74570. * @param scene defines the scene where you want your assets to be loaded
  74571. * @param onSuccess is a callback called when the task is successfully executed
  74572. * @param onError is a callback called if an error occurs
  74573. */
  74574. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74575. }
  74576. /**
  74577. * Define a task used by AssetsManager to load cube textures
  74578. */
  74579. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  74580. /**
  74581. * Defines the name of the task
  74582. */
  74583. name: string;
  74584. /**
  74585. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  74586. */
  74587. url: string;
  74588. /**
  74589. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  74590. */
  74591. extensions?: string[] | undefined;
  74592. /**
  74593. * Defines if mipmaps should not be generated (default is false)
  74594. */
  74595. noMipmap?: boolean | undefined;
  74596. /**
  74597. * Defines the explicit list of files (undefined by default)
  74598. */
  74599. files?: string[] | undefined;
  74600. /**
  74601. * Gets the loaded texture
  74602. */
  74603. texture: CubeTexture;
  74604. /**
  74605. * Callback called when the task is successful
  74606. */
  74607. onSuccess: (task: CubeTextureAssetTask) => void;
  74608. /**
  74609. * Callback called when the task is successful
  74610. */
  74611. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  74612. /**
  74613. * Creates a new CubeTextureAssetTask
  74614. * @param name defines the name of the task
  74615. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  74616. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  74617. * @param noMipmap defines if mipmaps should not be generated (default is false)
  74618. * @param files defines the explicit list of files (undefined by default)
  74619. */
  74620. constructor(
  74621. /**
  74622. * Defines the name of the task
  74623. */
  74624. name: string,
  74625. /**
  74626. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  74627. */
  74628. url: string,
  74629. /**
  74630. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  74631. */
  74632. extensions?: string[] | undefined,
  74633. /**
  74634. * Defines if mipmaps should not be generated (default is false)
  74635. */
  74636. noMipmap?: boolean | undefined,
  74637. /**
  74638. * Defines the explicit list of files (undefined by default)
  74639. */
  74640. files?: string[] | undefined);
  74641. /**
  74642. * Execute the current task
  74643. * @param scene defines the scene where you want your assets to be loaded
  74644. * @param onSuccess is a callback called when the task is successfully executed
  74645. * @param onError is a callback called if an error occurs
  74646. */
  74647. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74648. }
  74649. /**
  74650. * Define a task used by AssetsManager to load HDR cube textures
  74651. */
  74652. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  74653. /**
  74654. * Defines the name of the task
  74655. */
  74656. name: string;
  74657. /**
  74658. * Defines the location of the file to load
  74659. */
  74660. url: string;
  74661. /**
  74662. * Defines the desired size (the more it increases the longer the generation will be)
  74663. */
  74664. size: number;
  74665. /**
  74666. * Defines if mipmaps should not be generated (default is false)
  74667. */
  74668. noMipmap: boolean;
  74669. /**
  74670. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  74671. */
  74672. generateHarmonics: boolean;
  74673. /**
  74674. * 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)
  74675. */
  74676. gammaSpace: boolean;
  74677. /**
  74678. * Internal Use Only
  74679. */
  74680. reserved: boolean;
  74681. /**
  74682. * Gets the loaded texture
  74683. */
  74684. texture: HDRCubeTexture;
  74685. /**
  74686. * Callback called when the task is successful
  74687. */
  74688. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  74689. /**
  74690. * Callback called when the task is successful
  74691. */
  74692. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  74693. /**
  74694. * Creates a new HDRCubeTextureAssetTask object
  74695. * @param name defines the name of the task
  74696. * @param url defines the location of the file to load
  74697. * @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.
  74698. * @param noMipmap defines if mipmaps should not be generated (default is false)
  74699. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  74700. * @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)
  74701. * @param reserved Internal use only
  74702. */
  74703. constructor(
  74704. /**
  74705. * Defines the name of the task
  74706. */
  74707. name: string,
  74708. /**
  74709. * Defines the location of the file to load
  74710. */
  74711. url: string,
  74712. /**
  74713. * Defines the desired size (the more it increases the longer the generation will be)
  74714. */
  74715. size: number,
  74716. /**
  74717. * Defines if mipmaps should not be generated (default is false)
  74718. */
  74719. noMipmap?: boolean,
  74720. /**
  74721. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  74722. */
  74723. generateHarmonics?: boolean,
  74724. /**
  74725. * 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)
  74726. */
  74727. gammaSpace?: boolean,
  74728. /**
  74729. * Internal Use Only
  74730. */
  74731. reserved?: boolean);
  74732. /**
  74733. * Execute the current task
  74734. * @param scene defines the scene where you want your assets to be loaded
  74735. * @param onSuccess is a callback called when the task is successfully executed
  74736. * @param onError is a callback called if an error occurs
  74737. */
  74738. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74739. }
  74740. /**
  74741. * Define a task used by AssetsManager to load Equirectangular cube textures
  74742. */
  74743. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  74744. /**
  74745. * Defines the name of the task
  74746. */
  74747. name: string;
  74748. /**
  74749. * Defines the location of the file to load
  74750. */
  74751. url: string;
  74752. /**
  74753. * Defines the desired size (the more it increases the longer the generation will be)
  74754. */
  74755. size: number;
  74756. /**
  74757. * Defines if mipmaps should not be generated (default is false)
  74758. */
  74759. noMipmap: boolean;
  74760. /**
  74761. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  74762. * but the standard material would require them in Gamma space) (default is true)
  74763. */
  74764. gammaSpace: boolean;
  74765. /**
  74766. * Gets the loaded texture
  74767. */
  74768. texture: EquiRectangularCubeTexture;
  74769. /**
  74770. * Callback called when the task is successful
  74771. */
  74772. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  74773. /**
  74774. * Callback called when the task is successful
  74775. */
  74776. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  74777. /**
  74778. * Creates a new EquiRectangularCubeTextureAssetTask object
  74779. * @param name defines the name of the task
  74780. * @param url defines the location of the file to load
  74781. * @param size defines the desired size (the more it increases the longer the generation will be)
  74782. * If the size is omitted this implies you are using a preprocessed cubemap.
  74783. * @param noMipmap defines if mipmaps should not be generated (default is false)
  74784. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  74785. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  74786. * (default is true)
  74787. */
  74788. constructor(
  74789. /**
  74790. * Defines the name of the task
  74791. */
  74792. name: string,
  74793. /**
  74794. * Defines the location of the file to load
  74795. */
  74796. url: string,
  74797. /**
  74798. * Defines the desired size (the more it increases the longer the generation will be)
  74799. */
  74800. size: number,
  74801. /**
  74802. * Defines if mipmaps should not be generated (default is false)
  74803. */
  74804. noMipmap?: boolean,
  74805. /**
  74806. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  74807. * but the standard material would require them in Gamma space) (default is true)
  74808. */
  74809. gammaSpace?: boolean);
  74810. /**
  74811. * Execute the current task
  74812. * @param scene defines the scene where you want your assets to be loaded
  74813. * @param onSuccess is a callback called when the task is successfully executed
  74814. * @param onError is a callback called if an error occurs
  74815. */
  74816. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74817. }
  74818. /**
  74819. * This class can be used to easily import assets into a scene
  74820. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  74821. */
  74822. export class AssetsManager {
  74823. private _scene;
  74824. private _isLoading;
  74825. protected _tasks: AbstractAssetTask[];
  74826. protected _waitingTasksCount: number;
  74827. protected _totalTasksCount: number;
  74828. /**
  74829. * Callback called when all tasks are processed
  74830. */
  74831. onFinish: (tasks: AbstractAssetTask[]) => void;
  74832. /**
  74833. * Callback called when a task is successful
  74834. */
  74835. onTaskSuccess: (task: AbstractAssetTask) => void;
  74836. /**
  74837. * Callback called when a task had an error
  74838. */
  74839. onTaskError: (task: AbstractAssetTask) => void;
  74840. /**
  74841. * Callback called when a task is done (whatever the result is)
  74842. */
  74843. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  74844. /**
  74845. * Observable called when all tasks are processed
  74846. */
  74847. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  74848. /**
  74849. * Observable called when a task had an error
  74850. */
  74851. onTaskErrorObservable: Observable<AbstractAssetTask>;
  74852. /**
  74853. * Observable called when all tasks were executed
  74854. */
  74855. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  74856. /**
  74857. * Observable called when a task is done (whatever the result is)
  74858. */
  74859. onProgressObservable: Observable<IAssetsProgressEvent>;
  74860. /**
  74861. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  74862. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  74863. */
  74864. useDefaultLoadingScreen: boolean;
  74865. /**
  74866. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  74867. * when all assets have been downloaded.
  74868. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  74869. */
  74870. autoHideLoadingUI: boolean;
  74871. /**
  74872. * Creates a new AssetsManager
  74873. * @param scene defines the scene to work on
  74874. */
  74875. constructor(scene: Scene);
  74876. /**
  74877. * Add a MeshAssetTask to the list of active tasks
  74878. * @param taskName defines the name of the new task
  74879. * @param meshesNames defines the name of meshes to load
  74880. * @param rootUrl defines the root url to use to locate files
  74881. * @param sceneFilename defines the filename of the scene file
  74882. * @returns a new MeshAssetTask object
  74883. */
  74884. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  74885. /**
  74886. * Add a TextFileAssetTask to the list of active tasks
  74887. * @param taskName defines the name of the new task
  74888. * @param url defines the url of the file to load
  74889. * @returns a new TextFileAssetTask object
  74890. */
  74891. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  74892. /**
  74893. * Add a BinaryFileAssetTask to the list of active tasks
  74894. * @param taskName defines the name of the new task
  74895. * @param url defines the url of the file to load
  74896. * @returns a new BinaryFileAssetTask object
  74897. */
  74898. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  74899. /**
  74900. * Add a ImageAssetTask to the list of active tasks
  74901. * @param taskName defines the name of the new task
  74902. * @param url defines the url of the file to load
  74903. * @returns a new ImageAssetTask object
  74904. */
  74905. addImageTask(taskName: string, url: string): ImageAssetTask;
  74906. /**
  74907. * Add a TextureAssetTask to the list of active tasks
  74908. * @param taskName defines the name of the new task
  74909. * @param url defines the url of the file to load
  74910. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  74911. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  74912. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  74913. * @returns a new TextureAssetTask object
  74914. */
  74915. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  74916. /**
  74917. * Add a CubeTextureAssetTask to the list of active tasks
  74918. * @param taskName defines the name of the new task
  74919. * @param url defines the url of the file to load
  74920. * @param extensions defines the extension to use to load the cube map (can be null)
  74921. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  74922. * @param files defines the list of files to load (can be null)
  74923. * @returns a new CubeTextureAssetTask object
  74924. */
  74925. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  74926. /**
  74927. *
  74928. * Add a HDRCubeTextureAssetTask to the list of active tasks
  74929. * @param taskName defines the name of the new task
  74930. * @param url defines the url of the file to load
  74931. * @param size defines the size you want for the cubemap (can be null)
  74932. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  74933. * @param generateHarmonics defines if you want to automatically generate (true by default)
  74934. * @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)
  74935. * @param reserved Internal use only
  74936. * @returns a new HDRCubeTextureAssetTask object
  74937. */
  74938. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  74939. /**
  74940. *
  74941. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  74942. * @param taskName defines the name of the new task
  74943. * @param url defines the url of the file to load
  74944. * @param size defines the size you want for the cubemap (can be null)
  74945. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  74946. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  74947. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  74948. * @returns a new EquiRectangularCubeTextureAssetTask object
  74949. */
  74950. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  74951. /**
  74952. * Remove a task from the assets manager.
  74953. * @param task the task to remove
  74954. */
  74955. removeTask(task: AbstractAssetTask): void;
  74956. private _decreaseWaitingTasksCount;
  74957. private _runTask;
  74958. /**
  74959. * Reset the AssetsManager and remove all tasks
  74960. * @return the current instance of the AssetsManager
  74961. */
  74962. reset(): AssetsManager;
  74963. /**
  74964. * Start the loading process
  74965. * @return the current instance of the AssetsManager
  74966. */
  74967. load(): AssetsManager;
  74968. /**
  74969. * Start the loading process as an async operation
  74970. * @return a promise returning the list of failed tasks
  74971. */
  74972. loadAsync(): Promise<void>;
  74973. }
  74974. }
  74975. declare module "babylonjs/Misc/deferred" {
  74976. /**
  74977. * Wrapper class for promise with external resolve and reject.
  74978. */
  74979. export class Deferred<T> {
  74980. /**
  74981. * The promise associated with this deferred object.
  74982. */
  74983. readonly promise: Promise<T>;
  74984. private _resolve;
  74985. private _reject;
  74986. /**
  74987. * The resolve method of the promise associated with this deferred object.
  74988. */
  74989. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  74990. /**
  74991. * The reject method of the promise associated with this deferred object.
  74992. */
  74993. get reject(): (reason?: any) => void;
  74994. /**
  74995. * Constructor for this deferred object.
  74996. */
  74997. constructor();
  74998. }
  74999. }
  75000. declare module "babylonjs/Misc/meshExploder" {
  75001. import { Mesh } from "babylonjs/Meshes/mesh";
  75002. /**
  75003. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  75004. */
  75005. export class MeshExploder {
  75006. private _centerMesh;
  75007. private _meshes;
  75008. private _meshesOrigins;
  75009. private _toCenterVectors;
  75010. private _scaledDirection;
  75011. private _newPosition;
  75012. private _centerPosition;
  75013. /**
  75014. * Explodes meshes from a center mesh.
  75015. * @param meshes The meshes to explode.
  75016. * @param centerMesh The mesh to be center of explosion.
  75017. */
  75018. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  75019. private _setCenterMesh;
  75020. /**
  75021. * Get class name
  75022. * @returns "MeshExploder"
  75023. */
  75024. getClassName(): string;
  75025. /**
  75026. * "Exploded meshes"
  75027. * @returns Array of meshes with the centerMesh at index 0.
  75028. */
  75029. getMeshes(): Array<Mesh>;
  75030. /**
  75031. * Explodes meshes giving a specific direction
  75032. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  75033. */
  75034. explode(direction?: number): void;
  75035. }
  75036. }
  75037. declare module "babylonjs/Misc/filesInput" {
  75038. import { Engine } from "babylonjs/Engines/engine";
  75039. import { Scene } from "babylonjs/scene";
  75040. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  75041. /**
  75042. * Class used to help managing file picking and drag'n'drop
  75043. */
  75044. export class FilesInput {
  75045. /**
  75046. * List of files ready to be loaded
  75047. */
  75048. static get FilesToLoad(): {
  75049. [key: string]: File;
  75050. };
  75051. /**
  75052. * Callback called when a file is processed
  75053. */
  75054. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  75055. private _engine;
  75056. private _currentScene;
  75057. private _sceneLoadedCallback;
  75058. private _progressCallback;
  75059. private _additionalRenderLoopLogicCallback;
  75060. private _textureLoadingCallback;
  75061. private _startingProcessingFilesCallback;
  75062. private _onReloadCallback;
  75063. private _errorCallback;
  75064. private _elementToMonitor;
  75065. private _sceneFileToLoad;
  75066. private _filesToLoad;
  75067. /**
  75068. * Creates a new FilesInput
  75069. * @param engine defines the rendering engine
  75070. * @param scene defines the hosting scene
  75071. * @param sceneLoadedCallback callback called when scene is loaded
  75072. * @param progressCallback callback called to track progress
  75073. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  75074. * @param textureLoadingCallback callback called when a texture is loading
  75075. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  75076. * @param onReloadCallback callback called when a reload is requested
  75077. * @param errorCallback callback call if an error occurs
  75078. */
  75079. 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);
  75080. private _dragEnterHandler;
  75081. private _dragOverHandler;
  75082. private _dropHandler;
  75083. /**
  75084. * Calls this function to listen to drag'n'drop events on a specific DOM element
  75085. * @param elementToMonitor defines the DOM element to track
  75086. */
  75087. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  75088. /**
  75089. * Release all associated resources
  75090. */
  75091. dispose(): void;
  75092. private renderFunction;
  75093. private drag;
  75094. private drop;
  75095. private _traverseFolder;
  75096. private _processFiles;
  75097. /**
  75098. * Load files from a drop event
  75099. * @param event defines the drop event to use as source
  75100. */
  75101. loadFiles(event: any): void;
  75102. private _processReload;
  75103. /**
  75104. * Reload the current scene from the loaded files
  75105. */
  75106. reload(): void;
  75107. }
  75108. }
  75109. declare module "babylonjs/Misc/HighDynamicRange/index" {
  75110. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  75111. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  75112. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  75113. }
  75114. declare module "babylonjs/Misc/sceneOptimizer" {
  75115. import { Scene, IDisposable } from "babylonjs/scene";
  75116. import { Observable } from "babylonjs/Misc/observable";
  75117. /**
  75118. * Defines the root class used to create scene optimization to use with SceneOptimizer
  75119. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75120. */
  75121. export class SceneOptimization {
  75122. /**
  75123. * Defines the priority of this optimization (0 by default which means first in the list)
  75124. */
  75125. priority: number;
  75126. /**
  75127. * Gets a string describing the action executed by the current optimization
  75128. * @returns description string
  75129. */
  75130. getDescription(): string;
  75131. /**
  75132. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75133. * @param scene defines the current scene where to apply this optimization
  75134. * @param optimizer defines the current optimizer
  75135. * @returns true if everything that can be done was applied
  75136. */
  75137. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75138. /**
  75139. * Creates the SceneOptimization object
  75140. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  75141. * @param desc defines the description associated with the optimization
  75142. */
  75143. constructor(
  75144. /**
  75145. * Defines the priority of this optimization (0 by default which means first in the list)
  75146. */
  75147. priority?: number);
  75148. }
  75149. /**
  75150. * Defines an optimization used to reduce the size of render target textures
  75151. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75152. */
  75153. export class TextureOptimization extends SceneOptimization {
  75154. /**
  75155. * Defines the priority of this optimization (0 by default which means first in the list)
  75156. */
  75157. priority: number;
  75158. /**
  75159. * 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
  75160. */
  75161. maximumSize: number;
  75162. /**
  75163. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  75164. */
  75165. step: number;
  75166. /**
  75167. * Gets a string describing the action executed by the current optimization
  75168. * @returns description string
  75169. */
  75170. getDescription(): string;
  75171. /**
  75172. * Creates the TextureOptimization object
  75173. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  75174. * @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
  75175. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  75176. */
  75177. constructor(
  75178. /**
  75179. * Defines the priority of this optimization (0 by default which means first in the list)
  75180. */
  75181. priority?: number,
  75182. /**
  75183. * 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
  75184. */
  75185. maximumSize?: number,
  75186. /**
  75187. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  75188. */
  75189. step?: number);
  75190. /**
  75191. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75192. * @param scene defines the current scene where to apply this optimization
  75193. * @param optimizer defines the current optimizer
  75194. * @returns true if everything that can be done was applied
  75195. */
  75196. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75197. }
  75198. /**
  75199. * Defines an optimization used to increase or decrease the rendering resolution
  75200. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75201. */
  75202. export class HardwareScalingOptimization extends SceneOptimization {
  75203. /**
  75204. * Defines the priority of this optimization (0 by default which means first in the list)
  75205. */
  75206. priority: number;
  75207. /**
  75208. * Defines the maximum scale to use (2 by default)
  75209. */
  75210. maximumScale: number;
  75211. /**
  75212. * Defines the step to use between two passes (0.5 by default)
  75213. */
  75214. step: number;
  75215. private _currentScale;
  75216. private _directionOffset;
  75217. /**
  75218. * Gets a string describing the action executed by the current optimization
  75219. * @return description string
  75220. */
  75221. getDescription(): string;
  75222. /**
  75223. * Creates the HardwareScalingOptimization object
  75224. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  75225. * @param maximumScale defines the maximum scale to use (2 by default)
  75226. * @param step defines the step to use between two passes (0.5 by default)
  75227. */
  75228. constructor(
  75229. /**
  75230. * Defines the priority of this optimization (0 by default which means first in the list)
  75231. */
  75232. priority?: number,
  75233. /**
  75234. * Defines the maximum scale to use (2 by default)
  75235. */
  75236. maximumScale?: number,
  75237. /**
  75238. * Defines the step to use between two passes (0.5 by default)
  75239. */
  75240. step?: number);
  75241. /**
  75242. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75243. * @param scene defines the current scene where to apply this optimization
  75244. * @param optimizer defines the current optimizer
  75245. * @returns true if everything that can be done was applied
  75246. */
  75247. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75248. }
  75249. /**
  75250. * Defines an optimization used to remove shadows
  75251. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75252. */
  75253. export class ShadowsOptimization extends SceneOptimization {
  75254. /**
  75255. * Gets a string describing the action executed by the current optimization
  75256. * @return description string
  75257. */
  75258. getDescription(): string;
  75259. /**
  75260. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75261. * @param scene defines the current scene where to apply this optimization
  75262. * @param optimizer defines the current optimizer
  75263. * @returns true if everything that can be done was applied
  75264. */
  75265. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75266. }
  75267. /**
  75268. * Defines an optimization used to turn post-processes off
  75269. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75270. */
  75271. export class PostProcessesOptimization extends SceneOptimization {
  75272. /**
  75273. * Gets a string describing the action executed by the current optimization
  75274. * @return description string
  75275. */
  75276. getDescription(): string;
  75277. /**
  75278. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75279. * @param scene defines the current scene where to apply this optimization
  75280. * @param optimizer defines the current optimizer
  75281. * @returns true if everything that can be done was applied
  75282. */
  75283. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75284. }
  75285. /**
  75286. * Defines an optimization used to turn lens flares off
  75287. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75288. */
  75289. export class LensFlaresOptimization extends SceneOptimization {
  75290. /**
  75291. * Gets a string describing the action executed by the current optimization
  75292. * @return description string
  75293. */
  75294. getDescription(): string;
  75295. /**
  75296. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75297. * @param scene defines the current scene where to apply this optimization
  75298. * @param optimizer defines the current optimizer
  75299. * @returns true if everything that can be done was applied
  75300. */
  75301. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75302. }
  75303. /**
  75304. * Defines an optimization based on user defined callback.
  75305. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75306. */
  75307. export class CustomOptimization extends SceneOptimization {
  75308. /**
  75309. * Callback called to apply the custom optimization.
  75310. */
  75311. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  75312. /**
  75313. * Callback called to get custom description
  75314. */
  75315. onGetDescription: () => string;
  75316. /**
  75317. * Gets a string describing the action executed by the current optimization
  75318. * @returns description string
  75319. */
  75320. getDescription(): string;
  75321. /**
  75322. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75323. * @param scene defines the current scene where to apply this optimization
  75324. * @param optimizer defines the current optimizer
  75325. * @returns true if everything that can be done was applied
  75326. */
  75327. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75328. }
  75329. /**
  75330. * Defines an optimization used to turn particles off
  75331. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75332. */
  75333. export class ParticlesOptimization extends SceneOptimization {
  75334. /**
  75335. * Gets a string describing the action executed by the current optimization
  75336. * @return description string
  75337. */
  75338. getDescription(): string;
  75339. /**
  75340. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75341. * @param scene defines the current scene where to apply this optimization
  75342. * @param optimizer defines the current optimizer
  75343. * @returns true if everything that can be done was applied
  75344. */
  75345. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75346. }
  75347. /**
  75348. * Defines an optimization used to turn render targets off
  75349. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75350. */
  75351. export class RenderTargetsOptimization extends SceneOptimization {
  75352. /**
  75353. * Gets a string describing the action executed by the current optimization
  75354. * @return description string
  75355. */
  75356. getDescription(): string;
  75357. /**
  75358. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75359. * @param scene defines the current scene where to apply this optimization
  75360. * @param optimizer defines the current optimizer
  75361. * @returns true if everything that can be done was applied
  75362. */
  75363. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75364. }
  75365. /**
  75366. * Defines an optimization used to merge meshes with compatible materials
  75367. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75368. */
  75369. export class MergeMeshesOptimization extends SceneOptimization {
  75370. private static _UpdateSelectionTree;
  75371. /**
  75372. * Gets or sets a boolean which defines if optimization octree has to be updated
  75373. */
  75374. static get UpdateSelectionTree(): boolean;
  75375. /**
  75376. * Gets or sets a boolean which defines if optimization octree has to be updated
  75377. */
  75378. static set UpdateSelectionTree(value: boolean);
  75379. /**
  75380. * Gets a string describing the action executed by the current optimization
  75381. * @return description string
  75382. */
  75383. getDescription(): string;
  75384. private _canBeMerged;
  75385. /**
  75386. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75387. * @param scene defines the current scene where to apply this optimization
  75388. * @param optimizer defines the current optimizer
  75389. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  75390. * @returns true if everything that can be done was applied
  75391. */
  75392. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  75393. }
  75394. /**
  75395. * Defines a list of options used by SceneOptimizer
  75396. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75397. */
  75398. export class SceneOptimizerOptions {
  75399. /**
  75400. * Defines the target frame rate to reach (60 by default)
  75401. */
  75402. targetFrameRate: number;
  75403. /**
  75404. * Defines the interval between two checkes (2000ms by default)
  75405. */
  75406. trackerDuration: number;
  75407. /**
  75408. * Gets the list of optimizations to apply
  75409. */
  75410. optimizations: SceneOptimization[];
  75411. /**
  75412. * Creates a new list of options used by SceneOptimizer
  75413. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  75414. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  75415. */
  75416. constructor(
  75417. /**
  75418. * Defines the target frame rate to reach (60 by default)
  75419. */
  75420. targetFrameRate?: number,
  75421. /**
  75422. * Defines the interval between two checkes (2000ms by default)
  75423. */
  75424. trackerDuration?: number);
  75425. /**
  75426. * Add a new optimization
  75427. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  75428. * @returns the current SceneOptimizerOptions
  75429. */
  75430. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  75431. /**
  75432. * Add a new custom optimization
  75433. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  75434. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  75435. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  75436. * @returns the current SceneOptimizerOptions
  75437. */
  75438. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  75439. /**
  75440. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  75441. * @param targetFrameRate defines the target frame rate (60 by default)
  75442. * @returns a SceneOptimizerOptions object
  75443. */
  75444. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  75445. /**
  75446. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  75447. * @param targetFrameRate defines the target frame rate (60 by default)
  75448. * @returns a SceneOptimizerOptions object
  75449. */
  75450. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  75451. /**
  75452. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  75453. * @param targetFrameRate defines the target frame rate (60 by default)
  75454. * @returns a SceneOptimizerOptions object
  75455. */
  75456. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  75457. }
  75458. /**
  75459. * Class used to run optimizations in order to reach a target frame rate
  75460. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75461. */
  75462. export class SceneOptimizer implements IDisposable {
  75463. private _isRunning;
  75464. private _options;
  75465. private _scene;
  75466. private _currentPriorityLevel;
  75467. private _targetFrameRate;
  75468. private _trackerDuration;
  75469. private _currentFrameRate;
  75470. private _sceneDisposeObserver;
  75471. private _improvementMode;
  75472. /**
  75473. * Defines an observable called when the optimizer reaches the target frame rate
  75474. */
  75475. onSuccessObservable: Observable<SceneOptimizer>;
  75476. /**
  75477. * Defines an observable called when the optimizer enables an optimization
  75478. */
  75479. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  75480. /**
  75481. * Defines an observable called when the optimizer is not able to reach the target frame rate
  75482. */
  75483. onFailureObservable: Observable<SceneOptimizer>;
  75484. /**
  75485. * Gets a boolean indicating if the optimizer is in improvement mode
  75486. */
  75487. get isInImprovementMode(): boolean;
  75488. /**
  75489. * Gets the current priority level (0 at start)
  75490. */
  75491. get currentPriorityLevel(): number;
  75492. /**
  75493. * Gets the current frame rate checked by the SceneOptimizer
  75494. */
  75495. get currentFrameRate(): number;
  75496. /**
  75497. * Gets or sets the current target frame rate (60 by default)
  75498. */
  75499. get targetFrameRate(): number;
  75500. /**
  75501. * Gets or sets the current target frame rate (60 by default)
  75502. */
  75503. set targetFrameRate(value: number);
  75504. /**
  75505. * Gets or sets the current interval between two checks (every 2000ms by default)
  75506. */
  75507. get trackerDuration(): number;
  75508. /**
  75509. * Gets or sets the current interval between two checks (every 2000ms by default)
  75510. */
  75511. set trackerDuration(value: number);
  75512. /**
  75513. * Gets the list of active optimizations
  75514. */
  75515. get optimizations(): SceneOptimization[];
  75516. /**
  75517. * Creates a new SceneOptimizer
  75518. * @param scene defines the scene to work on
  75519. * @param options defines the options to use with the SceneOptimizer
  75520. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  75521. * @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)
  75522. */
  75523. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  75524. /**
  75525. * Stops the current optimizer
  75526. */
  75527. stop(): void;
  75528. /**
  75529. * Reset the optimizer to initial step (current priority level = 0)
  75530. */
  75531. reset(): void;
  75532. /**
  75533. * Start the optimizer. By default it will try to reach a specific framerate
  75534. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  75535. */
  75536. start(): void;
  75537. private _checkCurrentState;
  75538. /**
  75539. * Release all resources
  75540. */
  75541. dispose(): void;
  75542. /**
  75543. * Helper function to create a SceneOptimizer with one single line of code
  75544. * @param scene defines the scene to work on
  75545. * @param options defines the options to use with the SceneOptimizer
  75546. * @param onSuccess defines a callback to call on success
  75547. * @param onFailure defines a callback to call on failure
  75548. * @returns the new SceneOptimizer object
  75549. */
  75550. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  75551. }
  75552. }
  75553. declare module "babylonjs/Misc/sceneSerializer" {
  75554. import { Scene } from "babylonjs/scene";
  75555. /**
  75556. * Class used to serialize a scene into a string
  75557. */
  75558. export class SceneSerializer {
  75559. /**
  75560. * Clear cache used by a previous serialization
  75561. */
  75562. static ClearCache(): void;
  75563. /**
  75564. * Serialize a scene into a JSON compatible object
  75565. * @param scene defines the scene to serialize
  75566. * @returns a JSON compatible object
  75567. */
  75568. static Serialize(scene: Scene): any;
  75569. /**
  75570. * Serialize a mesh into a JSON compatible object
  75571. * @param toSerialize defines the mesh to serialize
  75572. * @param withParents defines if parents must be serialized as well
  75573. * @param withChildren defines if children must be serialized as well
  75574. * @returns a JSON compatible object
  75575. */
  75576. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  75577. }
  75578. }
  75579. declare module "babylonjs/Misc/textureTools" {
  75580. import { Texture } from "babylonjs/Materials/Textures/texture";
  75581. /**
  75582. * Class used to host texture specific utilities
  75583. */
  75584. export class TextureTools {
  75585. /**
  75586. * Uses the GPU to create a copy texture rescaled at a given size
  75587. * @param texture Texture to copy from
  75588. * @param width defines the desired width
  75589. * @param height defines the desired height
  75590. * @param useBilinearMode defines if bilinear mode has to be used
  75591. * @return the generated texture
  75592. */
  75593. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  75594. }
  75595. }
  75596. declare module "babylonjs/Misc/videoRecorder" {
  75597. import { Nullable } from "babylonjs/types";
  75598. import { Engine } from "babylonjs/Engines/engine";
  75599. /**
  75600. * This represents the different options available for the video capture.
  75601. */
  75602. export interface VideoRecorderOptions {
  75603. /** Defines the mime type of the video. */
  75604. mimeType: string;
  75605. /** Defines the FPS the video should be recorded at. */
  75606. fps: number;
  75607. /** Defines the chunk size for the recording data. */
  75608. recordChunckSize: number;
  75609. /** The audio tracks to attach to the recording. */
  75610. audioTracks?: MediaStreamTrack[];
  75611. }
  75612. /**
  75613. * This can help with recording videos from BabylonJS.
  75614. * This is based on the available WebRTC functionalities of the browser.
  75615. *
  75616. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  75617. */
  75618. export class VideoRecorder {
  75619. private static readonly _defaultOptions;
  75620. /**
  75621. * Returns whether or not the VideoRecorder is available in your browser.
  75622. * @param engine Defines the Babylon Engine.
  75623. * @returns true if supported otherwise false.
  75624. */
  75625. static IsSupported(engine: Engine): boolean;
  75626. private readonly _options;
  75627. private _canvas;
  75628. private _mediaRecorder;
  75629. private _recordedChunks;
  75630. private _fileName;
  75631. private _resolve;
  75632. private _reject;
  75633. /**
  75634. * True when a recording is already in progress.
  75635. */
  75636. get isRecording(): boolean;
  75637. /**
  75638. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  75639. * @param engine Defines the BabylonJS Engine you wish to record.
  75640. * @param options Defines options that can be used to customize the capture.
  75641. */
  75642. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  75643. /**
  75644. * Stops the current recording before the default capture timeout passed in the startRecording function.
  75645. */
  75646. stopRecording(): void;
  75647. /**
  75648. * Starts recording the canvas for a max duration specified in parameters.
  75649. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  75650. * If null no automatic download will start and you can rely on the promise to get the data back.
  75651. * @param maxDuration Defines the maximum recording time in seconds.
  75652. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  75653. * @return A promise callback at the end of the recording with the video data in Blob.
  75654. */
  75655. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  75656. /**
  75657. * Releases internal resources used during the recording.
  75658. */
  75659. dispose(): void;
  75660. private _handleDataAvailable;
  75661. private _handleError;
  75662. private _handleStop;
  75663. }
  75664. }
  75665. declare module "babylonjs/Misc/screenshotTools" {
  75666. import { Camera } from "babylonjs/Cameras/camera";
  75667. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  75668. import { Engine } from "babylonjs/Engines/engine";
  75669. /**
  75670. * Class containing a set of static utilities functions for screenshots
  75671. */
  75672. export class ScreenshotTools {
  75673. /**
  75674. * Captures a screenshot of the current rendering
  75675. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  75676. * @param engine defines the rendering engine
  75677. * @param camera defines the source camera
  75678. * @param size This parameter can be set to a single number or to an object with the
  75679. * following (optional) properties: precision, width, height. If a single number is passed,
  75680. * it will be used for both width and height. If an object is passed, the screenshot size
  75681. * will be derived from the parameters. The precision property is a multiplier allowing
  75682. * rendering at a higher or lower resolution
  75683. * @param successCallback defines the callback receives a single parameter which contains the
  75684. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  75685. * src parameter of an <img> to display it
  75686. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  75687. * Check your browser for supported MIME types
  75688. */
  75689. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  75690. /**
  75691. * Captures a screenshot of the current rendering
  75692. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  75693. * @param engine defines the rendering engine
  75694. * @param camera defines the source camera
  75695. * @param size This parameter can be set to a single number or to an object with the
  75696. * following (optional) properties: precision, width, height. If a single number is passed,
  75697. * it will be used for both width and height. If an object is passed, the screenshot size
  75698. * will be derived from the parameters. The precision property is a multiplier allowing
  75699. * rendering at a higher or lower resolution
  75700. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  75701. * Check your browser for supported MIME types
  75702. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  75703. * to the src parameter of an <img> to display it
  75704. */
  75705. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  75706. /**
  75707. * Generates an image screenshot from the specified camera.
  75708. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  75709. * @param engine The engine to use for rendering
  75710. * @param camera The camera to use for rendering
  75711. * @param size This parameter can be set to a single number or to an object with the
  75712. * following (optional) properties: precision, width, height. If a single number is passed,
  75713. * it will be used for both width and height. If an object is passed, the screenshot size
  75714. * will be derived from the parameters. The precision property is a multiplier allowing
  75715. * rendering at a higher or lower resolution
  75716. * @param successCallback The callback receives a single parameter which contains the
  75717. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  75718. * src parameter of an <img> to display it
  75719. * @param mimeType The MIME type of the screenshot image (default: image/png).
  75720. * Check your browser for supported MIME types
  75721. * @param samples Texture samples (default: 1)
  75722. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  75723. * @param fileName A name for for the downloaded file.
  75724. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  75725. */
  75726. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  75727. /**
  75728. * Generates an image screenshot from the specified camera.
  75729. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  75730. * @param engine The engine to use for rendering
  75731. * @param camera The camera to use for rendering
  75732. * @param size This parameter can be set to a single number or to an object with the
  75733. * following (optional) properties: precision, width, height. If a single number is passed,
  75734. * it will be used for both width and height. If an object is passed, the screenshot size
  75735. * will be derived from the parameters. The precision property is a multiplier allowing
  75736. * rendering at a higher or lower resolution
  75737. * @param mimeType The MIME type of the screenshot image (default: image/png).
  75738. * Check your browser for supported MIME types
  75739. * @param samples Texture samples (default: 1)
  75740. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  75741. * @param fileName A name for for the downloaded file.
  75742. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  75743. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  75744. * to the src parameter of an <img> to display it
  75745. */
  75746. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  75747. /**
  75748. * Gets height and width for screenshot size
  75749. * @private
  75750. */
  75751. private static _getScreenshotSize;
  75752. }
  75753. }
  75754. declare module "babylonjs/Misc/dataReader" {
  75755. /**
  75756. * Interface for a data buffer
  75757. */
  75758. export interface IDataBuffer {
  75759. /**
  75760. * Reads bytes from the data buffer.
  75761. * @param byteOffset The byte offset to read
  75762. * @param byteLength The byte length to read
  75763. * @returns A promise that resolves when the bytes are read
  75764. */
  75765. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  75766. /**
  75767. * The byte length of the buffer.
  75768. */
  75769. readonly byteLength: number;
  75770. }
  75771. /**
  75772. * Utility class for reading from a data buffer
  75773. */
  75774. export class DataReader {
  75775. /**
  75776. * The data buffer associated with this data reader.
  75777. */
  75778. readonly buffer: IDataBuffer;
  75779. /**
  75780. * The current byte offset from the beginning of the data buffer.
  75781. */
  75782. byteOffset: number;
  75783. private _dataView;
  75784. private _dataByteOffset;
  75785. /**
  75786. * Constructor
  75787. * @param buffer The buffer to read
  75788. */
  75789. constructor(buffer: IDataBuffer);
  75790. /**
  75791. * Loads the given byte length.
  75792. * @param byteLength The byte length to load
  75793. * @returns A promise that resolves when the load is complete
  75794. */
  75795. loadAsync(byteLength: number): Promise<void>;
  75796. /**
  75797. * Read a unsigned 32-bit integer from the currently loaded data range.
  75798. * @returns The 32-bit integer read
  75799. */
  75800. readUint32(): number;
  75801. /**
  75802. * Read a byte array from the currently loaded data range.
  75803. * @param byteLength The byte length to read
  75804. * @returns The byte array read
  75805. */
  75806. readUint8Array(byteLength: number): Uint8Array;
  75807. /**
  75808. * Read a string from the currently loaded data range.
  75809. * @param byteLength The byte length to read
  75810. * @returns The string read
  75811. */
  75812. readString(byteLength: number): string;
  75813. /**
  75814. * Skips the given byte length the currently loaded data range.
  75815. * @param byteLength The byte length to skip
  75816. */
  75817. skipBytes(byteLength: number): void;
  75818. }
  75819. }
  75820. declare module "babylonjs/Misc/dataStorage" {
  75821. /**
  75822. * Class for storing data to local storage if available or in-memory storage otherwise
  75823. */
  75824. export class DataStorage {
  75825. private static _Storage;
  75826. private static _GetStorage;
  75827. /**
  75828. * Reads a string from the data storage
  75829. * @param key The key to read
  75830. * @param defaultValue The value if the key doesn't exist
  75831. * @returns The string value
  75832. */
  75833. static ReadString(key: string, defaultValue: string): string;
  75834. /**
  75835. * Writes a string to the data storage
  75836. * @param key The key to write
  75837. * @param value The value to write
  75838. */
  75839. static WriteString(key: string, value: string): void;
  75840. /**
  75841. * Reads a boolean from the data storage
  75842. * @param key The key to read
  75843. * @param defaultValue The value if the key doesn't exist
  75844. * @returns The boolean value
  75845. */
  75846. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  75847. /**
  75848. * Writes a boolean to the data storage
  75849. * @param key The key to write
  75850. * @param value The value to write
  75851. */
  75852. static WriteBoolean(key: string, value: boolean): void;
  75853. /**
  75854. * Reads a number from the data storage
  75855. * @param key The key to read
  75856. * @param defaultValue The value if the key doesn't exist
  75857. * @returns The number value
  75858. */
  75859. static ReadNumber(key: string, defaultValue: number): number;
  75860. /**
  75861. * Writes a number to the data storage
  75862. * @param key The key to write
  75863. * @param value The value to write
  75864. */
  75865. static WriteNumber(key: string, value: number): void;
  75866. }
  75867. }
  75868. declare module "babylonjs/Misc/index" {
  75869. export * from "babylonjs/Misc/andOrNotEvaluator";
  75870. export * from "babylonjs/Misc/assetsManager";
  75871. export * from "babylonjs/Misc/basis";
  75872. export * from "babylonjs/Misc/dds";
  75873. export * from "babylonjs/Misc/decorators";
  75874. export * from "babylonjs/Misc/deferred";
  75875. export * from "babylonjs/Misc/environmentTextureTools";
  75876. export * from "babylonjs/Misc/meshExploder";
  75877. export * from "babylonjs/Misc/filesInput";
  75878. export * from "babylonjs/Misc/HighDynamicRange/index";
  75879. export * from "babylonjs/Misc/khronosTextureContainer";
  75880. export * from "babylonjs/Misc/observable";
  75881. export * from "babylonjs/Misc/performanceMonitor";
  75882. export * from "babylonjs/Misc/promise";
  75883. export * from "babylonjs/Misc/sceneOptimizer";
  75884. export * from "babylonjs/Misc/sceneSerializer";
  75885. export * from "babylonjs/Misc/smartArray";
  75886. export * from "babylonjs/Misc/stringDictionary";
  75887. export * from "babylonjs/Misc/tags";
  75888. export * from "babylonjs/Misc/textureTools";
  75889. export * from "babylonjs/Misc/tga";
  75890. export * from "babylonjs/Misc/tools";
  75891. export * from "babylonjs/Misc/videoRecorder";
  75892. export * from "babylonjs/Misc/virtualJoystick";
  75893. export * from "babylonjs/Misc/workerPool";
  75894. export * from "babylonjs/Misc/logger";
  75895. export * from "babylonjs/Misc/typeStore";
  75896. export * from "babylonjs/Misc/filesInputStore";
  75897. export * from "babylonjs/Misc/deepCopier";
  75898. export * from "babylonjs/Misc/pivotTools";
  75899. export * from "babylonjs/Misc/precisionDate";
  75900. export * from "babylonjs/Misc/screenshotTools";
  75901. export * from "babylonjs/Misc/typeStore";
  75902. export * from "babylonjs/Misc/webRequest";
  75903. export * from "babylonjs/Misc/iInspectable";
  75904. export * from "babylonjs/Misc/brdfTextureTools";
  75905. export * from "babylonjs/Misc/rgbdTextureTools";
  75906. export * from "babylonjs/Misc/gradients";
  75907. export * from "babylonjs/Misc/perfCounter";
  75908. export * from "babylonjs/Misc/fileRequest";
  75909. export * from "babylonjs/Misc/customAnimationFrameRequester";
  75910. export * from "babylonjs/Misc/retryStrategy";
  75911. export * from "babylonjs/Misc/interfaces/screenshotSize";
  75912. export * from "babylonjs/Misc/canvasGenerator";
  75913. export * from "babylonjs/Misc/fileTools";
  75914. export * from "babylonjs/Misc/stringTools";
  75915. export * from "babylonjs/Misc/dataReader";
  75916. export * from "babylonjs/Misc/minMaxReducer";
  75917. export * from "babylonjs/Misc/depthReducer";
  75918. export * from "babylonjs/Misc/dataStorage";
  75919. }
  75920. declare module "babylonjs/XR/features/WebXRHitTestLegacy" {
  75921. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  75922. import { Observable } from "babylonjs/Misc/observable";
  75923. import { Matrix } from "babylonjs/Maths/math.vector";
  75924. import { TransformNode } from "babylonjs/Meshes/transformNode";
  75925. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  75926. /**
  75927. * Options used for hit testing
  75928. */
  75929. export interface IWebXRLegacyHitTestOptions {
  75930. /**
  75931. * Only test when user interacted with the scene. Default - hit test every frame
  75932. */
  75933. testOnPointerDownOnly?: boolean;
  75934. /**
  75935. * The node to use to transform the local results to world coordinates
  75936. */
  75937. worldParentNode?: TransformNode;
  75938. }
  75939. /**
  75940. * Interface defining the babylon result of raycasting/hit-test
  75941. */
  75942. export interface IWebXRLegacyHitResult {
  75943. /**
  75944. * Transformation matrix that can be applied to a node that will put it in the hit point location
  75945. */
  75946. transformationMatrix: Matrix;
  75947. /**
  75948. * The native hit test result
  75949. */
  75950. xrHitResult: XRHitResult | XRHitTestResult;
  75951. }
  75952. /**
  75953. * The currently-working hit-test module.
  75954. * Hit test (or Ray-casting) is used to interact with the real world.
  75955. * For further information read here - https://github.com/immersive-web/hit-test
  75956. */
  75957. export class WebXRHitTestLegacy extends WebXRAbstractFeature {
  75958. /**
  75959. * options to use when constructing this feature
  75960. */
  75961. readonly options: IWebXRLegacyHitTestOptions;
  75962. private _direction;
  75963. private _mat;
  75964. private _onSelectEnabled;
  75965. private _origin;
  75966. /**
  75967. * The module's name
  75968. */
  75969. static readonly Name: string;
  75970. /**
  75971. * The (Babylon) version of this module.
  75972. * This is an integer representing the implementation version.
  75973. * This number does not correspond to the WebXR specs version
  75974. */
  75975. static readonly Version: number;
  75976. /**
  75977. * Populated with the last native XR Hit Results
  75978. */
  75979. lastNativeXRHitResults: XRHitResult[];
  75980. /**
  75981. * Triggered when new babylon (transformed) hit test results are available
  75982. */
  75983. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  75984. /**
  75985. * Creates a new instance of the (legacy version) hit test feature
  75986. * @param _xrSessionManager an instance of WebXRSessionManager
  75987. * @param options options to use when constructing this feature
  75988. */
  75989. constructor(_xrSessionManager: WebXRSessionManager,
  75990. /**
  75991. * options to use when constructing this feature
  75992. */
  75993. options?: IWebXRLegacyHitTestOptions);
  75994. /**
  75995. * execute a hit test with an XR Ray
  75996. *
  75997. * @param xrSession a native xrSession that will execute this hit test
  75998. * @param xrRay the ray (position and direction) to use for ray-casting
  75999. * @param referenceSpace native XR reference space to use for the hit-test
  76000. * @param filter filter function that will filter the results
  76001. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  76002. */
  76003. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  76004. /**
  76005. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  76006. * @param event the (select) event to use to select with
  76007. * @param referenceSpace the reference space to use for this hit test
  76008. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  76009. */
  76010. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  76011. /**
  76012. * attach this feature
  76013. * Will usually be called by the features manager
  76014. *
  76015. * @returns true if successful.
  76016. */
  76017. attach(): boolean;
  76018. /**
  76019. * detach this feature.
  76020. * Will usually be called by the features manager
  76021. *
  76022. * @returns true if successful.
  76023. */
  76024. detach(): boolean;
  76025. /**
  76026. * Dispose this feature and all of the resources attached
  76027. */
  76028. dispose(): void;
  76029. protected _onXRFrame(frame: XRFrame): void;
  76030. private _onHitTestResults;
  76031. private _onSelect;
  76032. }
  76033. }
  76034. declare module "babylonjs/XR/features/WebXRPlaneDetector" {
  76035. import { TransformNode } from "babylonjs/Meshes/transformNode";
  76036. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  76037. import { Observable } from "babylonjs/Misc/observable";
  76038. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  76039. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  76040. /**
  76041. * Options used in the plane detector module
  76042. */
  76043. export interface IWebXRPlaneDetectorOptions {
  76044. /**
  76045. * The node to use to transform the local results to world coordinates
  76046. */
  76047. worldParentNode?: TransformNode;
  76048. }
  76049. /**
  76050. * A babylon interface for a WebXR plane.
  76051. * A Plane is actually a polygon, built from N points in space
  76052. *
  76053. * Supported in chrome 79, not supported in canary 81 ATM
  76054. */
  76055. export interface IWebXRPlane {
  76056. /**
  76057. * a babylon-assigned ID for this polygon
  76058. */
  76059. id: number;
  76060. /**
  76061. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  76062. */
  76063. polygonDefinition: Array<Vector3>;
  76064. /**
  76065. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  76066. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  76067. */
  76068. transformationMatrix: Matrix;
  76069. /**
  76070. * the native xr-plane object
  76071. */
  76072. xrPlane: XRPlane;
  76073. }
  76074. /**
  76075. * The plane detector is used to detect planes in the real world when in AR
  76076. * For more information see https://github.com/immersive-web/real-world-geometry/
  76077. */
  76078. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  76079. private _options;
  76080. private _detectedPlanes;
  76081. private _enabled;
  76082. private _lastFrameDetected;
  76083. /**
  76084. * The module's name
  76085. */
  76086. static readonly Name: string;
  76087. /**
  76088. * The (Babylon) version of this module.
  76089. * This is an integer representing the implementation version.
  76090. * This number does not correspond to the WebXR specs version
  76091. */
  76092. static readonly Version: number;
  76093. /**
  76094. * Observers registered here will be executed when a new plane was added to the session
  76095. */
  76096. onPlaneAddedObservable: Observable<IWebXRPlane>;
  76097. /**
  76098. * Observers registered here will be executed when a plane is no longer detected in the session
  76099. */
  76100. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  76101. /**
  76102. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  76103. * This can execute N times every frame
  76104. */
  76105. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  76106. /**
  76107. * construct a new Plane Detector
  76108. * @param _xrSessionManager an instance of xr Session manager
  76109. * @param _options configuration to use when constructing this feature
  76110. */
  76111. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  76112. /**
  76113. * Dispose this feature and all of the resources attached
  76114. */
  76115. dispose(): void;
  76116. protected _onXRFrame(frame: XRFrame): void;
  76117. private _init;
  76118. private _updatePlaneWithXRPlane;
  76119. /**
  76120. * avoiding using Array.find for global support.
  76121. * @param xrPlane the plane to find in the array
  76122. */
  76123. private findIndexInPlaneArray;
  76124. }
  76125. }
  76126. declare module "babylonjs/XR/features/WebXRAnchorSystem" {
  76127. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  76128. import { Observable } from "babylonjs/Misc/observable";
  76129. import { Matrix } from "babylonjs/Maths/math.vector";
  76130. import { TransformNode } from "babylonjs/Meshes/transformNode";
  76131. import { WebXRPlaneDetector } from "babylonjs/XR/features/WebXRPlaneDetector";
  76132. import { WebXRHitTestLegacy } from "babylonjs/XR/features/WebXRHitTestLegacy";
  76133. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  76134. /**
  76135. * Configuration options of the anchor system
  76136. */
  76137. export interface IWebXRAnchorSystemOptions {
  76138. /**
  76139. * Should a new anchor be added every time a select event is triggered
  76140. */
  76141. addAnchorOnSelect?: boolean;
  76142. /**
  76143. * should the anchor system use plane detection.
  76144. * If set to true, the plane-detection feature should be set using setPlaneDetector
  76145. */
  76146. usePlaneDetection?: boolean;
  76147. /**
  76148. * a node that will be used to convert local to world coordinates
  76149. */
  76150. worldParentNode?: TransformNode;
  76151. }
  76152. /**
  76153. * A babylon container for an XR Anchor
  76154. */
  76155. export interface IWebXRAnchor {
  76156. /**
  76157. * A babylon-assigned ID for this anchor
  76158. */
  76159. id: number;
  76160. /**
  76161. * Transformation matrix to apply to an object attached to this anchor
  76162. */
  76163. transformationMatrix: Matrix;
  76164. /**
  76165. * The native anchor object
  76166. */
  76167. xrAnchor: XRAnchor;
  76168. }
  76169. /**
  76170. * An implementation of the anchor system of WebXR.
  76171. * Note that the current documented implementation is not available in any browser. Future implementations
  76172. * will use the frame to create an anchor and not the session or a detected plane
  76173. * For further information see https://github.com/immersive-web/anchors/
  76174. */
  76175. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  76176. private _options;
  76177. private _enabled;
  76178. private _hitTestModule;
  76179. private _lastFrameDetected;
  76180. private _onSelect;
  76181. private _planeDetector;
  76182. private _trackedAnchors;
  76183. /**
  76184. * The module's name
  76185. */
  76186. static readonly Name: string;
  76187. /**
  76188. * The (Babylon) version of this module.
  76189. * This is an integer representing the implementation version.
  76190. * This number does not correspond to the WebXR specs version
  76191. */
  76192. static readonly Version: number;
  76193. /**
  76194. * Observers registered here will be executed when a new anchor was added to the session
  76195. */
  76196. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  76197. /**
  76198. * Observers registered here will be executed when an anchor was removed from the session
  76199. */
  76200. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  76201. /**
  76202. * Observers registered here will be executed when an existing anchor updates
  76203. * This can execute N times every frame
  76204. */
  76205. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  76206. /**
  76207. * constructs a new anchor system
  76208. * @param _xrSessionManager an instance of WebXRSessionManager
  76209. * @param _options configuration object for this feature
  76210. */
  76211. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  76212. /**
  76213. * Add anchor at a specific XR point.
  76214. *
  76215. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  76216. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  76217. * @returns a promise the fulfills when the anchor was created
  76218. */
  76219. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  76220. /**
  76221. * attach this feature
  76222. * Will usually be called by the features manager
  76223. *
  76224. * @returns true if successful.
  76225. */
  76226. attach(): boolean;
  76227. /**
  76228. * detach this feature.
  76229. * Will usually be called by the features manager
  76230. *
  76231. * @returns true if successful.
  76232. */
  76233. detach(): boolean;
  76234. /**
  76235. * Dispose this feature and all of the resources attached
  76236. */
  76237. dispose(): void;
  76238. /**
  76239. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  76240. * @param hitTestModule the hit-test module to use.
  76241. */
  76242. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  76243. /**
  76244. * set the plane detector to use in order to create anchors from frames
  76245. * @param planeDetector the plane-detector module to use
  76246. * @param enable enable plane-anchors. default is true
  76247. */
  76248. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  76249. protected _onXRFrame(frame: XRFrame): void;
  76250. /**
  76251. * avoiding using Array.find for global support.
  76252. * @param xrAnchor the plane to find in the array
  76253. */
  76254. private _findIndexInAnchorArray;
  76255. private _updateAnchorWithXRFrame;
  76256. }
  76257. }
  76258. declare module "babylonjs/XR/features/WebXRBackgroundRemover" {
  76259. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  76260. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  76261. import { Observable } from "babylonjs/Misc/observable";
  76262. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  76263. /**
  76264. * Options interface for the background remover plugin
  76265. */
  76266. export interface IWebXRBackgroundRemoverOptions {
  76267. /**
  76268. * Further background meshes to disable when entering AR
  76269. */
  76270. backgroundMeshes?: AbstractMesh[];
  76271. /**
  76272. * flags to configure the removal of the environment helper.
  76273. * If not set, the entire background will be removed. If set, flags should be set as well.
  76274. */
  76275. environmentHelperRemovalFlags?: {
  76276. /**
  76277. * Should the skybox be removed (default false)
  76278. */
  76279. skyBox?: boolean;
  76280. /**
  76281. * Should the ground be removed (default false)
  76282. */
  76283. ground?: boolean;
  76284. };
  76285. /**
  76286. * don't disable the environment helper
  76287. */
  76288. ignoreEnvironmentHelper?: boolean;
  76289. }
  76290. /**
  76291. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  76292. */
  76293. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  76294. /**
  76295. * read-only options to be used in this module
  76296. */
  76297. readonly options: IWebXRBackgroundRemoverOptions;
  76298. /**
  76299. * The module's name
  76300. */
  76301. static readonly Name: string;
  76302. /**
  76303. * The (Babylon) version of this module.
  76304. * This is an integer representing the implementation version.
  76305. * This number does not correspond to the WebXR specs version
  76306. */
  76307. static readonly Version: number;
  76308. /**
  76309. * registered observers will be triggered when the background state changes
  76310. */
  76311. onBackgroundStateChangedObservable: Observable<boolean>;
  76312. /**
  76313. * constructs a new background remover module
  76314. * @param _xrSessionManager the session manager for this module
  76315. * @param options read-only options to be used in this module
  76316. */
  76317. constructor(_xrSessionManager: WebXRSessionManager,
  76318. /**
  76319. * read-only options to be used in this module
  76320. */
  76321. options?: IWebXRBackgroundRemoverOptions);
  76322. /**
  76323. * attach this feature
  76324. * Will usually be called by the features manager
  76325. *
  76326. * @returns true if successful.
  76327. */
  76328. attach(): boolean;
  76329. /**
  76330. * detach this feature.
  76331. * Will usually be called by the features manager
  76332. *
  76333. * @returns true if successful.
  76334. */
  76335. detach(): boolean;
  76336. /**
  76337. * Dispose this feature and all of the resources attached
  76338. */
  76339. dispose(): void;
  76340. protected _onXRFrame(_xrFrame: XRFrame): void;
  76341. private _setBackgroundState;
  76342. }
  76343. }
  76344. declare module "babylonjs/XR/features/WebXRControllerPhysics" {
  76345. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  76346. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  76347. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  76348. import { WebXRInput } from "babylonjs/XR/webXRInput";
  76349. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  76350. import { Nullable } from "babylonjs/types";
  76351. /**
  76352. * Options for the controller physics feature
  76353. */
  76354. export class IWebXRControllerPhysicsOptions {
  76355. /**
  76356. * Should the headset get its own impostor
  76357. */
  76358. enableHeadsetImpostor?: boolean;
  76359. /**
  76360. * Optional parameters for the headset impostor
  76361. */
  76362. headsetImpostorParams?: {
  76363. /**
  76364. * The type of impostor to create. Default is sphere
  76365. */
  76366. impostorType: number;
  76367. /**
  76368. * the size of the impostor. Defaults to 10cm
  76369. */
  76370. impostorSize?: number | {
  76371. width: number;
  76372. height: number;
  76373. depth: number;
  76374. };
  76375. /**
  76376. * Friction definitions
  76377. */
  76378. friction?: number;
  76379. /**
  76380. * Restitution
  76381. */
  76382. restitution?: number;
  76383. };
  76384. /**
  76385. * The physics properties of the future impostors
  76386. */
  76387. physicsProperties?: {
  76388. /**
  76389. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  76390. * Note that this requires a physics engine that supports mesh impostors!
  76391. */
  76392. useControllerMesh?: boolean;
  76393. /**
  76394. * The type of impostor to create. Default is sphere
  76395. */
  76396. impostorType?: number;
  76397. /**
  76398. * the size of the impostor. Defaults to 10cm
  76399. */
  76400. impostorSize?: number | {
  76401. width: number;
  76402. height: number;
  76403. depth: number;
  76404. };
  76405. /**
  76406. * Friction definitions
  76407. */
  76408. friction?: number;
  76409. /**
  76410. * Restitution
  76411. */
  76412. restitution?: number;
  76413. };
  76414. /**
  76415. * the xr input to use with this pointer selection
  76416. */
  76417. xrInput: WebXRInput;
  76418. }
  76419. /**
  76420. * Add physics impostor to your webxr controllers,
  76421. * including naive calculation of their linear and angular velocity
  76422. */
  76423. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  76424. private readonly _options;
  76425. private _attachController;
  76426. private _controllers;
  76427. private _debugMode;
  76428. private _delta;
  76429. private _headsetImpostor?;
  76430. private _headsetMesh?;
  76431. private _lastTimestamp;
  76432. private _tmpQuaternion;
  76433. private _tmpVector;
  76434. /**
  76435. * The module's name
  76436. */
  76437. static readonly Name: string;
  76438. /**
  76439. * The (Babylon) version of this module.
  76440. * This is an integer representing the implementation version.
  76441. * This number does not correspond to the webxr specs version
  76442. */
  76443. static readonly Version: number;
  76444. /**
  76445. * Construct a new Controller Physics Feature
  76446. * @param _xrSessionManager the corresponding xr session manager
  76447. * @param _options options to create this feature with
  76448. */
  76449. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  76450. /**
  76451. * @hidden
  76452. * enable debugging - will show console outputs and the impostor mesh
  76453. */
  76454. _enablePhysicsDebug(): void;
  76455. /**
  76456. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  76457. * @param xrController the controller to add
  76458. */
  76459. addController(xrController: WebXRInputSource): void;
  76460. /**
  76461. * attach this feature
  76462. * Will usually be called by the features manager
  76463. *
  76464. * @returns true if successful.
  76465. */
  76466. attach(): boolean;
  76467. /**
  76468. * detach this feature.
  76469. * Will usually be called by the features manager
  76470. *
  76471. * @returns true if successful.
  76472. */
  76473. detach(): boolean;
  76474. /**
  76475. * Get the headset impostor, if enabled
  76476. * @returns the impostor
  76477. */
  76478. getHeadsetImpostor(): PhysicsImpostor | undefined;
  76479. /**
  76480. * Get the physics impostor of a specific controller.
  76481. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  76482. * @param controller the controller or the controller id of which to get the impostor
  76483. * @returns the impostor or null
  76484. */
  76485. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  76486. /**
  76487. * Update the physics properties provided in the constructor
  76488. * @param newProperties the new properties object
  76489. */
  76490. setPhysicsProperties(newProperties: {
  76491. impostorType?: number;
  76492. impostorSize?: number | {
  76493. width: number;
  76494. height: number;
  76495. depth: number;
  76496. };
  76497. friction?: number;
  76498. restitution?: number;
  76499. }): void;
  76500. protected _onXRFrame(_xrFrame: any): void;
  76501. private _detachController;
  76502. }
  76503. }
  76504. declare module "babylonjs/XR/features/WebXRHitTest" {
  76505. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  76506. import { Observable } from "babylonjs/Misc/observable";
  76507. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  76508. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  76509. import { IWebXRLegacyHitTestOptions, IWebXRLegacyHitResult } from "babylonjs/XR/features/WebXRHitTestLegacy";
  76510. /**
  76511. * Options used for hit testing (version 2)
  76512. */
  76513. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  76514. /**
  76515. * Do not create a permanent hit test. Will usually be used when only
  76516. * transient inputs are needed.
  76517. */
  76518. disablePermanentHitTest?: boolean;
  76519. /**
  76520. * Enable transient (for example touch-based) hit test inspections
  76521. */
  76522. enableTransientHitTest?: boolean;
  76523. /**
  76524. * Offset ray for the permanent hit test
  76525. */
  76526. offsetRay?: Vector3;
  76527. /**
  76528. * Offset ray for the transient hit test
  76529. */
  76530. transientOffsetRay?: Vector3;
  76531. /**
  76532. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  76533. */
  76534. useReferenceSpace?: boolean;
  76535. }
  76536. /**
  76537. * Interface defining the babylon result of hit-test
  76538. */
  76539. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  76540. /**
  76541. * The input source that generated this hit test (if transient)
  76542. */
  76543. inputSource?: XRInputSource;
  76544. /**
  76545. * Is this a transient hit test
  76546. */
  76547. isTransient?: boolean;
  76548. /**
  76549. * Position of the hit test result
  76550. */
  76551. position: Vector3;
  76552. /**
  76553. * Rotation of the hit test result
  76554. */
  76555. rotationQuaternion: Quaternion;
  76556. }
  76557. /**
  76558. * The currently-working hit-test module.
  76559. * Hit test (or Ray-casting) is used to interact with the real world.
  76560. * For further information read here - https://github.com/immersive-web/hit-test
  76561. *
  76562. * Tested on chrome (mobile) 80.
  76563. */
  76564. export class WebXRHitTest extends WebXRAbstractFeature {
  76565. /**
  76566. * options to use when constructing this feature
  76567. */
  76568. readonly options: IWebXRHitTestOptions;
  76569. private _tmpMat;
  76570. private _tmpPos;
  76571. private _tmpQuat;
  76572. private _transientXrHitTestSource;
  76573. private _xrHitTestSource;
  76574. private initHitTestSource;
  76575. /**
  76576. * The module's name
  76577. */
  76578. static readonly Name: string;
  76579. /**
  76580. * The (Babylon) version of this module.
  76581. * This is an integer representing the implementation version.
  76582. * This number does not correspond to the WebXR specs version
  76583. */
  76584. static readonly Version: number;
  76585. /**
  76586. * When set to true, each hit test will have its own position/rotation objects
  76587. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  76588. * the developers will clone them or copy them as they see fit.
  76589. */
  76590. autoCloneTransformation: boolean;
  76591. /**
  76592. * Populated with the last native XR Hit Results
  76593. */
  76594. lastNativeXRHitResults: XRHitResult[];
  76595. /**
  76596. * Triggered when new babylon (transformed) hit test results are available
  76597. */
  76598. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  76599. /**
  76600. * Use this to temporarily pause hit test checks.
  76601. */
  76602. paused: boolean;
  76603. /**
  76604. * Creates a new instance of the hit test feature
  76605. * @param _xrSessionManager an instance of WebXRSessionManager
  76606. * @param options options to use when constructing this feature
  76607. */
  76608. constructor(_xrSessionManager: WebXRSessionManager,
  76609. /**
  76610. * options to use when constructing this feature
  76611. */
  76612. options?: IWebXRHitTestOptions);
  76613. /**
  76614. * attach this feature
  76615. * Will usually be called by the features manager
  76616. *
  76617. * @returns true if successful.
  76618. */
  76619. attach(): boolean;
  76620. /**
  76621. * detach this feature.
  76622. * Will usually be called by the features manager
  76623. *
  76624. * @returns true if successful.
  76625. */
  76626. detach(): boolean;
  76627. /**
  76628. * Dispose this feature and all of the resources attached
  76629. */
  76630. dispose(): void;
  76631. protected _onXRFrame(frame: XRFrame): void;
  76632. private _processWebXRHitTestResult;
  76633. }
  76634. }
  76635. declare module "babylonjs/XR/features/index" {
  76636. export * from "babylonjs/XR/features/WebXRHitTestLegacy";
  76637. export * from "babylonjs/XR/features/WebXRAnchorSystem";
  76638. export * from "babylonjs/XR/features/WebXRPlaneDetector";
  76639. export * from "babylonjs/XR/features/WebXRBackgroundRemover";
  76640. export * from "babylonjs/XR/features/WebXRControllerTeleportation";
  76641. export * from "babylonjs/XR/features/WebXRControllerPointerSelection";
  76642. export * from "babylonjs/XR/features/WebXRControllerPhysics";
  76643. export * from "babylonjs/XR/features/WebXRHitTest";
  76644. }
  76645. declare module "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController" {
  76646. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  76647. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  76648. import { Scene } from "babylonjs/scene";
  76649. /**
  76650. * The motion controller class for all microsoft mixed reality controllers
  76651. */
  76652. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  76653. protected readonly _mapping: {
  76654. defaultButton: {
  76655. valueNodeName: string;
  76656. unpressedNodeName: string;
  76657. pressedNodeName: string;
  76658. };
  76659. defaultAxis: {
  76660. valueNodeName: string;
  76661. minNodeName: string;
  76662. maxNodeName: string;
  76663. };
  76664. buttons: {
  76665. "xr-standard-trigger": {
  76666. rootNodeName: string;
  76667. componentProperty: string;
  76668. states: string[];
  76669. };
  76670. "xr-standard-squeeze": {
  76671. rootNodeName: string;
  76672. componentProperty: string;
  76673. states: string[];
  76674. };
  76675. "xr-standard-touchpad": {
  76676. rootNodeName: string;
  76677. labelAnchorNodeName: string;
  76678. touchPointNodeName: string;
  76679. };
  76680. "xr-standard-thumbstick": {
  76681. rootNodeName: string;
  76682. componentProperty: string;
  76683. states: string[];
  76684. };
  76685. };
  76686. axes: {
  76687. "xr-standard-touchpad": {
  76688. "x-axis": {
  76689. rootNodeName: string;
  76690. };
  76691. "y-axis": {
  76692. rootNodeName: string;
  76693. };
  76694. };
  76695. "xr-standard-thumbstick": {
  76696. "x-axis": {
  76697. rootNodeName: string;
  76698. };
  76699. "y-axis": {
  76700. rootNodeName: string;
  76701. };
  76702. };
  76703. };
  76704. };
  76705. /**
  76706. * The base url used to load the left and right controller models
  76707. */
  76708. static MODEL_BASE_URL: string;
  76709. /**
  76710. * The name of the left controller model file
  76711. */
  76712. static MODEL_LEFT_FILENAME: string;
  76713. /**
  76714. * The name of the right controller model file
  76715. */
  76716. static MODEL_RIGHT_FILENAME: string;
  76717. profileId: string;
  76718. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  76719. protected _getFilenameAndPath(): {
  76720. filename: string;
  76721. path: string;
  76722. };
  76723. protected _getModelLoadingConstraints(): boolean;
  76724. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  76725. protected _setRootMesh(meshes: AbstractMesh[]): void;
  76726. protected _updateModel(): void;
  76727. }
  76728. }
  76729. declare module "babylonjs/XR/motionController/webXROculusTouchMotionController" {
  76730. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  76731. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  76732. import { Scene } from "babylonjs/scene";
  76733. /**
  76734. * The motion controller class for oculus touch (quest, rift).
  76735. * This class supports legacy mapping as well the standard xr mapping
  76736. */
  76737. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  76738. private _forceLegacyControllers;
  76739. private _modelRootNode;
  76740. /**
  76741. * The base url used to load the left and right controller models
  76742. */
  76743. static MODEL_BASE_URL: string;
  76744. /**
  76745. * The name of the left controller model file
  76746. */
  76747. static MODEL_LEFT_FILENAME: string;
  76748. /**
  76749. * The name of the right controller model file
  76750. */
  76751. static MODEL_RIGHT_FILENAME: string;
  76752. /**
  76753. * Base Url for the Quest controller model.
  76754. */
  76755. static QUEST_MODEL_BASE_URL: string;
  76756. profileId: string;
  76757. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  76758. protected _getFilenameAndPath(): {
  76759. filename: string;
  76760. path: string;
  76761. };
  76762. protected _getModelLoadingConstraints(): boolean;
  76763. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  76764. protected _setRootMesh(meshes: AbstractMesh[]): void;
  76765. protected _updateModel(): void;
  76766. /**
  76767. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  76768. * between the touch and touch 2.
  76769. */
  76770. private _isQuest;
  76771. }
  76772. }
  76773. declare module "babylonjs/XR/motionController/webXRHTCViveMotionController" {
  76774. import { IMinimalMotionControllerObject, MotionControllerHandedness, WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  76775. import { Scene } from "babylonjs/scene";
  76776. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  76777. /**
  76778. * The motion controller class for the standard HTC-Vive controllers
  76779. */
  76780. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  76781. private _modelRootNode;
  76782. /**
  76783. * The base url used to load the left and right controller models
  76784. */
  76785. static MODEL_BASE_URL: string;
  76786. /**
  76787. * File name for the controller model.
  76788. */
  76789. static MODEL_FILENAME: string;
  76790. profileId: string;
  76791. /**
  76792. * Create a new Vive motion controller object
  76793. * @param scene the scene to use to create this controller
  76794. * @param gamepadObject the corresponding gamepad object
  76795. * @param handedness the handedness of the controller
  76796. */
  76797. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  76798. protected _getFilenameAndPath(): {
  76799. filename: string;
  76800. path: string;
  76801. };
  76802. protected _getModelLoadingConstraints(): boolean;
  76803. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  76804. protected _setRootMesh(meshes: AbstractMesh[]): void;
  76805. protected _updateModel(): void;
  76806. }
  76807. }
  76808. declare module "babylonjs/XR/motionController/index" {
  76809. export * from "babylonjs/XR/motionController/webXRAbstractMotionController";
  76810. export * from "babylonjs/XR/motionController/webXRControllerComponent";
  76811. export * from "babylonjs/XR/motionController/webXRGenericMotionController";
  76812. export * from "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController";
  76813. export * from "babylonjs/XR/motionController/webXRMotionControllerManager";
  76814. export * from "babylonjs/XR/motionController/webXROculusTouchMotionController";
  76815. export * from "babylonjs/XR/motionController/webXRHTCViveMotionController";
  76816. export * from "babylonjs/XR/motionController/webXRProfiledMotionController";
  76817. }
  76818. declare module "babylonjs/XR/index" {
  76819. export * from "babylonjs/XR/webXRCamera";
  76820. export * from "babylonjs/XR/webXREnterExitUI";
  76821. export * from "babylonjs/XR/webXRExperienceHelper";
  76822. export * from "babylonjs/XR/webXRInput";
  76823. export * from "babylonjs/XR/webXRInputSource";
  76824. export * from "babylonjs/XR/webXRManagedOutputCanvas";
  76825. export * from "babylonjs/XR/webXRTypes";
  76826. export * from "babylonjs/XR/webXRSessionManager";
  76827. export * from "babylonjs/XR/webXRDefaultExperience";
  76828. export * from "babylonjs/XR/webXRFeaturesManager";
  76829. export * from "babylonjs/XR/features/index";
  76830. export * from "babylonjs/XR/motionController/index";
  76831. }
  76832. declare module "babylonjs/index" {
  76833. export * from "babylonjs/abstractScene";
  76834. export * from "babylonjs/Actions/index";
  76835. export * from "babylonjs/Animations/index";
  76836. export * from "babylonjs/assetContainer";
  76837. export * from "babylonjs/Audio/index";
  76838. export * from "babylonjs/Behaviors/index";
  76839. export * from "babylonjs/Bones/index";
  76840. export * from "babylonjs/Cameras/index";
  76841. export * from "babylonjs/Collisions/index";
  76842. export * from "babylonjs/Culling/index";
  76843. export * from "babylonjs/Debug/index";
  76844. export * from "babylonjs/DeviceInput/index";
  76845. export * from "babylonjs/Engines/index";
  76846. export * from "babylonjs/Events/index";
  76847. export * from "babylonjs/Gamepads/index";
  76848. export * from "babylonjs/Gizmos/index";
  76849. export * from "babylonjs/Helpers/index";
  76850. export * from "babylonjs/Instrumentation/index";
  76851. export * from "babylonjs/Layers/index";
  76852. export * from "babylonjs/LensFlares/index";
  76853. export * from "babylonjs/Lights/index";
  76854. export * from "babylonjs/Loading/index";
  76855. export * from "babylonjs/Materials/index";
  76856. export * from "babylonjs/Maths/index";
  76857. export * from "babylonjs/Meshes/index";
  76858. export * from "babylonjs/Morph/index";
  76859. export * from "babylonjs/Navigation/index";
  76860. export * from "babylonjs/node";
  76861. export * from "babylonjs/Offline/index";
  76862. export * from "babylonjs/Particles/index";
  76863. export * from "babylonjs/Physics/index";
  76864. export * from "babylonjs/PostProcesses/index";
  76865. export * from "babylonjs/Probes/index";
  76866. export * from "babylonjs/Rendering/index";
  76867. export * from "babylonjs/scene";
  76868. export * from "babylonjs/sceneComponent";
  76869. export * from "babylonjs/Sprites/index";
  76870. export * from "babylonjs/States/index";
  76871. export * from "babylonjs/Misc/index";
  76872. export * from "babylonjs/XR/index";
  76873. export * from "babylonjs/types";
  76874. }
  76875. declare module "babylonjs/Animations/pathCursor" {
  76876. import { Vector3 } from "babylonjs/Maths/math.vector";
  76877. import { Path2 } from "babylonjs/Maths/math.path";
  76878. /**
  76879. * A cursor which tracks a point on a path
  76880. */
  76881. export class PathCursor {
  76882. private path;
  76883. /**
  76884. * Stores path cursor callbacks for when an onchange event is triggered
  76885. */
  76886. private _onchange;
  76887. /**
  76888. * The value of the path cursor
  76889. */
  76890. value: number;
  76891. /**
  76892. * The animation array of the path cursor
  76893. */
  76894. animations: Animation[];
  76895. /**
  76896. * Initializes the path cursor
  76897. * @param path The path to track
  76898. */
  76899. constructor(path: Path2);
  76900. /**
  76901. * Gets the cursor point on the path
  76902. * @returns A point on the path cursor at the cursor location
  76903. */
  76904. getPoint(): Vector3;
  76905. /**
  76906. * Moves the cursor ahead by the step amount
  76907. * @param step The amount to move the cursor forward
  76908. * @returns This path cursor
  76909. */
  76910. moveAhead(step?: number): PathCursor;
  76911. /**
  76912. * Moves the cursor behind by the step amount
  76913. * @param step The amount to move the cursor back
  76914. * @returns This path cursor
  76915. */
  76916. moveBack(step?: number): PathCursor;
  76917. /**
  76918. * Moves the cursor by the step amount
  76919. * If the step amount is greater than one, an exception is thrown
  76920. * @param step The amount to move the cursor
  76921. * @returns This path cursor
  76922. */
  76923. move(step: number): PathCursor;
  76924. /**
  76925. * Ensures that the value is limited between zero and one
  76926. * @returns This path cursor
  76927. */
  76928. private ensureLimits;
  76929. /**
  76930. * Runs onchange callbacks on change (used by the animation engine)
  76931. * @returns This path cursor
  76932. */
  76933. private raiseOnChange;
  76934. /**
  76935. * Executes a function on change
  76936. * @param f A path cursor onchange callback
  76937. * @returns This path cursor
  76938. */
  76939. onchange(f: (cursor: PathCursor) => void): PathCursor;
  76940. }
  76941. }
  76942. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  76943. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  76944. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  76945. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  76946. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  76947. }
  76948. declare module "babylonjs/Engines/Processors/Expressions/index" {
  76949. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  76950. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  76951. }
  76952. declare module "babylonjs/Engines/Processors/index" {
  76953. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  76954. export * from "babylonjs/Engines/Processors/Expressions/index";
  76955. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  76956. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  76957. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  76958. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  76959. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  76960. export * from "babylonjs/Engines/Processors/shaderProcessor";
  76961. export * from "babylonjs/Engines/Processors/shaderCodeInliner";
  76962. }
  76963. declare module "babylonjs/Legacy/legacy" {
  76964. import * as Babylon from "babylonjs/index";
  76965. export * from "babylonjs/index";
  76966. }
  76967. declare module "babylonjs/Shaders/blur.fragment" {
  76968. /** @hidden */
  76969. export var blurPixelShader: {
  76970. name: string;
  76971. shader: string;
  76972. };
  76973. }
  76974. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  76975. /** @hidden */
  76976. export var pointCloudVertexDeclaration: {
  76977. name: string;
  76978. shader: string;
  76979. };
  76980. }
  76981. declare module "babylonjs" {
  76982. export * from "babylonjs/Legacy/legacy";
  76983. }
  76984. declare module BABYLON {
  76985. /** Alias type for value that can be null */
  76986. export type Nullable<T> = T | null;
  76987. /**
  76988. * Alias type for number that are floats
  76989. * @ignorenaming
  76990. */
  76991. export type float = number;
  76992. /**
  76993. * Alias type for number that are doubles.
  76994. * @ignorenaming
  76995. */
  76996. export type double = number;
  76997. /**
  76998. * Alias type for number that are integer
  76999. * @ignorenaming
  77000. */
  77001. export type int = number;
  77002. /** Alias type for number array or Float32Array */
  77003. export type FloatArray = number[] | Float32Array;
  77004. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  77005. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  77006. /**
  77007. * Alias for types that can be used by a Buffer or VertexBuffer.
  77008. */
  77009. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  77010. /**
  77011. * Alias type for primitive types
  77012. * @ignorenaming
  77013. */
  77014. type Primitive = undefined | null | boolean | string | number | Function;
  77015. /**
  77016. * Type modifier to make all the properties of an object Readonly
  77017. */
  77018. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  77019. /**
  77020. * Type modifier to make all the properties of an object Readonly recursively
  77021. */
  77022. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  77023. /**
  77024. * Type modifier to make object properties readonly.
  77025. */
  77026. export type DeepImmutableObject<T> = {
  77027. readonly [K in keyof T]: DeepImmutable<T[K]>;
  77028. };
  77029. /** @hidden */
  77030. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  77031. }
  77032. }
  77033. declare module BABYLON {
  77034. /**
  77035. * A class serves as a medium between the observable and its observers
  77036. */
  77037. export class EventState {
  77038. /**
  77039. * Create a new EventState
  77040. * @param mask defines the mask associated with this state
  77041. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  77042. * @param target defines the original target of the state
  77043. * @param currentTarget defines the current target of the state
  77044. */
  77045. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  77046. /**
  77047. * Initialize the current event state
  77048. * @param mask defines the mask associated with this state
  77049. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  77050. * @param target defines the original target of the state
  77051. * @param currentTarget defines the current target of the state
  77052. * @returns the current event state
  77053. */
  77054. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  77055. /**
  77056. * An Observer can set this property to true to prevent subsequent observers of being notified
  77057. */
  77058. skipNextObservers: boolean;
  77059. /**
  77060. * Get the mask value that were used to trigger the event corresponding to this EventState object
  77061. */
  77062. mask: number;
  77063. /**
  77064. * The object that originally notified the event
  77065. */
  77066. target?: any;
  77067. /**
  77068. * The current object in the bubbling phase
  77069. */
  77070. currentTarget?: any;
  77071. /**
  77072. * This will be populated with the return value of the last function that was executed.
  77073. * If it is the first function in the callback chain it will be the event data.
  77074. */
  77075. lastReturnValue?: any;
  77076. }
  77077. /**
  77078. * Represent an Observer registered to a given Observable object.
  77079. */
  77080. export class Observer<T> {
  77081. /**
  77082. * Defines the callback to call when the observer is notified
  77083. */
  77084. callback: (eventData: T, eventState: EventState) => void;
  77085. /**
  77086. * Defines the mask of the observer (used to filter notifications)
  77087. */
  77088. mask: number;
  77089. /**
  77090. * Defines the current scope used to restore the JS context
  77091. */
  77092. scope: any;
  77093. /** @hidden */
  77094. _willBeUnregistered: boolean;
  77095. /**
  77096. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  77097. */
  77098. unregisterOnNextCall: boolean;
  77099. /**
  77100. * Creates a new observer
  77101. * @param callback defines the callback to call when the observer is notified
  77102. * @param mask defines the mask of the observer (used to filter notifications)
  77103. * @param scope defines the current scope used to restore the JS context
  77104. */
  77105. constructor(
  77106. /**
  77107. * Defines the callback to call when the observer is notified
  77108. */
  77109. callback: (eventData: T, eventState: EventState) => void,
  77110. /**
  77111. * Defines the mask of the observer (used to filter notifications)
  77112. */
  77113. mask: number,
  77114. /**
  77115. * Defines the current scope used to restore the JS context
  77116. */
  77117. scope?: any);
  77118. }
  77119. /**
  77120. * Represent a list of observers registered to multiple Observables object.
  77121. */
  77122. export class MultiObserver<T> {
  77123. private _observers;
  77124. private _observables;
  77125. /**
  77126. * Release associated resources
  77127. */
  77128. dispose(): void;
  77129. /**
  77130. * Raise a callback when one of the observable will notify
  77131. * @param observables defines a list of observables to watch
  77132. * @param callback defines the callback to call on notification
  77133. * @param mask defines the mask used to filter notifications
  77134. * @param scope defines the current scope used to restore the JS context
  77135. * @returns the new MultiObserver
  77136. */
  77137. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  77138. }
  77139. /**
  77140. * The Observable class is a simple implementation of the Observable pattern.
  77141. *
  77142. * 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.
  77143. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  77144. * 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).
  77145. * 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.
  77146. */
  77147. export class Observable<T> {
  77148. private _observers;
  77149. private _eventState;
  77150. private _onObserverAdded;
  77151. /**
  77152. * Gets the list of observers
  77153. */
  77154. get observers(): Array<Observer<T>>;
  77155. /**
  77156. * Creates a new observable
  77157. * @param onObserverAdded defines a callback to call when a new observer is added
  77158. */
  77159. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  77160. /**
  77161. * Create a new Observer with the specified callback
  77162. * @param callback the callback that will be executed for that Observer
  77163. * @param mask the mask used to filter observers
  77164. * @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.
  77165. * @param scope optional scope for the callback to be called from
  77166. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  77167. * @returns the new observer created for the callback
  77168. */
  77169. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  77170. /**
  77171. * Create a new Observer with the specified callback and unregisters after the next notification
  77172. * @param callback the callback that will be executed for that Observer
  77173. * @returns the new observer created for the callback
  77174. */
  77175. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  77176. /**
  77177. * Remove an Observer from the Observable object
  77178. * @param observer the instance of the Observer to remove
  77179. * @returns false if it doesn't belong to this Observable
  77180. */
  77181. remove(observer: Nullable<Observer<T>>): boolean;
  77182. /**
  77183. * Remove a callback from the Observable object
  77184. * @param callback the callback to remove
  77185. * @param scope optional scope. If used only the callbacks with this scope will be removed
  77186. * @returns false if it doesn't belong to this Observable
  77187. */
  77188. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  77189. private _deferUnregister;
  77190. private _remove;
  77191. /**
  77192. * Moves the observable to the top of the observer list making it get called first when notified
  77193. * @param observer the observer to move
  77194. */
  77195. makeObserverTopPriority(observer: Observer<T>): void;
  77196. /**
  77197. * Moves the observable to the bottom of the observer list making it get called last when notified
  77198. * @param observer the observer to move
  77199. */
  77200. makeObserverBottomPriority(observer: Observer<T>): void;
  77201. /**
  77202. * Notify all Observers by calling their respective callback with the given data
  77203. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  77204. * @param eventData defines the data to send to all observers
  77205. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  77206. * @param target defines the original target of the state
  77207. * @param currentTarget defines the current target of the state
  77208. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  77209. */
  77210. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  77211. /**
  77212. * Calling this will execute each callback, expecting it to be a promise or return a value.
  77213. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  77214. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  77215. * and it is crucial that all callbacks will be executed.
  77216. * The order of the callbacks is kept, callbacks are not executed parallel.
  77217. *
  77218. * @param eventData The data to be sent to each callback
  77219. * @param mask is used to filter observers defaults to -1
  77220. * @param target defines the callback target (see EventState)
  77221. * @param currentTarget defines he current object in the bubbling phase
  77222. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  77223. */
  77224. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  77225. /**
  77226. * Notify a specific observer
  77227. * @param observer defines the observer to notify
  77228. * @param eventData defines the data to be sent to each callback
  77229. * @param mask is used to filter observers defaults to -1
  77230. */
  77231. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  77232. /**
  77233. * Gets a boolean indicating if the observable has at least one observer
  77234. * @returns true is the Observable has at least one Observer registered
  77235. */
  77236. hasObservers(): boolean;
  77237. /**
  77238. * Clear the list of observers
  77239. */
  77240. clear(): void;
  77241. /**
  77242. * Clone the current observable
  77243. * @returns a new observable
  77244. */
  77245. clone(): Observable<T>;
  77246. /**
  77247. * Does this observable handles observer registered with a given mask
  77248. * @param mask defines the mask to be tested
  77249. * @return whether or not one observer registered with the given mask is handeled
  77250. **/
  77251. hasSpecificMask(mask?: number): boolean;
  77252. }
  77253. }
  77254. declare module BABYLON {
  77255. /**
  77256. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  77257. * Babylon.js
  77258. */
  77259. export class DomManagement {
  77260. /**
  77261. * Checks if the window object exists
  77262. * @returns true if the window object exists
  77263. */
  77264. static IsWindowObjectExist(): boolean;
  77265. /**
  77266. * Checks if the navigator object exists
  77267. * @returns true if the navigator object exists
  77268. */
  77269. static IsNavigatorAvailable(): boolean;
  77270. /**
  77271. * Check if the document object exists
  77272. * @returns true if the document object exists
  77273. */
  77274. static IsDocumentAvailable(): boolean;
  77275. /**
  77276. * Extracts text content from a DOM element hierarchy
  77277. * @param element defines the root element
  77278. * @returns a string
  77279. */
  77280. static GetDOMTextContent(element: HTMLElement): string;
  77281. }
  77282. }
  77283. declare module BABYLON {
  77284. /**
  77285. * Logger used througouht the application to allow configuration of
  77286. * the log level required for the messages.
  77287. */
  77288. export class Logger {
  77289. /**
  77290. * No log
  77291. */
  77292. static readonly NoneLogLevel: number;
  77293. /**
  77294. * Only message logs
  77295. */
  77296. static readonly MessageLogLevel: number;
  77297. /**
  77298. * Only warning logs
  77299. */
  77300. static readonly WarningLogLevel: number;
  77301. /**
  77302. * Only error logs
  77303. */
  77304. static readonly ErrorLogLevel: number;
  77305. /**
  77306. * All logs
  77307. */
  77308. static readonly AllLogLevel: number;
  77309. private static _LogCache;
  77310. /**
  77311. * Gets a value indicating the number of loading errors
  77312. * @ignorenaming
  77313. */
  77314. static errorsCount: number;
  77315. /**
  77316. * Callback called when a new log is added
  77317. */
  77318. static OnNewCacheEntry: (entry: string) => void;
  77319. private static _AddLogEntry;
  77320. private static _FormatMessage;
  77321. private static _LogDisabled;
  77322. private static _LogEnabled;
  77323. private static _WarnDisabled;
  77324. private static _WarnEnabled;
  77325. private static _ErrorDisabled;
  77326. private static _ErrorEnabled;
  77327. /**
  77328. * Log a message to the console
  77329. */
  77330. static Log: (message: string) => void;
  77331. /**
  77332. * Write a warning message to the console
  77333. */
  77334. static Warn: (message: string) => void;
  77335. /**
  77336. * Write an error message to the console
  77337. */
  77338. static Error: (message: string) => void;
  77339. /**
  77340. * Gets current log cache (list of logs)
  77341. */
  77342. static get LogCache(): string;
  77343. /**
  77344. * Clears the log cache
  77345. */
  77346. static ClearLogCache(): void;
  77347. /**
  77348. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  77349. */
  77350. static set LogLevels(level: number);
  77351. }
  77352. }
  77353. declare module BABYLON {
  77354. /** @hidden */
  77355. export class _TypeStore {
  77356. /** @hidden */
  77357. static RegisteredTypes: {
  77358. [key: string]: Object;
  77359. };
  77360. /** @hidden */
  77361. static GetClass(fqdn: string): any;
  77362. }
  77363. }
  77364. declare module BABYLON {
  77365. /**
  77366. * Helper to manipulate strings
  77367. */
  77368. export class StringTools {
  77369. /**
  77370. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  77371. * @param str Source string
  77372. * @param suffix Suffix to search for in the source string
  77373. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  77374. */
  77375. static EndsWith(str: string, suffix: string): boolean;
  77376. /**
  77377. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  77378. * @param str Source string
  77379. * @param suffix Suffix to search for in the source string
  77380. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  77381. */
  77382. static StartsWith(str: string, suffix: string): boolean;
  77383. /**
  77384. * Decodes a buffer into a string
  77385. * @param buffer The buffer to decode
  77386. * @returns The decoded string
  77387. */
  77388. static Decode(buffer: Uint8Array | Uint16Array): string;
  77389. /**
  77390. * Encode a buffer to a base64 string
  77391. * @param buffer defines the buffer to encode
  77392. * @returns the encoded string
  77393. */
  77394. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  77395. /**
  77396. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  77397. * @param num the number to convert and pad
  77398. * @param length the expected length of the string
  77399. * @returns the padded string
  77400. */
  77401. static PadNumber(num: number, length: number): string;
  77402. }
  77403. }
  77404. declare module BABYLON {
  77405. /**
  77406. * Class containing a set of static utilities functions for deep copy.
  77407. */
  77408. export class DeepCopier {
  77409. /**
  77410. * Tries to copy an object by duplicating every property
  77411. * @param source defines the source object
  77412. * @param destination defines the target object
  77413. * @param doNotCopyList defines a list of properties to avoid
  77414. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  77415. */
  77416. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  77417. }
  77418. }
  77419. declare module BABYLON {
  77420. /**
  77421. * Class containing a set of static utilities functions for precision date
  77422. */
  77423. export class PrecisionDate {
  77424. /**
  77425. * Gets either window.performance.now() if supported or Date.now() else
  77426. */
  77427. static get Now(): number;
  77428. }
  77429. }
  77430. declare module BABYLON {
  77431. /** @hidden */
  77432. export class _DevTools {
  77433. static WarnImport(name: string): string;
  77434. }
  77435. }
  77436. declare module BABYLON {
  77437. /**
  77438. * Interface used to define the mechanism to get data from the network
  77439. */
  77440. export interface IWebRequest {
  77441. /**
  77442. * Returns client's response url
  77443. */
  77444. responseURL: string;
  77445. /**
  77446. * Returns client's status
  77447. */
  77448. status: number;
  77449. /**
  77450. * Returns client's status as a text
  77451. */
  77452. statusText: string;
  77453. }
  77454. }
  77455. declare module BABYLON {
  77456. /**
  77457. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  77458. */
  77459. export class WebRequest implements IWebRequest {
  77460. private _xhr;
  77461. /**
  77462. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  77463. * i.e. when loading files, where the server/service expects an Authorization header
  77464. */
  77465. static CustomRequestHeaders: {
  77466. [key: string]: string;
  77467. };
  77468. /**
  77469. * Add callback functions in this array to update all the requests before they get sent to the network
  77470. */
  77471. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  77472. private _injectCustomRequestHeaders;
  77473. /**
  77474. * Gets or sets a function to be called when loading progress changes
  77475. */
  77476. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  77477. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  77478. /**
  77479. * Returns client's state
  77480. */
  77481. get readyState(): number;
  77482. /**
  77483. * Returns client's status
  77484. */
  77485. get status(): number;
  77486. /**
  77487. * Returns client's status as a text
  77488. */
  77489. get statusText(): string;
  77490. /**
  77491. * Returns client's response
  77492. */
  77493. get response(): any;
  77494. /**
  77495. * Returns client's response url
  77496. */
  77497. get responseURL(): string;
  77498. /**
  77499. * Returns client's response as text
  77500. */
  77501. get responseText(): string;
  77502. /**
  77503. * Gets or sets the expected response type
  77504. */
  77505. get responseType(): XMLHttpRequestResponseType;
  77506. set responseType(value: XMLHttpRequestResponseType);
  77507. /** @hidden */
  77508. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  77509. /** @hidden */
  77510. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  77511. /**
  77512. * Cancels any network activity
  77513. */
  77514. abort(): void;
  77515. /**
  77516. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  77517. * @param body defines an optional request body
  77518. */
  77519. send(body?: Document | BodyInit | null): void;
  77520. /**
  77521. * Sets the request method, request URL
  77522. * @param method defines the method to use (GET, POST, etc..)
  77523. * @param url defines the url to connect with
  77524. */
  77525. open(method: string, url: string): void;
  77526. /**
  77527. * Sets the value of a request header.
  77528. * @param name The name of the header whose value is to be set
  77529. * @param value The value to set as the body of the header
  77530. */
  77531. setRequestHeader(name: string, value: string): void;
  77532. /**
  77533. * Get the string containing the text of a particular header's value.
  77534. * @param name The name of the header
  77535. * @returns The string containing the text of the given header name
  77536. */
  77537. getResponseHeader(name: string): Nullable<string>;
  77538. }
  77539. }
  77540. declare module BABYLON {
  77541. /**
  77542. * File request interface
  77543. */
  77544. export interface IFileRequest {
  77545. /**
  77546. * Raised when the request is complete (success or error).
  77547. */
  77548. onCompleteObservable: Observable<IFileRequest>;
  77549. /**
  77550. * Aborts the request for a file.
  77551. */
  77552. abort: () => void;
  77553. }
  77554. }
  77555. declare module BABYLON {
  77556. /**
  77557. * Define options used to create a render target texture
  77558. */
  77559. export class RenderTargetCreationOptions {
  77560. /**
  77561. * Specifies is mipmaps must be generated
  77562. */
  77563. generateMipMaps?: boolean;
  77564. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  77565. generateDepthBuffer?: boolean;
  77566. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  77567. generateStencilBuffer?: boolean;
  77568. /** Defines texture type (int by default) */
  77569. type?: number;
  77570. /** Defines sampling mode (trilinear by default) */
  77571. samplingMode?: number;
  77572. /** Defines format (RGBA by default) */
  77573. format?: number;
  77574. }
  77575. }
  77576. declare module BABYLON {
  77577. /** Defines the cross module used constants to avoid circular dependncies */
  77578. export class Constants {
  77579. /** Defines that alpha blending is disabled */
  77580. static readonly ALPHA_DISABLE: number;
  77581. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  77582. static readonly ALPHA_ADD: number;
  77583. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  77584. static readonly ALPHA_COMBINE: number;
  77585. /** Defines that alpha blending is DEST - SRC * DEST */
  77586. static readonly ALPHA_SUBTRACT: number;
  77587. /** Defines that alpha blending is SRC * DEST */
  77588. static readonly ALPHA_MULTIPLY: number;
  77589. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  77590. static readonly ALPHA_MAXIMIZED: number;
  77591. /** Defines that alpha blending is SRC + DEST */
  77592. static readonly ALPHA_ONEONE: number;
  77593. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  77594. static readonly ALPHA_PREMULTIPLIED: number;
  77595. /**
  77596. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  77597. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  77598. */
  77599. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  77600. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  77601. static readonly ALPHA_INTERPOLATE: number;
  77602. /**
  77603. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  77604. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  77605. */
  77606. static readonly ALPHA_SCREENMODE: number;
  77607. /**
  77608. * Defines that alpha blending is SRC + DST
  77609. * Alpha will be set to SRC ALPHA + DST ALPHA
  77610. */
  77611. static readonly ALPHA_ONEONE_ONEONE: number;
  77612. /**
  77613. * Defines that alpha blending is SRC * DST ALPHA + DST
  77614. * Alpha will be set to 0
  77615. */
  77616. static readonly ALPHA_ALPHATOCOLOR: number;
  77617. /**
  77618. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  77619. */
  77620. static readonly ALPHA_REVERSEONEMINUS: number;
  77621. /**
  77622. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  77623. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  77624. */
  77625. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  77626. /**
  77627. * Defines that alpha blending is SRC + DST
  77628. * Alpha will be set to SRC ALPHA
  77629. */
  77630. static readonly ALPHA_ONEONE_ONEZERO: number;
  77631. /**
  77632. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  77633. * Alpha will be set to DST ALPHA
  77634. */
  77635. static readonly ALPHA_EXCLUSION: number;
  77636. /** Defines that alpha blending equation a SUM */
  77637. static readonly ALPHA_EQUATION_ADD: number;
  77638. /** Defines that alpha blending equation a SUBSTRACTION */
  77639. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  77640. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  77641. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  77642. /** Defines that alpha blending equation a MAX operation */
  77643. static readonly ALPHA_EQUATION_MAX: number;
  77644. /** Defines that alpha blending equation a MIN operation */
  77645. static readonly ALPHA_EQUATION_MIN: number;
  77646. /**
  77647. * Defines that alpha blending equation a DARKEN operation:
  77648. * It takes the min of the src and sums the alpha channels.
  77649. */
  77650. static readonly ALPHA_EQUATION_DARKEN: number;
  77651. /** Defines that the ressource is not delayed*/
  77652. static readonly DELAYLOADSTATE_NONE: number;
  77653. /** Defines that the ressource was successfully delay loaded */
  77654. static readonly DELAYLOADSTATE_LOADED: number;
  77655. /** Defines that the ressource is currently delay loading */
  77656. static readonly DELAYLOADSTATE_LOADING: number;
  77657. /** Defines that the ressource is delayed and has not started loading */
  77658. static readonly DELAYLOADSTATE_NOTLOADED: number;
  77659. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  77660. static readonly NEVER: number;
  77661. /** 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 */
  77662. static readonly ALWAYS: number;
  77663. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  77664. static readonly LESS: number;
  77665. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  77666. static readonly EQUAL: number;
  77667. /** 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 */
  77668. static readonly LEQUAL: number;
  77669. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  77670. static readonly GREATER: number;
  77671. /** 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 */
  77672. static readonly GEQUAL: number;
  77673. /** 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 */
  77674. static readonly NOTEQUAL: number;
  77675. /** Passed to stencilOperation to specify that stencil value must be kept */
  77676. static readonly KEEP: number;
  77677. /** Passed to stencilOperation to specify that stencil value must be replaced */
  77678. static readonly REPLACE: number;
  77679. /** Passed to stencilOperation to specify that stencil value must be incremented */
  77680. static readonly INCR: number;
  77681. /** Passed to stencilOperation to specify that stencil value must be decremented */
  77682. static readonly DECR: number;
  77683. /** Passed to stencilOperation to specify that stencil value must be inverted */
  77684. static readonly INVERT: number;
  77685. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  77686. static readonly INCR_WRAP: number;
  77687. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  77688. static readonly DECR_WRAP: number;
  77689. /** Texture is not repeating outside of 0..1 UVs */
  77690. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  77691. /** Texture is repeating outside of 0..1 UVs */
  77692. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  77693. /** Texture is repeating and mirrored */
  77694. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  77695. /** ALPHA */
  77696. static readonly TEXTUREFORMAT_ALPHA: number;
  77697. /** LUMINANCE */
  77698. static readonly TEXTUREFORMAT_LUMINANCE: number;
  77699. /** LUMINANCE_ALPHA */
  77700. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  77701. /** RGB */
  77702. static readonly TEXTUREFORMAT_RGB: number;
  77703. /** RGBA */
  77704. static readonly TEXTUREFORMAT_RGBA: number;
  77705. /** RED */
  77706. static readonly TEXTUREFORMAT_RED: number;
  77707. /** RED (2nd reference) */
  77708. static readonly TEXTUREFORMAT_R: number;
  77709. /** RG */
  77710. static readonly TEXTUREFORMAT_RG: number;
  77711. /** RED_INTEGER */
  77712. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  77713. /** RED_INTEGER (2nd reference) */
  77714. static readonly TEXTUREFORMAT_R_INTEGER: number;
  77715. /** RG_INTEGER */
  77716. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  77717. /** RGB_INTEGER */
  77718. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  77719. /** RGBA_INTEGER */
  77720. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  77721. /** UNSIGNED_BYTE */
  77722. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  77723. /** UNSIGNED_BYTE (2nd reference) */
  77724. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  77725. /** FLOAT */
  77726. static readonly TEXTURETYPE_FLOAT: number;
  77727. /** HALF_FLOAT */
  77728. static readonly TEXTURETYPE_HALF_FLOAT: number;
  77729. /** BYTE */
  77730. static readonly TEXTURETYPE_BYTE: number;
  77731. /** SHORT */
  77732. static readonly TEXTURETYPE_SHORT: number;
  77733. /** UNSIGNED_SHORT */
  77734. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  77735. /** INT */
  77736. static readonly TEXTURETYPE_INT: number;
  77737. /** UNSIGNED_INT */
  77738. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  77739. /** UNSIGNED_SHORT_4_4_4_4 */
  77740. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  77741. /** UNSIGNED_SHORT_5_5_5_1 */
  77742. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  77743. /** UNSIGNED_SHORT_5_6_5 */
  77744. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  77745. /** UNSIGNED_INT_2_10_10_10_REV */
  77746. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  77747. /** UNSIGNED_INT_24_8 */
  77748. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  77749. /** UNSIGNED_INT_10F_11F_11F_REV */
  77750. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  77751. /** UNSIGNED_INT_5_9_9_9_REV */
  77752. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  77753. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  77754. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  77755. /** nearest is mag = nearest and min = nearest and no mip */
  77756. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  77757. /** mag = nearest and min = nearest and mip = none */
  77758. static readonly TEXTURE_NEAREST_NEAREST: number;
  77759. /** Bilinear is mag = linear and min = linear and no mip */
  77760. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  77761. /** mag = linear and min = linear and mip = none */
  77762. static readonly TEXTURE_LINEAR_LINEAR: number;
  77763. /** Trilinear is mag = linear and min = linear and mip = linear */
  77764. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  77765. /** Trilinear is mag = linear and min = linear and mip = linear */
  77766. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  77767. /** mag = nearest and min = nearest and mip = nearest */
  77768. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  77769. /** mag = nearest and min = linear and mip = nearest */
  77770. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  77771. /** mag = nearest and min = linear and mip = linear */
  77772. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  77773. /** mag = nearest and min = linear and mip = none */
  77774. static readonly TEXTURE_NEAREST_LINEAR: number;
  77775. /** nearest is mag = nearest and min = nearest and mip = linear */
  77776. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  77777. /** mag = linear and min = nearest and mip = nearest */
  77778. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  77779. /** mag = linear and min = nearest and mip = linear */
  77780. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  77781. /** Bilinear is mag = linear and min = linear and mip = nearest */
  77782. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  77783. /** mag = linear and min = nearest and mip = none */
  77784. static readonly TEXTURE_LINEAR_NEAREST: number;
  77785. /** Explicit coordinates mode */
  77786. static readonly TEXTURE_EXPLICIT_MODE: number;
  77787. /** Spherical coordinates mode */
  77788. static readonly TEXTURE_SPHERICAL_MODE: number;
  77789. /** Planar coordinates mode */
  77790. static readonly TEXTURE_PLANAR_MODE: number;
  77791. /** Cubic coordinates mode */
  77792. static readonly TEXTURE_CUBIC_MODE: number;
  77793. /** Projection coordinates mode */
  77794. static readonly TEXTURE_PROJECTION_MODE: number;
  77795. /** Skybox coordinates mode */
  77796. static readonly TEXTURE_SKYBOX_MODE: number;
  77797. /** Inverse Cubic coordinates mode */
  77798. static readonly TEXTURE_INVCUBIC_MODE: number;
  77799. /** Equirectangular coordinates mode */
  77800. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  77801. /** Equirectangular Fixed coordinates mode */
  77802. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  77803. /** Equirectangular Fixed Mirrored coordinates mode */
  77804. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  77805. /** Offline (baking) quality for texture filtering */
  77806. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  77807. /** High quality for texture filtering */
  77808. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  77809. /** Medium quality for texture filtering */
  77810. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  77811. /** Low quality for texture filtering */
  77812. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  77813. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  77814. static readonly SCALEMODE_FLOOR: number;
  77815. /** Defines that texture rescaling will look for the nearest power of 2 size */
  77816. static readonly SCALEMODE_NEAREST: number;
  77817. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  77818. static readonly SCALEMODE_CEILING: number;
  77819. /**
  77820. * The dirty texture flag value
  77821. */
  77822. static readonly MATERIAL_TextureDirtyFlag: number;
  77823. /**
  77824. * The dirty light flag value
  77825. */
  77826. static readonly MATERIAL_LightDirtyFlag: number;
  77827. /**
  77828. * The dirty fresnel flag value
  77829. */
  77830. static readonly MATERIAL_FresnelDirtyFlag: number;
  77831. /**
  77832. * The dirty attribute flag value
  77833. */
  77834. static readonly MATERIAL_AttributesDirtyFlag: number;
  77835. /**
  77836. * The dirty misc flag value
  77837. */
  77838. static readonly MATERIAL_MiscDirtyFlag: number;
  77839. /**
  77840. * The all dirty flag value
  77841. */
  77842. static readonly MATERIAL_AllDirtyFlag: number;
  77843. /**
  77844. * Returns the triangle fill mode
  77845. */
  77846. static readonly MATERIAL_TriangleFillMode: number;
  77847. /**
  77848. * Returns the wireframe mode
  77849. */
  77850. static readonly MATERIAL_WireFrameFillMode: number;
  77851. /**
  77852. * Returns the point fill mode
  77853. */
  77854. static readonly MATERIAL_PointFillMode: number;
  77855. /**
  77856. * Returns the point list draw mode
  77857. */
  77858. static readonly MATERIAL_PointListDrawMode: number;
  77859. /**
  77860. * Returns the line list draw mode
  77861. */
  77862. static readonly MATERIAL_LineListDrawMode: number;
  77863. /**
  77864. * Returns the line loop draw mode
  77865. */
  77866. static readonly MATERIAL_LineLoopDrawMode: number;
  77867. /**
  77868. * Returns the line strip draw mode
  77869. */
  77870. static readonly MATERIAL_LineStripDrawMode: number;
  77871. /**
  77872. * Returns the triangle strip draw mode
  77873. */
  77874. static readonly MATERIAL_TriangleStripDrawMode: number;
  77875. /**
  77876. * Returns the triangle fan draw mode
  77877. */
  77878. static readonly MATERIAL_TriangleFanDrawMode: number;
  77879. /**
  77880. * Stores the clock-wise side orientation
  77881. */
  77882. static readonly MATERIAL_ClockWiseSideOrientation: number;
  77883. /**
  77884. * Stores the counter clock-wise side orientation
  77885. */
  77886. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  77887. /**
  77888. * Nothing
  77889. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77890. */
  77891. static readonly ACTION_NothingTrigger: number;
  77892. /**
  77893. * On pick
  77894. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77895. */
  77896. static readonly ACTION_OnPickTrigger: number;
  77897. /**
  77898. * On left pick
  77899. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77900. */
  77901. static readonly ACTION_OnLeftPickTrigger: number;
  77902. /**
  77903. * On right pick
  77904. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77905. */
  77906. static readonly ACTION_OnRightPickTrigger: number;
  77907. /**
  77908. * On center pick
  77909. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77910. */
  77911. static readonly ACTION_OnCenterPickTrigger: number;
  77912. /**
  77913. * On pick down
  77914. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77915. */
  77916. static readonly ACTION_OnPickDownTrigger: number;
  77917. /**
  77918. * On double pick
  77919. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77920. */
  77921. static readonly ACTION_OnDoublePickTrigger: number;
  77922. /**
  77923. * On pick up
  77924. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77925. */
  77926. static readonly ACTION_OnPickUpTrigger: number;
  77927. /**
  77928. * On pick out.
  77929. * This trigger will only be raised if you also declared a OnPickDown
  77930. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77931. */
  77932. static readonly ACTION_OnPickOutTrigger: number;
  77933. /**
  77934. * On long press
  77935. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77936. */
  77937. static readonly ACTION_OnLongPressTrigger: number;
  77938. /**
  77939. * On pointer over
  77940. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77941. */
  77942. static readonly ACTION_OnPointerOverTrigger: number;
  77943. /**
  77944. * On pointer out
  77945. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77946. */
  77947. static readonly ACTION_OnPointerOutTrigger: number;
  77948. /**
  77949. * On every frame
  77950. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77951. */
  77952. static readonly ACTION_OnEveryFrameTrigger: number;
  77953. /**
  77954. * On intersection enter
  77955. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77956. */
  77957. static readonly ACTION_OnIntersectionEnterTrigger: number;
  77958. /**
  77959. * On intersection exit
  77960. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77961. */
  77962. static readonly ACTION_OnIntersectionExitTrigger: number;
  77963. /**
  77964. * On key down
  77965. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77966. */
  77967. static readonly ACTION_OnKeyDownTrigger: number;
  77968. /**
  77969. * On key up
  77970. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77971. */
  77972. static readonly ACTION_OnKeyUpTrigger: number;
  77973. /**
  77974. * Billboard mode will only apply to Y axis
  77975. */
  77976. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  77977. /**
  77978. * Billboard mode will apply to all axes
  77979. */
  77980. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  77981. /**
  77982. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  77983. */
  77984. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  77985. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  77986. * Test order :
  77987. * Is the bounding sphere outside the frustum ?
  77988. * If not, are the bounding box vertices outside the frustum ?
  77989. * It not, then the cullable object is in the frustum.
  77990. */
  77991. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  77992. /** Culling strategy : Bounding Sphere Only.
  77993. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  77994. * It's also less accurate than the standard because some not visible objects can still be selected.
  77995. * Test : is the bounding sphere outside the frustum ?
  77996. * If not, then the cullable object is in the frustum.
  77997. */
  77998. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  77999. /** Culling strategy : Optimistic Inclusion.
  78000. * This in an inclusion test first, then the standard exclusion test.
  78001. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  78002. * 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.
  78003. * Anyway, it's as accurate as the standard strategy.
  78004. * Test :
  78005. * Is the cullable object bounding sphere center in the frustum ?
  78006. * If not, apply the default culling strategy.
  78007. */
  78008. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  78009. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  78010. * This in an inclusion test first, then the bounding sphere only exclusion test.
  78011. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  78012. * 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.
  78013. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  78014. * Test :
  78015. * Is the cullable object bounding sphere center in the frustum ?
  78016. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  78017. */
  78018. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  78019. /**
  78020. * No logging while loading
  78021. */
  78022. static readonly SCENELOADER_NO_LOGGING: number;
  78023. /**
  78024. * Minimal logging while loading
  78025. */
  78026. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  78027. /**
  78028. * Summary logging while loading
  78029. */
  78030. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  78031. /**
  78032. * Detailled logging while loading
  78033. */
  78034. static readonly SCENELOADER_DETAILED_LOGGING: number;
  78035. }
  78036. }
  78037. declare module BABYLON {
  78038. /**
  78039. * This represents the required contract to create a new type of texture loader.
  78040. */
  78041. export interface IInternalTextureLoader {
  78042. /**
  78043. * Defines wether the loader supports cascade loading the different faces.
  78044. */
  78045. supportCascades: boolean;
  78046. /**
  78047. * This returns if the loader support the current file information.
  78048. * @param extension defines the file extension of the file being loaded
  78049. * @returns true if the loader can load the specified file
  78050. */
  78051. canLoad(extension: string): boolean;
  78052. /**
  78053. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  78054. * @param data contains the texture data
  78055. * @param texture defines the BabylonJS internal texture
  78056. * @param createPolynomials will be true if polynomials have been requested
  78057. * @param onLoad defines the callback to trigger once the texture is ready
  78058. * @param onError defines the callback to trigger in case of error
  78059. */
  78060. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  78061. /**
  78062. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  78063. * @param data contains the texture data
  78064. * @param texture defines the BabylonJS internal texture
  78065. * @param callback defines the method to call once ready to upload
  78066. */
  78067. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  78068. }
  78069. }
  78070. declare module BABYLON {
  78071. /**
  78072. * Class used to store and describe the pipeline context associated with an effect
  78073. */
  78074. export interface IPipelineContext {
  78075. /**
  78076. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  78077. */
  78078. isAsync: boolean;
  78079. /**
  78080. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  78081. */
  78082. isReady: boolean;
  78083. /** @hidden */
  78084. _getVertexShaderCode(): string | null;
  78085. /** @hidden */
  78086. _getFragmentShaderCode(): string | null;
  78087. /** @hidden */
  78088. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  78089. }
  78090. }
  78091. declare module BABYLON {
  78092. /**
  78093. * Class used to store gfx data (like WebGLBuffer)
  78094. */
  78095. export class DataBuffer {
  78096. /**
  78097. * Gets or sets the number of objects referencing this buffer
  78098. */
  78099. references: number;
  78100. /** Gets or sets the size of the underlying buffer */
  78101. capacity: number;
  78102. /**
  78103. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  78104. */
  78105. is32Bits: boolean;
  78106. /**
  78107. * Gets the underlying buffer
  78108. */
  78109. get underlyingResource(): any;
  78110. }
  78111. }
  78112. declare module BABYLON {
  78113. /** @hidden */
  78114. export interface IShaderProcessor {
  78115. attributeProcessor?: (attribute: string) => string;
  78116. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  78117. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  78118. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  78119. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  78120. lineProcessor?: (line: string, isFragment: boolean) => string;
  78121. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  78122. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  78123. }
  78124. }
  78125. declare module BABYLON {
  78126. /** @hidden */
  78127. export interface ProcessingOptions {
  78128. defines: string[];
  78129. indexParameters: any;
  78130. isFragment: boolean;
  78131. shouldUseHighPrecisionShader: boolean;
  78132. supportsUniformBuffers: boolean;
  78133. shadersRepository: string;
  78134. includesShadersStore: {
  78135. [key: string]: string;
  78136. };
  78137. processor?: IShaderProcessor;
  78138. version: string;
  78139. platformName: string;
  78140. lookForClosingBracketForUniformBuffer?: boolean;
  78141. }
  78142. }
  78143. declare module BABYLON {
  78144. /** @hidden */
  78145. export class ShaderCodeNode {
  78146. line: string;
  78147. children: ShaderCodeNode[];
  78148. additionalDefineKey?: string;
  78149. additionalDefineValue?: string;
  78150. isValid(preprocessors: {
  78151. [key: string]: string;
  78152. }): boolean;
  78153. process(preprocessors: {
  78154. [key: string]: string;
  78155. }, options: ProcessingOptions): string;
  78156. }
  78157. }
  78158. declare module BABYLON {
  78159. /** @hidden */
  78160. export class ShaderCodeCursor {
  78161. private _lines;
  78162. lineIndex: number;
  78163. get currentLine(): string;
  78164. get canRead(): boolean;
  78165. set lines(value: string[]);
  78166. }
  78167. }
  78168. declare module BABYLON {
  78169. /** @hidden */
  78170. export class ShaderCodeConditionNode extends ShaderCodeNode {
  78171. process(preprocessors: {
  78172. [key: string]: string;
  78173. }, options: ProcessingOptions): string;
  78174. }
  78175. }
  78176. declare module BABYLON {
  78177. /** @hidden */
  78178. export class ShaderDefineExpression {
  78179. isTrue(preprocessors: {
  78180. [key: string]: string;
  78181. }): boolean;
  78182. private static _OperatorPriority;
  78183. private static _Stack;
  78184. static postfixToInfix(postfix: string[]): string;
  78185. static infixToPostfix(infix: string): string[];
  78186. }
  78187. }
  78188. declare module BABYLON {
  78189. /** @hidden */
  78190. export class ShaderCodeTestNode extends ShaderCodeNode {
  78191. testExpression: ShaderDefineExpression;
  78192. isValid(preprocessors: {
  78193. [key: string]: string;
  78194. }): boolean;
  78195. }
  78196. }
  78197. declare module BABYLON {
  78198. /** @hidden */
  78199. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  78200. define: string;
  78201. not: boolean;
  78202. constructor(define: string, not?: boolean);
  78203. isTrue(preprocessors: {
  78204. [key: string]: string;
  78205. }): boolean;
  78206. }
  78207. }
  78208. declare module BABYLON {
  78209. /** @hidden */
  78210. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  78211. leftOperand: ShaderDefineExpression;
  78212. rightOperand: ShaderDefineExpression;
  78213. isTrue(preprocessors: {
  78214. [key: string]: string;
  78215. }): boolean;
  78216. }
  78217. }
  78218. declare module BABYLON {
  78219. /** @hidden */
  78220. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  78221. leftOperand: ShaderDefineExpression;
  78222. rightOperand: ShaderDefineExpression;
  78223. isTrue(preprocessors: {
  78224. [key: string]: string;
  78225. }): boolean;
  78226. }
  78227. }
  78228. declare module BABYLON {
  78229. /** @hidden */
  78230. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  78231. define: string;
  78232. operand: string;
  78233. testValue: string;
  78234. constructor(define: string, operand: string, testValue: string);
  78235. isTrue(preprocessors: {
  78236. [key: string]: string;
  78237. }): boolean;
  78238. }
  78239. }
  78240. declare module BABYLON {
  78241. /**
  78242. * Class used to enable access to offline support
  78243. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  78244. */
  78245. export interface IOfflineProvider {
  78246. /**
  78247. * Gets a boolean indicating if scene must be saved in the database
  78248. */
  78249. enableSceneOffline: boolean;
  78250. /**
  78251. * Gets a boolean indicating if textures must be saved in the database
  78252. */
  78253. enableTexturesOffline: boolean;
  78254. /**
  78255. * Open the offline support and make it available
  78256. * @param successCallback defines the callback to call on success
  78257. * @param errorCallback defines the callback to call on error
  78258. */
  78259. open(successCallback: () => void, errorCallback: () => void): void;
  78260. /**
  78261. * Loads an image from the offline support
  78262. * @param url defines the url to load from
  78263. * @param image defines the target DOM image
  78264. */
  78265. loadImage(url: string, image: HTMLImageElement): void;
  78266. /**
  78267. * Loads a file from offline support
  78268. * @param url defines the URL to load from
  78269. * @param sceneLoaded defines a callback to call on success
  78270. * @param progressCallBack defines a callback to call when progress changed
  78271. * @param errorCallback defines a callback to call on error
  78272. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  78273. */
  78274. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  78275. }
  78276. }
  78277. declare module BABYLON {
  78278. /**
  78279. * Class used to help managing file picking and drag'n'drop
  78280. * File Storage
  78281. */
  78282. export class FilesInputStore {
  78283. /**
  78284. * List of files ready to be loaded
  78285. */
  78286. static FilesToLoad: {
  78287. [key: string]: File;
  78288. };
  78289. }
  78290. }
  78291. declare module BABYLON {
  78292. /**
  78293. * Class used to define a retry strategy when error happens while loading assets
  78294. */
  78295. export class RetryStrategy {
  78296. /**
  78297. * Function used to defines an exponential back off strategy
  78298. * @param maxRetries defines the maximum number of retries (3 by default)
  78299. * @param baseInterval defines the interval between retries
  78300. * @returns the strategy function to use
  78301. */
  78302. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  78303. }
  78304. }
  78305. declare module BABYLON {
  78306. /**
  78307. * @ignore
  78308. * Application error to support additional information when loading a file
  78309. */
  78310. export abstract class BaseError extends Error {
  78311. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  78312. }
  78313. }
  78314. declare module BABYLON {
  78315. /** @ignore */
  78316. export class LoadFileError extends BaseError {
  78317. request?: WebRequest;
  78318. file?: File;
  78319. /**
  78320. * Creates a new LoadFileError
  78321. * @param message defines the message of the error
  78322. * @param request defines the optional web request
  78323. * @param file defines the optional file
  78324. */
  78325. constructor(message: string, object?: WebRequest | File);
  78326. }
  78327. /** @ignore */
  78328. export class RequestFileError extends BaseError {
  78329. request: WebRequest;
  78330. /**
  78331. * Creates a new LoadFileError
  78332. * @param message defines the message of the error
  78333. * @param request defines the optional web request
  78334. */
  78335. constructor(message: string, request: WebRequest);
  78336. }
  78337. /** @ignore */
  78338. export class ReadFileError extends BaseError {
  78339. file: File;
  78340. /**
  78341. * Creates a new ReadFileError
  78342. * @param message defines the message of the error
  78343. * @param file defines the optional file
  78344. */
  78345. constructor(message: string, file: File);
  78346. }
  78347. /**
  78348. * @hidden
  78349. */
  78350. export class FileTools {
  78351. /**
  78352. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  78353. */
  78354. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  78355. /**
  78356. * Gets or sets the base URL to use to load assets
  78357. */
  78358. static BaseUrl: string;
  78359. /**
  78360. * Default behaviour for cors in the application.
  78361. * It can be a string if the expected behavior is identical in the entire app.
  78362. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  78363. */
  78364. static CorsBehavior: string | ((url: string | string[]) => string);
  78365. /**
  78366. * Gets or sets a function used to pre-process url before using them to load assets
  78367. */
  78368. static PreprocessUrl: (url: string) => string;
  78369. /**
  78370. * Removes unwanted characters from an url
  78371. * @param url defines the url to clean
  78372. * @returns the cleaned url
  78373. */
  78374. private static _CleanUrl;
  78375. /**
  78376. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  78377. * @param url define the url we are trying
  78378. * @param element define the dom element where to configure the cors policy
  78379. */
  78380. static SetCorsBehavior(url: string | string[], element: {
  78381. crossOrigin: string | null;
  78382. }): void;
  78383. /**
  78384. * Loads an image as an HTMLImageElement.
  78385. * @param input url string, ArrayBuffer, or Blob to load
  78386. * @param onLoad callback called when the image successfully loads
  78387. * @param onError callback called when the image fails to load
  78388. * @param offlineProvider offline provider for caching
  78389. * @param mimeType optional mime type
  78390. * @returns the HTMLImageElement of the loaded image
  78391. */
  78392. 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>;
  78393. /**
  78394. * Reads a file from a File object
  78395. * @param file defines the file to load
  78396. * @param onSuccess defines the callback to call when data is loaded
  78397. * @param onProgress defines the callback to call during loading process
  78398. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  78399. * @param onError defines the callback to call when an error occurs
  78400. * @returns a file request object
  78401. */
  78402. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  78403. /**
  78404. * Loads a file from a url
  78405. * @param url url to load
  78406. * @param onSuccess callback called when the file successfully loads
  78407. * @param onProgress callback called while file is loading (if the server supports this mode)
  78408. * @param offlineProvider defines the offline provider for caching
  78409. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  78410. * @param onError callback called when the file fails to load
  78411. * @returns a file request object
  78412. */
  78413. 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;
  78414. /**
  78415. * Loads a file
  78416. * @param url url to load
  78417. * @param onSuccess callback called when the file successfully loads
  78418. * @param onProgress callback called while file is loading (if the server supports this mode)
  78419. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  78420. * @param onError callback called when the file fails to load
  78421. * @param onOpened callback called when the web request is opened
  78422. * @returns a file request object
  78423. */
  78424. 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;
  78425. /**
  78426. * Checks if the loaded document was accessed via `file:`-Protocol.
  78427. * @returns boolean
  78428. */
  78429. static IsFileURL(): boolean;
  78430. }
  78431. }
  78432. declare module BABYLON {
  78433. /** @hidden */
  78434. export class ShaderProcessor {
  78435. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  78436. private static _ProcessPrecision;
  78437. private static _ExtractOperation;
  78438. private static _BuildSubExpression;
  78439. private static _BuildExpression;
  78440. private static _MoveCursorWithinIf;
  78441. private static _MoveCursor;
  78442. private static _EvaluatePreProcessors;
  78443. private static _PreparePreProcessors;
  78444. private static _ProcessShaderConversion;
  78445. private static _ProcessIncludes;
  78446. /**
  78447. * Loads a file from a url
  78448. * @param url url to load
  78449. * @param onSuccess callback called when the file successfully loads
  78450. * @param onProgress callback called while file is loading (if the server supports this mode)
  78451. * @param offlineProvider defines the offline provider for caching
  78452. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  78453. * @param onError callback called when the file fails to load
  78454. * @returns a file request object
  78455. * @hidden
  78456. */
  78457. 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;
  78458. }
  78459. }
  78460. declare module BABYLON {
  78461. /**
  78462. * @hidden
  78463. */
  78464. export interface IColor4Like {
  78465. r: float;
  78466. g: float;
  78467. b: float;
  78468. a: float;
  78469. }
  78470. /**
  78471. * @hidden
  78472. */
  78473. export interface IColor3Like {
  78474. r: float;
  78475. g: float;
  78476. b: float;
  78477. }
  78478. /**
  78479. * @hidden
  78480. */
  78481. export interface IVector4Like {
  78482. x: float;
  78483. y: float;
  78484. z: float;
  78485. w: float;
  78486. }
  78487. /**
  78488. * @hidden
  78489. */
  78490. export interface IVector3Like {
  78491. x: float;
  78492. y: float;
  78493. z: float;
  78494. }
  78495. /**
  78496. * @hidden
  78497. */
  78498. export interface IVector2Like {
  78499. x: float;
  78500. y: float;
  78501. }
  78502. /**
  78503. * @hidden
  78504. */
  78505. export interface IMatrixLike {
  78506. toArray(): DeepImmutable<Float32Array>;
  78507. updateFlag: int;
  78508. }
  78509. /**
  78510. * @hidden
  78511. */
  78512. export interface IViewportLike {
  78513. x: float;
  78514. y: float;
  78515. width: float;
  78516. height: float;
  78517. }
  78518. /**
  78519. * @hidden
  78520. */
  78521. export interface IPlaneLike {
  78522. normal: IVector3Like;
  78523. d: float;
  78524. normalize(): void;
  78525. }
  78526. }
  78527. declare module BABYLON {
  78528. /**
  78529. * Interface used to define common properties for effect fallbacks
  78530. */
  78531. export interface IEffectFallbacks {
  78532. /**
  78533. * Removes the defines that should be removed when falling back.
  78534. * @param currentDefines defines the current define statements for the shader.
  78535. * @param effect defines the current effect we try to compile
  78536. * @returns The resulting defines with defines of the current rank removed.
  78537. */
  78538. reduce(currentDefines: string, effect: Effect): string;
  78539. /**
  78540. * Removes the fallback from the bound mesh.
  78541. */
  78542. unBindMesh(): void;
  78543. /**
  78544. * Checks to see if more fallbacks are still availible.
  78545. */
  78546. hasMoreFallbacks: boolean;
  78547. }
  78548. }
  78549. declare module BABYLON {
  78550. /**
  78551. * Class used to evalaute queries containing `and` and `or` operators
  78552. */
  78553. export class AndOrNotEvaluator {
  78554. /**
  78555. * Evaluate a query
  78556. * @param query defines the query to evaluate
  78557. * @param evaluateCallback defines the callback used to filter result
  78558. * @returns true if the query matches
  78559. */
  78560. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  78561. private static _HandleParenthesisContent;
  78562. private static _SimplifyNegation;
  78563. }
  78564. }
  78565. declare module BABYLON {
  78566. /**
  78567. * Class used to store custom tags
  78568. */
  78569. export class Tags {
  78570. /**
  78571. * Adds support for tags on the given object
  78572. * @param obj defines the object to use
  78573. */
  78574. static EnableFor(obj: any): void;
  78575. /**
  78576. * Removes tags support
  78577. * @param obj defines the object to use
  78578. */
  78579. static DisableFor(obj: any): void;
  78580. /**
  78581. * Gets a boolean indicating if the given object has tags
  78582. * @param obj defines the object to use
  78583. * @returns a boolean
  78584. */
  78585. static HasTags(obj: any): boolean;
  78586. /**
  78587. * Gets the tags available on a given object
  78588. * @param obj defines the object to use
  78589. * @param asString defines if the tags must be returned as a string instead of an array of strings
  78590. * @returns the tags
  78591. */
  78592. static GetTags(obj: any, asString?: boolean): any;
  78593. /**
  78594. * Adds tags to an object
  78595. * @param obj defines the object to use
  78596. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  78597. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  78598. */
  78599. static AddTagsTo(obj: any, tagsString: string): void;
  78600. /**
  78601. * @hidden
  78602. */
  78603. static _AddTagTo(obj: any, tag: string): void;
  78604. /**
  78605. * Removes specific tags from a specific object
  78606. * @param obj defines the object to use
  78607. * @param tagsString defines the tags to remove
  78608. */
  78609. static RemoveTagsFrom(obj: any, tagsString: string): void;
  78610. /**
  78611. * @hidden
  78612. */
  78613. static _RemoveTagFrom(obj: any, tag: string): void;
  78614. /**
  78615. * Defines if tags hosted on an object match a given query
  78616. * @param obj defines the object to use
  78617. * @param tagsQuery defines the tag query
  78618. * @returns a boolean
  78619. */
  78620. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  78621. }
  78622. }
  78623. declare module BABYLON {
  78624. /**
  78625. * Scalar computation library
  78626. */
  78627. export class Scalar {
  78628. /**
  78629. * Two pi constants convenient for computation.
  78630. */
  78631. static TwoPi: number;
  78632. /**
  78633. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  78634. * @param a number
  78635. * @param b number
  78636. * @param epsilon (default = 1.401298E-45)
  78637. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  78638. */
  78639. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  78640. /**
  78641. * Returns a string : the upper case translation of the number i to hexadecimal.
  78642. * @param i number
  78643. * @returns the upper case translation of the number i to hexadecimal.
  78644. */
  78645. static ToHex(i: number): string;
  78646. /**
  78647. * Returns -1 if value is negative and +1 is value is positive.
  78648. * @param value the value
  78649. * @returns the value itself if it's equal to zero.
  78650. */
  78651. static Sign(value: number): number;
  78652. /**
  78653. * Returns the value itself if it's between min and max.
  78654. * Returns min if the value is lower than min.
  78655. * Returns max if the value is greater than max.
  78656. * @param value the value to clmap
  78657. * @param min the min value to clamp to (default: 0)
  78658. * @param max the max value to clamp to (default: 1)
  78659. * @returns the clamped value
  78660. */
  78661. static Clamp(value: number, min?: number, max?: number): number;
  78662. /**
  78663. * the log2 of value.
  78664. * @param value the value to compute log2 of
  78665. * @returns the log2 of value.
  78666. */
  78667. static Log2(value: number): number;
  78668. /**
  78669. * Loops the value, so that it is never larger than length and never smaller than 0.
  78670. *
  78671. * This is similar to the modulo operator but it works with floating point numbers.
  78672. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  78673. * With t = 5 and length = 2.5, the result would be 0.0.
  78674. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  78675. * @param value the value
  78676. * @param length the length
  78677. * @returns the looped value
  78678. */
  78679. static Repeat(value: number, length: number): number;
  78680. /**
  78681. * Normalize the value between 0.0 and 1.0 using min and max values
  78682. * @param value value to normalize
  78683. * @param min max to normalize between
  78684. * @param max min to normalize between
  78685. * @returns the normalized value
  78686. */
  78687. static Normalize(value: number, min: number, max: number): number;
  78688. /**
  78689. * Denormalize the value from 0.0 and 1.0 using min and max values
  78690. * @param normalized value to denormalize
  78691. * @param min max to denormalize between
  78692. * @param max min to denormalize between
  78693. * @returns the denormalized value
  78694. */
  78695. static Denormalize(normalized: number, min: number, max: number): number;
  78696. /**
  78697. * Calculates the shortest difference between two given angles given in degrees.
  78698. * @param current current angle in degrees
  78699. * @param target target angle in degrees
  78700. * @returns the delta
  78701. */
  78702. static DeltaAngle(current: number, target: number): number;
  78703. /**
  78704. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  78705. * @param tx value
  78706. * @param length length
  78707. * @returns The returned value will move back and forth between 0 and length
  78708. */
  78709. static PingPong(tx: number, length: number): number;
  78710. /**
  78711. * Interpolates between min and max with smoothing at the limits.
  78712. *
  78713. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  78714. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  78715. * @param from from
  78716. * @param to to
  78717. * @param tx value
  78718. * @returns the smooth stepped value
  78719. */
  78720. static SmoothStep(from: number, to: number, tx: number): number;
  78721. /**
  78722. * Moves a value current towards target.
  78723. *
  78724. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  78725. * Negative values of maxDelta pushes the value away from target.
  78726. * @param current current value
  78727. * @param target target value
  78728. * @param maxDelta max distance to move
  78729. * @returns resulting value
  78730. */
  78731. static MoveTowards(current: number, target: number, maxDelta: number): number;
  78732. /**
  78733. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  78734. *
  78735. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  78736. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  78737. * @param current current value
  78738. * @param target target value
  78739. * @param maxDelta max distance to move
  78740. * @returns resulting angle
  78741. */
  78742. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  78743. /**
  78744. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  78745. * @param start start value
  78746. * @param end target value
  78747. * @param amount amount to lerp between
  78748. * @returns the lerped value
  78749. */
  78750. static Lerp(start: number, end: number, amount: number): number;
  78751. /**
  78752. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  78753. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  78754. * @param start start value
  78755. * @param end target value
  78756. * @param amount amount to lerp between
  78757. * @returns the lerped value
  78758. */
  78759. static LerpAngle(start: number, end: number, amount: number): number;
  78760. /**
  78761. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  78762. * @param a start value
  78763. * @param b target value
  78764. * @param value value between a and b
  78765. * @returns the inverseLerp value
  78766. */
  78767. static InverseLerp(a: number, b: number, value: number): number;
  78768. /**
  78769. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  78770. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  78771. * @param value1 spline value
  78772. * @param tangent1 spline value
  78773. * @param value2 spline value
  78774. * @param tangent2 spline value
  78775. * @param amount input value
  78776. * @returns hermite result
  78777. */
  78778. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  78779. /**
  78780. * Returns a random float number between and min and max values
  78781. * @param min min value of random
  78782. * @param max max value of random
  78783. * @returns random value
  78784. */
  78785. static RandomRange(min: number, max: number): number;
  78786. /**
  78787. * This function returns percentage of a number in a given range.
  78788. *
  78789. * RangeToPercent(40,20,60) will return 0.5 (50%)
  78790. * RangeToPercent(34,0,100) will return 0.34 (34%)
  78791. * @param number to convert to percentage
  78792. * @param min min range
  78793. * @param max max range
  78794. * @returns the percentage
  78795. */
  78796. static RangeToPercent(number: number, min: number, max: number): number;
  78797. /**
  78798. * This function returns number that corresponds to the percentage in a given range.
  78799. *
  78800. * PercentToRange(0.34,0,100) will return 34.
  78801. * @param percent to convert to number
  78802. * @param min min range
  78803. * @param max max range
  78804. * @returns the number
  78805. */
  78806. static PercentToRange(percent: number, min: number, max: number): number;
  78807. /**
  78808. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  78809. * @param angle The angle to normalize in radian.
  78810. * @return The converted angle.
  78811. */
  78812. static NormalizeRadians(angle: number): number;
  78813. }
  78814. }
  78815. declare module BABYLON {
  78816. /**
  78817. * Constant used to convert a value to gamma space
  78818. * @ignorenaming
  78819. */
  78820. export const ToGammaSpace: number;
  78821. /**
  78822. * Constant used to convert a value to linear space
  78823. * @ignorenaming
  78824. */
  78825. export const ToLinearSpace = 2.2;
  78826. /**
  78827. * Constant used to define the minimal number value in Babylon.js
  78828. * @ignorenaming
  78829. */
  78830. let Epsilon: number;
  78831. }
  78832. declare module BABYLON {
  78833. /**
  78834. * Class used to represent a viewport on screen
  78835. */
  78836. export class Viewport {
  78837. /** viewport left coordinate */
  78838. x: number;
  78839. /** viewport top coordinate */
  78840. y: number;
  78841. /**viewport width */
  78842. width: number;
  78843. /** viewport height */
  78844. height: number;
  78845. /**
  78846. * Creates a Viewport object located at (x, y) and sized (width, height)
  78847. * @param x defines viewport left coordinate
  78848. * @param y defines viewport top coordinate
  78849. * @param width defines the viewport width
  78850. * @param height defines the viewport height
  78851. */
  78852. constructor(
  78853. /** viewport left coordinate */
  78854. x: number,
  78855. /** viewport top coordinate */
  78856. y: number,
  78857. /**viewport width */
  78858. width: number,
  78859. /** viewport height */
  78860. height: number);
  78861. /**
  78862. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  78863. * @param renderWidth defines the rendering width
  78864. * @param renderHeight defines the rendering height
  78865. * @returns a new Viewport
  78866. */
  78867. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  78868. /**
  78869. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  78870. * @param renderWidth defines the rendering width
  78871. * @param renderHeight defines the rendering height
  78872. * @param ref defines the target viewport
  78873. * @returns the current viewport
  78874. */
  78875. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  78876. /**
  78877. * Returns a new Viewport copied from the current one
  78878. * @returns a new Viewport
  78879. */
  78880. clone(): Viewport;
  78881. }
  78882. }
  78883. declare module BABYLON {
  78884. /**
  78885. * Class containing a set of static utilities functions for arrays.
  78886. */
  78887. export class ArrayTools {
  78888. /**
  78889. * Returns an array of the given size filled with element built from the given constructor and the paramters
  78890. * @param size the number of element to construct and put in the array
  78891. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  78892. * @returns a new array filled with new objects
  78893. */
  78894. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  78895. }
  78896. }
  78897. declare module BABYLON {
  78898. /**
  78899. * Represens a plane by the equation ax + by + cz + d = 0
  78900. */
  78901. export class Plane {
  78902. private static _TmpMatrix;
  78903. /**
  78904. * Normal of the plane (a,b,c)
  78905. */
  78906. normal: Vector3;
  78907. /**
  78908. * d component of the plane
  78909. */
  78910. d: number;
  78911. /**
  78912. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  78913. * @param a a component of the plane
  78914. * @param b b component of the plane
  78915. * @param c c component of the plane
  78916. * @param d d component of the plane
  78917. */
  78918. constructor(a: number, b: number, c: number, d: number);
  78919. /**
  78920. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  78921. */
  78922. asArray(): number[];
  78923. /**
  78924. * @returns a new plane copied from the current Plane.
  78925. */
  78926. clone(): Plane;
  78927. /**
  78928. * @returns the string "Plane".
  78929. */
  78930. getClassName(): string;
  78931. /**
  78932. * @returns the Plane hash code.
  78933. */
  78934. getHashCode(): number;
  78935. /**
  78936. * Normalize the current Plane in place.
  78937. * @returns the updated Plane.
  78938. */
  78939. normalize(): Plane;
  78940. /**
  78941. * Applies a transformation the plane and returns the result
  78942. * @param transformation the transformation matrix to be applied to the plane
  78943. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  78944. */
  78945. transform(transformation: DeepImmutable<Matrix>): Plane;
  78946. /**
  78947. * Compute the dot product between the point and the plane normal
  78948. * @param point point to calculate the dot product with
  78949. * @returns the dot product (float) of the point coordinates and the plane normal.
  78950. */
  78951. dotCoordinate(point: DeepImmutable<Vector3>): number;
  78952. /**
  78953. * Updates the current Plane from the plane defined by the three given points.
  78954. * @param point1 one of the points used to contruct the plane
  78955. * @param point2 one of the points used to contruct the plane
  78956. * @param point3 one of the points used to contruct the plane
  78957. * @returns the updated Plane.
  78958. */
  78959. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  78960. /**
  78961. * Checks if the plane is facing a given direction
  78962. * @param direction the direction to check if the plane is facing
  78963. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  78964. * @returns True is the vector "direction" is the same side than the plane normal.
  78965. */
  78966. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  78967. /**
  78968. * Calculates the distance to a point
  78969. * @param point point to calculate distance to
  78970. * @returns the signed distance (float) from the given point to the Plane.
  78971. */
  78972. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  78973. /**
  78974. * Creates a plane from an array
  78975. * @param array the array to create a plane from
  78976. * @returns a new Plane from the given array.
  78977. */
  78978. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  78979. /**
  78980. * Creates a plane from three points
  78981. * @param point1 point used to create the plane
  78982. * @param point2 point used to create the plane
  78983. * @param point3 point used to create the plane
  78984. * @returns a new Plane defined by the three given points.
  78985. */
  78986. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  78987. /**
  78988. * Creates a plane from an origin point and a normal
  78989. * @param origin origin of the plane to be constructed
  78990. * @param normal normal of the plane to be constructed
  78991. * @returns a new Plane the normal vector to this plane at the given origin point.
  78992. * Note : the vector "normal" is updated because normalized.
  78993. */
  78994. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  78995. /**
  78996. * Calculates the distance from a plane and a point
  78997. * @param origin origin of the plane to be constructed
  78998. * @param normal normal of the plane to be constructed
  78999. * @param point point to calculate distance to
  79000. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  79001. */
  79002. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  79003. }
  79004. }
  79005. declare module BABYLON {
  79006. /**
  79007. * Class representing a vector containing 2 coordinates
  79008. */
  79009. export class Vector2 {
  79010. /** defines the first coordinate */
  79011. x: number;
  79012. /** defines the second coordinate */
  79013. y: number;
  79014. /**
  79015. * Creates a new Vector2 from the given x and y coordinates
  79016. * @param x defines the first coordinate
  79017. * @param y defines the second coordinate
  79018. */
  79019. constructor(
  79020. /** defines the first coordinate */
  79021. x?: number,
  79022. /** defines the second coordinate */
  79023. y?: number);
  79024. /**
  79025. * Gets a string with the Vector2 coordinates
  79026. * @returns a string with the Vector2 coordinates
  79027. */
  79028. toString(): string;
  79029. /**
  79030. * Gets class name
  79031. * @returns the string "Vector2"
  79032. */
  79033. getClassName(): string;
  79034. /**
  79035. * Gets current vector hash code
  79036. * @returns the Vector2 hash code as a number
  79037. */
  79038. getHashCode(): number;
  79039. /**
  79040. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  79041. * @param array defines the source array
  79042. * @param index defines the offset in source array
  79043. * @returns the current Vector2
  79044. */
  79045. toArray(array: FloatArray, index?: number): Vector2;
  79046. /**
  79047. * Copy the current vector to an array
  79048. * @returns a new array with 2 elements: the Vector2 coordinates.
  79049. */
  79050. asArray(): number[];
  79051. /**
  79052. * Sets the Vector2 coordinates with the given Vector2 coordinates
  79053. * @param source defines the source Vector2
  79054. * @returns the current updated Vector2
  79055. */
  79056. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  79057. /**
  79058. * Sets the Vector2 coordinates with the given floats
  79059. * @param x defines the first coordinate
  79060. * @param y defines the second coordinate
  79061. * @returns the current updated Vector2
  79062. */
  79063. copyFromFloats(x: number, y: number): Vector2;
  79064. /**
  79065. * Sets the Vector2 coordinates with the given floats
  79066. * @param x defines the first coordinate
  79067. * @param y defines the second coordinate
  79068. * @returns the current updated Vector2
  79069. */
  79070. set(x: number, y: number): Vector2;
  79071. /**
  79072. * Add another vector with the current one
  79073. * @param otherVector defines the other vector
  79074. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  79075. */
  79076. add(otherVector: DeepImmutable<Vector2>): Vector2;
  79077. /**
  79078. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  79079. * @param otherVector defines the other vector
  79080. * @param result defines the target vector
  79081. * @returns the unmodified current Vector2
  79082. */
  79083. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  79084. /**
  79085. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  79086. * @param otherVector defines the other vector
  79087. * @returns the current updated Vector2
  79088. */
  79089. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  79090. /**
  79091. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  79092. * @param otherVector defines the other vector
  79093. * @returns a new Vector2
  79094. */
  79095. addVector3(otherVector: Vector3): Vector2;
  79096. /**
  79097. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  79098. * @param otherVector defines the other vector
  79099. * @returns a new Vector2
  79100. */
  79101. subtract(otherVector: Vector2): Vector2;
  79102. /**
  79103. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  79104. * @param otherVector defines the other vector
  79105. * @param result defines the target vector
  79106. * @returns the unmodified current Vector2
  79107. */
  79108. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  79109. /**
  79110. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  79111. * @param otherVector defines the other vector
  79112. * @returns the current updated Vector2
  79113. */
  79114. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  79115. /**
  79116. * Multiplies in place the current Vector2 coordinates by the given ones
  79117. * @param otherVector defines the other vector
  79118. * @returns the current updated Vector2
  79119. */
  79120. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  79121. /**
  79122. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  79123. * @param otherVector defines the other vector
  79124. * @returns a new Vector2
  79125. */
  79126. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  79127. /**
  79128. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  79129. * @param otherVector defines the other vector
  79130. * @param result defines the target vector
  79131. * @returns the unmodified current Vector2
  79132. */
  79133. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  79134. /**
  79135. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  79136. * @param x defines the first coordinate
  79137. * @param y defines the second coordinate
  79138. * @returns a new Vector2
  79139. */
  79140. multiplyByFloats(x: number, y: number): Vector2;
  79141. /**
  79142. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  79143. * @param otherVector defines the other vector
  79144. * @returns a new Vector2
  79145. */
  79146. divide(otherVector: Vector2): Vector2;
  79147. /**
  79148. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  79149. * @param otherVector defines the other vector
  79150. * @param result defines the target vector
  79151. * @returns the unmodified current Vector2
  79152. */
  79153. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  79154. /**
  79155. * Divides the current Vector2 coordinates by the given ones
  79156. * @param otherVector defines the other vector
  79157. * @returns the current updated Vector2
  79158. */
  79159. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  79160. /**
  79161. * Gets a new Vector2 with current Vector2 negated coordinates
  79162. * @returns a new Vector2
  79163. */
  79164. negate(): Vector2;
  79165. /**
  79166. * Negate this vector in place
  79167. * @returns this
  79168. */
  79169. negateInPlace(): Vector2;
  79170. /**
  79171. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  79172. * @param result defines the Vector3 object where to store the result
  79173. * @returns the current Vector2
  79174. */
  79175. negateToRef(result: Vector2): Vector2;
  79176. /**
  79177. * Multiply the Vector2 coordinates by scale
  79178. * @param scale defines the scaling factor
  79179. * @returns the current updated Vector2
  79180. */
  79181. scaleInPlace(scale: number): Vector2;
  79182. /**
  79183. * Returns a new Vector2 scaled by "scale" from the current Vector2
  79184. * @param scale defines the scaling factor
  79185. * @returns a new Vector2
  79186. */
  79187. scale(scale: number): Vector2;
  79188. /**
  79189. * Scale the current Vector2 values by a factor to a given Vector2
  79190. * @param scale defines the scale factor
  79191. * @param result defines the Vector2 object where to store the result
  79192. * @returns the unmodified current Vector2
  79193. */
  79194. scaleToRef(scale: number, result: Vector2): Vector2;
  79195. /**
  79196. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  79197. * @param scale defines the scale factor
  79198. * @param result defines the Vector2 object where to store the result
  79199. * @returns the unmodified current Vector2
  79200. */
  79201. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  79202. /**
  79203. * Gets a boolean if two vectors are equals
  79204. * @param otherVector defines the other vector
  79205. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  79206. */
  79207. equals(otherVector: DeepImmutable<Vector2>): boolean;
  79208. /**
  79209. * Gets a boolean if two vectors are equals (using an epsilon value)
  79210. * @param otherVector defines the other vector
  79211. * @param epsilon defines the minimal distance to consider equality
  79212. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  79213. */
  79214. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  79215. /**
  79216. * Gets a new Vector2 from current Vector2 floored values
  79217. * @returns a new Vector2
  79218. */
  79219. floor(): Vector2;
  79220. /**
  79221. * Gets a new Vector2 from current Vector2 floored values
  79222. * @returns a new Vector2
  79223. */
  79224. fract(): Vector2;
  79225. /**
  79226. * Gets the length of the vector
  79227. * @returns the vector length (float)
  79228. */
  79229. length(): number;
  79230. /**
  79231. * Gets the vector squared length
  79232. * @returns the vector squared length (float)
  79233. */
  79234. lengthSquared(): number;
  79235. /**
  79236. * Normalize the vector
  79237. * @returns the current updated Vector2
  79238. */
  79239. normalize(): Vector2;
  79240. /**
  79241. * Gets a new Vector2 copied from the Vector2
  79242. * @returns a new Vector2
  79243. */
  79244. clone(): Vector2;
  79245. /**
  79246. * Gets a new Vector2(0, 0)
  79247. * @returns a new Vector2
  79248. */
  79249. static Zero(): Vector2;
  79250. /**
  79251. * Gets a new Vector2(1, 1)
  79252. * @returns a new Vector2
  79253. */
  79254. static One(): Vector2;
  79255. /**
  79256. * Gets a new Vector2 set from the given index element of the given array
  79257. * @param array defines the data source
  79258. * @param offset defines the offset in the data source
  79259. * @returns a new Vector2
  79260. */
  79261. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  79262. /**
  79263. * Sets "result" from the given index element of the given array
  79264. * @param array defines the data source
  79265. * @param offset defines the offset in the data source
  79266. * @param result defines the target vector
  79267. */
  79268. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  79269. /**
  79270. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  79271. * @param value1 defines 1st point of control
  79272. * @param value2 defines 2nd point of control
  79273. * @param value3 defines 3rd point of control
  79274. * @param value4 defines 4th point of control
  79275. * @param amount defines the interpolation factor
  79276. * @returns a new Vector2
  79277. */
  79278. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  79279. /**
  79280. * 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".
  79281. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  79282. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  79283. * @param value defines the value to clamp
  79284. * @param min defines the lower limit
  79285. * @param max defines the upper limit
  79286. * @returns a new Vector2
  79287. */
  79288. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  79289. /**
  79290. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  79291. * @param value1 defines the 1st control point
  79292. * @param tangent1 defines the outgoing tangent
  79293. * @param value2 defines the 2nd control point
  79294. * @param tangent2 defines the incoming tangent
  79295. * @param amount defines the interpolation factor
  79296. * @returns a new Vector2
  79297. */
  79298. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  79299. /**
  79300. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  79301. * @param start defines the start vector
  79302. * @param end defines the end vector
  79303. * @param amount defines the interpolation factor
  79304. * @returns a new Vector2
  79305. */
  79306. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  79307. /**
  79308. * Gets the dot product of the vector "left" and the vector "right"
  79309. * @param left defines first vector
  79310. * @param right defines second vector
  79311. * @returns the dot product (float)
  79312. */
  79313. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  79314. /**
  79315. * Returns a new Vector2 equal to the normalized given vector
  79316. * @param vector defines the vector to normalize
  79317. * @returns a new Vector2
  79318. */
  79319. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  79320. /**
  79321. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  79322. * @param left defines 1st vector
  79323. * @param right defines 2nd vector
  79324. * @returns a new Vector2
  79325. */
  79326. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  79327. /**
  79328. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  79329. * @param left defines 1st vector
  79330. * @param right defines 2nd vector
  79331. * @returns a new Vector2
  79332. */
  79333. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  79334. /**
  79335. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  79336. * @param vector defines the vector to transform
  79337. * @param transformation defines the matrix to apply
  79338. * @returns a new Vector2
  79339. */
  79340. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  79341. /**
  79342. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  79343. * @param vector defines the vector to transform
  79344. * @param transformation defines the matrix to apply
  79345. * @param result defines the target vector
  79346. */
  79347. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  79348. /**
  79349. * Determines if a given vector is included in a triangle
  79350. * @param p defines the vector to test
  79351. * @param p0 defines 1st triangle point
  79352. * @param p1 defines 2nd triangle point
  79353. * @param p2 defines 3rd triangle point
  79354. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  79355. */
  79356. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  79357. /**
  79358. * Gets the distance between the vectors "value1" and "value2"
  79359. * @param value1 defines first vector
  79360. * @param value2 defines second vector
  79361. * @returns the distance between vectors
  79362. */
  79363. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  79364. /**
  79365. * Returns the squared distance between the vectors "value1" and "value2"
  79366. * @param value1 defines first vector
  79367. * @param value2 defines second vector
  79368. * @returns the squared distance between vectors
  79369. */
  79370. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  79371. /**
  79372. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  79373. * @param value1 defines first vector
  79374. * @param value2 defines second vector
  79375. * @returns a new Vector2
  79376. */
  79377. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  79378. /**
  79379. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  79380. * @param p defines the middle point
  79381. * @param segA defines one point of the segment
  79382. * @param segB defines the other point of the segment
  79383. * @returns the shortest distance
  79384. */
  79385. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  79386. }
  79387. /**
  79388. * Class used to store (x,y,z) vector representation
  79389. * A Vector3 is the main object used in 3D geometry
  79390. * It can represent etiher the coordinates of a point the space, either a direction
  79391. * Reminder: js uses a left handed forward facing system
  79392. */
  79393. export class Vector3 {
  79394. /**
  79395. * Defines the first coordinates (on X axis)
  79396. */
  79397. x: number;
  79398. /**
  79399. * Defines the second coordinates (on Y axis)
  79400. */
  79401. y: number;
  79402. /**
  79403. * Defines the third coordinates (on Z axis)
  79404. */
  79405. z: number;
  79406. private static _UpReadOnly;
  79407. private static _ZeroReadOnly;
  79408. /**
  79409. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  79410. * @param x defines the first coordinates (on X axis)
  79411. * @param y defines the second coordinates (on Y axis)
  79412. * @param z defines the third coordinates (on Z axis)
  79413. */
  79414. constructor(
  79415. /**
  79416. * Defines the first coordinates (on X axis)
  79417. */
  79418. x?: number,
  79419. /**
  79420. * Defines the second coordinates (on Y axis)
  79421. */
  79422. y?: number,
  79423. /**
  79424. * Defines the third coordinates (on Z axis)
  79425. */
  79426. z?: number);
  79427. /**
  79428. * Creates a string representation of the Vector3
  79429. * @returns a string with the Vector3 coordinates.
  79430. */
  79431. toString(): string;
  79432. /**
  79433. * Gets the class name
  79434. * @returns the string "Vector3"
  79435. */
  79436. getClassName(): string;
  79437. /**
  79438. * Creates the Vector3 hash code
  79439. * @returns a number which tends to be unique between Vector3 instances
  79440. */
  79441. getHashCode(): number;
  79442. /**
  79443. * Creates an array containing three elements : the coordinates of the Vector3
  79444. * @returns a new array of numbers
  79445. */
  79446. asArray(): number[];
  79447. /**
  79448. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  79449. * @param array defines the destination array
  79450. * @param index defines the offset in the destination array
  79451. * @returns the current Vector3
  79452. */
  79453. toArray(array: FloatArray, index?: number): Vector3;
  79454. /**
  79455. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  79456. * @returns a new Quaternion object, computed from the Vector3 coordinates
  79457. */
  79458. toQuaternion(): Quaternion;
  79459. /**
  79460. * Adds the given vector to the current Vector3
  79461. * @param otherVector defines the second operand
  79462. * @returns the current updated Vector3
  79463. */
  79464. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  79465. /**
  79466. * Adds the given coordinates to the current Vector3
  79467. * @param x defines the x coordinate of the operand
  79468. * @param y defines the y coordinate of the operand
  79469. * @param z defines the z coordinate of the operand
  79470. * @returns the current updated Vector3
  79471. */
  79472. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  79473. /**
  79474. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  79475. * @param otherVector defines the second operand
  79476. * @returns the resulting Vector3
  79477. */
  79478. add(otherVector: DeepImmutable<Vector3>): Vector3;
  79479. /**
  79480. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  79481. * @param otherVector defines the second operand
  79482. * @param result defines the Vector3 object where to store the result
  79483. * @returns the current Vector3
  79484. */
  79485. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  79486. /**
  79487. * Subtract the given vector from the current Vector3
  79488. * @param otherVector defines the second operand
  79489. * @returns the current updated Vector3
  79490. */
  79491. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  79492. /**
  79493. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  79494. * @param otherVector defines the second operand
  79495. * @returns the resulting Vector3
  79496. */
  79497. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  79498. /**
  79499. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  79500. * @param otherVector defines the second operand
  79501. * @param result defines the Vector3 object where to store the result
  79502. * @returns the current Vector3
  79503. */
  79504. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  79505. /**
  79506. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  79507. * @param x defines the x coordinate of the operand
  79508. * @param y defines the y coordinate of the operand
  79509. * @param z defines the z coordinate of the operand
  79510. * @returns the resulting Vector3
  79511. */
  79512. subtractFromFloats(x: number, y: number, z: number): Vector3;
  79513. /**
  79514. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  79515. * @param x defines the x coordinate of the operand
  79516. * @param y defines the y coordinate of the operand
  79517. * @param z defines the z coordinate of the operand
  79518. * @param result defines the Vector3 object where to store the result
  79519. * @returns the current Vector3
  79520. */
  79521. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  79522. /**
  79523. * Gets a new Vector3 set with the current Vector3 negated coordinates
  79524. * @returns a new Vector3
  79525. */
  79526. negate(): Vector3;
  79527. /**
  79528. * Negate this vector in place
  79529. * @returns this
  79530. */
  79531. negateInPlace(): Vector3;
  79532. /**
  79533. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  79534. * @param result defines the Vector3 object where to store the result
  79535. * @returns the current Vector3
  79536. */
  79537. negateToRef(result: Vector3): Vector3;
  79538. /**
  79539. * Multiplies the Vector3 coordinates by the float "scale"
  79540. * @param scale defines the multiplier factor
  79541. * @returns the current updated Vector3
  79542. */
  79543. scaleInPlace(scale: number): Vector3;
  79544. /**
  79545. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  79546. * @param scale defines the multiplier factor
  79547. * @returns a new Vector3
  79548. */
  79549. scale(scale: number): Vector3;
  79550. /**
  79551. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  79552. * @param scale defines the multiplier factor
  79553. * @param result defines the Vector3 object where to store the result
  79554. * @returns the current Vector3
  79555. */
  79556. scaleToRef(scale: number, result: Vector3): Vector3;
  79557. /**
  79558. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  79559. * @param scale defines the scale factor
  79560. * @param result defines the Vector3 object where to store the result
  79561. * @returns the unmodified current Vector3
  79562. */
  79563. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  79564. /**
  79565. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  79566. * @param origin defines the origin of the projection ray
  79567. * @param plane defines the plane to project to
  79568. * @returns the projected vector3
  79569. */
  79570. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  79571. /**
  79572. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  79573. * @param origin defines the origin of the projection ray
  79574. * @param plane defines the plane to project to
  79575. * @param result defines the Vector3 where to store the result
  79576. */
  79577. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  79578. /**
  79579. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  79580. * @param otherVector defines the second operand
  79581. * @returns true if both vectors are equals
  79582. */
  79583. equals(otherVector: DeepImmutable<Vector3>): boolean;
  79584. /**
  79585. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  79586. * @param otherVector defines the second operand
  79587. * @param epsilon defines the minimal distance to define values as equals
  79588. * @returns true if both vectors are distant less than epsilon
  79589. */
  79590. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  79591. /**
  79592. * Returns true if the current Vector3 coordinates equals the given floats
  79593. * @param x defines the x coordinate of the operand
  79594. * @param y defines the y coordinate of the operand
  79595. * @param z defines the z coordinate of the operand
  79596. * @returns true if both vectors are equals
  79597. */
  79598. equalsToFloats(x: number, y: number, z: number): boolean;
  79599. /**
  79600. * Multiplies the current Vector3 coordinates by the given ones
  79601. * @param otherVector defines the second operand
  79602. * @returns the current updated Vector3
  79603. */
  79604. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  79605. /**
  79606. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  79607. * @param otherVector defines the second operand
  79608. * @returns the new Vector3
  79609. */
  79610. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  79611. /**
  79612. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  79613. * @param otherVector defines the second operand
  79614. * @param result defines the Vector3 object where to store the result
  79615. * @returns the current Vector3
  79616. */
  79617. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  79618. /**
  79619. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  79620. * @param x defines the x coordinate of the operand
  79621. * @param y defines the y coordinate of the operand
  79622. * @param z defines the z coordinate of the operand
  79623. * @returns the new Vector3
  79624. */
  79625. multiplyByFloats(x: number, y: number, z: number): Vector3;
  79626. /**
  79627. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  79628. * @param otherVector defines the second operand
  79629. * @returns the new Vector3
  79630. */
  79631. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  79632. /**
  79633. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  79634. * @param otherVector defines the second operand
  79635. * @param result defines the Vector3 object where to store the result
  79636. * @returns the current Vector3
  79637. */
  79638. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  79639. /**
  79640. * Divides the current Vector3 coordinates by the given ones.
  79641. * @param otherVector defines the second operand
  79642. * @returns the current updated Vector3
  79643. */
  79644. divideInPlace(otherVector: Vector3): Vector3;
  79645. /**
  79646. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  79647. * @param other defines the second operand
  79648. * @returns the current updated Vector3
  79649. */
  79650. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  79651. /**
  79652. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  79653. * @param other defines the second operand
  79654. * @returns the current updated Vector3
  79655. */
  79656. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  79657. /**
  79658. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  79659. * @param x defines the x coordinate of the operand
  79660. * @param y defines the y coordinate of the operand
  79661. * @param z defines the z coordinate of the operand
  79662. * @returns the current updated Vector3
  79663. */
  79664. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  79665. /**
  79666. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  79667. * @param x defines the x coordinate of the operand
  79668. * @param y defines the y coordinate of the operand
  79669. * @param z defines the z coordinate of the operand
  79670. * @returns the current updated Vector3
  79671. */
  79672. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  79673. /**
  79674. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  79675. * Check if is non uniform within a certain amount of decimal places to account for this
  79676. * @param epsilon the amount the values can differ
  79677. * @returns if the the vector is non uniform to a certain number of decimal places
  79678. */
  79679. isNonUniformWithinEpsilon(epsilon: number): boolean;
  79680. /**
  79681. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  79682. */
  79683. get isNonUniform(): boolean;
  79684. /**
  79685. * Gets a new Vector3 from current Vector3 floored values
  79686. * @returns a new Vector3
  79687. */
  79688. floor(): Vector3;
  79689. /**
  79690. * Gets a new Vector3 from current Vector3 floored values
  79691. * @returns a new Vector3
  79692. */
  79693. fract(): Vector3;
  79694. /**
  79695. * Gets the length of the Vector3
  79696. * @returns the length of the Vector3
  79697. */
  79698. length(): number;
  79699. /**
  79700. * Gets the squared length of the Vector3
  79701. * @returns squared length of the Vector3
  79702. */
  79703. lengthSquared(): number;
  79704. /**
  79705. * Normalize the current Vector3.
  79706. * Please note that this is an in place operation.
  79707. * @returns the current updated Vector3
  79708. */
  79709. normalize(): Vector3;
  79710. /**
  79711. * Reorders the x y z properties of the vector in place
  79712. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  79713. * @returns the current updated vector
  79714. */
  79715. reorderInPlace(order: string): this;
  79716. /**
  79717. * Rotates the vector around 0,0,0 by a quaternion
  79718. * @param quaternion the rotation quaternion
  79719. * @param result vector to store the result
  79720. * @returns the resulting vector
  79721. */
  79722. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  79723. /**
  79724. * Rotates a vector around a given point
  79725. * @param quaternion the rotation quaternion
  79726. * @param point the point to rotate around
  79727. * @param result vector to store the result
  79728. * @returns the resulting vector
  79729. */
  79730. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  79731. /**
  79732. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  79733. * The cross product is then orthogonal to both current and "other"
  79734. * @param other defines the right operand
  79735. * @returns the cross product
  79736. */
  79737. cross(other: Vector3): Vector3;
  79738. /**
  79739. * Normalize the current Vector3 with the given input length.
  79740. * Please note that this is an in place operation.
  79741. * @param len the length of the vector
  79742. * @returns the current updated Vector3
  79743. */
  79744. normalizeFromLength(len: number): Vector3;
  79745. /**
  79746. * Normalize the current Vector3 to a new vector
  79747. * @returns the new Vector3
  79748. */
  79749. normalizeToNew(): Vector3;
  79750. /**
  79751. * Normalize the current Vector3 to the reference
  79752. * @param reference define the Vector3 to update
  79753. * @returns the updated Vector3
  79754. */
  79755. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  79756. /**
  79757. * Creates a new Vector3 copied from the current Vector3
  79758. * @returns the new Vector3
  79759. */
  79760. clone(): Vector3;
  79761. /**
  79762. * Copies the given vector coordinates to the current Vector3 ones
  79763. * @param source defines the source Vector3
  79764. * @returns the current updated Vector3
  79765. */
  79766. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  79767. /**
  79768. * Copies the given floats to the current Vector3 coordinates
  79769. * @param x defines the x coordinate of the operand
  79770. * @param y defines the y coordinate of the operand
  79771. * @param z defines the z coordinate of the operand
  79772. * @returns the current updated Vector3
  79773. */
  79774. copyFromFloats(x: number, y: number, z: number): Vector3;
  79775. /**
  79776. * Copies the given floats to the current Vector3 coordinates
  79777. * @param x defines the x coordinate of the operand
  79778. * @param y defines the y coordinate of the operand
  79779. * @param z defines the z coordinate of the operand
  79780. * @returns the current updated Vector3
  79781. */
  79782. set(x: number, y: number, z: number): Vector3;
  79783. /**
  79784. * Copies the given float to the current Vector3 coordinates
  79785. * @param v defines the x, y and z coordinates of the operand
  79786. * @returns the current updated Vector3
  79787. */
  79788. setAll(v: number): Vector3;
  79789. /**
  79790. * Get the clip factor between two vectors
  79791. * @param vector0 defines the first operand
  79792. * @param vector1 defines the second operand
  79793. * @param axis defines the axis to use
  79794. * @param size defines the size along the axis
  79795. * @returns the clip factor
  79796. */
  79797. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  79798. /**
  79799. * Get angle between two vectors
  79800. * @param vector0 angle between vector0 and vector1
  79801. * @param vector1 angle between vector0 and vector1
  79802. * @param normal direction of the normal
  79803. * @return the angle between vector0 and vector1
  79804. */
  79805. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  79806. /**
  79807. * Returns a new Vector3 set from the index "offset" of the given array
  79808. * @param array defines the source array
  79809. * @param offset defines the offset in the source array
  79810. * @returns the new Vector3
  79811. */
  79812. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  79813. /**
  79814. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  79815. * @param array defines the source array
  79816. * @param offset defines the offset in the source array
  79817. * @returns the new Vector3
  79818. * @deprecated Please use FromArray instead.
  79819. */
  79820. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  79821. /**
  79822. * Sets the given vector "result" with the element values from the index "offset" of the given array
  79823. * @param array defines the source array
  79824. * @param offset defines the offset in the source array
  79825. * @param result defines the Vector3 where to store the result
  79826. */
  79827. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  79828. /**
  79829. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  79830. * @param array defines the source array
  79831. * @param offset defines the offset in the source array
  79832. * @param result defines the Vector3 where to store the result
  79833. * @deprecated Please use FromArrayToRef instead.
  79834. */
  79835. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  79836. /**
  79837. * Sets the given vector "result" with the given floats.
  79838. * @param x defines the x coordinate of the source
  79839. * @param y defines the y coordinate of the source
  79840. * @param z defines the z coordinate of the source
  79841. * @param result defines the Vector3 where to store the result
  79842. */
  79843. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  79844. /**
  79845. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  79846. * @returns a new empty Vector3
  79847. */
  79848. static Zero(): Vector3;
  79849. /**
  79850. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  79851. * @returns a new unit Vector3
  79852. */
  79853. static One(): Vector3;
  79854. /**
  79855. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  79856. * @returns a new up Vector3
  79857. */
  79858. static Up(): Vector3;
  79859. /**
  79860. * Gets a up Vector3 that must not be updated
  79861. */
  79862. static get UpReadOnly(): DeepImmutable<Vector3>;
  79863. /**
  79864. * Gets a zero Vector3 that must not be updated
  79865. */
  79866. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  79867. /**
  79868. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  79869. * @returns a new down Vector3
  79870. */
  79871. static Down(): Vector3;
  79872. /**
  79873. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  79874. * @param rightHandedSystem is the scene right-handed (negative z)
  79875. * @returns a new forward Vector3
  79876. */
  79877. static Forward(rightHandedSystem?: boolean): Vector3;
  79878. /**
  79879. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  79880. * @param rightHandedSystem is the scene right-handed (negative-z)
  79881. * @returns a new forward Vector3
  79882. */
  79883. static Backward(rightHandedSystem?: boolean): Vector3;
  79884. /**
  79885. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  79886. * @returns a new right Vector3
  79887. */
  79888. static Right(): Vector3;
  79889. /**
  79890. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  79891. * @returns a new left Vector3
  79892. */
  79893. static Left(): Vector3;
  79894. /**
  79895. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  79896. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  79897. * @param vector defines the Vector3 to transform
  79898. * @param transformation defines the transformation matrix
  79899. * @returns the transformed Vector3
  79900. */
  79901. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  79902. /**
  79903. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  79904. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  79905. * @param vector defines the Vector3 to transform
  79906. * @param transformation defines the transformation matrix
  79907. * @param result defines the Vector3 where to store the result
  79908. */
  79909. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  79910. /**
  79911. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  79912. * This method computes tranformed coordinates only, not transformed direction vectors
  79913. * @param x define the x coordinate of the source vector
  79914. * @param y define the y coordinate of the source vector
  79915. * @param z define the z coordinate of the source vector
  79916. * @param transformation defines the transformation matrix
  79917. * @param result defines the Vector3 where to store the result
  79918. */
  79919. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  79920. /**
  79921. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  79922. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  79923. * @param vector defines the Vector3 to transform
  79924. * @param transformation defines the transformation matrix
  79925. * @returns the new Vector3
  79926. */
  79927. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  79928. /**
  79929. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  79930. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  79931. * @param vector defines the Vector3 to transform
  79932. * @param transformation defines the transformation matrix
  79933. * @param result defines the Vector3 where to store the result
  79934. */
  79935. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  79936. /**
  79937. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  79938. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  79939. * @param x define the x coordinate of the source vector
  79940. * @param y define the y coordinate of the source vector
  79941. * @param z define the z coordinate of the source vector
  79942. * @param transformation defines the transformation matrix
  79943. * @param result defines the Vector3 where to store the result
  79944. */
  79945. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  79946. /**
  79947. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  79948. * @param value1 defines the first control point
  79949. * @param value2 defines the second control point
  79950. * @param value3 defines the third control point
  79951. * @param value4 defines the fourth control point
  79952. * @param amount defines the amount on the spline to use
  79953. * @returns the new Vector3
  79954. */
  79955. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  79956. /**
  79957. * 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"
  79958. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  79959. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  79960. * @param value defines the current value
  79961. * @param min defines the lower range value
  79962. * @param max defines the upper range value
  79963. * @returns the new Vector3
  79964. */
  79965. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  79966. /**
  79967. * 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"
  79968. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  79969. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  79970. * @param value defines the current value
  79971. * @param min defines the lower range value
  79972. * @param max defines the upper range value
  79973. * @param result defines the Vector3 where to store the result
  79974. */
  79975. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  79976. /**
  79977. * Checks if a given vector is inside a specific range
  79978. * @param v defines the vector to test
  79979. * @param min defines the minimum range
  79980. * @param max defines the maximum range
  79981. */
  79982. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  79983. /**
  79984. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  79985. * @param value1 defines the first control point
  79986. * @param tangent1 defines the first tangent vector
  79987. * @param value2 defines the second control point
  79988. * @param tangent2 defines the second tangent vector
  79989. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  79990. * @returns the new Vector3
  79991. */
  79992. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  79993. /**
  79994. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  79995. * @param start defines the start value
  79996. * @param end defines the end value
  79997. * @param amount max defines amount between both (between 0 and 1)
  79998. * @returns the new Vector3
  79999. */
  80000. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  80001. /**
  80002. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  80003. * @param start defines the start value
  80004. * @param end defines the end value
  80005. * @param amount max defines amount between both (between 0 and 1)
  80006. * @param result defines the Vector3 where to store the result
  80007. */
  80008. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  80009. /**
  80010. * Returns the dot product (float) between the vectors "left" and "right"
  80011. * @param left defines the left operand
  80012. * @param right defines the right operand
  80013. * @returns the dot product
  80014. */
  80015. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  80016. /**
  80017. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  80018. * The cross product is then orthogonal to both "left" and "right"
  80019. * @param left defines the left operand
  80020. * @param right defines the right operand
  80021. * @returns the cross product
  80022. */
  80023. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  80024. /**
  80025. * Sets the given vector "result" with the cross product of "left" and "right"
  80026. * The cross product is then orthogonal to both "left" and "right"
  80027. * @param left defines the left operand
  80028. * @param right defines the right operand
  80029. * @param result defines the Vector3 where to store the result
  80030. */
  80031. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  80032. /**
  80033. * Returns a new Vector3 as the normalization of the given vector
  80034. * @param vector defines the Vector3 to normalize
  80035. * @returns the new Vector3
  80036. */
  80037. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  80038. /**
  80039. * Sets the given vector "result" with the normalization of the given first vector
  80040. * @param vector defines the Vector3 to normalize
  80041. * @param result defines the Vector3 where to store the result
  80042. */
  80043. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  80044. /**
  80045. * Project a Vector3 onto screen space
  80046. * @param vector defines the Vector3 to project
  80047. * @param world defines the world matrix to use
  80048. * @param transform defines the transform (view x projection) matrix to use
  80049. * @param viewport defines the screen viewport to use
  80050. * @returns the new Vector3
  80051. */
  80052. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  80053. /** @hidden */
  80054. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  80055. /**
  80056. * Unproject from screen space to object space
  80057. * @param source defines the screen space Vector3 to use
  80058. * @param viewportWidth defines the current width of the viewport
  80059. * @param viewportHeight defines the current height of the viewport
  80060. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  80061. * @param transform defines the transform (view x projection) matrix to use
  80062. * @returns the new Vector3
  80063. */
  80064. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  80065. /**
  80066. * Unproject from screen space to object space
  80067. * @param source defines the screen space Vector3 to use
  80068. * @param viewportWidth defines the current width of the viewport
  80069. * @param viewportHeight defines the current height of the viewport
  80070. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  80071. * @param view defines the view matrix to use
  80072. * @param projection defines the projection matrix to use
  80073. * @returns the new Vector3
  80074. */
  80075. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  80076. /**
  80077. * Unproject from screen space to object space
  80078. * @param source defines the screen space Vector3 to use
  80079. * @param viewportWidth defines the current width of the viewport
  80080. * @param viewportHeight defines the current height of the viewport
  80081. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  80082. * @param view defines the view matrix to use
  80083. * @param projection defines the projection matrix to use
  80084. * @param result defines the Vector3 where to store the result
  80085. */
  80086. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  80087. /**
  80088. * Unproject from screen space to object space
  80089. * @param sourceX defines the screen space x coordinate to use
  80090. * @param sourceY defines the screen space y coordinate to use
  80091. * @param sourceZ defines the screen space z coordinate to use
  80092. * @param viewportWidth defines the current width of the viewport
  80093. * @param viewportHeight defines the current height of the viewport
  80094. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  80095. * @param view defines the view matrix to use
  80096. * @param projection defines the projection matrix to use
  80097. * @param result defines the Vector3 where to store the result
  80098. */
  80099. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  80100. /**
  80101. * Gets the minimal coordinate values between two Vector3
  80102. * @param left defines the first operand
  80103. * @param right defines the second operand
  80104. * @returns the new Vector3
  80105. */
  80106. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  80107. /**
  80108. * Gets the maximal coordinate values between two Vector3
  80109. * @param left defines the first operand
  80110. * @param right defines the second operand
  80111. * @returns the new Vector3
  80112. */
  80113. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  80114. /**
  80115. * Returns the distance between the vectors "value1" and "value2"
  80116. * @param value1 defines the first operand
  80117. * @param value2 defines the second operand
  80118. * @returns the distance
  80119. */
  80120. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  80121. /**
  80122. * Returns the squared distance between the vectors "value1" and "value2"
  80123. * @param value1 defines the first operand
  80124. * @param value2 defines the second operand
  80125. * @returns the squared distance
  80126. */
  80127. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  80128. /**
  80129. * Returns a new Vector3 located at the center between "value1" and "value2"
  80130. * @param value1 defines the first operand
  80131. * @param value2 defines the second operand
  80132. * @returns the new Vector3
  80133. */
  80134. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  80135. /**
  80136. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  80137. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  80138. * to something in order to rotate it from its local system to the given target system
  80139. * Note: axis1, axis2 and axis3 are normalized during this operation
  80140. * @param axis1 defines the first axis
  80141. * @param axis2 defines the second axis
  80142. * @param axis3 defines the third axis
  80143. * @returns a new Vector3
  80144. */
  80145. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  80146. /**
  80147. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  80148. * @param axis1 defines the first axis
  80149. * @param axis2 defines the second axis
  80150. * @param axis3 defines the third axis
  80151. * @param ref defines the Vector3 where to store the result
  80152. */
  80153. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  80154. }
  80155. /**
  80156. * Vector4 class created for EulerAngle class conversion to Quaternion
  80157. */
  80158. export class Vector4 {
  80159. /** x value of the vector */
  80160. x: number;
  80161. /** y value of the vector */
  80162. y: number;
  80163. /** z value of the vector */
  80164. z: number;
  80165. /** w value of the vector */
  80166. w: number;
  80167. /**
  80168. * Creates a Vector4 object from the given floats.
  80169. * @param x x value of the vector
  80170. * @param y y value of the vector
  80171. * @param z z value of the vector
  80172. * @param w w value of the vector
  80173. */
  80174. constructor(
  80175. /** x value of the vector */
  80176. x: number,
  80177. /** y value of the vector */
  80178. y: number,
  80179. /** z value of the vector */
  80180. z: number,
  80181. /** w value of the vector */
  80182. w: number);
  80183. /**
  80184. * Returns the string with the Vector4 coordinates.
  80185. * @returns a string containing all the vector values
  80186. */
  80187. toString(): string;
  80188. /**
  80189. * Returns the string "Vector4".
  80190. * @returns "Vector4"
  80191. */
  80192. getClassName(): string;
  80193. /**
  80194. * Returns the Vector4 hash code.
  80195. * @returns a unique hash code
  80196. */
  80197. getHashCode(): number;
  80198. /**
  80199. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  80200. * @returns the resulting array
  80201. */
  80202. asArray(): number[];
  80203. /**
  80204. * Populates the given array from the given index with the Vector4 coordinates.
  80205. * @param array array to populate
  80206. * @param index index of the array to start at (default: 0)
  80207. * @returns the Vector4.
  80208. */
  80209. toArray(array: FloatArray, index?: number): Vector4;
  80210. /**
  80211. * Adds the given vector to the current Vector4.
  80212. * @param otherVector the vector to add
  80213. * @returns the updated Vector4.
  80214. */
  80215. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  80216. /**
  80217. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  80218. * @param otherVector the vector to add
  80219. * @returns the resulting vector
  80220. */
  80221. add(otherVector: DeepImmutable<Vector4>): Vector4;
  80222. /**
  80223. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  80224. * @param otherVector the vector to add
  80225. * @param result the vector to store the result
  80226. * @returns the current Vector4.
  80227. */
  80228. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  80229. /**
  80230. * Subtract in place the given vector from the current Vector4.
  80231. * @param otherVector the vector to subtract
  80232. * @returns the updated Vector4.
  80233. */
  80234. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  80235. /**
  80236. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  80237. * @param otherVector the vector to add
  80238. * @returns the new vector with the result
  80239. */
  80240. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  80241. /**
  80242. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  80243. * @param otherVector the vector to subtract
  80244. * @param result the vector to store the result
  80245. * @returns the current Vector4.
  80246. */
  80247. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  80248. /**
  80249. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  80250. */
  80251. /**
  80252. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  80253. * @param x value to subtract
  80254. * @param y value to subtract
  80255. * @param z value to subtract
  80256. * @param w value to subtract
  80257. * @returns new vector containing the result
  80258. */
  80259. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  80260. /**
  80261. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  80262. * @param x value to subtract
  80263. * @param y value to subtract
  80264. * @param z value to subtract
  80265. * @param w value to subtract
  80266. * @param result the vector to store the result in
  80267. * @returns the current Vector4.
  80268. */
  80269. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  80270. /**
  80271. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  80272. * @returns a new vector with the negated values
  80273. */
  80274. negate(): Vector4;
  80275. /**
  80276. * Negate this vector in place
  80277. * @returns this
  80278. */
  80279. negateInPlace(): Vector4;
  80280. /**
  80281. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  80282. * @param result defines the Vector3 object where to store the result
  80283. * @returns the current Vector4
  80284. */
  80285. negateToRef(result: Vector4): Vector4;
  80286. /**
  80287. * Multiplies the current Vector4 coordinates by scale (float).
  80288. * @param scale the number to scale with
  80289. * @returns the updated Vector4.
  80290. */
  80291. scaleInPlace(scale: number): Vector4;
  80292. /**
  80293. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  80294. * @param scale the number to scale with
  80295. * @returns a new vector with the result
  80296. */
  80297. scale(scale: number): Vector4;
  80298. /**
  80299. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  80300. * @param scale the number to scale with
  80301. * @param result a vector to store the result in
  80302. * @returns the current Vector4.
  80303. */
  80304. scaleToRef(scale: number, result: Vector4): Vector4;
  80305. /**
  80306. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  80307. * @param scale defines the scale factor
  80308. * @param result defines the Vector4 object where to store the result
  80309. * @returns the unmodified current Vector4
  80310. */
  80311. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  80312. /**
  80313. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  80314. * @param otherVector the vector to compare against
  80315. * @returns true if they are equal
  80316. */
  80317. equals(otherVector: DeepImmutable<Vector4>): boolean;
  80318. /**
  80319. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  80320. * @param otherVector vector to compare against
  80321. * @param epsilon (Default: very small number)
  80322. * @returns true if they are equal
  80323. */
  80324. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  80325. /**
  80326. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  80327. * @param x x value to compare against
  80328. * @param y y value to compare against
  80329. * @param z z value to compare against
  80330. * @param w w value to compare against
  80331. * @returns true if equal
  80332. */
  80333. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  80334. /**
  80335. * Multiplies in place the current Vector4 by the given one.
  80336. * @param otherVector vector to multiple with
  80337. * @returns the updated Vector4.
  80338. */
  80339. multiplyInPlace(otherVector: Vector4): Vector4;
  80340. /**
  80341. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  80342. * @param otherVector vector to multiple with
  80343. * @returns resulting new vector
  80344. */
  80345. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  80346. /**
  80347. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  80348. * @param otherVector vector to multiple with
  80349. * @param result vector to store the result
  80350. * @returns the current Vector4.
  80351. */
  80352. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  80353. /**
  80354. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  80355. * @param x x value multiply with
  80356. * @param y y value multiply with
  80357. * @param z z value multiply with
  80358. * @param w w value multiply with
  80359. * @returns resulting new vector
  80360. */
  80361. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  80362. /**
  80363. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  80364. * @param otherVector vector to devide with
  80365. * @returns resulting new vector
  80366. */
  80367. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  80368. /**
  80369. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  80370. * @param otherVector vector to devide with
  80371. * @param result vector to store the result
  80372. * @returns the current Vector4.
  80373. */
  80374. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  80375. /**
  80376. * Divides the current Vector3 coordinates by the given ones.
  80377. * @param otherVector vector to devide with
  80378. * @returns the updated Vector3.
  80379. */
  80380. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  80381. /**
  80382. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  80383. * @param other defines the second operand
  80384. * @returns the current updated Vector4
  80385. */
  80386. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  80387. /**
  80388. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  80389. * @param other defines the second operand
  80390. * @returns the current updated Vector4
  80391. */
  80392. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  80393. /**
  80394. * Gets a new Vector4 from current Vector4 floored values
  80395. * @returns a new Vector4
  80396. */
  80397. floor(): Vector4;
  80398. /**
  80399. * Gets a new Vector4 from current Vector3 floored values
  80400. * @returns a new Vector4
  80401. */
  80402. fract(): Vector4;
  80403. /**
  80404. * Returns the Vector4 length (float).
  80405. * @returns the length
  80406. */
  80407. length(): number;
  80408. /**
  80409. * Returns the Vector4 squared length (float).
  80410. * @returns the length squared
  80411. */
  80412. lengthSquared(): number;
  80413. /**
  80414. * Normalizes in place the Vector4.
  80415. * @returns the updated Vector4.
  80416. */
  80417. normalize(): Vector4;
  80418. /**
  80419. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  80420. * @returns this converted to a new vector3
  80421. */
  80422. toVector3(): Vector3;
  80423. /**
  80424. * Returns a new Vector4 copied from the current one.
  80425. * @returns the new cloned vector
  80426. */
  80427. clone(): Vector4;
  80428. /**
  80429. * Updates the current Vector4 with the given one coordinates.
  80430. * @param source the source vector to copy from
  80431. * @returns the updated Vector4.
  80432. */
  80433. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  80434. /**
  80435. * Updates the current Vector4 coordinates with the given floats.
  80436. * @param x float to copy from
  80437. * @param y float to copy from
  80438. * @param z float to copy from
  80439. * @param w float to copy from
  80440. * @returns the updated Vector4.
  80441. */
  80442. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  80443. /**
  80444. * Updates the current Vector4 coordinates with the given floats.
  80445. * @param x float to set from
  80446. * @param y float to set from
  80447. * @param z float to set from
  80448. * @param w float to set from
  80449. * @returns the updated Vector4.
  80450. */
  80451. set(x: number, y: number, z: number, w: number): Vector4;
  80452. /**
  80453. * Copies the given float to the current Vector3 coordinates
  80454. * @param v defines the x, y, z and w coordinates of the operand
  80455. * @returns the current updated Vector3
  80456. */
  80457. setAll(v: number): Vector4;
  80458. /**
  80459. * Returns a new Vector4 set from the starting index of the given array.
  80460. * @param array the array to pull values from
  80461. * @param offset the offset into the array to start at
  80462. * @returns the new vector
  80463. */
  80464. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  80465. /**
  80466. * Updates the given vector "result" from the starting index of the given array.
  80467. * @param array the array to pull values from
  80468. * @param offset the offset into the array to start at
  80469. * @param result the vector to store the result in
  80470. */
  80471. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  80472. /**
  80473. * Updates the given vector "result" from the starting index of the given Float32Array.
  80474. * @param array the array to pull values from
  80475. * @param offset the offset into the array to start at
  80476. * @param result the vector to store the result in
  80477. */
  80478. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  80479. /**
  80480. * Updates the given vector "result" coordinates from the given floats.
  80481. * @param x float to set from
  80482. * @param y float to set from
  80483. * @param z float to set from
  80484. * @param w float to set from
  80485. * @param result the vector to the floats in
  80486. */
  80487. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  80488. /**
  80489. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  80490. * @returns the new vector
  80491. */
  80492. static Zero(): Vector4;
  80493. /**
  80494. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  80495. * @returns the new vector
  80496. */
  80497. static One(): Vector4;
  80498. /**
  80499. * Returns a new normalized Vector4 from the given one.
  80500. * @param vector the vector to normalize
  80501. * @returns the vector
  80502. */
  80503. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  80504. /**
  80505. * Updates the given vector "result" from the normalization of the given one.
  80506. * @param vector the vector to normalize
  80507. * @param result the vector to store the result in
  80508. */
  80509. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  80510. /**
  80511. * Returns a vector with the minimum values from the left and right vectors
  80512. * @param left left vector to minimize
  80513. * @param right right vector to minimize
  80514. * @returns a new vector with the minimum of the left and right vector values
  80515. */
  80516. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  80517. /**
  80518. * Returns a vector with the maximum values from the left and right vectors
  80519. * @param left left vector to maximize
  80520. * @param right right vector to maximize
  80521. * @returns a new vector with the maximum of the left and right vector values
  80522. */
  80523. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  80524. /**
  80525. * Returns the distance (float) between the vectors "value1" and "value2".
  80526. * @param value1 value to calulate the distance between
  80527. * @param value2 value to calulate the distance between
  80528. * @return the distance between the two vectors
  80529. */
  80530. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  80531. /**
  80532. * Returns the squared distance (float) between the vectors "value1" and "value2".
  80533. * @param value1 value to calulate the distance between
  80534. * @param value2 value to calulate the distance between
  80535. * @return the distance between the two vectors squared
  80536. */
  80537. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  80538. /**
  80539. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  80540. * @param value1 value to calulate the center between
  80541. * @param value2 value to calulate the center between
  80542. * @return the center between the two vectors
  80543. */
  80544. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  80545. /**
  80546. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  80547. * This methods computes transformed normalized direction vectors only.
  80548. * @param vector the vector to transform
  80549. * @param transformation the transformation matrix to apply
  80550. * @returns the new vector
  80551. */
  80552. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  80553. /**
  80554. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  80555. * This methods computes transformed normalized direction vectors only.
  80556. * @param vector the vector to transform
  80557. * @param transformation the transformation matrix to apply
  80558. * @param result the vector to store the result in
  80559. */
  80560. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  80561. /**
  80562. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  80563. * This methods computes transformed normalized direction vectors only.
  80564. * @param x value to transform
  80565. * @param y value to transform
  80566. * @param z value to transform
  80567. * @param w value to transform
  80568. * @param transformation the transformation matrix to apply
  80569. * @param result the vector to store the results in
  80570. */
  80571. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  80572. /**
  80573. * Creates a new Vector4 from a Vector3
  80574. * @param source defines the source data
  80575. * @param w defines the 4th component (default is 0)
  80576. * @returns a new Vector4
  80577. */
  80578. static FromVector3(source: Vector3, w?: number): Vector4;
  80579. }
  80580. /**
  80581. * Class used to store quaternion data
  80582. * @see https://en.wikipedia.org/wiki/Quaternion
  80583. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  80584. */
  80585. export class Quaternion {
  80586. /** defines the first component (0 by default) */
  80587. x: number;
  80588. /** defines the second component (0 by default) */
  80589. y: number;
  80590. /** defines the third component (0 by default) */
  80591. z: number;
  80592. /** defines the fourth component (1.0 by default) */
  80593. w: number;
  80594. /**
  80595. * Creates a new Quaternion from the given floats
  80596. * @param x defines the first component (0 by default)
  80597. * @param y defines the second component (0 by default)
  80598. * @param z defines the third component (0 by default)
  80599. * @param w defines the fourth component (1.0 by default)
  80600. */
  80601. constructor(
  80602. /** defines the first component (0 by default) */
  80603. x?: number,
  80604. /** defines the second component (0 by default) */
  80605. y?: number,
  80606. /** defines the third component (0 by default) */
  80607. z?: number,
  80608. /** defines the fourth component (1.0 by default) */
  80609. w?: number);
  80610. /**
  80611. * Gets a string representation for the current quaternion
  80612. * @returns a string with the Quaternion coordinates
  80613. */
  80614. toString(): string;
  80615. /**
  80616. * Gets the class name of the quaternion
  80617. * @returns the string "Quaternion"
  80618. */
  80619. getClassName(): string;
  80620. /**
  80621. * Gets a hash code for this quaternion
  80622. * @returns the quaternion hash code
  80623. */
  80624. getHashCode(): number;
  80625. /**
  80626. * Copy the quaternion to an array
  80627. * @returns a new array populated with 4 elements from the quaternion coordinates
  80628. */
  80629. asArray(): number[];
  80630. /**
  80631. * Check if two quaternions are equals
  80632. * @param otherQuaternion defines the second operand
  80633. * @return true if the current quaternion and the given one coordinates are strictly equals
  80634. */
  80635. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  80636. /**
  80637. * Gets a boolean if two quaternions are equals (using an epsilon value)
  80638. * @param otherQuaternion defines the other quaternion
  80639. * @param epsilon defines the minimal distance to consider equality
  80640. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  80641. */
  80642. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  80643. /**
  80644. * Clone the current quaternion
  80645. * @returns a new quaternion copied from the current one
  80646. */
  80647. clone(): Quaternion;
  80648. /**
  80649. * Copy a quaternion to the current one
  80650. * @param other defines the other quaternion
  80651. * @returns the updated current quaternion
  80652. */
  80653. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  80654. /**
  80655. * Updates the current quaternion with the given float coordinates
  80656. * @param x defines the x coordinate
  80657. * @param y defines the y coordinate
  80658. * @param z defines the z coordinate
  80659. * @param w defines the w coordinate
  80660. * @returns the updated current quaternion
  80661. */
  80662. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  80663. /**
  80664. * Updates the current quaternion from the given float coordinates
  80665. * @param x defines the x coordinate
  80666. * @param y defines the y coordinate
  80667. * @param z defines the z coordinate
  80668. * @param w defines the w coordinate
  80669. * @returns the updated current quaternion
  80670. */
  80671. set(x: number, y: number, z: number, w: number): Quaternion;
  80672. /**
  80673. * Adds two quaternions
  80674. * @param other defines the second operand
  80675. * @returns a new quaternion as the addition result of the given one and the current quaternion
  80676. */
  80677. add(other: DeepImmutable<Quaternion>): Quaternion;
  80678. /**
  80679. * Add a quaternion to the current one
  80680. * @param other defines the quaternion to add
  80681. * @returns the current quaternion
  80682. */
  80683. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  80684. /**
  80685. * Subtract two quaternions
  80686. * @param other defines the second operand
  80687. * @returns a new quaternion as the subtraction result of the given one from the current one
  80688. */
  80689. subtract(other: Quaternion): Quaternion;
  80690. /**
  80691. * Multiplies the current quaternion by a scale factor
  80692. * @param value defines the scale factor
  80693. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  80694. */
  80695. scale(value: number): Quaternion;
  80696. /**
  80697. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  80698. * @param scale defines the scale factor
  80699. * @param result defines the Quaternion object where to store the result
  80700. * @returns the unmodified current quaternion
  80701. */
  80702. scaleToRef(scale: number, result: Quaternion): Quaternion;
  80703. /**
  80704. * Multiplies in place the current quaternion by a scale factor
  80705. * @param value defines the scale factor
  80706. * @returns the current modified quaternion
  80707. */
  80708. scaleInPlace(value: number): Quaternion;
  80709. /**
  80710. * Scale the current quaternion values by a factor and add the result to a given quaternion
  80711. * @param scale defines the scale factor
  80712. * @param result defines the Quaternion object where to store the result
  80713. * @returns the unmodified current quaternion
  80714. */
  80715. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  80716. /**
  80717. * Multiplies two quaternions
  80718. * @param q1 defines the second operand
  80719. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  80720. */
  80721. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  80722. /**
  80723. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  80724. * @param q1 defines the second operand
  80725. * @param result defines the target quaternion
  80726. * @returns the current quaternion
  80727. */
  80728. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  80729. /**
  80730. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  80731. * @param q1 defines the second operand
  80732. * @returns the currentupdated quaternion
  80733. */
  80734. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  80735. /**
  80736. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  80737. * @param ref defines the target quaternion
  80738. * @returns the current quaternion
  80739. */
  80740. conjugateToRef(ref: Quaternion): Quaternion;
  80741. /**
  80742. * Conjugates in place (1-q) the current quaternion
  80743. * @returns the current updated quaternion
  80744. */
  80745. conjugateInPlace(): Quaternion;
  80746. /**
  80747. * Conjugates in place (1-q) the current quaternion
  80748. * @returns a new quaternion
  80749. */
  80750. conjugate(): Quaternion;
  80751. /**
  80752. * Gets length of current quaternion
  80753. * @returns the quaternion length (float)
  80754. */
  80755. length(): number;
  80756. /**
  80757. * Normalize in place the current quaternion
  80758. * @returns the current updated quaternion
  80759. */
  80760. normalize(): Quaternion;
  80761. /**
  80762. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  80763. * @param order is a reserved parameter and is ignore for now
  80764. * @returns a new Vector3 containing the Euler angles
  80765. */
  80766. toEulerAngles(order?: string): Vector3;
  80767. /**
  80768. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  80769. * @param result defines the vector which will be filled with the Euler angles
  80770. * @param order is a reserved parameter and is ignore for now
  80771. * @returns the current unchanged quaternion
  80772. */
  80773. toEulerAnglesToRef(result: Vector3): Quaternion;
  80774. /**
  80775. * Updates the given rotation matrix with the current quaternion values
  80776. * @param result defines the target matrix
  80777. * @returns the current unchanged quaternion
  80778. */
  80779. toRotationMatrix(result: Matrix): Quaternion;
  80780. /**
  80781. * Updates the current quaternion from the given rotation matrix values
  80782. * @param matrix defines the source matrix
  80783. * @returns the current updated quaternion
  80784. */
  80785. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  80786. /**
  80787. * Creates a new quaternion from a rotation matrix
  80788. * @param matrix defines the source matrix
  80789. * @returns a new quaternion created from the given rotation matrix values
  80790. */
  80791. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  80792. /**
  80793. * Updates the given quaternion with the given rotation matrix values
  80794. * @param matrix defines the source matrix
  80795. * @param result defines the target quaternion
  80796. */
  80797. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  80798. /**
  80799. * Returns the dot product (float) between the quaternions "left" and "right"
  80800. * @param left defines the left operand
  80801. * @param right defines the right operand
  80802. * @returns the dot product
  80803. */
  80804. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  80805. /**
  80806. * Checks if the two quaternions are close to each other
  80807. * @param quat0 defines the first quaternion to check
  80808. * @param quat1 defines the second quaternion to check
  80809. * @returns true if the two quaternions are close to each other
  80810. */
  80811. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  80812. /**
  80813. * Creates an empty quaternion
  80814. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  80815. */
  80816. static Zero(): Quaternion;
  80817. /**
  80818. * Inverse a given quaternion
  80819. * @param q defines the source quaternion
  80820. * @returns a new quaternion as the inverted current quaternion
  80821. */
  80822. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  80823. /**
  80824. * Inverse a given quaternion
  80825. * @param q defines the source quaternion
  80826. * @param result the quaternion the result will be stored in
  80827. * @returns the result quaternion
  80828. */
  80829. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  80830. /**
  80831. * Creates an identity quaternion
  80832. * @returns the identity quaternion
  80833. */
  80834. static Identity(): Quaternion;
  80835. /**
  80836. * Gets a boolean indicating if the given quaternion is identity
  80837. * @param quaternion defines the quaternion to check
  80838. * @returns true if the quaternion is identity
  80839. */
  80840. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  80841. /**
  80842. * Creates a quaternion from a rotation around an axis
  80843. * @param axis defines the axis to use
  80844. * @param angle defines the angle to use
  80845. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  80846. */
  80847. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  80848. /**
  80849. * Creates a rotation around an axis and stores it into the given quaternion
  80850. * @param axis defines the axis to use
  80851. * @param angle defines the angle to use
  80852. * @param result defines the target quaternion
  80853. * @returns the target quaternion
  80854. */
  80855. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  80856. /**
  80857. * Creates a new quaternion from data stored into an array
  80858. * @param array defines the data source
  80859. * @param offset defines the offset in the source array where the data starts
  80860. * @returns a new quaternion
  80861. */
  80862. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  80863. /**
  80864. * Updates the given quaternion "result" from the starting index of the given array.
  80865. * @param array the array to pull values from
  80866. * @param offset the offset into the array to start at
  80867. * @param result the quaternion to store the result in
  80868. */
  80869. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  80870. /**
  80871. * Create a quaternion from Euler rotation angles
  80872. * @param x Pitch
  80873. * @param y Yaw
  80874. * @param z Roll
  80875. * @returns the new Quaternion
  80876. */
  80877. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  80878. /**
  80879. * Updates a quaternion from Euler rotation angles
  80880. * @param x Pitch
  80881. * @param y Yaw
  80882. * @param z Roll
  80883. * @param result the quaternion to store the result
  80884. * @returns the updated quaternion
  80885. */
  80886. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  80887. /**
  80888. * Create a quaternion from Euler rotation vector
  80889. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  80890. * @returns the new Quaternion
  80891. */
  80892. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  80893. /**
  80894. * Updates a quaternion from Euler rotation vector
  80895. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  80896. * @param result the quaternion to store the result
  80897. * @returns the updated quaternion
  80898. */
  80899. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  80900. /**
  80901. * Creates a new quaternion from the given Euler float angles (y, x, z)
  80902. * @param yaw defines the rotation around Y axis
  80903. * @param pitch defines the rotation around X axis
  80904. * @param roll defines the rotation around Z axis
  80905. * @returns the new quaternion
  80906. */
  80907. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  80908. /**
  80909. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  80910. * @param yaw defines the rotation around Y axis
  80911. * @param pitch defines the rotation around X axis
  80912. * @param roll defines the rotation around Z axis
  80913. * @param result defines the target quaternion
  80914. */
  80915. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  80916. /**
  80917. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  80918. * @param alpha defines the rotation around first axis
  80919. * @param beta defines the rotation around second axis
  80920. * @param gamma defines the rotation around third axis
  80921. * @returns the new quaternion
  80922. */
  80923. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  80924. /**
  80925. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  80926. * @param alpha defines the rotation around first axis
  80927. * @param beta defines the rotation around second axis
  80928. * @param gamma defines the rotation around third axis
  80929. * @param result defines the target quaternion
  80930. */
  80931. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  80932. /**
  80933. * 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)
  80934. * @param axis1 defines the first axis
  80935. * @param axis2 defines the second axis
  80936. * @param axis3 defines the third axis
  80937. * @returns the new quaternion
  80938. */
  80939. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  80940. /**
  80941. * 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
  80942. * @param axis1 defines the first axis
  80943. * @param axis2 defines the second axis
  80944. * @param axis3 defines the third axis
  80945. * @param ref defines the target quaternion
  80946. */
  80947. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  80948. /**
  80949. * Interpolates between two quaternions
  80950. * @param left defines first quaternion
  80951. * @param right defines second quaternion
  80952. * @param amount defines the gradient to use
  80953. * @returns the new interpolated quaternion
  80954. */
  80955. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  80956. /**
  80957. * Interpolates between two quaternions and stores it into a target quaternion
  80958. * @param left defines first quaternion
  80959. * @param right defines second quaternion
  80960. * @param amount defines the gradient to use
  80961. * @param result defines the target quaternion
  80962. */
  80963. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  80964. /**
  80965. * Interpolate between two quaternions using Hermite interpolation
  80966. * @param value1 defines first quaternion
  80967. * @param tangent1 defines the incoming tangent
  80968. * @param value2 defines second quaternion
  80969. * @param tangent2 defines the outgoing tangent
  80970. * @param amount defines the target quaternion
  80971. * @returns the new interpolated quaternion
  80972. */
  80973. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  80974. }
  80975. /**
  80976. * Class used to store matrix data (4x4)
  80977. */
  80978. export class Matrix {
  80979. private static _updateFlagSeed;
  80980. private static _identityReadOnly;
  80981. private _isIdentity;
  80982. private _isIdentityDirty;
  80983. private _isIdentity3x2;
  80984. private _isIdentity3x2Dirty;
  80985. /**
  80986. * Gets the update flag of the matrix which is an unique number for the matrix.
  80987. * It will be incremented every time the matrix data change.
  80988. * You can use it to speed the comparison between two versions of the same matrix.
  80989. */
  80990. updateFlag: number;
  80991. private readonly _m;
  80992. /**
  80993. * Gets the internal data of the matrix
  80994. */
  80995. get m(): DeepImmutable<Float32Array>;
  80996. /** @hidden */
  80997. _markAsUpdated(): void;
  80998. /** @hidden */
  80999. private _updateIdentityStatus;
  81000. /**
  81001. * Creates an empty matrix (filled with zeros)
  81002. */
  81003. constructor();
  81004. /**
  81005. * Check if the current matrix is identity
  81006. * @returns true is the matrix is the identity matrix
  81007. */
  81008. isIdentity(): boolean;
  81009. /**
  81010. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  81011. * @returns true is the matrix is the identity matrix
  81012. */
  81013. isIdentityAs3x2(): boolean;
  81014. /**
  81015. * Gets the determinant of the matrix
  81016. * @returns the matrix determinant
  81017. */
  81018. determinant(): number;
  81019. /**
  81020. * Returns the matrix as a Float32Array
  81021. * @returns the matrix underlying array
  81022. */
  81023. toArray(): DeepImmutable<Float32Array>;
  81024. /**
  81025. * Returns the matrix as a Float32Array
  81026. * @returns the matrix underlying array.
  81027. */
  81028. asArray(): DeepImmutable<Float32Array>;
  81029. /**
  81030. * Inverts the current matrix in place
  81031. * @returns the current inverted matrix
  81032. */
  81033. invert(): Matrix;
  81034. /**
  81035. * Sets all the matrix elements to zero
  81036. * @returns the current matrix
  81037. */
  81038. reset(): Matrix;
  81039. /**
  81040. * Adds the current matrix with a second one
  81041. * @param other defines the matrix to add
  81042. * @returns a new matrix as the addition of the current matrix and the given one
  81043. */
  81044. add(other: DeepImmutable<Matrix>): Matrix;
  81045. /**
  81046. * Sets the given matrix "result" to the addition of the current matrix and the given one
  81047. * @param other defines the matrix to add
  81048. * @param result defines the target matrix
  81049. * @returns the current matrix
  81050. */
  81051. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  81052. /**
  81053. * Adds in place the given matrix to the current matrix
  81054. * @param other defines the second operand
  81055. * @returns the current updated matrix
  81056. */
  81057. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  81058. /**
  81059. * Sets the given matrix to the current inverted Matrix
  81060. * @param other defines the target matrix
  81061. * @returns the unmodified current matrix
  81062. */
  81063. invertToRef(other: Matrix): Matrix;
  81064. /**
  81065. * add a value at the specified position in the current Matrix
  81066. * @param index the index of the value within the matrix. between 0 and 15.
  81067. * @param value the value to be added
  81068. * @returns the current updated matrix
  81069. */
  81070. addAtIndex(index: number, value: number): Matrix;
  81071. /**
  81072. * mutiply the specified position in the current Matrix by a value
  81073. * @param index the index of the value within the matrix. between 0 and 15.
  81074. * @param value the value to be added
  81075. * @returns the current updated matrix
  81076. */
  81077. multiplyAtIndex(index: number, value: number): Matrix;
  81078. /**
  81079. * Inserts the translation vector (using 3 floats) in the current matrix
  81080. * @param x defines the 1st component of the translation
  81081. * @param y defines the 2nd component of the translation
  81082. * @param z defines the 3rd component of the translation
  81083. * @returns the current updated matrix
  81084. */
  81085. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  81086. /**
  81087. * Adds the translation vector (using 3 floats) in the current matrix
  81088. * @param x defines the 1st component of the translation
  81089. * @param y defines the 2nd component of the translation
  81090. * @param z defines the 3rd component of the translation
  81091. * @returns the current updated matrix
  81092. */
  81093. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  81094. /**
  81095. * Inserts the translation vector in the current matrix
  81096. * @param vector3 defines the translation to insert
  81097. * @returns the current updated matrix
  81098. */
  81099. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  81100. /**
  81101. * Gets the translation value of the current matrix
  81102. * @returns a new Vector3 as the extracted translation from the matrix
  81103. */
  81104. getTranslation(): Vector3;
  81105. /**
  81106. * Fill a Vector3 with the extracted translation from the matrix
  81107. * @param result defines the Vector3 where to store the translation
  81108. * @returns the current matrix
  81109. */
  81110. getTranslationToRef(result: Vector3): Matrix;
  81111. /**
  81112. * Remove rotation and scaling part from the matrix
  81113. * @returns the updated matrix
  81114. */
  81115. removeRotationAndScaling(): Matrix;
  81116. /**
  81117. * Multiply two matrices
  81118. * @param other defines the second operand
  81119. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  81120. */
  81121. multiply(other: DeepImmutable<Matrix>): Matrix;
  81122. /**
  81123. * Copy the current matrix from the given one
  81124. * @param other defines the source matrix
  81125. * @returns the current updated matrix
  81126. */
  81127. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  81128. /**
  81129. * Populates the given array from the starting index with the current matrix values
  81130. * @param array defines the target array
  81131. * @param offset defines the offset in the target array where to start storing values
  81132. * @returns the current matrix
  81133. */
  81134. copyToArray(array: Float32Array, offset?: number): Matrix;
  81135. /**
  81136. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  81137. * @param other defines the second operand
  81138. * @param result defines the matrix where to store the multiplication
  81139. * @returns the current matrix
  81140. */
  81141. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  81142. /**
  81143. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  81144. * @param other defines the second operand
  81145. * @param result defines the array where to store the multiplication
  81146. * @param offset defines the offset in the target array where to start storing values
  81147. * @returns the current matrix
  81148. */
  81149. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  81150. /**
  81151. * Check equality between this matrix and a second one
  81152. * @param value defines the second matrix to compare
  81153. * @returns true is the current matrix and the given one values are strictly equal
  81154. */
  81155. equals(value: DeepImmutable<Matrix>): boolean;
  81156. /**
  81157. * Clone the current matrix
  81158. * @returns a new matrix from the current matrix
  81159. */
  81160. clone(): Matrix;
  81161. /**
  81162. * Returns the name of the current matrix class
  81163. * @returns the string "Matrix"
  81164. */
  81165. getClassName(): string;
  81166. /**
  81167. * Gets the hash code of the current matrix
  81168. * @returns the hash code
  81169. */
  81170. getHashCode(): number;
  81171. /**
  81172. * Decomposes the current Matrix into a translation, rotation and scaling components
  81173. * @param scale defines the scale vector3 given as a reference to update
  81174. * @param rotation defines the rotation quaternion given as a reference to update
  81175. * @param translation defines the translation vector3 given as a reference to update
  81176. * @returns true if operation was successful
  81177. */
  81178. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  81179. /**
  81180. * Gets specific row of the matrix
  81181. * @param index defines the number of the row to get
  81182. * @returns the index-th row of the current matrix as a new Vector4
  81183. */
  81184. getRow(index: number): Nullable<Vector4>;
  81185. /**
  81186. * Sets the index-th row of the current matrix to the vector4 values
  81187. * @param index defines the number of the row to set
  81188. * @param row defines the target vector4
  81189. * @returns the updated current matrix
  81190. */
  81191. setRow(index: number, row: Vector4): Matrix;
  81192. /**
  81193. * Compute the transpose of the matrix
  81194. * @returns the new transposed matrix
  81195. */
  81196. transpose(): Matrix;
  81197. /**
  81198. * Compute the transpose of the matrix and store it in a given matrix
  81199. * @param result defines the target matrix
  81200. * @returns the current matrix
  81201. */
  81202. transposeToRef(result: Matrix): Matrix;
  81203. /**
  81204. * Sets the index-th row of the current matrix with the given 4 x float values
  81205. * @param index defines the row index
  81206. * @param x defines the x component to set
  81207. * @param y defines the y component to set
  81208. * @param z defines the z component to set
  81209. * @param w defines the w component to set
  81210. * @returns the updated current matrix
  81211. */
  81212. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  81213. /**
  81214. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  81215. * @param scale defines the scale factor
  81216. * @returns a new matrix
  81217. */
  81218. scale(scale: number): Matrix;
  81219. /**
  81220. * Scale the current matrix values by a factor to a given result matrix
  81221. * @param scale defines the scale factor
  81222. * @param result defines the matrix to store the result
  81223. * @returns the current matrix
  81224. */
  81225. scaleToRef(scale: number, result: Matrix): Matrix;
  81226. /**
  81227. * Scale the current matrix values by a factor and add the result to a given matrix
  81228. * @param scale defines the scale factor
  81229. * @param result defines the Matrix to store the result
  81230. * @returns the current matrix
  81231. */
  81232. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  81233. /**
  81234. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  81235. * @param ref matrix to store the result
  81236. */
  81237. toNormalMatrix(ref: Matrix): void;
  81238. /**
  81239. * Gets only rotation part of the current matrix
  81240. * @returns a new matrix sets to the extracted rotation matrix from the current one
  81241. */
  81242. getRotationMatrix(): Matrix;
  81243. /**
  81244. * Extracts the rotation matrix from the current one and sets it as the given "result"
  81245. * @param result defines the target matrix to store data to
  81246. * @returns the current matrix
  81247. */
  81248. getRotationMatrixToRef(result: Matrix): Matrix;
  81249. /**
  81250. * Toggles model matrix from being right handed to left handed in place and vice versa
  81251. */
  81252. toggleModelMatrixHandInPlace(): void;
  81253. /**
  81254. * Toggles projection matrix from being right handed to left handed in place and vice versa
  81255. */
  81256. toggleProjectionMatrixHandInPlace(): void;
  81257. /**
  81258. * Creates a matrix from an array
  81259. * @param array defines the source array
  81260. * @param offset defines an offset in the source array
  81261. * @returns a new Matrix set from the starting index of the given array
  81262. */
  81263. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  81264. /**
  81265. * Copy the content of an array into a given matrix
  81266. * @param array defines the source array
  81267. * @param offset defines an offset in the source array
  81268. * @param result defines the target matrix
  81269. */
  81270. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  81271. /**
  81272. * Stores an array into a matrix after having multiplied each component by a given factor
  81273. * @param array defines the source array
  81274. * @param offset defines the offset in the source array
  81275. * @param scale defines the scaling factor
  81276. * @param result defines the target matrix
  81277. */
  81278. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  81279. /**
  81280. * Gets an identity matrix that must not be updated
  81281. */
  81282. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  81283. /**
  81284. * Stores a list of values (16) inside a given matrix
  81285. * @param initialM11 defines 1st value of 1st row
  81286. * @param initialM12 defines 2nd value of 1st row
  81287. * @param initialM13 defines 3rd value of 1st row
  81288. * @param initialM14 defines 4th value of 1st row
  81289. * @param initialM21 defines 1st value of 2nd row
  81290. * @param initialM22 defines 2nd value of 2nd row
  81291. * @param initialM23 defines 3rd value of 2nd row
  81292. * @param initialM24 defines 4th value of 2nd row
  81293. * @param initialM31 defines 1st value of 3rd row
  81294. * @param initialM32 defines 2nd value of 3rd row
  81295. * @param initialM33 defines 3rd value of 3rd row
  81296. * @param initialM34 defines 4th value of 3rd row
  81297. * @param initialM41 defines 1st value of 4th row
  81298. * @param initialM42 defines 2nd value of 4th row
  81299. * @param initialM43 defines 3rd value of 4th row
  81300. * @param initialM44 defines 4th value of 4th row
  81301. * @param result defines the target matrix
  81302. */
  81303. 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;
  81304. /**
  81305. * Creates new matrix from a list of values (16)
  81306. * @param initialM11 defines 1st value of 1st row
  81307. * @param initialM12 defines 2nd value of 1st row
  81308. * @param initialM13 defines 3rd value of 1st row
  81309. * @param initialM14 defines 4th value of 1st row
  81310. * @param initialM21 defines 1st value of 2nd row
  81311. * @param initialM22 defines 2nd value of 2nd row
  81312. * @param initialM23 defines 3rd value of 2nd row
  81313. * @param initialM24 defines 4th value of 2nd row
  81314. * @param initialM31 defines 1st value of 3rd row
  81315. * @param initialM32 defines 2nd value of 3rd row
  81316. * @param initialM33 defines 3rd value of 3rd row
  81317. * @param initialM34 defines 4th value of 3rd row
  81318. * @param initialM41 defines 1st value of 4th row
  81319. * @param initialM42 defines 2nd value of 4th row
  81320. * @param initialM43 defines 3rd value of 4th row
  81321. * @param initialM44 defines 4th value of 4th row
  81322. * @returns the new matrix
  81323. */
  81324. 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;
  81325. /**
  81326. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  81327. * @param scale defines the scale vector3
  81328. * @param rotation defines the rotation quaternion
  81329. * @param translation defines the translation vector3
  81330. * @returns a new matrix
  81331. */
  81332. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  81333. /**
  81334. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  81335. * @param scale defines the scale vector3
  81336. * @param rotation defines the rotation quaternion
  81337. * @param translation defines the translation vector3
  81338. * @param result defines the target matrix
  81339. */
  81340. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  81341. /**
  81342. * Creates a new identity matrix
  81343. * @returns a new identity matrix
  81344. */
  81345. static Identity(): Matrix;
  81346. /**
  81347. * Creates a new identity matrix and stores the result in a given matrix
  81348. * @param result defines the target matrix
  81349. */
  81350. static IdentityToRef(result: Matrix): void;
  81351. /**
  81352. * Creates a new zero matrix
  81353. * @returns a new zero matrix
  81354. */
  81355. static Zero(): Matrix;
  81356. /**
  81357. * Creates a new rotation matrix for "angle" radians around the X axis
  81358. * @param angle defines the angle (in radians) to use
  81359. * @return the new matrix
  81360. */
  81361. static RotationX(angle: number): Matrix;
  81362. /**
  81363. * Creates a new matrix as the invert of a given matrix
  81364. * @param source defines the source matrix
  81365. * @returns the new matrix
  81366. */
  81367. static Invert(source: DeepImmutable<Matrix>): Matrix;
  81368. /**
  81369. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  81370. * @param angle defines the angle (in radians) to use
  81371. * @param result defines the target matrix
  81372. */
  81373. static RotationXToRef(angle: number, result: Matrix): void;
  81374. /**
  81375. * Creates a new rotation matrix for "angle" radians around the Y axis
  81376. * @param angle defines the angle (in radians) to use
  81377. * @return the new matrix
  81378. */
  81379. static RotationY(angle: number): Matrix;
  81380. /**
  81381. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  81382. * @param angle defines the angle (in radians) to use
  81383. * @param result defines the target matrix
  81384. */
  81385. static RotationYToRef(angle: number, result: Matrix): void;
  81386. /**
  81387. * Creates a new rotation matrix for "angle" radians around the Z axis
  81388. * @param angle defines the angle (in radians) to use
  81389. * @return the new matrix
  81390. */
  81391. static RotationZ(angle: number): Matrix;
  81392. /**
  81393. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  81394. * @param angle defines the angle (in radians) to use
  81395. * @param result defines the target matrix
  81396. */
  81397. static RotationZToRef(angle: number, result: Matrix): void;
  81398. /**
  81399. * Creates a new rotation matrix for "angle" radians around the given axis
  81400. * @param axis defines the axis to use
  81401. * @param angle defines the angle (in radians) to use
  81402. * @return the new matrix
  81403. */
  81404. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  81405. /**
  81406. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  81407. * @param axis defines the axis to use
  81408. * @param angle defines the angle (in radians) to use
  81409. * @param result defines the target matrix
  81410. */
  81411. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  81412. /**
  81413. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  81414. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  81415. * @param from defines the vector to align
  81416. * @param to defines the vector to align to
  81417. * @param result defines the target matrix
  81418. */
  81419. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  81420. /**
  81421. * Creates a rotation matrix
  81422. * @param yaw defines the yaw angle in radians (Y axis)
  81423. * @param pitch defines the pitch angle in radians (X axis)
  81424. * @param roll defines the roll angle in radians (X axis)
  81425. * @returns the new rotation matrix
  81426. */
  81427. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  81428. /**
  81429. * Creates a rotation matrix and stores it in a given matrix
  81430. * @param yaw defines the yaw angle in radians (Y axis)
  81431. * @param pitch defines the pitch angle in radians (X axis)
  81432. * @param roll defines the roll angle in radians (X axis)
  81433. * @param result defines the target matrix
  81434. */
  81435. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  81436. /**
  81437. * Creates a scaling matrix
  81438. * @param x defines the scale factor on X axis
  81439. * @param y defines the scale factor on Y axis
  81440. * @param z defines the scale factor on Z axis
  81441. * @returns the new matrix
  81442. */
  81443. static Scaling(x: number, y: number, z: number): Matrix;
  81444. /**
  81445. * Creates a scaling matrix and stores it in a given matrix
  81446. * @param x defines the scale factor on X axis
  81447. * @param y defines the scale factor on Y axis
  81448. * @param z defines the scale factor on Z axis
  81449. * @param result defines the target matrix
  81450. */
  81451. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  81452. /**
  81453. * Creates a translation matrix
  81454. * @param x defines the translation on X axis
  81455. * @param y defines the translation on Y axis
  81456. * @param z defines the translationon Z axis
  81457. * @returns the new matrix
  81458. */
  81459. static Translation(x: number, y: number, z: number): Matrix;
  81460. /**
  81461. * Creates a translation matrix and stores it in a given matrix
  81462. * @param x defines the translation on X axis
  81463. * @param y defines the translation on Y axis
  81464. * @param z defines the translationon Z axis
  81465. * @param result defines the target matrix
  81466. */
  81467. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  81468. /**
  81469. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  81470. * @param startValue defines the start value
  81471. * @param endValue defines the end value
  81472. * @param gradient defines the gradient factor
  81473. * @returns the new matrix
  81474. */
  81475. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  81476. /**
  81477. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  81478. * @param startValue defines the start value
  81479. * @param endValue defines the end value
  81480. * @param gradient defines the gradient factor
  81481. * @param result defines the Matrix object where to store data
  81482. */
  81483. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  81484. /**
  81485. * Builds a new matrix whose values are computed by:
  81486. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  81487. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  81488. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  81489. * @param startValue defines the first matrix
  81490. * @param endValue defines the second matrix
  81491. * @param gradient defines the gradient between the two matrices
  81492. * @returns the new matrix
  81493. */
  81494. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  81495. /**
  81496. * Update a matrix to values which are computed by:
  81497. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  81498. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  81499. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  81500. * @param startValue defines the first matrix
  81501. * @param endValue defines the second matrix
  81502. * @param gradient defines the gradient between the two matrices
  81503. * @param result defines the target matrix
  81504. */
  81505. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  81506. /**
  81507. * 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"
  81508. * This function works in left handed mode
  81509. * @param eye defines the final position of the entity
  81510. * @param target defines where the entity should look at
  81511. * @param up defines the up vector for the entity
  81512. * @returns the new matrix
  81513. */
  81514. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  81515. /**
  81516. * 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".
  81517. * This function works in left handed mode
  81518. * @param eye defines the final position of the entity
  81519. * @param target defines where the entity should look at
  81520. * @param up defines the up vector for the entity
  81521. * @param result defines the target matrix
  81522. */
  81523. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  81524. /**
  81525. * 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"
  81526. * This function works in right handed mode
  81527. * @param eye defines the final position of the entity
  81528. * @param target defines where the entity should look at
  81529. * @param up defines the up vector for the entity
  81530. * @returns the new matrix
  81531. */
  81532. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  81533. /**
  81534. * 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".
  81535. * This function works in right handed mode
  81536. * @param eye defines the final position of the entity
  81537. * @param target defines where the entity should look at
  81538. * @param up defines the up vector for the entity
  81539. * @param result defines the target matrix
  81540. */
  81541. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  81542. /**
  81543. * Create a left-handed orthographic projection matrix
  81544. * @param width defines the viewport width
  81545. * @param height defines the viewport height
  81546. * @param znear defines the near clip plane
  81547. * @param zfar defines the far clip plane
  81548. * @returns a new matrix as a left-handed orthographic projection matrix
  81549. */
  81550. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  81551. /**
  81552. * Store a left-handed orthographic projection to a given matrix
  81553. * @param width defines the viewport width
  81554. * @param height defines the viewport height
  81555. * @param znear defines the near clip plane
  81556. * @param zfar defines the far clip plane
  81557. * @param result defines the target matrix
  81558. */
  81559. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  81560. /**
  81561. * Create a left-handed orthographic projection matrix
  81562. * @param left defines the viewport left coordinate
  81563. * @param right defines the viewport right coordinate
  81564. * @param bottom defines the viewport bottom coordinate
  81565. * @param top defines the viewport top coordinate
  81566. * @param znear defines the near clip plane
  81567. * @param zfar defines the far clip plane
  81568. * @returns a new matrix as a left-handed orthographic projection matrix
  81569. */
  81570. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  81571. /**
  81572. * Stores a left-handed orthographic projection into a given matrix
  81573. * @param left defines the viewport left coordinate
  81574. * @param right defines the viewport right coordinate
  81575. * @param bottom defines the viewport bottom coordinate
  81576. * @param top defines the viewport top coordinate
  81577. * @param znear defines the near clip plane
  81578. * @param zfar defines the far clip plane
  81579. * @param result defines the target matrix
  81580. */
  81581. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  81582. /**
  81583. * Creates a right-handed orthographic projection matrix
  81584. * @param left defines the viewport left coordinate
  81585. * @param right defines the viewport right coordinate
  81586. * @param bottom defines the viewport bottom coordinate
  81587. * @param top defines the viewport top coordinate
  81588. * @param znear defines the near clip plane
  81589. * @param zfar defines the far clip plane
  81590. * @returns a new matrix as a right-handed orthographic projection matrix
  81591. */
  81592. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  81593. /**
  81594. * Stores a right-handed orthographic projection into a given matrix
  81595. * @param left defines the viewport left coordinate
  81596. * @param right defines the viewport right coordinate
  81597. * @param bottom defines the viewport bottom coordinate
  81598. * @param top defines the viewport top coordinate
  81599. * @param znear defines the near clip plane
  81600. * @param zfar defines the far clip plane
  81601. * @param result defines the target matrix
  81602. */
  81603. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  81604. /**
  81605. * Creates a left-handed perspective projection matrix
  81606. * @param width defines the viewport width
  81607. * @param height defines the viewport height
  81608. * @param znear defines the near clip plane
  81609. * @param zfar defines the far clip plane
  81610. * @returns a new matrix as a left-handed perspective projection matrix
  81611. */
  81612. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  81613. /**
  81614. * Creates a left-handed perspective projection matrix
  81615. * @param fov defines the horizontal field of view
  81616. * @param aspect defines the aspect ratio
  81617. * @param znear defines the near clip plane
  81618. * @param zfar defines the far clip plane
  81619. * @returns a new matrix as a left-handed perspective projection matrix
  81620. */
  81621. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  81622. /**
  81623. * Stores a left-handed perspective projection into a given matrix
  81624. * @param fov defines the horizontal field of view
  81625. * @param aspect defines the aspect ratio
  81626. * @param znear defines the near clip plane
  81627. * @param zfar defines the far clip plane
  81628. * @param result defines the target matrix
  81629. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  81630. */
  81631. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  81632. /**
  81633. * Stores a left-handed perspective projection into a given matrix with depth reversed
  81634. * @param fov defines the horizontal field of view
  81635. * @param aspect defines the aspect ratio
  81636. * @param znear defines the near clip plane
  81637. * @param zfar not used as infinity is used as far clip
  81638. * @param result defines the target matrix
  81639. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  81640. */
  81641. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  81642. /**
  81643. * Creates a right-handed perspective projection matrix
  81644. * @param fov defines the horizontal field of view
  81645. * @param aspect defines the aspect ratio
  81646. * @param znear defines the near clip plane
  81647. * @param zfar defines the far clip plane
  81648. * @returns a new matrix as a right-handed perspective projection matrix
  81649. */
  81650. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  81651. /**
  81652. * Stores a right-handed perspective projection into a given matrix
  81653. * @param fov defines the horizontal field of view
  81654. * @param aspect defines the aspect ratio
  81655. * @param znear defines the near clip plane
  81656. * @param zfar defines the far clip plane
  81657. * @param result defines the target matrix
  81658. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  81659. */
  81660. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  81661. /**
  81662. * Stores a right-handed perspective projection into a given matrix
  81663. * @param fov defines the horizontal field of view
  81664. * @param aspect defines the aspect ratio
  81665. * @param znear defines the near clip plane
  81666. * @param zfar not used as infinity is used as far clip
  81667. * @param result defines the target matrix
  81668. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  81669. */
  81670. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  81671. /**
  81672. * Stores a perspective projection for WebVR info a given matrix
  81673. * @param fov defines the field of view
  81674. * @param znear defines the near clip plane
  81675. * @param zfar defines the far clip plane
  81676. * @param result defines the target matrix
  81677. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  81678. */
  81679. static PerspectiveFovWebVRToRef(fov: {
  81680. upDegrees: number;
  81681. downDegrees: number;
  81682. leftDegrees: number;
  81683. rightDegrees: number;
  81684. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  81685. /**
  81686. * Computes a complete transformation matrix
  81687. * @param viewport defines the viewport to use
  81688. * @param world defines the world matrix
  81689. * @param view defines the view matrix
  81690. * @param projection defines the projection matrix
  81691. * @param zmin defines the near clip plane
  81692. * @param zmax defines the far clip plane
  81693. * @returns the transformation matrix
  81694. */
  81695. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  81696. /**
  81697. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  81698. * @param matrix defines the matrix to use
  81699. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  81700. */
  81701. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  81702. /**
  81703. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  81704. * @param matrix defines the matrix to use
  81705. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  81706. */
  81707. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  81708. /**
  81709. * Compute the transpose of a given matrix
  81710. * @param matrix defines the matrix to transpose
  81711. * @returns the new matrix
  81712. */
  81713. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  81714. /**
  81715. * Compute the transpose of a matrix and store it in a target matrix
  81716. * @param matrix defines the matrix to transpose
  81717. * @param result defines the target matrix
  81718. */
  81719. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  81720. /**
  81721. * Computes a reflection matrix from a plane
  81722. * @param plane defines the reflection plane
  81723. * @returns a new matrix
  81724. */
  81725. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  81726. /**
  81727. * Computes a reflection matrix from a plane
  81728. * @param plane defines the reflection plane
  81729. * @param result defines the target matrix
  81730. */
  81731. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  81732. /**
  81733. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  81734. * @param xaxis defines the value of the 1st axis
  81735. * @param yaxis defines the value of the 2nd axis
  81736. * @param zaxis defines the value of the 3rd axis
  81737. * @param result defines the target matrix
  81738. */
  81739. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  81740. /**
  81741. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  81742. * @param quat defines the quaternion to use
  81743. * @param result defines the target matrix
  81744. */
  81745. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  81746. }
  81747. /**
  81748. * @hidden
  81749. */
  81750. export class TmpVectors {
  81751. static Vector2: Vector2[];
  81752. static Vector3: Vector3[];
  81753. static Vector4: Vector4[];
  81754. static Quaternion: Quaternion[];
  81755. static Matrix: Matrix[];
  81756. }
  81757. }
  81758. declare module BABYLON {
  81759. /**
  81760. * Defines potential orientation for back face culling
  81761. */
  81762. export enum Orientation {
  81763. /**
  81764. * Clockwise
  81765. */
  81766. CW = 0,
  81767. /** Counter clockwise */
  81768. CCW = 1
  81769. }
  81770. /** Class used to represent a Bezier curve */
  81771. export class BezierCurve {
  81772. /**
  81773. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  81774. * @param t defines the time
  81775. * @param x1 defines the left coordinate on X axis
  81776. * @param y1 defines the left coordinate on Y axis
  81777. * @param x2 defines the right coordinate on X axis
  81778. * @param y2 defines the right coordinate on Y axis
  81779. * @returns the interpolated value
  81780. */
  81781. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  81782. }
  81783. /**
  81784. * Defines angle representation
  81785. */
  81786. export class Angle {
  81787. private _radians;
  81788. /**
  81789. * Creates an Angle object of "radians" radians (float).
  81790. * @param radians the angle in radians
  81791. */
  81792. constructor(radians: number);
  81793. /**
  81794. * Get value in degrees
  81795. * @returns the Angle value in degrees (float)
  81796. */
  81797. degrees(): number;
  81798. /**
  81799. * Get value in radians
  81800. * @returns the Angle value in radians (float)
  81801. */
  81802. radians(): number;
  81803. /**
  81804. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  81805. * @param a defines first vector
  81806. * @param b defines second vector
  81807. * @returns a new Angle
  81808. */
  81809. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  81810. /**
  81811. * Gets a new Angle object from the given float in radians
  81812. * @param radians defines the angle value in radians
  81813. * @returns a new Angle
  81814. */
  81815. static FromRadians(radians: number): Angle;
  81816. /**
  81817. * Gets a new Angle object from the given float in degrees
  81818. * @param degrees defines the angle value in degrees
  81819. * @returns a new Angle
  81820. */
  81821. static FromDegrees(degrees: number): Angle;
  81822. }
  81823. /**
  81824. * This represents an arc in a 2d space.
  81825. */
  81826. export class Arc2 {
  81827. /** Defines the start point of the arc */
  81828. startPoint: Vector2;
  81829. /** Defines the mid point of the arc */
  81830. midPoint: Vector2;
  81831. /** Defines the end point of the arc */
  81832. endPoint: Vector2;
  81833. /**
  81834. * Defines the center point of the arc.
  81835. */
  81836. centerPoint: Vector2;
  81837. /**
  81838. * Defines the radius of the arc.
  81839. */
  81840. radius: number;
  81841. /**
  81842. * Defines the angle of the arc (from mid point to end point).
  81843. */
  81844. angle: Angle;
  81845. /**
  81846. * Defines the start angle of the arc (from start point to middle point).
  81847. */
  81848. startAngle: Angle;
  81849. /**
  81850. * Defines the orientation of the arc (clock wise/counter clock wise).
  81851. */
  81852. orientation: Orientation;
  81853. /**
  81854. * Creates an Arc object from the three given points : start, middle and end.
  81855. * @param startPoint Defines the start point of the arc
  81856. * @param midPoint Defines the midlle point of the arc
  81857. * @param endPoint Defines the end point of the arc
  81858. */
  81859. constructor(
  81860. /** Defines the start point of the arc */
  81861. startPoint: Vector2,
  81862. /** Defines the mid point of the arc */
  81863. midPoint: Vector2,
  81864. /** Defines the end point of the arc */
  81865. endPoint: Vector2);
  81866. }
  81867. /**
  81868. * Represents a 2D path made up of multiple 2D points
  81869. */
  81870. export class Path2 {
  81871. private _points;
  81872. private _length;
  81873. /**
  81874. * If the path start and end point are the same
  81875. */
  81876. closed: boolean;
  81877. /**
  81878. * Creates a Path2 object from the starting 2D coordinates x and y.
  81879. * @param x the starting points x value
  81880. * @param y the starting points y value
  81881. */
  81882. constructor(x: number, y: number);
  81883. /**
  81884. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  81885. * @param x the added points x value
  81886. * @param y the added points y value
  81887. * @returns the updated Path2.
  81888. */
  81889. addLineTo(x: number, y: number): Path2;
  81890. /**
  81891. * 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.
  81892. * @param midX middle point x value
  81893. * @param midY middle point y value
  81894. * @param endX end point x value
  81895. * @param endY end point y value
  81896. * @param numberOfSegments (default: 36)
  81897. * @returns the updated Path2.
  81898. */
  81899. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  81900. /**
  81901. * Closes the Path2.
  81902. * @returns the Path2.
  81903. */
  81904. close(): Path2;
  81905. /**
  81906. * Gets the sum of the distance between each sequential point in the path
  81907. * @returns the Path2 total length (float).
  81908. */
  81909. length(): number;
  81910. /**
  81911. * Gets the points which construct the path
  81912. * @returns the Path2 internal array of points.
  81913. */
  81914. getPoints(): Vector2[];
  81915. /**
  81916. * Retreives the point at the distance aways from the starting point
  81917. * @param normalizedLengthPosition the length along the path to retreive the point from
  81918. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  81919. */
  81920. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  81921. /**
  81922. * Creates a new path starting from an x and y position
  81923. * @param x starting x value
  81924. * @param y starting y value
  81925. * @returns a new Path2 starting at the coordinates (x, y).
  81926. */
  81927. static StartingAt(x: number, y: number): Path2;
  81928. }
  81929. /**
  81930. * Represents a 3D path made up of multiple 3D points
  81931. */
  81932. export class Path3D {
  81933. /**
  81934. * an array of Vector3, the curve axis of the Path3D
  81935. */
  81936. path: Vector3[];
  81937. private _curve;
  81938. private _distances;
  81939. private _tangents;
  81940. private _normals;
  81941. private _binormals;
  81942. private _raw;
  81943. private _alignTangentsWithPath;
  81944. private readonly _pointAtData;
  81945. /**
  81946. * new Path3D(path, normal, raw)
  81947. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  81948. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  81949. * @param path an array of Vector3, the curve axis of the Path3D
  81950. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  81951. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  81952. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  81953. */
  81954. constructor(
  81955. /**
  81956. * an array of Vector3, the curve axis of the Path3D
  81957. */
  81958. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  81959. /**
  81960. * Returns the Path3D array of successive Vector3 designing its curve.
  81961. * @returns the Path3D array of successive Vector3 designing its curve.
  81962. */
  81963. getCurve(): Vector3[];
  81964. /**
  81965. * Returns the Path3D array of successive Vector3 designing its curve.
  81966. * @returns the Path3D array of successive Vector3 designing its curve.
  81967. */
  81968. getPoints(): Vector3[];
  81969. /**
  81970. * @returns the computed length (float) of the path.
  81971. */
  81972. length(): number;
  81973. /**
  81974. * Returns an array populated with tangent vectors on each Path3D curve point.
  81975. * @returns an array populated with tangent vectors on each Path3D curve point.
  81976. */
  81977. getTangents(): Vector3[];
  81978. /**
  81979. * Returns an array populated with normal vectors on each Path3D curve point.
  81980. * @returns an array populated with normal vectors on each Path3D curve point.
  81981. */
  81982. getNormals(): Vector3[];
  81983. /**
  81984. * Returns an array populated with binormal vectors on each Path3D curve point.
  81985. * @returns an array populated with binormal vectors on each Path3D curve point.
  81986. */
  81987. getBinormals(): Vector3[];
  81988. /**
  81989. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  81990. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  81991. */
  81992. getDistances(): number[];
  81993. /**
  81994. * Returns an interpolated point along this path
  81995. * @param position the position of the point along this path, from 0.0 to 1.0
  81996. * @returns a new Vector3 as the point
  81997. */
  81998. getPointAt(position: number): Vector3;
  81999. /**
  82000. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  82001. * @param position the position of the point along this path, from 0.0 to 1.0
  82002. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  82003. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  82004. */
  82005. getTangentAt(position: number, interpolated?: boolean): Vector3;
  82006. /**
  82007. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  82008. * @param position the position of the point along this path, from 0.0 to 1.0
  82009. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  82010. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  82011. */
  82012. getNormalAt(position: number, interpolated?: boolean): Vector3;
  82013. /**
  82014. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  82015. * @param position the position of the point along this path, from 0.0 to 1.0
  82016. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  82017. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  82018. */
  82019. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  82020. /**
  82021. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  82022. * @param position the position of the point along this path, from 0.0 to 1.0
  82023. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  82024. */
  82025. getDistanceAt(position: number): number;
  82026. /**
  82027. * Returns the array index of the previous point of an interpolated point along this path
  82028. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  82029. * @returns the array index
  82030. */
  82031. getPreviousPointIndexAt(position: number): number;
  82032. /**
  82033. * 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)
  82034. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  82035. * @returns the sub position
  82036. */
  82037. getSubPositionAt(position: number): number;
  82038. /**
  82039. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  82040. * @param target the vector of which to get the closest position to
  82041. * @returns the position of the closest virtual point on this path to the target vector
  82042. */
  82043. getClosestPositionTo(target: Vector3): number;
  82044. /**
  82045. * Returns a sub path (slice) of this path
  82046. * @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
  82047. * @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
  82048. * @returns a sub path (slice) of this path
  82049. */
  82050. slice(start?: number, end?: number): Path3D;
  82051. /**
  82052. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  82053. * @param path path which all values are copied into the curves points
  82054. * @param firstNormal which should be projected onto the curve
  82055. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  82056. * @returns the same object updated.
  82057. */
  82058. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  82059. private _compute;
  82060. private _getFirstNonNullVector;
  82061. private _getLastNonNullVector;
  82062. private _normalVector;
  82063. /**
  82064. * Updates the point at data for an interpolated point along this curve
  82065. * @param position the position of the point along this curve, from 0.0 to 1.0
  82066. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  82067. * @returns the (updated) point at data
  82068. */
  82069. private _updatePointAtData;
  82070. /**
  82071. * Updates the point at data from the specified parameters
  82072. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  82073. * @param point the interpolated point
  82074. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  82075. */
  82076. private _setPointAtData;
  82077. /**
  82078. * Updates the point at interpolation matrix for the tangents, normals and binormals
  82079. */
  82080. private _updateInterpolationMatrix;
  82081. }
  82082. /**
  82083. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  82084. * A Curve3 is designed from a series of successive Vector3.
  82085. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  82086. */
  82087. export class Curve3 {
  82088. private _points;
  82089. private _length;
  82090. /**
  82091. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  82092. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  82093. * @param v1 (Vector3) the control point
  82094. * @param v2 (Vector3) the end point of the Quadratic Bezier
  82095. * @param nbPoints (integer) the wanted number of points in the curve
  82096. * @returns the created Curve3
  82097. */
  82098. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  82099. /**
  82100. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  82101. * @param v0 (Vector3) the origin point of the Cubic Bezier
  82102. * @param v1 (Vector3) the first control point
  82103. * @param v2 (Vector3) the second control point
  82104. * @param v3 (Vector3) the end point of the Cubic Bezier
  82105. * @param nbPoints (integer) the wanted number of points in the curve
  82106. * @returns the created Curve3
  82107. */
  82108. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  82109. /**
  82110. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  82111. * @param p1 (Vector3) the origin point of the Hermite Spline
  82112. * @param t1 (Vector3) the tangent vector at the origin point
  82113. * @param p2 (Vector3) the end point of the Hermite Spline
  82114. * @param t2 (Vector3) the tangent vector at the end point
  82115. * @param nbPoints (integer) the wanted number of points in the curve
  82116. * @returns the created Curve3
  82117. */
  82118. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  82119. /**
  82120. * Returns a Curve3 object along a CatmullRom Spline curve :
  82121. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  82122. * @param nbPoints (integer) the wanted number of points between each curve control points
  82123. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  82124. * @returns the created Curve3
  82125. */
  82126. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  82127. /**
  82128. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  82129. * A Curve3 is designed from a series of successive Vector3.
  82130. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  82131. * @param points points which make up the curve
  82132. */
  82133. constructor(points: Vector3[]);
  82134. /**
  82135. * @returns the Curve3 stored array of successive Vector3
  82136. */
  82137. getPoints(): Vector3[];
  82138. /**
  82139. * @returns the computed length (float) of the curve.
  82140. */
  82141. length(): number;
  82142. /**
  82143. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  82144. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  82145. * curveA and curveB keep unchanged.
  82146. * @param curve the curve to continue from this curve
  82147. * @returns the newly constructed curve
  82148. */
  82149. continue(curve: DeepImmutable<Curve3>): Curve3;
  82150. private _computeLength;
  82151. }
  82152. }
  82153. declare module BABYLON {
  82154. /**
  82155. * This represents the main contract an easing function should follow.
  82156. * Easing functions are used throughout the animation system.
  82157. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  82158. */
  82159. export interface IEasingFunction {
  82160. /**
  82161. * Given an input gradient between 0 and 1, this returns the corrseponding value
  82162. * of the easing function.
  82163. * The link below provides some of the most common examples of easing functions.
  82164. * @see https://easings.net/
  82165. * @param gradient Defines the value between 0 and 1 we want the easing value for
  82166. * @returns the corresponding value on the curve defined by the easing function
  82167. */
  82168. ease(gradient: number): number;
  82169. }
  82170. /**
  82171. * Base class used for every default easing function.
  82172. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  82173. */
  82174. export class EasingFunction implements IEasingFunction {
  82175. /**
  82176. * Interpolation follows the mathematical formula associated with the easing function.
  82177. */
  82178. static readonly EASINGMODE_EASEIN: number;
  82179. /**
  82180. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  82181. */
  82182. static readonly EASINGMODE_EASEOUT: number;
  82183. /**
  82184. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  82185. */
  82186. static readonly EASINGMODE_EASEINOUT: number;
  82187. private _easingMode;
  82188. /**
  82189. * Sets the easing mode of the current function.
  82190. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  82191. */
  82192. setEasingMode(easingMode: number): void;
  82193. /**
  82194. * Gets the current easing mode.
  82195. * @returns the easing mode
  82196. */
  82197. getEasingMode(): number;
  82198. /**
  82199. * @hidden
  82200. */
  82201. easeInCore(gradient: number): number;
  82202. /**
  82203. * Given an input gradient between 0 and 1, this returns the corresponding value
  82204. * of the easing function.
  82205. * @param gradient Defines the value between 0 and 1 we want the easing value for
  82206. * @returns the corresponding value on the curve defined by the easing function
  82207. */
  82208. ease(gradient: number): number;
  82209. }
  82210. /**
  82211. * Easing function with a circle shape (see link below).
  82212. * @see https://easings.net/#easeInCirc
  82213. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  82214. */
  82215. export class CircleEase extends EasingFunction implements IEasingFunction {
  82216. /** @hidden */
  82217. easeInCore(gradient: number): number;
  82218. }
  82219. /**
  82220. * Easing function with a ease back shape (see link below).
  82221. * @see https://easings.net/#easeInBack
  82222. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  82223. */
  82224. export class BackEase extends EasingFunction implements IEasingFunction {
  82225. /** Defines the amplitude of the function */
  82226. amplitude: number;
  82227. /**
  82228. * Instantiates a back ease easing
  82229. * @see https://easings.net/#easeInBack
  82230. * @param amplitude Defines the amplitude of the function
  82231. */
  82232. constructor(
  82233. /** Defines the amplitude of the function */
  82234. amplitude?: number);
  82235. /** @hidden */
  82236. easeInCore(gradient: number): number;
  82237. }
  82238. /**
  82239. * Easing function with a bouncing shape (see link below).
  82240. * @see https://easings.net/#easeInBounce
  82241. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  82242. */
  82243. export class BounceEase extends EasingFunction implements IEasingFunction {
  82244. /** Defines the number of bounces */
  82245. bounces: number;
  82246. /** Defines the amplitude of the bounce */
  82247. bounciness: number;
  82248. /**
  82249. * Instantiates a bounce easing
  82250. * @see https://easings.net/#easeInBounce
  82251. * @param bounces Defines the number of bounces
  82252. * @param bounciness Defines the amplitude of the bounce
  82253. */
  82254. constructor(
  82255. /** Defines the number of bounces */
  82256. bounces?: number,
  82257. /** Defines the amplitude of the bounce */
  82258. bounciness?: number);
  82259. /** @hidden */
  82260. easeInCore(gradient: number): number;
  82261. }
  82262. /**
  82263. * Easing function with a power of 3 shape (see link below).
  82264. * @see https://easings.net/#easeInCubic
  82265. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  82266. */
  82267. export class CubicEase extends EasingFunction implements IEasingFunction {
  82268. /** @hidden */
  82269. easeInCore(gradient: number): number;
  82270. }
  82271. /**
  82272. * Easing function with an elastic shape (see link below).
  82273. * @see https://easings.net/#easeInElastic
  82274. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  82275. */
  82276. export class ElasticEase extends EasingFunction implements IEasingFunction {
  82277. /** Defines the number of oscillations*/
  82278. oscillations: number;
  82279. /** Defines the amplitude of the oscillations*/
  82280. springiness: number;
  82281. /**
  82282. * Instantiates an elastic easing function
  82283. * @see https://easings.net/#easeInElastic
  82284. * @param oscillations Defines the number of oscillations
  82285. * @param springiness Defines the amplitude of the oscillations
  82286. */
  82287. constructor(
  82288. /** Defines the number of oscillations*/
  82289. oscillations?: number,
  82290. /** Defines the amplitude of the oscillations*/
  82291. springiness?: number);
  82292. /** @hidden */
  82293. easeInCore(gradient: number): number;
  82294. }
  82295. /**
  82296. * Easing function with an exponential shape (see link below).
  82297. * @see https://easings.net/#easeInExpo
  82298. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  82299. */
  82300. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  82301. /** Defines the exponent of the function */
  82302. exponent: number;
  82303. /**
  82304. * Instantiates an exponential easing function
  82305. * @see https://easings.net/#easeInExpo
  82306. * @param exponent Defines the exponent of the function
  82307. */
  82308. constructor(
  82309. /** Defines the exponent of the function */
  82310. exponent?: number);
  82311. /** @hidden */
  82312. easeInCore(gradient: number): number;
  82313. }
  82314. /**
  82315. * Easing function with a power shape (see link below).
  82316. * @see https://easings.net/#easeInQuad
  82317. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  82318. */
  82319. export class PowerEase extends EasingFunction implements IEasingFunction {
  82320. /** Defines the power of the function */
  82321. power: number;
  82322. /**
  82323. * Instantiates an power base easing function
  82324. * @see https://easings.net/#easeInQuad
  82325. * @param power Defines the power of the function
  82326. */
  82327. constructor(
  82328. /** Defines the power of the function */
  82329. power?: number);
  82330. /** @hidden */
  82331. easeInCore(gradient: number): number;
  82332. }
  82333. /**
  82334. * Easing function with a power of 2 shape (see link below).
  82335. * @see https://easings.net/#easeInQuad
  82336. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  82337. */
  82338. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  82339. /** @hidden */
  82340. easeInCore(gradient: number): number;
  82341. }
  82342. /**
  82343. * Easing function with a power of 4 shape (see link below).
  82344. * @see https://easings.net/#easeInQuart
  82345. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  82346. */
  82347. export class QuarticEase extends EasingFunction implements IEasingFunction {
  82348. /** @hidden */
  82349. easeInCore(gradient: number): number;
  82350. }
  82351. /**
  82352. * Easing function with a power of 5 shape (see link below).
  82353. * @see https://easings.net/#easeInQuint
  82354. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  82355. */
  82356. export class QuinticEase extends EasingFunction implements IEasingFunction {
  82357. /** @hidden */
  82358. easeInCore(gradient: number): number;
  82359. }
  82360. /**
  82361. * Easing function with a sin shape (see link below).
  82362. * @see https://easings.net/#easeInSine
  82363. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  82364. */
  82365. export class SineEase extends EasingFunction implements IEasingFunction {
  82366. /** @hidden */
  82367. easeInCore(gradient: number): number;
  82368. }
  82369. /**
  82370. * Easing function with a bezier shape (see link below).
  82371. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  82372. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  82373. */
  82374. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  82375. /** Defines the x component of the start tangent in the bezier curve */
  82376. x1: number;
  82377. /** Defines the y component of the start tangent in the bezier curve */
  82378. y1: number;
  82379. /** Defines the x component of the end tangent in the bezier curve */
  82380. x2: number;
  82381. /** Defines the y component of the end tangent in the bezier curve */
  82382. y2: number;
  82383. /**
  82384. * Instantiates a bezier function
  82385. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  82386. * @param x1 Defines the x component of the start tangent in the bezier curve
  82387. * @param y1 Defines the y component of the start tangent in the bezier curve
  82388. * @param x2 Defines the x component of the end tangent in the bezier curve
  82389. * @param y2 Defines the y component of the end tangent in the bezier curve
  82390. */
  82391. constructor(
  82392. /** Defines the x component of the start tangent in the bezier curve */
  82393. x1?: number,
  82394. /** Defines the y component of the start tangent in the bezier curve */
  82395. y1?: number,
  82396. /** Defines the x component of the end tangent in the bezier curve */
  82397. x2?: number,
  82398. /** Defines the y component of the end tangent in the bezier curve */
  82399. y2?: number);
  82400. /** @hidden */
  82401. easeInCore(gradient: number): number;
  82402. }
  82403. }
  82404. declare module BABYLON {
  82405. /**
  82406. * Class used to hold a RBG color
  82407. */
  82408. export class Color3 {
  82409. /**
  82410. * Defines the red component (between 0 and 1, default is 0)
  82411. */
  82412. r: number;
  82413. /**
  82414. * Defines the green component (between 0 and 1, default is 0)
  82415. */
  82416. g: number;
  82417. /**
  82418. * Defines the blue component (between 0 and 1, default is 0)
  82419. */
  82420. b: number;
  82421. /**
  82422. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  82423. * @param r defines the red component (between 0 and 1, default is 0)
  82424. * @param g defines the green component (between 0 and 1, default is 0)
  82425. * @param b defines the blue component (between 0 and 1, default is 0)
  82426. */
  82427. constructor(
  82428. /**
  82429. * Defines the red component (between 0 and 1, default is 0)
  82430. */
  82431. r?: number,
  82432. /**
  82433. * Defines the green component (between 0 and 1, default is 0)
  82434. */
  82435. g?: number,
  82436. /**
  82437. * Defines the blue component (between 0 and 1, default is 0)
  82438. */
  82439. b?: number);
  82440. /**
  82441. * Creates a string with the Color3 current values
  82442. * @returns the string representation of the Color3 object
  82443. */
  82444. toString(): string;
  82445. /**
  82446. * Returns the string "Color3"
  82447. * @returns "Color3"
  82448. */
  82449. getClassName(): string;
  82450. /**
  82451. * Compute the Color3 hash code
  82452. * @returns an unique number that can be used to hash Color3 objects
  82453. */
  82454. getHashCode(): number;
  82455. /**
  82456. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  82457. * @param array defines the array where to store the r,g,b components
  82458. * @param index defines an optional index in the target array to define where to start storing values
  82459. * @returns the current Color3 object
  82460. */
  82461. toArray(array: FloatArray, index?: number): Color3;
  82462. /**
  82463. * Returns a new Color4 object from the current Color3 and the given alpha
  82464. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  82465. * @returns a new Color4 object
  82466. */
  82467. toColor4(alpha?: number): Color4;
  82468. /**
  82469. * Returns a new array populated with 3 numeric elements : red, green and blue values
  82470. * @returns the new array
  82471. */
  82472. asArray(): number[];
  82473. /**
  82474. * Returns the luminance value
  82475. * @returns a float value
  82476. */
  82477. toLuminance(): number;
  82478. /**
  82479. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  82480. * @param otherColor defines the second operand
  82481. * @returns the new Color3 object
  82482. */
  82483. multiply(otherColor: DeepImmutable<Color3>): Color3;
  82484. /**
  82485. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  82486. * @param otherColor defines the second operand
  82487. * @param result defines the Color3 object where to store the result
  82488. * @returns the current Color3
  82489. */
  82490. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  82491. /**
  82492. * Determines equality between Color3 objects
  82493. * @param otherColor defines the second operand
  82494. * @returns true if the rgb values are equal to the given ones
  82495. */
  82496. equals(otherColor: DeepImmutable<Color3>): boolean;
  82497. /**
  82498. * Determines equality between the current Color3 object and a set of r,b,g values
  82499. * @param r defines the red component to check
  82500. * @param g defines the green component to check
  82501. * @param b defines the blue component to check
  82502. * @returns true if the rgb values are equal to the given ones
  82503. */
  82504. equalsFloats(r: number, g: number, b: number): boolean;
  82505. /**
  82506. * Multiplies in place each rgb value by scale
  82507. * @param scale defines the scaling factor
  82508. * @returns the updated Color3
  82509. */
  82510. scale(scale: number): Color3;
  82511. /**
  82512. * Multiplies the rgb values by scale and stores the result into "result"
  82513. * @param scale defines the scaling factor
  82514. * @param result defines the Color3 object where to store the result
  82515. * @returns the unmodified current Color3
  82516. */
  82517. scaleToRef(scale: number, result: Color3): Color3;
  82518. /**
  82519. * Scale the current Color3 values by a factor and add the result to a given Color3
  82520. * @param scale defines the scale factor
  82521. * @param result defines color to store the result into
  82522. * @returns the unmodified current Color3
  82523. */
  82524. scaleAndAddToRef(scale: number, result: Color3): Color3;
  82525. /**
  82526. * Clamps the rgb values by the min and max values and stores the result into "result"
  82527. * @param min defines minimum clamping value (default is 0)
  82528. * @param max defines maximum clamping value (default is 1)
  82529. * @param result defines color to store the result into
  82530. * @returns the original Color3
  82531. */
  82532. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  82533. /**
  82534. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  82535. * @param otherColor defines the second operand
  82536. * @returns the new Color3
  82537. */
  82538. add(otherColor: DeepImmutable<Color3>): Color3;
  82539. /**
  82540. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  82541. * @param otherColor defines the second operand
  82542. * @param result defines Color3 object to store the result into
  82543. * @returns the unmodified current Color3
  82544. */
  82545. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  82546. /**
  82547. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  82548. * @param otherColor defines the second operand
  82549. * @returns the new Color3
  82550. */
  82551. subtract(otherColor: DeepImmutable<Color3>): Color3;
  82552. /**
  82553. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  82554. * @param otherColor defines the second operand
  82555. * @param result defines Color3 object to store the result into
  82556. * @returns the unmodified current Color3
  82557. */
  82558. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  82559. /**
  82560. * Copy the current object
  82561. * @returns a new Color3 copied the current one
  82562. */
  82563. clone(): Color3;
  82564. /**
  82565. * Copies the rgb values from the source in the current Color3
  82566. * @param source defines the source Color3 object
  82567. * @returns the updated Color3 object
  82568. */
  82569. copyFrom(source: DeepImmutable<Color3>): Color3;
  82570. /**
  82571. * Updates the Color3 rgb values from the given floats
  82572. * @param r defines the red component to read from
  82573. * @param g defines the green component to read from
  82574. * @param b defines the blue component to read from
  82575. * @returns the current Color3 object
  82576. */
  82577. copyFromFloats(r: number, g: number, b: number): Color3;
  82578. /**
  82579. * Updates the Color3 rgb values from the given floats
  82580. * @param r defines the red component to read from
  82581. * @param g defines the green component to read from
  82582. * @param b defines the blue component to read from
  82583. * @returns the current Color3 object
  82584. */
  82585. set(r: number, g: number, b: number): Color3;
  82586. /**
  82587. * Compute the Color3 hexadecimal code as a string
  82588. * @returns a string containing the hexadecimal representation of the Color3 object
  82589. */
  82590. toHexString(): string;
  82591. /**
  82592. * Computes a new Color3 converted from the current one to linear space
  82593. * @returns a new Color3 object
  82594. */
  82595. toLinearSpace(): Color3;
  82596. /**
  82597. * Converts current color in rgb space to HSV values
  82598. * @returns a new color3 representing the HSV values
  82599. */
  82600. toHSV(): Color3;
  82601. /**
  82602. * Converts current color in rgb space to HSV values
  82603. * @param result defines the Color3 where to store the HSV values
  82604. */
  82605. toHSVToRef(result: Color3): void;
  82606. /**
  82607. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  82608. * @param convertedColor defines the Color3 object where to store the linear space version
  82609. * @returns the unmodified Color3
  82610. */
  82611. toLinearSpaceToRef(convertedColor: Color3): Color3;
  82612. /**
  82613. * Computes a new Color3 converted from the current one to gamma space
  82614. * @returns a new Color3 object
  82615. */
  82616. toGammaSpace(): Color3;
  82617. /**
  82618. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  82619. * @param convertedColor defines the Color3 object where to store the gamma space version
  82620. * @returns the unmodified Color3
  82621. */
  82622. toGammaSpaceToRef(convertedColor: Color3): Color3;
  82623. private static _BlackReadOnly;
  82624. /**
  82625. * Convert Hue, saturation and value to a Color3 (RGB)
  82626. * @param hue defines the hue
  82627. * @param saturation defines the saturation
  82628. * @param value defines the value
  82629. * @param result defines the Color3 where to store the RGB values
  82630. */
  82631. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  82632. /**
  82633. * Creates a new Color3 from the string containing valid hexadecimal values
  82634. * @param hex defines a string containing valid hexadecimal values
  82635. * @returns a new Color3 object
  82636. */
  82637. static FromHexString(hex: string): Color3;
  82638. /**
  82639. * Creates a new Color3 from the starting index of the given array
  82640. * @param array defines the source array
  82641. * @param offset defines an offset in the source array
  82642. * @returns a new Color3 object
  82643. */
  82644. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  82645. /**
  82646. * Creates a new Color3 from integer values (< 256)
  82647. * @param r defines the red component to read from (value between 0 and 255)
  82648. * @param g defines the green component to read from (value between 0 and 255)
  82649. * @param b defines the blue component to read from (value between 0 and 255)
  82650. * @returns a new Color3 object
  82651. */
  82652. static FromInts(r: number, g: number, b: number): Color3;
  82653. /**
  82654. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  82655. * @param start defines the start Color3 value
  82656. * @param end defines the end Color3 value
  82657. * @param amount defines the gradient value between start and end
  82658. * @returns a new Color3 object
  82659. */
  82660. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  82661. /**
  82662. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  82663. * @param left defines the start value
  82664. * @param right defines the end value
  82665. * @param amount defines the gradient factor
  82666. * @param result defines the Color3 object where to store the result
  82667. */
  82668. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  82669. /**
  82670. * Returns a Color3 value containing a red color
  82671. * @returns a new Color3 object
  82672. */
  82673. static Red(): Color3;
  82674. /**
  82675. * Returns a Color3 value containing a green color
  82676. * @returns a new Color3 object
  82677. */
  82678. static Green(): Color3;
  82679. /**
  82680. * Returns a Color3 value containing a blue color
  82681. * @returns a new Color3 object
  82682. */
  82683. static Blue(): Color3;
  82684. /**
  82685. * Returns a Color3 value containing a black color
  82686. * @returns a new Color3 object
  82687. */
  82688. static Black(): Color3;
  82689. /**
  82690. * Gets a Color3 value containing a black color that must not be updated
  82691. */
  82692. static get BlackReadOnly(): DeepImmutable<Color3>;
  82693. /**
  82694. * Returns a Color3 value containing a white color
  82695. * @returns a new Color3 object
  82696. */
  82697. static White(): Color3;
  82698. /**
  82699. * Returns a Color3 value containing a purple color
  82700. * @returns a new Color3 object
  82701. */
  82702. static Purple(): Color3;
  82703. /**
  82704. * Returns a Color3 value containing a magenta color
  82705. * @returns a new Color3 object
  82706. */
  82707. static Magenta(): Color3;
  82708. /**
  82709. * Returns a Color3 value containing a yellow color
  82710. * @returns a new Color3 object
  82711. */
  82712. static Yellow(): Color3;
  82713. /**
  82714. * Returns a Color3 value containing a gray color
  82715. * @returns a new Color3 object
  82716. */
  82717. static Gray(): Color3;
  82718. /**
  82719. * Returns a Color3 value containing a teal color
  82720. * @returns a new Color3 object
  82721. */
  82722. static Teal(): Color3;
  82723. /**
  82724. * Returns a Color3 value containing a random color
  82725. * @returns a new Color3 object
  82726. */
  82727. static Random(): Color3;
  82728. }
  82729. /**
  82730. * Class used to hold a RBGA color
  82731. */
  82732. export class Color4 {
  82733. /**
  82734. * Defines the red component (between 0 and 1, default is 0)
  82735. */
  82736. r: number;
  82737. /**
  82738. * Defines the green component (between 0 and 1, default is 0)
  82739. */
  82740. g: number;
  82741. /**
  82742. * Defines the blue component (between 0 and 1, default is 0)
  82743. */
  82744. b: number;
  82745. /**
  82746. * Defines the alpha component (between 0 and 1, default is 1)
  82747. */
  82748. a: number;
  82749. /**
  82750. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  82751. * @param r defines the red component (between 0 and 1, default is 0)
  82752. * @param g defines the green component (between 0 and 1, default is 0)
  82753. * @param b defines the blue component (between 0 and 1, default is 0)
  82754. * @param a defines the alpha component (between 0 and 1, default is 1)
  82755. */
  82756. constructor(
  82757. /**
  82758. * Defines the red component (between 0 and 1, default is 0)
  82759. */
  82760. r?: number,
  82761. /**
  82762. * Defines the green component (between 0 and 1, default is 0)
  82763. */
  82764. g?: number,
  82765. /**
  82766. * Defines the blue component (between 0 and 1, default is 0)
  82767. */
  82768. b?: number,
  82769. /**
  82770. * Defines the alpha component (between 0 and 1, default is 1)
  82771. */
  82772. a?: number);
  82773. /**
  82774. * Adds in place the given Color4 values to the current Color4 object
  82775. * @param right defines the second operand
  82776. * @returns the current updated Color4 object
  82777. */
  82778. addInPlace(right: DeepImmutable<Color4>): Color4;
  82779. /**
  82780. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  82781. * @returns the new array
  82782. */
  82783. asArray(): number[];
  82784. /**
  82785. * Stores from the starting index in the given array the Color4 successive values
  82786. * @param array defines the array where to store the r,g,b components
  82787. * @param index defines an optional index in the target array to define where to start storing values
  82788. * @returns the current Color4 object
  82789. */
  82790. toArray(array: number[], index?: number): Color4;
  82791. /**
  82792. * Determines equality between Color4 objects
  82793. * @param otherColor defines the second operand
  82794. * @returns true if the rgba values are equal to the given ones
  82795. */
  82796. equals(otherColor: DeepImmutable<Color4>): boolean;
  82797. /**
  82798. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  82799. * @param right defines the second operand
  82800. * @returns a new Color4 object
  82801. */
  82802. add(right: DeepImmutable<Color4>): Color4;
  82803. /**
  82804. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  82805. * @param right defines the second operand
  82806. * @returns a new Color4 object
  82807. */
  82808. subtract(right: DeepImmutable<Color4>): Color4;
  82809. /**
  82810. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  82811. * @param right defines the second operand
  82812. * @param result defines the Color4 object where to store the result
  82813. * @returns the current Color4 object
  82814. */
  82815. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  82816. /**
  82817. * Creates a new Color4 with the current Color4 values multiplied by scale
  82818. * @param scale defines the scaling factor to apply
  82819. * @returns a new Color4 object
  82820. */
  82821. scale(scale: number): Color4;
  82822. /**
  82823. * Multiplies the current Color4 values by scale and stores the result in "result"
  82824. * @param scale defines the scaling factor to apply
  82825. * @param result defines the Color4 object where to store the result
  82826. * @returns the current unmodified Color4
  82827. */
  82828. scaleToRef(scale: number, result: Color4): Color4;
  82829. /**
  82830. * Scale the current Color4 values by a factor and add the result to a given Color4
  82831. * @param scale defines the scale factor
  82832. * @param result defines the Color4 object where to store the result
  82833. * @returns the unmodified current Color4
  82834. */
  82835. scaleAndAddToRef(scale: number, result: Color4): Color4;
  82836. /**
  82837. * Clamps the rgb values by the min and max values and stores the result into "result"
  82838. * @param min defines minimum clamping value (default is 0)
  82839. * @param max defines maximum clamping value (default is 1)
  82840. * @param result defines color to store the result into.
  82841. * @returns the cuurent Color4
  82842. */
  82843. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  82844. /**
  82845. * Multipy an Color4 value by another and return a new Color4 object
  82846. * @param color defines the Color4 value to multiply by
  82847. * @returns a new Color4 object
  82848. */
  82849. multiply(color: Color4): Color4;
  82850. /**
  82851. * Multipy a Color4 value by another and push the result in a reference value
  82852. * @param color defines the Color4 value to multiply by
  82853. * @param result defines the Color4 to fill the result in
  82854. * @returns the result Color4
  82855. */
  82856. multiplyToRef(color: Color4, result: Color4): Color4;
  82857. /**
  82858. * Creates a string with the Color4 current values
  82859. * @returns the string representation of the Color4 object
  82860. */
  82861. toString(): string;
  82862. /**
  82863. * Returns the string "Color4"
  82864. * @returns "Color4"
  82865. */
  82866. getClassName(): string;
  82867. /**
  82868. * Compute the Color4 hash code
  82869. * @returns an unique number that can be used to hash Color4 objects
  82870. */
  82871. getHashCode(): number;
  82872. /**
  82873. * Creates a new Color4 copied from the current one
  82874. * @returns a new Color4 object
  82875. */
  82876. clone(): Color4;
  82877. /**
  82878. * Copies the given Color4 values into the current one
  82879. * @param source defines the source Color4 object
  82880. * @returns the current updated Color4 object
  82881. */
  82882. copyFrom(source: Color4): Color4;
  82883. /**
  82884. * Copies the given float values into the current one
  82885. * @param r defines the red component to read from
  82886. * @param g defines the green component to read from
  82887. * @param b defines the blue component to read from
  82888. * @param a defines the alpha component to read from
  82889. * @returns the current updated Color4 object
  82890. */
  82891. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  82892. /**
  82893. * Copies the given float values into the current one
  82894. * @param r defines the red component to read from
  82895. * @param g defines the green component to read from
  82896. * @param b defines the blue component to read from
  82897. * @param a defines the alpha component to read from
  82898. * @returns the current updated Color4 object
  82899. */
  82900. set(r: number, g: number, b: number, a: number): Color4;
  82901. /**
  82902. * Compute the Color4 hexadecimal code as a string
  82903. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  82904. * @returns a string containing the hexadecimal representation of the Color4 object
  82905. */
  82906. toHexString(returnAsColor3?: boolean): string;
  82907. /**
  82908. * Computes a new Color4 converted from the current one to linear space
  82909. * @returns a new Color4 object
  82910. */
  82911. toLinearSpace(): Color4;
  82912. /**
  82913. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  82914. * @param convertedColor defines the Color4 object where to store the linear space version
  82915. * @returns the unmodified Color4
  82916. */
  82917. toLinearSpaceToRef(convertedColor: Color4): Color4;
  82918. /**
  82919. * Computes a new Color4 converted from the current one to gamma space
  82920. * @returns a new Color4 object
  82921. */
  82922. toGammaSpace(): Color4;
  82923. /**
  82924. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  82925. * @param convertedColor defines the Color4 object where to store the gamma space version
  82926. * @returns the unmodified Color4
  82927. */
  82928. toGammaSpaceToRef(convertedColor: Color4): Color4;
  82929. /**
  82930. * Creates a new Color4 from the string containing valid hexadecimal values
  82931. * @param hex defines a string containing valid hexadecimal values
  82932. * @returns a new Color4 object
  82933. */
  82934. static FromHexString(hex: string): Color4;
  82935. /**
  82936. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  82937. * @param left defines the start value
  82938. * @param right defines the end value
  82939. * @param amount defines the gradient factor
  82940. * @returns a new Color4 object
  82941. */
  82942. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  82943. /**
  82944. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  82945. * @param left defines the start value
  82946. * @param right defines the end value
  82947. * @param amount defines the gradient factor
  82948. * @param result defines the Color4 object where to store data
  82949. */
  82950. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  82951. /**
  82952. * Creates a new Color4 from a Color3 and an alpha value
  82953. * @param color3 defines the source Color3 to read from
  82954. * @param alpha defines the alpha component (1.0 by default)
  82955. * @returns a new Color4 object
  82956. */
  82957. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  82958. /**
  82959. * Creates a new Color4 from the starting index element of the given array
  82960. * @param array defines the source array to read from
  82961. * @param offset defines the offset in the source array
  82962. * @returns a new Color4 object
  82963. */
  82964. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  82965. /**
  82966. * Creates a new Color3 from integer values (< 256)
  82967. * @param r defines the red component to read from (value between 0 and 255)
  82968. * @param g defines the green component to read from (value between 0 and 255)
  82969. * @param b defines the blue component to read from (value between 0 and 255)
  82970. * @param a defines the alpha component to read from (value between 0 and 255)
  82971. * @returns a new Color3 object
  82972. */
  82973. static FromInts(r: number, g: number, b: number, a: number): Color4;
  82974. /**
  82975. * Check the content of a given array and convert it to an array containing RGBA data
  82976. * If the original array was already containing count * 4 values then it is returned directly
  82977. * @param colors defines the array to check
  82978. * @param count defines the number of RGBA data to expect
  82979. * @returns an array containing count * 4 values (RGBA)
  82980. */
  82981. static CheckColors4(colors: number[], count: number): number[];
  82982. }
  82983. /**
  82984. * @hidden
  82985. */
  82986. export class TmpColors {
  82987. static Color3: Color3[];
  82988. static Color4: Color4[];
  82989. }
  82990. }
  82991. declare module BABYLON {
  82992. /**
  82993. * Defines an interface which represents an animation key frame
  82994. */
  82995. export interface IAnimationKey {
  82996. /**
  82997. * Frame of the key frame
  82998. */
  82999. frame: number;
  83000. /**
  83001. * Value at the specifies key frame
  83002. */
  83003. value: any;
  83004. /**
  83005. * The input tangent for the cubic hermite spline
  83006. */
  83007. inTangent?: any;
  83008. /**
  83009. * The output tangent for the cubic hermite spline
  83010. */
  83011. outTangent?: any;
  83012. /**
  83013. * The animation interpolation type
  83014. */
  83015. interpolation?: AnimationKeyInterpolation;
  83016. }
  83017. /**
  83018. * Enum for the animation key frame interpolation type
  83019. */
  83020. export enum AnimationKeyInterpolation {
  83021. /**
  83022. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  83023. */
  83024. STEP = 1
  83025. }
  83026. }
  83027. declare module BABYLON {
  83028. /**
  83029. * Represents the range of an animation
  83030. */
  83031. export class AnimationRange {
  83032. /**The name of the animation range**/
  83033. name: string;
  83034. /**The starting frame of the animation */
  83035. from: number;
  83036. /**The ending frame of the animation*/
  83037. to: number;
  83038. /**
  83039. * Initializes the range of an animation
  83040. * @param name The name of the animation range
  83041. * @param from The starting frame of the animation
  83042. * @param to The ending frame of the animation
  83043. */
  83044. constructor(
  83045. /**The name of the animation range**/
  83046. name: string,
  83047. /**The starting frame of the animation */
  83048. from: number,
  83049. /**The ending frame of the animation*/
  83050. to: number);
  83051. /**
  83052. * Makes a copy of the animation range
  83053. * @returns A copy of the animation range
  83054. */
  83055. clone(): AnimationRange;
  83056. }
  83057. }
  83058. declare module BABYLON {
  83059. /**
  83060. * Composed of a frame, and an action function
  83061. */
  83062. export class AnimationEvent {
  83063. /** The frame for which the event is triggered **/
  83064. frame: number;
  83065. /** The event to perform when triggered **/
  83066. action: (currentFrame: number) => void;
  83067. /** Specifies if the event should be triggered only once**/
  83068. onlyOnce?: boolean | undefined;
  83069. /**
  83070. * Specifies if the animation event is done
  83071. */
  83072. isDone: boolean;
  83073. /**
  83074. * Initializes the animation event
  83075. * @param frame The frame for which the event is triggered
  83076. * @param action The event to perform when triggered
  83077. * @param onlyOnce Specifies if the event should be triggered only once
  83078. */
  83079. constructor(
  83080. /** The frame for which the event is triggered **/
  83081. frame: number,
  83082. /** The event to perform when triggered **/
  83083. action: (currentFrame: number) => void,
  83084. /** Specifies if the event should be triggered only once**/
  83085. onlyOnce?: boolean | undefined);
  83086. /** @hidden */
  83087. _clone(): AnimationEvent;
  83088. }
  83089. }
  83090. declare module BABYLON {
  83091. /**
  83092. * Interface used to define a behavior
  83093. */
  83094. export interface Behavior<T> {
  83095. /** gets or sets behavior's name */
  83096. name: string;
  83097. /**
  83098. * Function called when the behavior needs to be initialized (after attaching it to a target)
  83099. */
  83100. init(): void;
  83101. /**
  83102. * Called when the behavior is attached to a target
  83103. * @param target defines the target where the behavior is attached to
  83104. */
  83105. attach(target: T): void;
  83106. /**
  83107. * Called when the behavior is detached from its target
  83108. */
  83109. detach(): void;
  83110. }
  83111. /**
  83112. * Interface implemented by classes supporting behaviors
  83113. */
  83114. export interface IBehaviorAware<T> {
  83115. /**
  83116. * Attach a behavior
  83117. * @param behavior defines the behavior to attach
  83118. * @returns the current host
  83119. */
  83120. addBehavior(behavior: Behavior<T>): T;
  83121. /**
  83122. * Remove a behavior from the current object
  83123. * @param behavior defines the behavior to detach
  83124. * @returns the current host
  83125. */
  83126. removeBehavior(behavior: Behavior<T>): T;
  83127. /**
  83128. * Gets a behavior using its name to search
  83129. * @param name defines the name to search
  83130. * @returns the behavior or null if not found
  83131. */
  83132. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  83133. }
  83134. }
  83135. declare module BABYLON {
  83136. /**
  83137. * Defines an array and its length.
  83138. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  83139. */
  83140. export interface ISmartArrayLike<T> {
  83141. /**
  83142. * The data of the array.
  83143. */
  83144. data: Array<T>;
  83145. /**
  83146. * The active length of the array.
  83147. */
  83148. length: number;
  83149. }
  83150. /**
  83151. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  83152. */
  83153. export class SmartArray<T> implements ISmartArrayLike<T> {
  83154. /**
  83155. * The full set of data from the array.
  83156. */
  83157. data: Array<T>;
  83158. /**
  83159. * The active length of the array.
  83160. */
  83161. length: number;
  83162. protected _id: number;
  83163. /**
  83164. * Instantiates a Smart Array.
  83165. * @param capacity defines the default capacity of the array.
  83166. */
  83167. constructor(capacity: number);
  83168. /**
  83169. * Pushes a value at the end of the active data.
  83170. * @param value defines the object to push in the array.
  83171. */
  83172. push(value: T): void;
  83173. /**
  83174. * Iterates over the active data and apply the lambda to them.
  83175. * @param func defines the action to apply on each value.
  83176. */
  83177. forEach(func: (content: T) => void): void;
  83178. /**
  83179. * Sorts the full sets of data.
  83180. * @param compareFn defines the comparison function to apply.
  83181. */
  83182. sort(compareFn: (a: T, b: T) => number): void;
  83183. /**
  83184. * Resets the active data to an empty array.
  83185. */
  83186. reset(): void;
  83187. /**
  83188. * Releases all the data from the array as well as the array.
  83189. */
  83190. dispose(): void;
  83191. /**
  83192. * Concats the active data with a given array.
  83193. * @param array defines the data to concatenate with.
  83194. */
  83195. concat(array: any): void;
  83196. /**
  83197. * Returns the position of a value in the active data.
  83198. * @param value defines the value to find the index for
  83199. * @returns the index if found in the active data otherwise -1
  83200. */
  83201. indexOf(value: T): number;
  83202. /**
  83203. * Returns whether an element is part of the active data.
  83204. * @param value defines the value to look for
  83205. * @returns true if found in the active data otherwise false
  83206. */
  83207. contains(value: T): boolean;
  83208. private static _GlobalId;
  83209. }
  83210. /**
  83211. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  83212. * The data in this array can only be present once
  83213. */
  83214. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  83215. private _duplicateId;
  83216. /**
  83217. * Pushes a value at the end of the active data.
  83218. * THIS DOES NOT PREVENT DUPPLICATE DATA
  83219. * @param value defines the object to push in the array.
  83220. */
  83221. push(value: T): void;
  83222. /**
  83223. * Pushes a value at the end of the active data.
  83224. * If the data is already present, it won t be added again
  83225. * @param value defines the object to push in the array.
  83226. * @returns true if added false if it was already present
  83227. */
  83228. pushNoDuplicate(value: T): boolean;
  83229. /**
  83230. * Resets the active data to an empty array.
  83231. */
  83232. reset(): void;
  83233. /**
  83234. * Concats the active data with a given array.
  83235. * This ensures no dupplicate will be present in the result.
  83236. * @param array defines the data to concatenate with.
  83237. */
  83238. concatWithNoDuplicate(array: any): void;
  83239. }
  83240. }
  83241. declare module BABYLON {
  83242. /**
  83243. * @ignore
  83244. * This is a list of all the different input types that are available in the application.
  83245. * Fo instance: ArcRotateCameraGamepadInput...
  83246. */
  83247. export var CameraInputTypes: {};
  83248. /**
  83249. * This is the contract to implement in order to create a new input class.
  83250. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  83251. */
  83252. export interface ICameraInput<TCamera extends Camera> {
  83253. /**
  83254. * Defines the camera the input is attached to.
  83255. */
  83256. camera: Nullable<TCamera>;
  83257. /**
  83258. * Gets the class name of the current intput.
  83259. * @returns the class name
  83260. */
  83261. getClassName(): string;
  83262. /**
  83263. * Get the friendly name associated with the input class.
  83264. * @returns the input friendly name
  83265. */
  83266. getSimpleName(): string;
  83267. /**
  83268. * Attach the input controls to a specific dom element to get the input from.
  83269. * @param element Defines the element the controls should be listened from
  83270. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  83271. */
  83272. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  83273. /**
  83274. * Detach the current controls from the specified dom element.
  83275. * @param element Defines the element to stop listening the inputs from
  83276. */
  83277. detachControl(element: Nullable<HTMLElement>): void;
  83278. /**
  83279. * Update the current camera state depending on the inputs that have been used this frame.
  83280. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  83281. */
  83282. checkInputs?: () => void;
  83283. }
  83284. /**
  83285. * Represents a map of input types to input instance or input index to input instance.
  83286. */
  83287. export interface CameraInputsMap<TCamera extends Camera> {
  83288. /**
  83289. * Accessor to the input by input type.
  83290. */
  83291. [name: string]: ICameraInput<TCamera>;
  83292. /**
  83293. * Accessor to the input by input index.
  83294. */
  83295. [idx: number]: ICameraInput<TCamera>;
  83296. }
  83297. /**
  83298. * This represents the input manager used within a camera.
  83299. * It helps dealing with all the different kind of input attached to a camera.
  83300. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  83301. */
  83302. export class CameraInputsManager<TCamera extends Camera> {
  83303. /**
  83304. * Defines the list of inputs attahed to the camera.
  83305. */
  83306. attached: CameraInputsMap<TCamera>;
  83307. /**
  83308. * Defines the dom element the camera is collecting inputs from.
  83309. * This is null if the controls have not been attached.
  83310. */
  83311. attachedElement: Nullable<HTMLElement>;
  83312. /**
  83313. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  83314. */
  83315. noPreventDefault: boolean;
  83316. /**
  83317. * Defined the camera the input manager belongs to.
  83318. */
  83319. camera: TCamera;
  83320. /**
  83321. * Update the current camera state depending on the inputs that have been used this frame.
  83322. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  83323. */
  83324. checkInputs: () => void;
  83325. /**
  83326. * Instantiate a new Camera Input Manager.
  83327. * @param camera Defines the camera the input manager blongs to
  83328. */
  83329. constructor(camera: TCamera);
  83330. /**
  83331. * Add an input method to a camera
  83332. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  83333. * @param input camera input method
  83334. */
  83335. add(input: ICameraInput<TCamera>): void;
  83336. /**
  83337. * Remove a specific input method from a camera
  83338. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  83339. * @param inputToRemove camera input method
  83340. */
  83341. remove(inputToRemove: ICameraInput<TCamera>): void;
  83342. /**
  83343. * Remove a specific input type from a camera
  83344. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  83345. * @param inputType the type of the input to remove
  83346. */
  83347. removeByType(inputType: string): void;
  83348. private _addCheckInputs;
  83349. /**
  83350. * Attach the input controls to the currently attached dom element to listen the events from.
  83351. * @param input Defines the input to attach
  83352. */
  83353. attachInput(input: ICameraInput<TCamera>): void;
  83354. /**
  83355. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  83356. * @param element Defines the dom element to collect the events from
  83357. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  83358. */
  83359. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  83360. /**
  83361. * Detach the current manager inputs controls from a specific dom element.
  83362. * @param element Defines the dom element to collect the events from
  83363. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  83364. */
  83365. detachElement(element: HTMLElement, disconnect?: boolean): void;
  83366. /**
  83367. * Rebuild the dynamic inputCheck function from the current list of
  83368. * defined inputs in the manager.
  83369. */
  83370. rebuildInputCheck(): void;
  83371. /**
  83372. * Remove all attached input methods from a camera
  83373. */
  83374. clear(): void;
  83375. /**
  83376. * Serialize the current input manager attached to a camera.
  83377. * This ensures than once parsed,
  83378. * the input associated to the camera will be identical to the current ones
  83379. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  83380. */
  83381. serialize(serializedCamera: any): void;
  83382. /**
  83383. * Parses an input manager serialized JSON to restore the previous list of inputs
  83384. * and states associated to a camera.
  83385. * @param parsedCamera Defines the JSON to parse
  83386. */
  83387. parse(parsedCamera: any): void;
  83388. }
  83389. }
  83390. declare module BABYLON {
  83391. /**
  83392. * Class used to store data that will be store in GPU memory
  83393. */
  83394. export class Buffer {
  83395. private _engine;
  83396. private _buffer;
  83397. /** @hidden */
  83398. _data: Nullable<DataArray>;
  83399. private _updatable;
  83400. private _instanced;
  83401. private _divisor;
  83402. /**
  83403. * Gets the byte stride.
  83404. */
  83405. readonly byteStride: number;
  83406. /**
  83407. * Constructor
  83408. * @param engine the engine
  83409. * @param data the data to use for this buffer
  83410. * @param updatable whether the data is updatable
  83411. * @param stride the stride (optional)
  83412. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  83413. * @param instanced whether the buffer is instanced (optional)
  83414. * @param useBytes set to true if the stride in in bytes (optional)
  83415. * @param divisor sets an optional divisor for instances (1 by default)
  83416. */
  83417. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  83418. /**
  83419. * Create a new VertexBuffer based on the current buffer
  83420. * @param kind defines the vertex buffer kind (position, normal, etc.)
  83421. * @param offset defines offset in the buffer (0 by default)
  83422. * @param size defines the size in floats of attributes (position is 3 for instance)
  83423. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  83424. * @param instanced defines if the vertex buffer contains indexed data
  83425. * @param useBytes defines if the offset and stride are in bytes *
  83426. * @param divisor sets an optional divisor for instances (1 by default)
  83427. * @returns the new vertex buffer
  83428. */
  83429. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  83430. /**
  83431. * Gets a boolean indicating if the Buffer is updatable?
  83432. * @returns true if the buffer is updatable
  83433. */
  83434. isUpdatable(): boolean;
  83435. /**
  83436. * Gets current buffer's data
  83437. * @returns a DataArray or null
  83438. */
  83439. getData(): Nullable<DataArray>;
  83440. /**
  83441. * Gets underlying native buffer
  83442. * @returns underlying native buffer
  83443. */
  83444. getBuffer(): Nullable<DataBuffer>;
  83445. /**
  83446. * Gets the stride in float32 units (i.e. byte stride / 4).
  83447. * May not be an integer if the byte stride is not divisible by 4.
  83448. * @returns the stride in float32 units
  83449. * @deprecated Please use byteStride instead.
  83450. */
  83451. getStrideSize(): number;
  83452. /**
  83453. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  83454. * @param data defines the data to store
  83455. */
  83456. create(data?: Nullable<DataArray>): void;
  83457. /** @hidden */
  83458. _rebuild(): void;
  83459. /**
  83460. * Update current buffer data
  83461. * @param data defines the data to store
  83462. */
  83463. update(data: DataArray): void;
  83464. /**
  83465. * Updates the data directly.
  83466. * @param data the new data
  83467. * @param offset the new offset
  83468. * @param vertexCount the vertex count (optional)
  83469. * @param useBytes set to true if the offset is in bytes
  83470. */
  83471. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  83472. /**
  83473. * Release all resources
  83474. */
  83475. dispose(): void;
  83476. }
  83477. /**
  83478. * Specialized buffer used to store vertex data
  83479. */
  83480. export class VertexBuffer {
  83481. /** @hidden */
  83482. _buffer: Buffer;
  83483. private _kind;
  83484. private _size;
  83485. private _ownsBuffer;
  83486. private _instanced;
  83487. private _instanceDivisor;
  83488. /**
  83489. * The byte type.
  83490. */
  83491. static readonly BYTE: number;
  83492. /**
  83493. * The unsigned byte type.
  83494. */
  83495. static readonly UNSIGNED_BYTE: number;
  83496. /**
  83497. * The short type.
  83498. */
  83499. static readonly SHORT: number;
  83500. /**
  83501. * The unsigned short type.
  83502. */
  83503. static readonly UNSIGNED_SHORT: number;
  83504. /**
  83505. * The integer type.
  83506. */
  83507. static readonly INT: number;
  83508. /**
  83509. * The unsigned integer type.
  83510. */
  83511. static readonly UNSIGNED_INT: number;
  83512. /**
  83513. * The float type.
  83514. */
  83515. static readonly FLOAT: number;
  83516. /**
  83517. * Gets or sets the instance divisor when in instanced mode
  83518. */
  83519. get instanceDivisor(): number;
  83520. set instanceDivisor(value: number);
  83521. /**
  83522. * Gets the byte stride.
  83523. */
  83524. readonly byteStride: number;
  83525. /**
  83526. * Gets the byte offset.
  83527. */
  83528. readonly byteOffset: number;
  83529. /**
  83530. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  83531. */
  83532. readonly normalized: boolean;
  83533. /**
  83534. * Gets the data type of each component in the array.
  83535. */
  83536. readonly type: number;
  83537. /**
  83538. * Constructor
  83539. * @param engine the engine
  83540. * @param data the data to use for this vertex buffer
  83541. * @param kind the vertex buffer kind
  83542. * @param updatable whether the data is updatable
  83543. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  83544. * @param stride the stride (optional)
  83545. * @param instanced whether the buffer is instanced (optional)
  83546. * @param offset the offset of the data (optional)
  83547. * @param size the number of components (optional)
  83548. * @param type the type of the component (optional)
  83549. * @param normalized whether the data contains normalized data (optional)
  83550. * @param useBytes set to true if stride and offset are in bytes (optional)
  83551. * @param divisor defines the instance divisor to use (1 by default)
  83552. */
  83553. 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);
  83554. /** @hidden */
  83555. _rebuild(): void;
  83556. /**
  83557. * Returns the kind of the VertexBuffer (string)
  83558. * @returns a string
  83559. */
  83560. getKind(): string;
  83561. /**
  83562. * Gets a boolean indicating if the VertexBuffer is updatable?
  83563. * @returns true if the buffer is updatable
  83564. */
  83565. isUpdatable(): boolean;
  83566. /**
  83567. * Gets current buffer's data
  83568. * @returns a DataArray or null
  83569. */
  83570. getData(): Nullable<DataArray>;
  83571. /**
  83572. * Gets underlying native buffer
  83573. * @returns underlying native buffer
  83574. */
  83575. getBuffer(): Nullable<DataBuffer>;
  83576. /**
  83577. * Gets the stride in float32 units (i.e. byte stride / 4).
  83578. * May not be an integer if the byte stride is not divisible by 4.
  83579. * @returns the stride in float32 units
  83580. * @deprecated Please use byteStride instead.
  83581. */
  83582. getStrideSize(): number;
  83583. /**
  83584. * Returns the offset as a multiple of the type byte length.
  83585. * @returns the offset in bytes
  83586. * @deprecated Please use byteOffset instead.
  83587. */
  83588. getOffset(): number;
  83589. /**
  83590. * Returns the number of components per vertex attribute (integer)
  83591. * @returns the size in float
  83592. */
  83593. getSize(): number;
  83594. /**
  83595. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  83596. * @returns true if this buffer is instanced
  83597. */
  83598. getIsInstanced(): boolean;
  83599. /**
  83600. * Returns the instancing divisor, zero for non-instanced (integer).
  83601. * @returns a number
  83602. */
  83603. getInstanceDivisor(): number;
  83604. /**
  83605. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  83606. * @param data defines the data to store
  83607. */
  83608. create(data?: DataArray): void;
  83609. /**
  83610. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  83611. * This function will create a new buffer if the current one is not updatable
  83612. * @param data defines the data to store
  83613. */
  83614. update(data: DataArray): void;
  83615. /**
  83616. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  83617. * Returns the directly updated WebGLBuffer.
  83618. * @param data the new data
  83619. * @param offset the new offset
  83620. * @param useBytes set to true if the offset is in bytes
  83621. */
  83622. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  83623. /**
  83624. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  83625. */
  83626. dispose(): void;
  83627. /**
  83628. * Enumerates each value of this vertex buffer as numbers.
  83629. * @param count the number of values to enumerate
  83630. * @param callback the callback function called for each value
  83631. */
  83632. forEach(count: number, callback: (value: number, index: number) => void): void;
  83633. /**
  83634. * Positions
  83635. */
  83636. static readonly PositionKind: string;
  83637. /**
  83638. * Normals
  83639. */
  83640. static readonly NormalKind: string;
  83641. /**
  83642. * Tangents
  83643. */
  83644. static readonly TangentKind: string;
  83645. /**
  83646. * Texture coordinates
  83647. */
  83648. static readonly UVKind: string;
  83649. /**
  83650. * Texture coordinates 2
  83651. */
  83652. static readonly UV2Kind: string;
  83653. /**
  83654. * Texture coordinates 3
  83655. */
  83656. static readonly UV3Kind: string;
  83657. /**
  83658. * Texture coordinates 4
  83659. */
  83660. static readonly UV4Kind: string;
  83661. /**
  83662. * Texture coordinates 5
  83663. */
  83664. static readonly UV5Kind: string;
  83665. /**
  83666. * Texture coordinates 6
  83667. */
  83668. static readonly UV6Kind: string;
  83669. /**
  83670. * Colors
  83671. */
  83672. static readonly ColorKind: string;
  83673. /**
  83674. * Matrix indices (for bones)
  83675. */
  83676. static readonly MatricesIndicesKind: string;
  83677. /**
  83678. * Matrix weights (for bones)
  83679. */
  83680. static readonly MatricesWeightsKind: string;
  83681. /**
  83682. * Additional matrix indices (for bones)
  83683. */
  83684. static readonly MatricesIndicesExtraKind: string;
  83685. /**
  83686. * Additional matrix weights (for bones)
  83687. */
  83688. static readonly MatricesWeightsExtraKind: string;
  83689. /**
  83690. * Deduces the stride given a kind.
  83691. * @param kind The kind string to deduce
  83692. * @returns The deduced stride
  83693. */
  83694. static DeduceStride(kind: string): number;
  83695. /**
  83696. * Gets the byte length of the given type.
  83697. * @param type the type
  83698. * @returns the number of bytes
  83699. */
  83700. static GetTypeByteLength(type: number): number;
  83701. /**
  83702. * Enumerates each value of the given parameters as numbers.
  83703. * @param data the data to enumerate
  83704. * @param byteOffset the byte offset of the data
  83705. * @param byteStride the byte stride of the data
  83706. * @param componentCount the number of components per element
  83707. * @param componentType the type of the component
  83708. * @param count the number of values to enumerate
  83709. * @param normalized whether the data is normalized
  83710. * @param callback the callback function called for each value
  83711. */
  83712. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  83713. private static _GetFloatValue;
  83714. }
  83715. }
  83716. declare module BABYLON {
  83717. /**
  83718. * @hidden
  83719. */
  83720. export class IntersectionInfo {
  83721. bu: Nullable<number>;
  83722. bv: Nullable<number>;
  83723. distance: number;
  83724. faceId: number;
  83725. subMeshId: number;
  83726. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  83727. }
  83728. }
  83729. declare module BABYLON {
  83730. /**
  83731. * Class used to store bounding sphere information
  83732. */
  83733. export class BoundingSphere {
  83734. /**
  83735. * Gets the center of the bounding sphere in local space
  83736. */
  83737. readonly center: Vector3;
  83738. /**
  83739. * Radius of the bounding sphere in local space
  83740. */
  83741. radius: number;
  83742. /**
  83743. * Gets the center of the bounding sphere in world space
  83744. */
  83745. readonly centerWorld: Vector3;
  83746. /**
  83747. * Radius of the bounding sphere in world space
  83748. */
  83749. radiusWorld: number;
  83750. /**
  83751. * Gets the minimum vector in local space
  83752. */
  83753. readonly minimum: Vector3;
  83754. /**
  83755. * Gets the maximum vector in local space
  83756. */
  83757. readonly maximum: Vector3;
  83758. private _worldMatrix;
  83759. private static readonly TmpVector3;
  83760. /**
  83761. * Creates a new bounding sphere
  83762. * @param min defines the minimum vector (in local space)
  83763. * @param max defines the maximum vector (in local space)
  83764. * @param worldMatrix defines the new world matrix
  83765. */
  83766. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  83767. /**
  83768. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  83769. * @param min defines the new minimum vector (in local space)
  83770. * @param max defines the new maximum vector (in local space)
  83771. * @param worldMatrix defines the new world matrix
  83772. */
  83773. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  83774. /**
  83775. * Scale the current bounding sphere by applying a scale factor
  83776. * @param factor defines the scale factor to apply
  83777. * @returns the current bounding box
  83778. */
  83779. scale(factor: number): BoundingSphere;
  83780. /**
  83781. * Gets the world matrix of the bounding box
  83782. * @returns a matrix
  83783. */
  83784. getWorldMatrix(): DeepImmutable<Matrix>;
  83785. /** @hidden */
  83786. _update(worldMatrix: DeepImmutable<Matrix>): void;
  83787. /**
  83788. * Tests if the bounding sphere is intersecting the frustum planes
  83789. * @param frustumPlanes defines the frustum planes to test
  83790. * @returns true if there is an intersection
  83791. */
  83792. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  83793. /**
  83794. * Tests if the bounding sphere center is in between the frustum planes.
  83795. * Used for optimistic fast inclusion.
  83796. * @param frustumPlanes defines the frustum planes to test
  83797. * @returns true if the sphere center is in between the frustum planes
  83798. */
  83799. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  83800. /**
  83801. * Tests if a point is inside the bounding sphere
  83802. * @param point defines the point to test
  83803. * @returns true if the point is inside the bounding sphere
  83804. */
  83805. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  83806. /**
  83807. * Checks if two sphere intersct
  83808. * @param sphere0 sphere 0
  83809. * @param sphere1 sphere 1
  83810. * @returns true if the speres intersect
  83811. */
  83812. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  83813. }
  83814. }
  83815. declare module BABYLON {
  83816. /**
  83817. * Class used to store bounding box information
  83818. */
  83819. export class BoundingBox implements ICullable {
  83820. /**
  83821. * Gets the 8 vectors representing the bounding box in local space
  83822. */
  83823. readonly vectors: Vector3[];
  83824. /**
  83825. * Gets the center of the bounding box in local space
  83826. */
  83827. readonly center: Vector3;
  83828. /**
  83829. * Gets the center of the bounding box in world space
  83830. */
  83831. readonly centerWorld: Vector3;
  83832. /**
  83833. * Gets the extend size in local space
  83834. */
  83835. readonly extendSize: Vector3;
  83836. /**
  83837. * Gets the extend size in world space
  83838. */
  83839. readonly extendSizeWorld: Vector3;
  83840. /**
  83841. * Gets the OBB (object bounding box) directions
  83842. */
  83843. readonly directions: Vector3[];
  83844. /**
  83845. * Gets the 8 vectors representing the bounding box in world space
  83846. */
  83847. readonly vectorsWorld: Vector3[];
  83848. /**
  83849. * Gets the minimum vector in world space
  83850. */
  83851. readonly minimumWorld: Vector3;
  83852. /**
  83853. * Gets the maximum vector in world space
  83854. */
  83855. readonly maximumWorld: Vector3;
  83856. /**
  83857. * Gets the minimum vector in local space
  83858. */
  83859. readonly minimum: Vector3;
  83860. /**
  83861. * Gets the maximum vector in local space
  83862. */
  83863. readonly maximum: Vector3;
  83864. private _worldMatrix;
  83865. private static readonly TmpVector3;
  83866. /**
  83867. * @hidden
  83868. */
  83869. _tag: number;
  83870. /**
  83871. * Creates a new bounding box
  83872. * @param min defines the minimum vector (in local space)
  83873. * @param max defines the maximum vector (in local space)
  83874. * @param worldMatrix defines the new world matrix
  83875. */
  83876. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  83877. /**
  83878. * Recreates the entire bounding box from scratch as if we call the constructor in place
  83879. * @param min defines the new minimum vector (in local space)
  83880. * @param max defines the new maximum vector (in local space)
  83881. * @param worldMatrix defines the new world matrix
  83882. */
  83883. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  83884. /**
  83885. * Scale the current bounding box by applying a scale factor
  83886. * @param factor defines the scale factor to apply
  83887. * @returns the current bounding box
  83888. */
  83889. scale(factor: number): BoundingBox;
  83890. /**
  83891. * Gets the world matrix of the bounding box
  83892. * @returns a matrix
  83893. */
  83894. getWorldMatrix(): DeepImmutable<Matrix>;
  83895. /** @hidden */
  83896. _update(world: DeepImmutable<Matrix>): void;
  83897. /**
  83898. * Tests if the bounding box is intersecting the frustum planes
  83899. * @param frustumPlanes defines the frustum planes to test
  83900. * @returns true if there is an intersection
  83901. */
  83902. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  83903. /**
  83904. * Tests if the bounding box is entirely inside the frustum planes
  83905. * @param frustumPlanes defines the frustum planes to test
  83906. * @returns true if there is an inclusion
  83907. */
  83908. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  83909. /**
  83910. * Tests if a point is inside the bounding box
  83911. * @param point defines the point to test
  83912. * @returns true if the point is inside the bounding box
  83913. */
  83914. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  83915. /**
  83916. * Tests if the bounding box intersects with a bounding sphere
  83917. * @param sphere defines the sphere to test
  83918. * @returns true if there is an intersection
  83919. */
  83920. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  83921. /**
  83922. * Tests if the bounding box intersects with a box defined by a min and max vectors
  83923. * @param min defines the min vector to use
  83924. * @param max defines the max vector to use
  83925. * @returns true if there is an intersection
  83926. */
  83927. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  83928. /**
  83929. * Tests if two bounding boxes are intersections
  83930. * @param box0 defines the first box to test
  83931. * @param box1 defines the second box to test
  83932. * @returns true if there is an intersection
  83933. */
  83934. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  83935. /**
  83936. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  83937. * @param minPoint defines the minimum vector of the bounding box
  83938. * @param maxPoint defines the maximum vector of the bounding box
  83939. * @param sphereCenter defines the sphere center
  83940. * @param sphereRadius defines the sphere radius
  83941. * @returns true if there is an intersection
  83942. */
  83943. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  83944. /**
  83945. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  83946. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  83947. * @param frustumPlanes defines the frustum planes to test
  83948. * @return true if there is an inclusion
  83949. */
  83950. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  83951. /**
  83952. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  83953. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  83954. * @param frustumPlanes defines the frustum planes to test
  83955. * @return true if there is an intersection
  83956. */
  83957. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  83958. }
  83959. }
  83960. declare module BABYLON {
  83961. /** @hidden */
  83962. export class Collider {
  83963. /** Define if a collision was found */
  83964. collisionFound: boolean;
  83965. /**
  83966. * Define last intersection point in local space
  83967. */
  83968. intersectionPoint: Vector3;
  83969. /**
  83970. * Define last collided mesh
  83971. */
  83972. collidedMesh: Nullable<AbstractMesh>;
  83973. private _collisionPoint;
  83974. private _planeIntersectionPoint;
  83975. private _tempVector;
  83976. private _tempVector2;
  83977. private _tempVector3;
  83978. private _tempVector4;
  83979. private _edge;
  83980. private _baseToVertex;
  83981. private _destinationPoint;
  83982. private _slidePlaneNormal;
  83983. private _displacementVector;
  83984. /** @hidden */
  83985. _radius: Vector3;
  83986. /** @hidden */
  83987. _retry: number;
  83988. private _velocity;
  83989. private _basePoint;
  83990. private _epsilon;
  83991. /** @hidden */
  83992. _velocityWorldLength: number;
  83993. /** @hidden */
  83994. _basePointWorld: Vector3;
  83995. private _velocityWorld;
  83996. private _normalizedVelocity;
  83997. /** @hidden */
  83998. _initialVelocity: Vector3;
  83999. /** @hidden */
  84000. _initialPosition: Vector3;
  84001. private _nearestDistance;
  84002. private _collisionMask;
  84003. get collisionMask(): number;
  84004. set collisionMask(mask: number);
  84005. /**
  84006. * Gets the plane normal used to compute the sliding response (in local space)
  84007. */
  84008. get slidePlaneNormal(): Vector3;
  84009. /** @hidden */
  84010. _initialize(source: Vector3, dir: Vector3, e: number): void;
  84011. /** @hidden */
  84012. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  84013. /** @hidden */
  84014. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  84015. /** @hidden */
  84016. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  84017. /** @hidden */
  84018. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  84019. /** @hidden */
  84020. _getResponse(pos: Vector3, vel: Vector3): void;
  84021. }
  84022. }
  84023. declare module BABYLON {
  84024. /**
  84025. * Interface for cullable objects
  84026. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  84027. */
  84028. export interface ICullable {
  84029. /**
  84030. * Checks if the object or part of the object is in the frustum
  84031. * @param frustumPlanes Camera near/planes
  84032. * @returns true if the object is in frustum otherwise false
  84033. */
  84034. isInFrustum(frustumPlanes: Plane[]): boolean;
  84035. /**
  84036. * Checks if a cullable object (mesh...) is in the camera frustum
  84037. * Unlike isInFrustum this cheks the full bounding box
  84038. * @param frustumPlanes Camera near/planes
  84039. * @returns true if the object is in frustum otherwise false
  84040. */
  84041. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  84042. }
  84043. /**
  84044. * Info for a bounding data of a mesh
  84045. */
  84046. export class BoundingInfo implements ICullable {
  84047. /**
  84048. * Bounding box for the mesh
  84049. */
  84050. readonly boundingBox: BoundingBox;
  84051. /**
  84052. * Bounding sphere for the mesh
  84053. */
  84054. readonly boundingSphere: BoundingSphere;
  84055. private _isLocked;
  84056. private static readonly TmpVector3;
  84057. /**
  84058. * Constructs bounding info
  84059. * @param minimum min vector of the bounding box/sphere
  84060. * @param maximum max vector of the bounding box/sphere
  84061. * @param worldMatrix defines the new world matrix
  84062. */
  84063. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  84064. /**
  84065. * Recreates the entire bounding info from scratch as if we call the constructor in place
  84066. * @param min defines the new minimum vector (in local space)
  84067. * @param max defines the new maximum vector (in local space)
  84068. * @param worldMatrix defines the new world matrix
  84069. */
  84070. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  84071. /**
  84072. * min vector of the bounding box/sphere
  84073. */
  84074. get minimum(): Vector3;
  84075. /**
  84076. * max vector of the bounding box/sphere
  84077. */
  84078. get maximum(): Vector3;
  84079. /**
  84080. * If the info is locked and won't be updated to avoid perf overhead
  84081. */
  84082. get isLocked(): boolean;
  84083. set isLocked(value: boolean);
  84084. /**
  84085. * Updates the bounding sphere and box
  84086. * @param world world matrix to be used to update
  84087. */
  84088. update(world: DeepImmutable<Matrix>): void;
  84089. /**
  84090. * Recreate the bounding info to be centered around a specific point given a specific extend.
  84091. * @param center New center of the bounding info
  84092. * @param extend New extend of the bounding info
  84093. * @returns the current bounding info
  84094. */
  84095. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  84096. /**
  84097. * Scale the current bounding info by applying a scale factor
  84098. * @param factor defines the scale factor to apply
  84099. * @returns the current bounding info
  84100. */
  84101. scale(factor: number): BoundingInfo;
  84102. /**
  84103. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  84104. * @param frustumPlanes defines the frustum to test
  84105. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  84106. * @returns true if the bounding info is in the frustum planes
  84107. */
  84108. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  84109. /**
  84110. * Gets the world distance between the min and max points of the bounding box
  84111. */
  84112. get diagonalLength(): number;
  84113. /**
  84114. * Checks if a cullable object (mesh...) is in the camera frustum
  84115. * Unlike isInFrustum this cheks the full bounding box
  84116. * @param frustumPlanes Camera near/planes
  84117. * @returns true if the object is in frustum otherwise false
  84118. */
  84119. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  84120. /** @hidden */
  84121. _checkCollision(collider: Collider): boolean;
  84122. /**
  84123. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  84124. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  84125. * @param point the point to check intersection with
  84126. * @returns if the point intersects
  84127. */
  84128. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  84129. /**
  84130. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  84131. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  84132. * @param boundingInfo the bounding info to check intersection with
  84133. * @param precise if the intersection should be done using OBB
  84134. * @returns if the bounding info intersects
  84135. */
  84136. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  84137. }
  84138. }
  84139. declare module BABYLON {
  84140. /**
  84141. * Extracts minimum and maximum values from a list of indexed positions
  84142. * @param positions defines the positions to use
  84143. * @param indices defines the indices to the positions
  84144. * @param indexStart defines the start index
  84145. * @param indexCount defines the end index
  84146. * @param bias defines bias value to add to the result
  84147. * @return minimum and maximum values
  84148. */
  84149. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  84150. minimum: Vector3;
  84151. maximum: Vector3;
  84152. };
  84153. /**
  84154. * Extracts minimum and maximum values from a list of positions
  84155. * @param positions defines the positions to use
  84156. * @param start defines the start index in the positions array
  84157. * @param count defines the number of positions to handle
  84158. * @param bias defines bias value to add to the result
  84159. * @param stride defines the stride size to use (distance between two positions in the positions array)
  84160. * @return minimum and maximum values
  84161. */
  84162. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  84163. minimum: Vector3;
  84164. maximum: Vector3;
  84165. };
  84166. }
  84167. declare module BABYLON {
  84168. /** @hidden */
  84169. export class WebGLDataBuffer extends DataBuffer {
  84170. private _buffer;
  84171. constructor(resource: WebGLBuffer);
  84172. get underlyingResource(): any;
  84173. }
  84174. }
  84175. declare module BABYLON {
  84176. /** @hidden */
  84177. export class WebGLPipelineContext implements IPipelineContext {
  84178. engine: ThinEngine;
  84179. program: Nullable<WebGLProgram>;
  84180. context?: WebGLRenderingContext;
  84181. vertexShader?: WebGLShader;
  84182. fragmentShader?: WebGLShader;
  84183. isParallelCompiled: boolean;
  84184. onCompiled?: () => void;
  84185. transformFeedback?: WebGLTransformFeedback | null;
  84186. vertexCompilationError: Nullable<string>;
  84187. fragmentCompilationError: Nullable<string>;
  84188. programLinkError: Nullable<string>;
  84189. programValidationError: Nullable<string>;
  84190. get isAsync(): boolean;
  84191. get isReady(): boolean;
  84192. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  84193. _getVertexShaderCode(): string | null;
  84194. _getFragmentShaderCode(): string | null;
  84195. }
  84196. }
  84197. declare module BABYLON {
  84198. interface ThinEngine {
  84199. /**
  84200. * Create an uniform buffer
  84201. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  84202. * @param elements defines the content of the uniform buffer
  84203. * @returns the webGL uniform buffer
  84204. */
  84205. createUniformBuffer(elements: FloatArray): DataBuffer;
  84206. /**
  84207. * Create a dynamic uniform buffer
  84208. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  84209. * @param elements defines the content of the uniform buffer
  84210. * @returns the webGL uniform buffer
  84211. */
  84212. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  84213. /**
  84214. * Update an existing uniform buffer
  84215. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  84216. * @param uniformBuffer defines the target uniform buffer
  84217. * @param elements defines the content to update
  84218. * @param offset defines the offset in the uniform buffer where update should start
  84219. * @param count defines the size of the data to update
  84220. */
  84221. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  84222. /**
  84223. * Bind an uniform buffer to the current webGL context
  84224. * @param buffer defines the buffer to bind
  84225. */
  84226. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  84227. /**
  84228. * Bind a buffer to the current webGL context at a given location
  84229. * @param buffer defines the buffer to bind
  84230. * @param location defines the index where to bind the buffer
  84231. */
  84232. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  84233. /**
  84234. * Bind a specific block at a given index in a specific shader program
  84235. * @param pipelineContext defines the pipeline context to use
  84236. * @param blockName defines the block name
  84237. * @param index defines the index where to bind the block
  84238. */
  84239. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  84240. }
  84241. }
  84242. declare module BABYLON {
  84243. /**
  84244. * Uniform buffer objects.
  84245. *
  84246. * Handles blocks of uniform on the GPU.
  84247. *
  84248. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  84249. *
  84250. * For more information, please refer to :
  84251. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  84252. */
  84253. export class UniformBuffer {
  84254. private _engine;
  84255. private _buffer;
  84256. private _data;
  84257. private _bufferData;
  84258. private _dynamic?;
  84259. private _uniformLocations;
  84260. private _uniformSizes;
  84261. private _uniformLocationPointer;
  84262. private _needSync;
  84263. private _noUBO;
  84264. private _currentEffect;
  84265. /** @hidden */
  84266. _alreadyBound: boolean;
  84267. private static _MAX_UNIFORM_SIZE;
  84268. private static _tempBuffer;
  84269. /**
  84270. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  84271. * This is dynamic to allow compat with webgl 1 and 2.
  84272. * You will need to pass the name of the uniform as well as the value.
  84273. */
  84274. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  84275. /**
  84276. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  84277. * This is dynamic to allow compat with webgl 1 and 2.
  84278. * You will need to pass the name of the uniform as well as the value.
  84279. */
  84280. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  84281. /**
  84282. * Lambda to Update a single float in a uniform buffer.
  84283. * This is dynamic to allow compat with webgl 1 and 2.
  84284. * You will need to pass the name of the uniform as well as the value.
  84285. */
  84286. updateFloat: (name: string, x: number) => void;
  84287. /**
  84288. * Lambda to Update a vec2 of float in a uniform buffer.
  84289. * This is dynamic to allow compat with webgl 1 and 2.
  84290. * You will need to pass the name of the uniform as well as the value.
  84291. */
  84292. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  84293. /**
  84294. * Lambda to Update a vec3 of float in a uniform buffer.
  84295. * This is dynamic to allow compat with webgl 1 and 2.
  84296. * You will need to pass the name of the uniform as well as the value.
  84297. */
  84298. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  84299. /**
  84300. * Lambda to Update a vec4 of float in a uniform buffer.
  84301. * This is dynamic to allow compat with webgl 1 and 2.
  84302. * You will need to pass the name of the uniform as well as the value.
  84303. */
  84304. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  84305. /**
  84306. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  84307. * This is dynamic to allow compat with webgl 1 and 2.
  84308. * You will need to pass the name of the uniform as well as the value.
  84309. */
  84310. updateMatrix: (name: string, mat: Matrix) => void;
  84311. /**
  84312. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  84313. * This is dynamic to allow compat with webgl 1 and 2.
  84314. * You will need to pass the name of the uniform as well as the value.
  84315. */
  84316. updateVector3: (name: string, vector: Vector3) => void;
  84317. /**
  84318. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  84319. * This is dynamic to allow compat with webgl 1 and 2.
  84320. * You will need to pass the name of the uniform as well as the value.
  84321. */
  84322. updateVector4: (name: string, vector: Vector4) => void;
  84323. /**
  84324. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  84325. * This is dynamic to allow compat with webgl 1 and 2.
  84326. * You will need to pass the name of the uniform as well as the value.
  84327. */
  84328. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  84329. /**
  84330. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  84331. * This is dynamic to allow compat with webgl 1 and 2.
  84332. * You will need to pass the name of the uniform as well as the value.
  84333. */
  84334. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  84335. /**
  84336. * Instantiates a new Uniform buffer objects.
  84337. *
  84338. * Handles blocks of uniform on the GPU.
  84339. *
  84340. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  84341. *
  84342. * For more information, please refer to :
  84343. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  84344. * @param engine Define the engine the buffer is associated with
  84345. * @param data Define the data contained in the buffer
  84346. * @param dynamic Define if the buffer is updatable
  84347. */
  84348. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  84349. /**
  84350. * Indicates if the buffer is using the WebGL2 UBO implementation,
  84351. * or just falling back on setUniformXXX calls.
  84352. */
  84353. get useUbo(): boolean;
  84354. /**
  84355. * Indicates if the WebGL underlying uniform buffer is in sync
  84356. * with the javascript cache data.
  84357. */
  84358. get isSync(): boolean;
  84359. /**
  84360. * Indicates if the WebGL underlying uniform buffer is dynamic.
  84361. * Also, a dynamic UniformBuffer will disable cache verification and always
  84362. * update the underlying WebGL uniform buffer to the GPU.
  84363. * @returns if Dynamic, otherwise false
  84364. */
  84365. isDynamic(): boolean;
  84366. /**
  84367. * The data cache on JS side.
  84368. * @returns the underlying data as a float array
  84369. */
  84370. getData(): Float32Array;
  84371. /**
  84372. * The underlying WebGL Uniform buffer.
  84373. * @returns the webgl buffer
  84374. */
  84375. getBuffer(): Nullable<DataBuffer>;
  84376. /**
  84377. * std140 layout specifies how to align data within an UBO structure.
  84378. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  84379. * for specs.
  84380. */
  84381. private _fillAlignment;
  84382. /**
  84383. * Adds an uniform in the buffer.
  84384. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  84385. * for the layout to be correct !
  84386. * @param name Name of the uniform, as used in the uniform block in the shader.
  84387. * @param size Data size, or data directly.
  84388. */
  84389. addUniform(name: string, size: number | number[]): void;
  84390. /**
  84391. * Adds a Matrix 4x4 to the uniform buffer.
  84392. * @param name Name of the uniform, as used in the uniform block in the shader.
  84393. * @param mat A 4x4 matrix.
  84394. */
  84395. addMatrix(name: string, mat: Matrix): void;
  84396. /**
  84397. * Adds a vec2 to the uniform buffer.
  84398. * @param name Name of the uniform, as used in the uniform block in the shader.
  84399. * @param x Define the x component value of the vec2
  84400. * @param y Define the y component value of the vec2
  84401. */
  84402. addFloat2(name: string, x: number, y: number): void;
  84403. /**
  84404. * Adds a vec3 to the uniform buffer.
  84405. * @param name Name of the uniform, as used in the uniform block in the shader.
  84406. * @param x Define the x component value of the vec3
  84407. * @param y Define the y component value of the vec3
  84408. * @param z Define the z component value of the vec3
  84409. */
  84410. addFloat3(name: string, x: number, y: number, z: number): void;
  84411. /**
  84412. * Adds a vec3 to the uniform buffer.
  84413. * @param name Name of the uniform, as used in the uniform block in the shader.
  84414. * @param color Define the vec3 from a Color
  84415. */
  84416. addColor3(name: string, color: Color3): void;
  84417. /**
  84418. * Adds a vec4 to the uniform buffer.
  84419. * @param name Name of the uniform, as used in the uniform block in the shader.
  84420. * @param color Define the rgb components from a Color
  84421. * @param alpha Define the a component of the vec4
  84422. */
  84423. addColor4(name: string, color: Color3, alpha: number): void;
  84424. /**
  84425. * Adds a vec3 to the uniform buffer.
  84426. * @param name Name of the uniform, as used in the uniform block in the shader.
  84427. * @param vector Define the vec3 components from a Vector
  84428. */
  84429. addVector3(name: string, vector: Vector3): void;
  84430. /**
  84431. * Adds a Matrix 3x3 to the uniform buffer.
  84432. * @param name Name of the uniform, as used in the uniform block in the shader.
  84433. */
  84434. addMatrix3x3(name: string): void;
  84435. /**
  84436. * Adds a Matrix 2x2 to the uniform buffer.
  84437. * @param name Name of the uniform, as used in the uniform block in the shader.
  84438. */
  84439. addMatrix2x2(name: string): void;
  84440. /**
  84441. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  84442. */
  84443. create(): void;
  84444. /** @hidden */
  84445. _rebuild(): void;
  84446. /**
  84447. * Updates the WebGL Uniform Buffer on the GPU.
  84448. * If the `dynamic` flag is set to true, no cache comparison is done.
  84449. * Otherwise, the buffer will be updated only if the cache differs.
  84450. */
  84451. update(): void;
  84452. /**
  84453. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  84454. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  84455. * @param data Define the flattened data
  84456. * @param size Define the size of the data.
  84457. */
  84458. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  84459. private _valueCache;
  84460. private _cacheMatrix;
  84461. private _updateMatrix3x3ForUniform;
  84462. private _updateMatrix3x3ForEffect;
  84463. private _updateMatrix2x2ForEffect;
  84464. private _updateMatrix2x2ForUniform;
  84465. private _updateFloatForEffect;
  84466. private _updateFloatForUniform;
  84467. private _updateFloat2ForEffect;
  84468. private _updateFloat2ForUniform;
  84469. private _updateFloat3ForEffect;
  84470. private _updateFloat3ForUniform;
  84471. private _updateFloat4ForEffect;
  84472. private _updateFloat4ForUniform;
  84473. private _updateMatrixForEffect;
  84474. private _updateMatrixForUniform;
  84475. private _updateVector3ForEffect;
  84476. private _updateVector3ForUniform;
  84477. private _updateVector4ForEffect;
  84478. private _updateVector4ForUniform;
  84479. private _updateColor3ForEffect;
  84480. private _updateColor3ForUniform;
  84481. private _updateColor4ForEffect;
  84482. private _updateColor4ForUniform;
  84483. /**
  84484. * Sets a sampler uniform on the effect.
  84485. * @param name Define the name of the sampler.
  84486. * @param texture Define the texture to set in the sampler
  84487. */
  84488. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  84489. /**
  84490. * Directly updates the value of the uniform in the cache AND on the GPU.
  84491. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  84492. * @param data Define the flattened data
  84493. */
  84494. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  84495. /**
  84496. * Binds this uniform buffer to an effect.
  84497. * @param effect Define the effect to bind the buffer to
  84498. * @param name Name of the uniform block in the shader.
  84499. */
  84500. bindToEffect(effect: Effect, name: string): void;
  84501. /**
  84502. * Disposes the uniform buffer.
  84503. */
  84504. dispose(): void;
  84505. }
  84506. }
  84507. declare module BABYLON {
  84508. /**
  84509. * Enum that determines the text-wrapping mode to use.
  84510. */
  84511. export enum InspectableType {
  84512. /**
  84513. * Checkbox for booleans
  84514. */
  84515. Checkbox = 0,
  84516. /**
  84517. * Sliders for numbers
  84518. */
  84519. Slider = 1,
  84520. /**
  84521. * Vector3
  84522. */
  84523. Vector3 = 2,
  84524. /**
  84525. * Quaternions
  84526. */
  84527. Quaternion = 3,
  84528. /**
  84529. * Color3
  84530. */
  84531. Color3 = 4,
  84532. /**
  84533. * String
  84534. */
  84535. String = 5
  84536. }
  84537. /**
  84538. * Interface used to define custom inspectable properties.
  84539. * This interface is used by the inspector to display custom property grids
  84540. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  84541. */
  84542. export interface IInspectable {
  84543. /**
  84544. * Gets the label to display
  84545. */
  84546. label: string;
  84547. /**
  84548. * Gets the name of the property to edit
  84549. */
  84550. propertyName: string;
  84551. /**
  84552. * Gets the type of the editor to use
  84553. */
  84554. type: InspectableType;
  84555. /**
  84556. * Gets the minimum value of the property when using in "slider" mode
  84557. */
  84558. min?: number;
  84559. /**
  84560. * Gets the maximum value of the property when using in "slider" mode
  84561. */
  84562. max?: number;
  84563. /**
  84564. * Gets the setp to use when using in "slider" mode
  84565. */
  84566. step?: number;
  84567. }
  84568. }
  84569. declare module BABYLON {
  84570. /**
  84571. * Class used to provide helper for timing
  84572. */
  84573. export class TimingTools {
  84574. /**
  84575. * Polyfill for setImmediate
  84576. * @param action defines the action to execute after the current execution block
  84577. */
  84578. static SetImmediate(action: () => void): void;
  84579. }
  84580. }
  84581. declare module BABYLON {
  84582. /**
  84583. * Class used to enable instatition of objects by class name
  84584. */
  84585. export class InstantiationTools {
  84586. /**
  84587. * Use this object to register external classes like custom textures or material
  84588. * to allow the laoders to instantiate them
  84589. */
  84590. static RegisteredExternalClasses: {
  84591. [key: string]: Object;
  84592. };
  84593. /**
  84594. * Tries to instantiate a new object from a given class name
  84595. * @param className defines the class name to instantiate
  84596. * @returns the new object or null if the system was not able to do the instantiation
  84597. */
  84598. static Instantiate(className: string): any;
  84599. }
  84600. }
  84601. declare module BABYLON {
  84602. /**
  84603. * Define options used to create a depth texture
  84604. */
  84605. export class DepthTextureCreationOptions {
  84606. /** Specifies whether or not a stencil should be allocated in the texture */
  84607. generateStencil?: boolean;
  84608. /** Specifies whether or not bilinear filtering is enable on the texture */
  84609. bilinearFiltering?: boolean;
  84610. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  84611. comparisonFunction?: number;
  84612. /** Specifies if the created texture is a cube texture */
  84613. isCube?: boolean;
  84614. }
  84615. }
  84616. declare module BABYLON {
  84617. interface ThinEngine {
  84618. /**
  84619. * Creates a depth stencil cube texture.
  84620. * This is only available in WebGL 2.
  84621. * @param size The size of face edge in the cube texture.
  84622. * @param options The options defining the cube texture.
  84623. * @returns The cube texture
  84624. */
  84625. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  84626. /**
  84627. * Creates a cube texture
  84628. * @param rootUrl defines the url where the files to load is located
  84629. * @param scene defines the current scene
  84630. * @param files defines the list of files to load (1 per face)
  84631. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  84632. * @param onLoad defines an optional callback raised when the texture is loaded
  84633. * @param onError defines an optional callback raised if there is an issue to load the texture
  84634. * @param format defines the format of the data
  84635. * @param forcedExtension defines the extension to use to pick the right loader
  84636. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  84637. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  84638. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  84639. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  84640. * @returns the cube texture as an InternalTexture
  84641. */
  84642. 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;
  84643. /**
  84644. * Creates a cube texture
  84645. * @param rootUrl defines the url where the files to load is located
  84646. * @param scene defines the current scene
  84647. * @param files defines the list of files to load (1 per face)
  84648. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  84649. * @param onLoad defines an optional callback raised when the texture is loaded
  84650. * @param onError defines an optional callback raised if there is an issue to load the texture
  84651. * @param format defines the format of the data
  84652. * @param forcedExtension defines the extension to use to pick the right loader
  84653. * @returns the cube texture as an InternalTexture
  84654. */
  84655. 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;
  84656. /**
  84657. * Creates a cube texture
  84658. * @param rootUrl defines the url where the files to load is located
  84659. * @param scene defines the current scene
  84660. * @param files defines the list of files to load (1 per face)
  84661. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  84662. * @param onLoad defines an optional callback raised when the texture is loaded
  84663. * @param onError defines an optional callback raised if there is an issue to load the texture
  84664. * @param format defines the format of the data
  84665. * @param forcedExtension defines the extension to use to pick the right loader
  84666. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  84667. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  84668. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  84669. * @returns the cube texture as an InternalTexture
  84670. */
  84671. 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;
  84672. /** @hidden */
  84673. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  84674. /** @hidden */
  84675. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  84676. /** @hidden */
  84677. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  84678. /** @hidden */
  84679. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  84680. /**
  84681. * @hidden
  84682. */
  84683. _setCubeMapTextureParams(loadMipmap: boolean): void;
  84684. }
  84685. }
  84686. declare module BABYLON {
  84687. /**
  84688. * Class for creating a cube texture
  84689. */
  84690. export class CubeTexture extends BaseTexture {
  84691. private _delayedOnLoad;
  84692. /**
  84693. * Observable triggered once the texture has been loaded.
  84694. */
  84695. onLoadObservable: Observable<CubeTexture>;
  84696. /**
  84697. * The url of the texture
  84698. */
  84699. url: string;
  84700. /**
  84701. * Gets or sets the center of the bounding box associated with the cube texture.
  84702. * It must define where the camera used to render the texture was set
  84703. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  84704. */
  84705. boundingBoxPosition: Vector3;
  84706. private _boundingBoxSize;
  84707. /**
  84708. * Gets or sets the size of the bounding box associated with the cube texture
  84709. * When defined, the cubemap will switch to local mode
  84710. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  84711. * @example https://www.babylonjs-playground.com/#RNASML
  84712. */
  84713. set boundingBoxSize(value: Vector3);
  84714. /**
  84715. * Returns the bounding box size
  84716. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  84717. */
  84718. get boundingBoxSize(): Vector3;
  84719. protected _rotationY: number;
  84720. /**
  84721. * Sets texture matrix rotation angle around Y axis in radians.
  84722. */
  84723. set rotationY(value: number);
  84724. /**
  84725. * Gets texture matrix rotation angle around Y axis radians.
  84726. */
  84727. get rotationY(): number;
  84728. /**
  84729. * Are mip maps generated for this texture or not.
  84730. */
  84731. get noMipmap(): boolean;
  84732. private _noMipmap;
  84733. private _files;
  84734. protected _forcedExtension: Nullable<string>;
  84735. private _extensions;
  84736. private _textureMatrix;
  84737. private _format;
  84738. private _createPolynomials;
  84739. /**
  84740. * Creates a cube texture from an array of image urls
  84741. * @param files defines an array of image urls
  84742. * @param scene defines the hosting scene
  84743. * @param noMipmap specifies if mip maps are not used
  84744. * @returns a cube texture
  84745. */
  84746. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  84747. /**
  84748. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  84749. * @param url defines the url of the prefiltered texture
  84750. * @param scene defines the scene the texture is attached to
  84751. * @param forcedExtension defines the extension of the file if different from the url
  84752. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  84753. * @return the prefiltered texture
  84754. */
  84755. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  84756. /**
  84757. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  84758. * as prefiltered data.
  84759. * @param rootUrl defines the url of the texture or the root name of the six images
  84760. * @param null defines the scene or engine the texture is attached to
  84761. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  84762. * @param noMipmap defines if mipmaps should be created or not
  84763. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  84764. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  84765. * @param onError defines a callback triggered in case of error during load
  84766. * @param format defines the internal format to use for the texture once loaded
  84767. * @param prefiltered defines whether or not the texture is created from prefiltered data
  84768. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  84769. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  84770. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  84771. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  84772. * @return the cube texture
  84773. */
  84774. 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);
  84775. /**
  84776. * Get the current class name of the texture useful for serialization or dynamic coding.
  84777. * @returns "CubeTexture"
  84778. */
  84779. getClassName(): string;
  84780. /**
  84781. * Update the url (and optional buffer) of this texture if url was null during construction.
  84782. * @param url the url of the texture
  84783. * @param forcedExtension defines the extension to use
  84784. * @param onLoad callback called when the texture is loaded (defaults to null)
  84785. * @param prefiltered Defines whether the updated texture is prefiltered or not
  84786. */
  84787. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  84788. /**
  84789. * Delays loading of the cube texture
  84790. * @param forcedExtension defines the extension to use
  84791. */
  84792. delayLoad(forcedExtension?: string): void;
  84793. /**
  84794. * Returns the reflection texture matrix
  84795. * @returns the reflection texture matrix
  84796. */
  84797. getReflectionTextureMatrix(): Matrix;
  84798. /**
  84799. * Sets the reflection texture matrix
  84800. * @param value Reflection texture matrix
  84801. */
  84802. setReflectionTextureMatrix(value: Matrix): void;
  84803. /**
  84804. * Parses text to create a cube texture
  84805. * @param parsedTexture define the serialized text to read from
  84806. * @param scene defines the hosting scene
  84807. * @param rootUrl defines the root url of the cube texture
  84808. * @returns a cube texture
  84809. */
  84810. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  84811. /**
  84812. * Makes a clone, or deep copy, of the cube texture
  84813. * @returns a new cube texture
  84814. */
  84815. clone(): CubeTexture;
  84816. }
  84817. }
  84818. declare module BABYLON {
  84819. /**
  84820. * Manages the defines for the Material
  84821. */
  84822. export class MaterialDefines {
  84823. /** @hidden */
  84824. protected _keys: string[];
  84825. private _isDirty;
  84826. /** @hidden */
  84827. _renderId: number;
  84828. /** @hidden */
  84829. _areLightsDirty: boolean;
  84830. /** @hidden */
  84831. _areLightsDisposed: boolean;
  84832. /** @hidden */
  84833. _areAttributesDirty: boolean;
  84834. /** @hidden */
  84835. _areTexturesDirty: boolean;
  84836. /** @hidden */
  84837. _areFresnelDirty: boolean;
  84838. /** @hidden */
  84839. _areMiscDirty: boolean;
  84840. /** @hidden */
  84841. _areImageProcessingDirty: boolean;
  84842. /** @hidden */
  84843. _normals: boolean;
  84844. /** @hidden */
  84845. _uvs: boolean;
  84846. /** @hidden */
  84847. _needNormals: boolean;
  84848. /** @hidden */
  84849. _needUVs: boolean;
  84850. [id: string]: any;
  84851. /**
  84852. * Specifies if the material needs to be re-calculated
  84853. */
  84854. get isDirty(): boolean;
  84855. /**
  84856. * Marks the material to indicate that it has been re-calculated
  84857. */
  84858. markAsProcessed(): void;
  84859. /**
  84860. * Marks the material to indicate that it needs to be re-calculated
  84861. */
  84862. markAsUnprocessed(): void;
  84863. /**
  84864. * Marks the material to indicate all of its defines need to be re-calculated
  84865. */
  84866. markAllAsDirty(): void;
  84867. /**
  84868. * Marks the material to indicate that image processing needs to be re-calculated
  84869. */
  84870. markAsImageProcessingDirty(): void;
  84871. /**
  84872. * Marks the material to indicate the lights need to be re-calculated
  84873. * @param disposed Defines whether the light is dirty due to dispose or not
  84874. */
  84875. markAsLightDirty(disposed?: boolean): void;
  84876. /**
  84877. * Marks the attribute state as changed
  84878. */
  84879. markAsAttributesDirty(): void;
  84880. /**
  84881. * Marks the texture state as changed
  84882. */
  84883. markAsTexturesDirty(): void;
  84884. /**
  84885. * Marks the fresnel state as changed
  84886. */
  84887. markAsFresnelDirty(): void;
  84888. /**
  84889. * Marks the misc state as changed
  84890. */
  84891. markAsMiscDirty(): void;
  84892. /**
  84893. * Rebuilds the material defines
  84894. */
  84895. rebuild(): void;
  84896. /**
  84897. * Specifies if two material defines are equal
  84898. * @param other - A material define instance to compare to
  84899. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  84900. */
  84901. isEqual(other: MaterialDefines): boolean;
  84902. /**
  84903. * Clones this instance's defines to another instance
  84904. * @param other - material defines to clone values to
  84905. */
  84906. cloneTo(other: MaterialDefines): void;
  84907. /**
  84908. * Resets the material define values
  84909. */
  84910. reset(): void;
  84911. /**
  84912. * Converts the material define values to a string
  84913. * @returns - String of material define information
  84914. */
  84915. toString(): string;
  84916. }
  84917. }
  84918. declare module BABYLON {
  84919. /**
  84920. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  84921. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  84922. * 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;
  84923. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  84924. */
  84925. export class ColorCurves {
  84926. private _dirty;
  84927. private _tempColor;
  84928. private _globalCurve;
  84929. private _highlightsCurve;
  84930. private _midtonesCurve;
  84931. private _shadowsCurve;
  84932. private _positiveCurve;
  84933. private _negativeCurve;
  84934. private _globalHue;
  84935. private _globalDensity;
  84936. private _globalSaturation;
  84937. private _globalExposure;
  84938. /**
  84939. * Gets the global Hue value.
  84940. * 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).
  84941. */
  84942. get globalHue(): number;
  84943. /**
  84944. * Sets the global Hue value.
  84945. * 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).
  84946. */
  84947. set globalHue(value: number);
  84948. /**
  84949. * Gets the global Density value.
  84950. * 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.
  84951. * Values less than zero provide a filter of opposite hue.
  84952. */
  84953. get globalDensity(): number;
  84954. /**
  84955. * Sets the global Density value.
  84956. * 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.
  84957. * Values less than zero provide a filter of opposite hue.
  84958. */
  84959. set globalDensity(value: number);
  84960. /**
  84961. * Gets the global Saturation value.
  84962. * 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.
  84963. */
  84964. get globalSaturation(): number;
  84965. /**
  84966. * Sets the global Saturation value.
  84967. * 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.
  84968. */
  84969. set globalSaturation(value: number);
  84970. /**
  84971. * Gets the global Exposure value.
  84972. * 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.
  84973. */
  84974. get globalExposure(): number;
  84975. /**
  84976. * Sets the global Exposure value.
  84977. * 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.
  84978. */
  84979. set globalExposure(value: number);
  84980. private _highlightsHue;
  84981. private _highlightsDensity;
  84982. private _highlightsSaturation;
  84983. private _highlightsExposure;
  84984. /**
  84985. * Gets the highlights Hue value.
  84986. * 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).
  84987. */
  84988. get highlightsHue(): number;
  84989. /**
  84990. * Sets the highlights Hue value.
  84991. * 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).
  84992. */
  84993. set highlightsHue(value: number);
  84994. /**
  84995. * Gets the highlights Density value.
  84996. * 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.
  84997. * Values less than zero provide a filter of opposite hue.
  84998. */
  84999. get highlightsDensity(): number;
  85000. /**
  85001. * Sets the highlights Density value.
  85002. * 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.
  85003. * Values less than zero provide a filter of opposite hue.
  85004. */
  85005. set highlightsDensity(value: number);
  85006. /**
  85007. * Gets the highlights Saturation value.
  85008. * 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.
  85009. */
  85010. get highlightsSaturation(): number;
  85011. /**
  85012. * Sets the highlights Saturation value.
  85013. * 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.
  85014. */
  85015. set highlightsSaturation(value: number);
  85016. /**
  85017. * Gets the highlights Exposure value.
  85018. * 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.
  85019. */
  85020. get highlightsExposure(): number;
  85021. /**
  85022. * Sets the highlights Exposure value.
  85023. * 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.
  85024. */
  85025. set highlightsExposure(value: number);
  85026. private _midtonesHue;
  85027. private _midtonesDensity;
  85028. private _midtonesSaturation;
  85029. private _midtonesExposure;
  85030. /**
  85031. * Gets the midtones Hue value.
  85032. * 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).
  85033. */
  85034. get midtonesHue(): number;
  85035. /**
  85036. * Sets the midtones Hue value.
  85037. * 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).
  85038. */
  85039. set midtonesHue(value: number);
  85040. /**
  85041. * Gets the midtones Density value.
  85042. * 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.
  85043. * Values less than zero provide a filter of opposite hue.
  85044. */
  85045. get midtonesDensity(): number;
  85046. /**
  85047. * Sets the midtones Density value.
  85048. * 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.
  85049. * Values less than zero provide a filter of opposite hue.
  85050. */
  85051. set midtonesDensity(value: number);
  85052. /**
  85053. * Gets the midtones Saturation value.
  85054. * 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.
  85055. */
  85056. get midtonesSaturation(): number;
  85057. /**
  85058. * Sets the midtones Saturation value.
  85059. * 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.
  85060. */
  85061. set midtonesSaturation(value: number);
  85062. /**
  85063. * Gets the midtones Exposure value.
  85064. * 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.
  85065. */
  85066. get midtonesExposure(): number;
  85067. /**
  85068. * Sets the midtones Exposure value.
  85069. * 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.
  85070. */
  85071. set midtonesExposure(value: number);
  85072. private _shadowsHue;
  85073. private _shadowsDensity;
  85074. private _shadowsSaturation;
  85075. private _shadowsExposure;
  85076. /**
  85077. * Gets the shadows Hue value.
  85078. * 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).
  85079. */
  85080. get shadowsHue(): number;
  85081. /**
  85082. * Sets the shadows Hue value.
  85083. * 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).
  85084. */
  85085. set shadowsHue(value: number);
  85086. /**
  85087. * Gets the shadows Density value.
  85088. * 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.
  85089. * Values less than zero provide a filter of opposite hue.
  85090. */
  85091. get shadowsDensity(): number;
  85092. /**
  85093. * Sets the shadows Density value.
  85094. * 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.
  85095. * Values less than zero provide a filter of opposite hue.
  85096. */
  85097. set shadowsDensity(value: number);
  85098. /**
  85099. * Gets the shadows Saturation value.
  85100. * 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.
  85101. */
  85102. get shadowsSaturation(): number;
  85103. /**
  85104. * Sets the shadows Saturation value.
  85105. * 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.
  85106. */
  85107. set shadowsSaturation(value: number);
  85108. /**
  85109. * Gets the shadows Exposure value.
  85110. * 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.
  85111. */
  85112. get shadowsExposure(): number;
  85113. /**
  85114. * Sets the shadows Exposure value.
  85115. * 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.
  85116. */
  85117. set shadowsExposure(value: number);
  85118. /**
  85119. * Returns the class name
  85120. * @returns The class name
  85121. */
  85122. getClassName(): string;
  85123. /**
  85124. * Binds the color curves to the shader.
  85125. * @param colorCurves The color curve to bind
  85126. * @param effect The effect to bind to
  85127. * @param positiveUniform The positive uniform shader parameter
  85128. * @param neutralUniform The neutral uniform shader parameter
  85129. * @param negativeUniform The negative uniform shader parameter
  85130. */
  85131. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  85132. /**
  85133. * Prepare the list of uniforms associated with the ColorCurves effects.
  85134. * @param uniformsList The list of uniforms used in the effect
  85135. */
  85136. static PrepareUniforms(uniformsList: string[]): void;
  85137. /**
  85138. * Returns color grading data based on a hue, density, saturation and exposure value.
  85139. * @param filterHue The hue of the color filter.
  85140. * @param filterDensity The density of the color filter.
  85141. * @param saturation The saturation.
  85142. * @param exposure The exposure.
  85143. * @param result The result data container.
  85144. */
  85145. private getColorGradingDataToRef;
  85146. /**
  85147. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  85148. * @param value The input slider value in range [-100,100].
  85149. * @returns Adjusted value.
  85150. */
  85151. private static applyColorGradingSliderNonlinear;
  85152. /**
  85153. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  85154. * @param hue The hue (H) input.
  85155. * @param saturation The saturation (S) input.
  85156. * @param brightness The brightness (B) input.
  85157. * @result An RGBA color represented as Vector4.
  85158. */
  85159. private static fromHSBToRef;
  85160. /**
  85161. * Returns a value clamped between min and max
  85162. * @param value The value to clamp
  85163. * @param min The minimum of value
  85164. * @param max The maximum of value
  85165. * @returns The clamped value.
  85166. */
  85167. private static clamp;
  85168. /**
  85169. * Clones the current color curve instance.
  85170. * @return The cloned curves
  85171. */
  85172. clone(): ColorCurves;
  85173. /**
  85174. * Serializes the current color curve instance to a json representation.
  85175. * @return a JSON representation
  85176. */
  85177. serialize(): any;
  85178. /**
  85179. * Parses the color curve from a json representation.
  85180. * @param source the JSON source to parse
  85181. * @return The parsed curves
  85182. */
  85183. static Parse(source: any): ColorCurves;
  85184. }
  85185. }
  85186. declare module BABYLON {
  85187. /**
  85188. * Interface to follow in your material defines to integrate easily the
  85189. * Image proccessing functions.
  85190. * @hidden
  85191. */
  85192. export interface IImageProcessingConfigurationDefines {
  85193. IMAGEPROCESSING: boolean;
  85194. VIGNETTE: boolean;
  85195. VIGNETTEBLENDMODEMULTIPLY: boolean;
  85196. VIGNETTEBLENDMODEOPAQUE: boolean;
  85197. TONEMAPPING: boolean;
  85198. TONEMAPPING_ACES: boolean;
  85199. CONTRAST: boolean;
  85200. EXPOSURE: boolean;
  85201. COLORCURVES: boolean;
  85202. COLORGRADING: boolean;
  85203. COLORGRADING3D: boolean;
  85204. SAMPLER3DGREENDEPTH: boolean;
  85205. SAMPLER3DBGRMAP: boolean;
  85206. IMAGEPROCESSINGPOSTPROCESS: boolean;
  85207. }
  85208. /**
  85209. * @hidden
  85210. */
  85211. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  85212. IMAGEPROCESSING: boolean;
  85213. VIGNETTE: boolean;
  85214. VIGNETTEBLENDMODEMULTIPLY: boolean;
  85215. VIGNETTEBLENDMODEOPAQUE: boolean;
  85216. TONEMAPPING: boolean;
  85217. TONEMAPPING_ACES: boolean;
  85218. CONTRAST: boolean;
  85219. COLORCURVES: boolean;
  85220. COLORGRADING: boolean;
  85221. COLORGRADING3D: boolean;
  85222. SAMPLER3DGREENDEPTH: boolean;
  85223. SAMPLER3DBGRMAP: boolean;
  85224. IMAGEPROCESSINGPOSTPROCESS: boolean;
  85225. EXPOSURE: boolean;
  85226. constructor();
  85227. }
  85228. /**
  85229. * This groups together the common properties used for image processing either in direct forward pass
  85230. * or through post processing effect depending on the use of the image processing pipeline in your scene
  85231. * or not.
  85232. */
  85233. export class ImageProcessingConfiguration {
  85234. /**
  85235. * Default tone mapping applied in BabylonJS.
  85236. */
  85237. static readonly TONEMAPPING_STANDARD: number;
  85238. /**
  85239. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  85240. * to other engines rendering to increase portability.
  85241. */
  85242. static readonly TONEMAPPING_ACES: number;
  85243. /**
  85244. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  85245. */
  85246. colorCurves: Nullable<ColorCurves>;
  85247. private _colorCurvesEnabled;
  85248. /**
  85249. * Gets wether the color curves effect is enabled.
  85250. */
  85251. get colorCurvesEnabled(): boolean;
  85252. /**
  85253. * Sets wether the color curves effect is enabled.
  85254. */
  85255. set colorCurvesEnabled(value: boolean);
  85256. private _colorGradingTexture;
  85257. /**
  85258. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  85259. */
  85260. get colorGradingTexture(): Nullable<BaseTexture>;
  85261. /**
  85262. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  85263. */
  85264. set colorGradingTexture(value: Nullable<BaseTexture>);
  85265. private _colorGradingEnabled;
  85266. /**
  85267. * Gets wether the color grading effect is enabled.
  85268. */
  85269. get colorGradingEnabled(): boolean;
  85270. /**
  85271. * Sets wether the color grading effect is enabled.
  85272. */
  85273. set colorGradingEnabled(value: boolean);
  85274. private _colorGradingWithGreenDepth;
  85275. /**
  85276. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  85277. */
  85278. get colorGradingWithGreenDepth(): boolean;
  85279. /**
  85280. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  85281. */
  85282. set colorGradingWithGreenDepth(value: boolean);
  85283. private _colorGradingBGR;
  85284. /**
  85285. * Gets wether the color grading texture contains BGR values.
  85286. */
  85287. get colorGradingBGR(): boolean;
  85288. /**
  85289. * Sets wether the color grading texture contains BGR values.
  85290. */
  85291. set colorGradingBGR(value: boolean);
  85292. /** @hidden */
  85293. _exposure: number;
  85294. /**
  85295. * Gets the Exposure used in the effect.
  85296. */
  85297. get exposure(): number;
  85298. /**
  85299. * Sets the Exposure used in the effect.
  85300. */
  85301. set exposure(value: number);
  85302. private _toneMappingEnabled;
  85303. /**
  85304. * Gets wether the tone mapping effect is enabled.
  85305. */
  85306. get toneMappingEnabled(): boolean;
  85307. /**
  85308. * Sets wether the tone mapping effect is enabled.
  85309. */
  85310. set toneMappingEnabled(value: boolean);
  85311. private _toneMappingType;
  85312. /**
  85313. * Gets the type of tone mapping effect.
  85314. */
  85315. get toneMappingType(): number;
  85316. /**
  85317. * Sets the type of tone mapping effect used in BabylonJS.
  85318. */
  85319. set toneMappingType(value: number);
  85320. protected _contrast: number;
  85321. /**
  85322. * Gets the contrast used in the effect.
  85323. */
  85324. get contrast(): number;
  85325. /**
  85326. * Sets the contrast used in the effect.
  85327. */
  85328. set contrast(value: number);
  85329. /**
  85330. * Vignette stretch size.
  85331. */
  85332. vignetteStretch: number;
  85333. /**
  85334. * Vignette centre X Offset.
  85335. */
  85336. vignetteCentreX: number;
  85337. /**
  85338. * Vignette centre Y Offset.
  85339. */
  85340. vignetteCentreY: number;
  85341. /**
  85342. * Vignette weight or intensity of the vignette effect.
  85343. */
  85344. vignetteWeight: number;
  85345. /**
  85346. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  85347. * if vignetteEnabled is set to true.
  85348. */
  85349. vignetteColor: Color4;
  85350. /**
  85351. * Camera field of view used by the Vignette effect.
  85352. */
  85353. vignetteCameraFov: number;
  85354. private _vignetteBlendMode;
  85355. /**
  85356. * Gets the vignette blend mode allowing different kind of effect.
  85357. */
  85358. get vignetteBlendMode(): number;
  85359. /**
  85360. * Sets the vignette blend mode allowing different kind of effect.
  85361. */
  85362. set vignetteBlendMode(value: number);
  85363. private _vignetteEnabled;
  85364. /**
  85365. * Gets wether the vignette effect is enabled.
  85366. */
  85367. get vignetteEnabled(): boolean;
  85368. /**
  85369. * Sets wether the vignette effect is enabled.
  85370. */
  85371. set vignetteEnabled(value: boolean);
  85372. private _applyByPostProcess;
  85373. /**
  85374. * Gets wether the image processing is applied through a post process or not.
  85375. */
  85376. get applyByPostProcess(): boolean;
  85377. /**
  85378. * Sets wether the image processing is applied through a post process or not.
  85379. */
  85380. set applyByPostProcess(value: boolean);
  85381. private _isEnabled;
  85382. /**
  85383. * Gets wether the image processing is enabled or not.
  85384. */
  85385. get isEnabled(): boolean;
  85386. /**
  85387. * Sets wether the image processing is enabled or not.
  85388. */
  85389. set isEnabled(value: boolean);
  85390. /**
  85391. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  85392. */
  85393. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  85394. /**
  85395. * Method called each time the image processing information changes requires to recompile the effect.
  85396. */
  85397. protected _updateParameters(): void;
  85398. /**
  85399. * Gets the current class name.
  85400. * @return "ImageProcessingConfiguration"
  85401. */
  85402. getClassName(): string;
  85403. /**
  85404. * Prepare the list of uniforms associated with the Image Processing effects.
  85405. * @param uniforms The list of uniforms used in the effect
  85406. * @param defines the list of defines currently in use
  85407. */
  85408. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  85409. /**
  85410. * Prepare the list of samplers associated with the Image Processing effects.
  85411. * @param samplersList The list of uniforms used in the effect
  85412. * @param defines the list of defines currently in use
  85413. */
  85414. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  85415. /**
  85416. * Prepare the list of defines associated to the shader.
  85417. * @param defines the list of defines to complete
  85418. * @param forPostProcess Define if we are currently in post process mode or not
  85419. */
  85420. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  85421. /**
  85422. * Returns true if all the image processing information are ready.
  85423. * @returns True if ready, otherwise, false
  85424. */
  85425. isReady(): boolean;
  85426. /**
  85427. * Binds the image processing to the shader.
  85428. * @param effect The effect to bind to
  85429. * @param overrideAspectRatio Override the aspect ratio of the effect
  85430. */
  85431. bind(effect: Effect, overrideAspectRatio?: number): void;
  85432. /**
  85433. * Clones the current image processing instance.
  85434. * @return The cloned image processing
  85435. */
  85436. clone(): ImageProcessingConfiguration;
  85437. /**
  85438. * Serializes the current image processing instance to a json representation.
  85439. * @return a JSON representation
  85440. */
  85441. serialize(): any;
  85442. /**
  85443. * Parses the image processing from a json representation.
  85444. * @param source the JSON source to parse
  85445. * @return The parsed image processing
  85446. */
  85447. static Parse(source: any): ImageProcessingConfiguration;
  85448. private static _VIGNETTEMODE_MULTIPLY;
  85449. private static _VIGNETTEMODE_OPAQUE;
  85450. /**
  85451. * Used to apply the vignette as a mix with the pixel color.
  85452. */
  85453. static get VIGNETTEMODE_MULTIPLY(): number;
  85454. /**
  85455. * Used to apply the vignette as a replacement of the pixel color.
  85456. */
  85457. static get VIGNETTEMODE_OPAQUE(): number;
  85458. }
  85459. }
  85460. declare module BABYLON {
  85461. /** @hidden */
  85462. export var postprocessVertexShader: {
  85463. name: string;
  85464. shader: string;
  85465. };
  85466. }
  85467. declare module BABYLON {
  85468. interface ThinEngine {
  85469. /**
  85470. * Creates a new render target texture
  85471. * @param size defines the size of the texture
  85472. * @param options defines the options used to create the texture
  85473. * @returns a new render target texture stored in an InternalTexture
  85474. */
  85475. createRenderTargetTexture(size: number | {
  85476. width: number;
  85477. height: number;
  85478. layers?: number;
  85479. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  85480. /**
  85481. * Creates a depth stencil texture.
  85482. * This is only available in WebGL 2 or with the depth texture extension available.
  85483. * @param size The size of face edge in the texture.
  85484. * @param options The options defining the texture.
  85485. * @returns The texture
  85486. */
  85487. createDepthStencilTexture(size: number | {
  85488. width: number;
  85489. height: number;
  85490. layers?: number;
  85491. }, options: DepthTextureCreationOptions): InternalTexture;
  85492. /** @hidden */
  85493. _createDepthStencilTexture(size: number | {
  85494. width: number;
  85495. height: number;
  85496. layers?: number;
  85497. }, options: DepthTextureCreationOptions): InternalTexture;
  85498. }
  85499. }
  85500. declare module BABYLON {
  85501. /**
  85502. * Defines the kind of connection point for node based material
  85503. */
  85504. export enum NodeMaterialBlockConnectionPointTypes {
  85505. /** Float */
  85506. Float = 1,
  85507. /** Int */
  85508. Int = 2,
  85509. /** Vector2 */
  85510. Vector2 = 4,
  85511. /** Vector3 */
  85512. Vector3 = 8,
  85513. /** Vector4 */
  85514. Vector4 = 16,
  85515. /** Color3 */
  85516. Color3 = 32,
  85517. /** Color4 */
  85518. Color4 = 64,
  85519. /** Matrix */
  85520. Matrix = 128,
  85521. /** Custom object */
  85522. Object = 256,
  85523. /** Detect type based on connection */
  85524. AutoDetect = 1024,
  85525. /** Output type that will be defined by input type */
  85526. BasedOnInput = 2048
  85527. }
  85528. }
  85529. declare module BABYLON {
  85530. /**
  85531. * Enum used to define the target of a block
  85532. */
  85533. export enum NodeMaterialBlockTargets {
  85534. /** Vertex shader */
  85535. Vertex = 1,
  85536. /** Fragment shader */
  85537. Fragment = 2,
  85538. /** Neutral */
  85539. Neutral = 4,
  85540. /** Vertex and Fragment */
  85541. VertexAndFragment = 3
  85542. }
  85543. }
  85544. declare module BABYLON {
  85545. /**
  85546. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  85547. */
  85548. export enum NodeMaterialBlockConnectionPointMode {
  85549. /** Value is an uniform */
  85550. Uniform = 0,
  85551. /** Value is a mesh attribute */
  85552. Attribute = 1,
  85553. /** Value is a varying between vertex and fragment shaders */
  85554. Varying = 2,
  85555. /** Mode is undefined */
  85556. Undefined = 3
  85557. }
  85558. }
  85559. declare module BABYLON {
  85560. /**
  85561. * Enum used to define system values e.g. values automatically provided by the system
  85562. */
  85563. export enum NodeMaterialSystemValues {
  85564. /** World */
  85565. World = 1,
  85566. /** View */
  85567. View = 2,
  85568. /** Projection */
  85569. Projection = 3,
  85570. /** ViewProjection */
  85571. ViewProjection = 4,
  85572. /** WorldView */
  85573. WorldView = 5,
  85574. /** WorldViewProjection */
  85575. WorldViewProjection = 6,
  85576. /** CameraPosition */
  85577. CameraPosition = 7,
  85578. /** Fog Color */
  85579. FogColor = 8,
  85580. /** Delta time */
  85581. DeltaTime = 9
  85582. }
  85583. }
  85584. declare module BABYLON {
  85585. /** Defines supported spaces */
  85586. export enum Space {
  85587. /** Local (object) space */
  85588. LOCAL = 0,
  85589. /** World space */
  85590. WORLD = 1,
  85591. /** Bone space */
  85592. BONE = 2
  85593. }
  85594. /** Defines the 3 main axes */
  85595. export class Axis {
  85596. /** X axis */
  85597. static X: Vector3;
  85598. /** Y axis */
  85599. static Y: Vector3;
  85600. /** Z axis */
  85601. static Z: Vector3;
  85602. }
  85603. }
  85604. declare module BABYLON {
  85605. /**
  85606. * Represents a camera frustum
  85607. */
  85608. export class Frustum {
  85609. /**
  85610. * Gets the planes representing the frustum
  85611. * @param transform matrix to be applied to the returned planes
  85612. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  85613. */
  85614. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  85615. /**
  85616. * Gets the near frustum plane transformed by the transform matrix
  85617. * @param transform transformation matrix to be applied to the resulting frustum plane
  85618. * @param frustumPlane the resuling frustum plane
  85619. */
  85620. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  85621. /**
  85622. * Gets the far frustum plane transformed by the transform matrix
  85623. * @param transform transformation matrix to be applied to the resulting frustum plane
  85624. * @param frustumPlane the resuling frustum plane
  85625. */
  85626. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  85627. /**
  85628. * Gets the left frustum plane transformed by the transform matrix
  85629. * @param transform transformation matrix to be applied to the resulting frustum plane
  85630. * @param frustumPlane the resuling frustum plane
  85631. */
  85632. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  85633. /**
  85634. * Gets the right frustum plane transformed by the transform matrix
  85635. * @param transform transformation matrix to be applied to the resulting frustum plane
  85636. * @param frustumPlane the resuling frustum plane
  85637. */
  85638. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  85639. /**
  85640. * Gets the top frustum plane transformed by the transform matrix
  85641. * @param transform transformation matrix to be applied to the resulting frustum plane
  85642. * @param frustumPlane the resuling frustum plane
  85643. */
  85644. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  85645. /**
  85646. * Gets the bottom frustum plane transformed by the transform matrix
  85647. * @param transform transformation matrix to be applied to the resulting frustum plane
  85648. * @param frustumPlane the resuling frustum plane
  85649. */
  85650. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  85651. /**
  85652. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  85653. * @param transform transformation matrix to be applied to the resulting frustum planes
  85654. * @param frustumPlanes the resuling frustum planes
  85655. */
  85656. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  85657. }
  85658. }
  85659. declare module BABYLON {
  85660. /**
  85661. * Interface for the size containing width and height
  85662. */
  85663. export interface ISize {
  85664. /**
  85665. * Width
  85666. */
  85667. width: number;
  85668. /**
  85669. * Heighht
  85670. */
  85671. height: number;
  85672. }
  85673. /**
  85674. * Size containing widht and height
  85675. */
  85676. export class Size implements ISize {
  85677. /**
  85678. * Width
  85679. */
  85680. width: number;
  85681. /**
  85682. * Height
  85683. */
  85684. height: number;
  85685. /**
  85686. * Creates a Size object from the given width and height (floats).
  85687. * @param width width of the new size
  85688. * @param height height of the new size
  85689. */
  85690. constructor(width: number, height: number);
  85691. /**
  85692. * Returns a string with the Size width and height
  85693. * @returns a string with the Size width and height
  85694. */
  85695. toString(): string;
  85696. /**
  85697. * "Size"
  85698. * @returns the string "Size"
  85699. */
  85700. getClassName(): string;
  85701. /**
  85702. * Returns the Size hash code.
  85703. * @returns a hash code for a unique width and height
  85704. */
  85705. getHashCode(): number;
  85706. /**
  85707. * Updates the current size from the given one.
  85708. * @param src the given size
  85709. */
  85710. copyFrom(src: Size): void;
  85711. /**
  85712. * Updates in place the current Size from the given floats.
  85713. * @param width width of the new size
  85714. * @param height height of the new size
  85715. * @returns the updated Size.
  85716. */
  85717. copyFromFloats(width: number, height: number): Size;
  85718. /**
  85719. * Updates in place the current Size from the given floats.
  85720. * @param width width to set
  85721. * @param height height to set
  85722. * @returns the updated Size.
  85723. */
  85724. set(width: number, height: number): Size;
  85725. /**
  85726. * Multiplies the width and height by numbers
  85727. * @param w factor to multiple the width by
  85728. * @param h factor to multiple the height by
  85729. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  85730. */
  85731. multiplyByFloats(w: number, h: number): Size;
  85732. /**
  85733. * Clones the size
  85734. * @returns a new Size copied from the given one.
  85735. */
  85736. clone(): Size;
  85737. /**
  85738. * True if the current Size and the given one width and height are strictly equal.
  85739. * @param other the other size to compare against
  85740. * @returns True if the current Size and the given one width and height are strictly equal.
  85741. */
  85742. equals(other: Size): boolean;
  85743. /**
  85744. * The surface of the Size : width * height (float).
  85745. */
  85746. get surface(): number;
  85747. /**
  85748. * Create a new size of zero
  85749. * @returns a new Size set to (0.0, 0.0)
  85750. */
  85751. static Zero(): Size;
  85752. /**
  85753. * Sums the width and height of two sizes
  85754. * @param otherSize size to add to this size
  85755. * @returns a new Size set as the addition result of the current Size and the given one.
  85756. */
  85757. add(otherSize: Size): Size;
  85758. /**
  85759. * Subtracts the width and height of two
  85760. * @param otherSize size to subtract to this size
  85761. * @returns a new Size set as the subtraction result of the given one from the current Size.
  85762. */
  85763. subtract(otherSize: Size): Size;
  85764. /**
  85765. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  85766. * @param start starting size to lerp between
  85767. * @param end end size to lerp between
  85768. * @param amount amount to lerp between the start and end values
  85769. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  85770. */
  85771. static Lerp(start: Size, end: Size, amount: number): Size;
  85772. }
  85773. }
  85774. declare module BABYLON {
  85775. /**
  85776. * Contains position and normal vectors for a vertex
  85777. */
  85778. export class PositionNormalVertex {
  85779. /** the position of the vertex (defaut: 0,0,0) */
  85780. position: Vector3;
  85781. /** the normal of the vertex (defaut: 0,1,0) */
  85782. normal: Vector3;
  85783. /**
  85784. * Creates a PositionNormalVertex
  85785. * @param position the position of the vertex (defaut: 0,0,0)
  85786. * @param normal the normal of the vertex (defaut: 0,1,0)
  85787. */
  85788. constructor(
  85789. /** the position of the vertex (defaut: 0,0,0) */
  85790. position?: Vector3,
  85791. /** the normal of the vertex (defaut: 0,1,0) */
  85792. normal?: Vector3);
  85793. /**
  85794. * Clones the PositionNormalVertex
  85795. * @returns the cloned PositionNormalVertex
  85796. */
  85797. clone(): PositionNormalVertex;
  85798. }
  85799. /**
  85800. * Contains position, normal and uv vectors for a vertex
  85801. */
  85802. export class PositionNormalTextureVertex {
  85803. /** the position of the vertex (defaut: 0,0,0) */
  85804. position: Vector3;
  85805. /** the normal of the vertex (defaut: 0,1,0) */
  85806. normal: Vector3;
  85807. /** the uv of the vertex (default: 0,0) */
  85808. uv: Vector2;
  85809. /**
  85810. * Creates a PositionNormalTextureVertex
  85811. * @param position the position of the vertex (defaut: 0,0,0)
  85812. * @param normal the normal of the vertex (defaut: 0,1,0)
  85813. * @param uv the uv of the vertex (default: 0,0)
  85814. */
  85815. constructor(
  85816. /** the position of the vertex (defaut: 0,0,0) */
  85817. position?: Vector3,
  85818. /** the normal of the vertex (defaut: 0,1,0) */
  85819. normal?: Vector3,
  85820. /** the uv of the vertex (default: 0,0) */
  85821. uv?: Vector2);
  85822. /**
  85823. * Clones the PositionNormalTextureVertex
  85824. * @returns the cloned PositionNormalTextureVertex
  85825. */
  85826. clone(): PositionNormalTextureVertex;
  85827. }
  85828. }
  85829. declare module BABYLON {
  85830. /**
  85831. * Enum defining the type of animations supported by InputBlock
  85832. */
  85833. export enum AnimatedInputBlockTypes {
  85834. /** No animation */
  85835. None = 0,
  85836. /** Time based animation. Will only work for floats */
  85837. Time = 1
  85838. }
  85839. }
  85840. declare module BABYLON {
  85841. /**
  85842. * Interface describing all the common properties and methods a shadow light needs to implement.
  85843. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  85844. * as well as binding the different shadow properties to the effects.
  85845. */
  85846. export interface IShadowLight extends Light {
  85847. /**
  85848. * The light id in the scene (used in scene.findLighById for instance)
  85849. */
  85850. id: string;
  85851. /**
  85852. * The position the shdow will be casted from.
  85853. */
  85854. position: Vector3;
  85855. /**
  85856. * In 2d mode (needCube being false), the direction used to cast the shadow.
  85857. */
  85858. direction: Vector3;
  85859. /**
  85860. * The transformed position. Position of the light in world space taking parenting in account.
  85861. */
  85862. transformedPosition: Vector3;
  85863. /**
  85864. * The transformed direction. Direction of the light in world space taking parenting in account.
  85865. */
  85866. transformedDirection: Vector3;
  85867. /**
  85868. * The friendly name of the light in the scene.
  85869. */
  85870. name: string;
  85871. /**
  85872. * Defines the shadow projection clipping minimum z value.
  85873. */
  85874. shadowMinZ: number;
  85875. /**
  85876. * Defines the shadow projection clipping maximum z value.
  85877. */
  85878. shadowMaxZ: number;
  85879. /**
  85880. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  85881. * @returns true if the information has been computed, false if it does not need to (no parenting)
  85882. */
  85883. computeTransformedInformation(): boolean;
  85884. /**
  85885. * Gets the scene the light belongs to.
  85886. * @returns The scene
  85887. */
  85888. getScene(): Scene;
  85889. /**
  85890. * Callback defining a custom Projection Matrix Builder.
  85891. * This can be used to override the default projection matrix computation.
  85892. */
  85893. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  85894. /**
  85895. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  85896. * @param matrix The materix to updated with the projection information
  85897. * @param viewMatrix The transform matrix of the light
  85898. * @param renderList The list of mesh to render in the map
  85899. * @returns The current light
  85900. */
  85901. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  85902. /**
  85903. * Gets the current depth scale used in ESM.
  85904. * @returns The scale
  85905. */
  85906. getDepthScale(): number;
  85907. /**
  85908. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  85909. * @returns true if a cube texture needs to be use
  85910. */
  85911. needCube(): boolean;
  85912. /**
  85913. * Detects if the projection matrix requires to be recomputed this frame.
  85914. * @returns true if it requires to be recomputed otherwise, false.
  85915. */
  85916. needProjectionMatrixCompute(): boolean;
  85917. /**
  85918. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  85919. */
  85920. forceProjectionMatrixCompute(): void;
  85921. /**
  85922. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  85923. * @param faceIndex The index of the face we are computed the direction to generate shadow
  85924. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  85925. */
  85926. getShadowDirection(faceIndex?: number): Vector3;
  85927. /**
  85928. * Gets the minZ used for shadow according to both the scene and the light.
  85929. * @param activeCamera The camera we are returning the min for
  85930. * @returns the depth min z
  85931. */
  85932. getDepthMinZ(activeCamera: Camera): number;
  85933. /**
  85934. * Gets the maxZ used for shadow according to both the scene and the light.
  85935. * @param activeCamera The camera we are returning the max for
  85936. * @returns the depth max z
  85937. */
  85938. getDepthMaxZ(activeCamera: Camera): number;
  85939. }
  85940. /**
  85941. * Base implementation IShadowLight
  85942. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  85943. */
  85944. export abstract class ShadowLight extends Light implements IShadowLight {
  85945. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  85946. protected _position: Vector3;
  85947. protected _setPosition(value: Vector3): void;
  85948. /**
  85949. * Sets the position the shadow will be casted from. Also use as the light position for both
  85950. * point and spot lights.
  85951. */
  85952. get position(): Vector3;
  85953. /**
  85954. * Sets the position the shadow will be casted from. Also use as the light position for both
  85955. * point and spot lights.
  85956. */
  85957. set position(value: Vector3);
  85958. protected _direction: Vector3;
  85959. protected _setDirection(value: Vector3): void;
  85960. /**
  85961. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  85962. * Also use as the light direction on spot and directional lights.
  85963. */
  85964. get direction(): Vector3;
  85965. /**
  85966. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  85967. * Also use as the light direction on spot and directional lights.
  85968. */
  85969. set direction(value: Vector3);
  85970. protected _shadowMinZ: number;
  85971. /**
  85972. * Gets the shadow projection clipping minimum z value.
  85973. */
  85974. get shadowMinZ(): number;
  85975. /**
  85976. * Sets the shadow projection clipping minimum z value.
  85977. */
  85978. set shadowMinZ(value: number);
  85979. protected _shadowMaxZ: number;
  85980. /**
  85981. * Sets the shadow projection clipping maximum z value.
  85982. */
  85983. get shadowMaxZ(): number;
  85984. /**
  85985. * Gets the shadow projection clipping maximum z value.
  85986. */
  85987. set shadowMaxZ(value: number);
  85988. /**
  85989. * Callback defining a custom Projection Matrix Builder.
  85990. * This can be used to override the default projection matrix computation.
  85991. */
  85992. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  85993. /**
  85994. * The transformed position. Position of the light in world space taking parenting in account.
  85995. */
  85996. transformedPosition: Vector3;
  85997. /**
  85998. * The transformed direction. Direction of the light in world space taking parenting in account.
  85999. */
  86000. transformedDirection: Vector3;
  86001. private _needProjectionMatrixCompute;
  86002. /**
  86003. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  86004. * @returns true if the information has been computed, false if it does not need to (no parenting)
  86005. */
  86006. computeTransformedInformation(): boolean;
  86007. /**
  86008. * Return the depth scale used for the shadow map.
  86009. * @returns the depth scale.
  86010. */
  86011. getDepthScale(): number;
  86012. /**
  86013. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  86014. * @param faceIndex The index of the face we are computed the direction to generate shadow
  86015. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  86016. */
  86017. getShadowDirection(faceIndex?: number): Vector3;
  86018. /**
  86019. * Returns the ShadowLight absolute position in the World.
  86020. * @returns the position vector in world space
  86021. */
  86022. getAbsolutePosition(): Vector3;
  86023. /**
  86024. * Sets the ShadowLight direction toward the passed target.
  86025. * @param target The point to target in local space
  86026. * @returns the updated ShadowLight direction
  86027. */
  86028. setDirectionToTarget(target: Vector3): Vector3;
  86029. /**
  86030. * Returns the light rotation in euler definition.
  86031. * @returns the x y z rotation in local space.
  86032. */
  86033. getRotation(): Vector3;
  86034. /**
  86035. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  86036. * @returns true if a cube texture needs to be use
  86037. */
  86038. needCube(): boolean;
  86039. /**
  86040. * Detects if the projection matrix requires to be recomputed this frame.
  86041. * @returns true if it requires to be recomputed otherwise, false.
  86042. */
  86043. needProjectionMatrixCompute(): boolean;
  86044. /**
  86045. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  86046. */
  86047. forceProjectionMatrixCompute(): void;
  86048. /** @hidden */
  86049. _initCache(): void;
  86050. /** @hidden */
  86051. _isSynchronized(): boolean;
  86052. /**
  86053. * Computes the world matrix of the node
  86054. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  86055. * @returns the world matrix
  86056. */
  86057. computeWorldMatrix(force?: boolean): Matrix;
  86058. /**
  86059. * Gets the minZ used for shadow according to both the scene and the light.
  86060. * @param activeCamera The camera we are returning the min for
  86061. * @returns the depth min z
  86062. */
  86063. getDepthMinZ(activeCamera: Camera): number;
  86064. /**
  86065. * Gets the maxZ used for shadow according to both the scene and the light.
  86066. * @param activeCamera The camera we are returning the max for
  86067. * @returns the depth max z
  86068. */
  86069. getDepthMaxZ(activeCamera: Camera): number;
  86070. /**
  86071. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  86072. * @param matrix The materix to updated with the projection information
  86073. * @param viewMatrix The transform matrix of the light
  86074. * @param renderList The list of mesh to render in the map
  86075. * @returns The current light
  86076. */
  86077. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  86078. }
  86079. }
  86080. declare module BABYLON {
  86081. /** @hidden */
  86082. export var packingFunctions: {
  86083. name: string;
  86084. shader: string;
  86085. };
  86086. }
  86087. declare module BABYLON {
  86088. /** @hidden */
  86089. export var bayerDitherFunctions: {
  86090. name: string;
  86091. shader: string;
  86092. };
  86093. }
  86094. declare module BABYLON {
  86095. /** @hidden */
  86096. export var shadowMapFragmentDeclaration: {
  86097. name: string;
  86098. shader: string;
  86099. };
  86100. }
  86101. declare module BABYLON {
  86102. /** @hidden */
  86103. export var clipPlaneFragmentDeclaration: {
  86104. name: string;
  86105. shader: string;
  86106. };
  86107. }
  86108. declare module BABYLON {
  86109. /** @hidden */
  86110. export var clipPlaneFragment: {
  86111. name: string;
  86112. shader: string;
  86113. };
  86114. }
  86115. declare module BABYLON {
  86116. /** @hidden */
  86117. export var shadowMapFragment: {
  86118. name: string;
  86119. shader: string;
  86120. };
  86121. }
  86122. declare module BABYLON {
  86123. /** @hidden */
  86124. export var shadowMapPixelShader: {
  86125. name: string;
  86126. shader: string;
  86127. };
  86128. }
  86129. declare module BABYLON {
  86130. /** @hidden */
  86131. export var bonesDeclaration: {
  86132. name: string;
  86133. shader: string;
  86134. };
  86135. }
  86136. declare module BABYLON {
  86137. /** @hidden */
  86138. export var morphTargetsVertexGlobalDeclaration: {
  86139. name: string;
  86140. shader: string;
  86141. };
  86142. }
  86143. declare module BABYLON {
  86144. /** @hidden */
  86145. export var morphTargetsVertexDeclaration: {
  86146. name: string;
  86147. shader: string;
  86148. };
  86149. }
  86150. declare module BABYLON {
  86151. /** @hidden */
  86152. export var instancesDeclaration: {
  86153. name: string;
  86154. shader: string;
  86155. };
  86156. }
  86157. declare module BABYLON {
  86158. /** @hidden */
  86159. export var helperFunctions: {
  86160. name: string;
  86161. shader: string;
  86162. };
  86163. }
  86164. declare module BABYLON {
  86165. /** @hidden */
  86166. export var shadowMapVertexDeclaration: {
  86167. name: string;
  86168. shader: string;
  86169. };
  86170. }
  86171. declare module BABYLON {
  86172. /** @hidden */
  86173. export var clipPlaneVertexDeclaration: {
  86174. name: string;
  86175. shader: string;
  86176. };
  86177. }
  86178. declare module BABYLON {
  86179. /** @hidden */
  86180. export var morphTargetsVertex: {
  86181. name: string;
  86182. shader: string;
  86183. };
  86184. }
  86185. declare module BABYLON {
  86186. /** @hidden */
  86187. export var instancesVertex: {
  86188. name: string;
  86189. shader: string;
  86190. };
  86191. }
  86192. declare module BABYLON {
  86193. /** @hidden */
  86194. export var bonesVertex: {
  86195. name: string;
  86196. shader: string;
  86197. };
  86198. }
  86199. declare module BABYLON {
  86200. /** @hidden */
  86201. export var shadowMapVertexNormalBias: {
  86202. name: string;
  86203. shader: string;
  86204. };
  86205. }
  86206. declare module BABYLON {
  86207. /** @hidden */
  86208. export var shadowMapVertexMetric: {
  86209. name: string;
  86210. shader: string;
  86211. };
  86212. }
  86213. declare module BABYLON {
  86214. /** @hidden */
  86215. export var clipPlaneVertex: {
  86216. name: string;
  86217. shader: string;
  86218. };
  86219. }
  86220. declare module BABYLON {
  86221. /** @hidden */
  86222. export var shadowMapVertexShader: {
  86223. name: string;
  86224. shader: string;
  86225. };
  86226. }
  86227. declare module BABYLON {
  86228. /** @hidden */
  86229. export var depthBoxBlurPixelShader: {
  86230. name: string;
  86231. shader: string;
  86232. };
  86233. }
  86234. declare module BABYLON {
  86235. /** @hidden */
  86236. export var shadowMapFragmentSoftTransparentShadow: {
  86237. name: string;
  86238. shader: string;
  86239. };
  86240. }
  86241. declare module BABYLON {
  86242. /**
  86243. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  86244. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  86245. */
  86246. export class EffectFallbacks implements IEffectFallbacks {
  86247. private _defines;
  86248. private _currentRank;
  86249. private _maxRank;
  86250. private _mesh;
  86251. /**
  86252. * Removes the fallback from the bound mesh.
  86253. */
  86254. unBindMesh(): void;
  86255. /**
  86256. * Adds a fallback on the specified property.
  86257. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  86258. * @param define The name of the define in the shader
  86259. */
  86260. addFallback(rank: number, define: string): void;
  86261. /**
  86262. * Sets the mesh to use CPU skinning when needing to fallback.
  86263. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  86264. * @param mesh The mesh to use the fallbacks.
  86265. */
  86266. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  86267. /**
  86268. * Checks to see if more fallbacks are still availible.
  86269. */
  86270. get hasMoreFallbacks(): boolean;
  86271. /**
  86272. * Removes the defines that should be removed when falling back.
  86273. * @param currentDefines defines the current define statements for the shader.
  86274. * @param effect defines the current effect we try to compile
  86275. * @returns The resulting defines with defines of the current rank removed.
  86276. */
  86277. reduce(currentDefines: string, effect: Effect): string;
  86278. }
  86279. }
  86280. declare module BABYLON {
  86281. /**
  86282. * Interface used to define Action
  86283. */
  86284. export interface IAction {
  86285. /**
  86286. * Trigger for the action
  86287. */
  86288. trigger: number;
  86289. /** Options of the trigger */
  86290. triggerOptions: any;
  86291. /**
  86292. * Gets the trigger parameters
  86293. * @returns the trigger parameters
  86294. */
  86295. getTriggerParameter(): any;
  86296. /**
  86297. * Internal only - executes current action event
  86298. * @hidden
  86299. */
  86300. _executeCurrent(evt?: ActionEvent): void;
  86301. /**
  86302. * Serialize placeholder for child classes
  86303. * @param parent of child
  86304. * @returns the serialized object
  86305. */
  86306. serialize(parent: any): any;
  86307. /**
  86308. * Internal only
  86309. * @hidden
  86310. */
  86311. _prepare(): void;
  86312. /**
  86313. * Internal only - manager for action
  86314. * @hidden
  86315. */
  86316. _actionManager: AbstractActionManager;
  86317. /**
  86318. * Adds action to chain of actions, may be a DoNothingAction
  86319. * @param action defines the next action to execute
  86320. * @returns The action passed in
  86321. * @see https://www.babylonjs-playground.com/#1T30HR#0
  86322. */
  86323. then(action: IAction): IAction;
  86324. }
  86325. /**
  86326. * The action to be carried out following a trigger
  86327. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  86328. */
  86329. export class Action implements IAction {
  86330. /** the trigger, with or without parameters, for the action */
  86331. triggerOptions: any;
  86332. /**
  86333. * Trigger for the action
  86334. */
  86335. trigger: number;
  86336. /**
  86337. * Internal only - manager for action
  86338. * @hidden
  86339. */
  86340. _actionManager: ActionManager;
  86341. private _nextActiveAction;
  86342. private _child;
  86343. private _condition?;
  86344. private _triggerParameter;
  86345. /**
  86346. * An event triggered prior to action being executed.
  86347. */
  86348. onBeforeExecuteObservable: Observable<Action>;
  86349. /**
  86350. * Creates a new Action
  86351. * @param triggerOptions the trigger, with or without parameters, for the action
  86352. * @param condition an optional determinant of action
  86353. */
  86354. constructor(
  86355. /** the trigger, with or without parameters, for the action */
  86356. triggerOptions: any, condition?: Condition);
  86357. /**
  86358. * Internal only
  86359. * @hidden
  86360. */
  86361. _prepare(): void;
  86362. /**
  86363. * Gets the trigger parameters
  86364. * @returns the trigger parameters
  86365. */
  86366. getTriggerParameter(): any;
  86367. /**
  86368. * Internal only - executes current action event
  86369. * @hidden
  86370. */
  86371. _executeCurrent(evt?: ActionEvent): void;
  86372. /**
  86373. * Execute placeholder for child classes
  86374. * @param evt optional action event
  86375. */
  86376. execute(evt?: ActionEvent): void;
  86377. /**
  86378. * Skips to next active action
  86379. */
  86380. skipToNextActiveAction(): void;
  86381. /**
  86382. * Adds action to chain of actions, may be a DoNothingAction
  86383. * @param action defines the next action to execute
  86384. * @returns The action passed in
  86385. * @see https://www.babylonjs-playground.com/#1T30HR#0
  86386. */
  86387. then(action: Action): Action;
  86388. /**
  86389. * Internal only
  86390. * @hidden
  86391. */
  86392. _getProperty(propertyPath: string): string;
  86393. /**
  86394. * Internal only
  86395. * @hidden
  86396. */
  86397. _getEffectiveTarget(target: any, propertyPath: string): any;
  86398. /**
  86399. * Serialize placeholder for child classes
  86400. * @param parent of child
  86401. * @returns the serialized object
  86402. */
  86403. serialize(parent: any): any;
  86404. /**
  86405. * Internal only called by serialize
  86406. * @hidden
  86407. */
  86408. protected _serialize(serializedAction: any, parent?: any): any;
  86409. /**
  86410. * Internal only
  86411. * @hidden
  86412. */
  86413. static _SerializeValueAsString: (value: any) => string;
  86414. /**
  86415. * Internal only
  86416. * @hidden
  86417. */
  86418. static _GetTargetProperty: (target: Node | Scene) => {
  86419. name: string;
  86420. targetType: string;
  86421. value: string;
  86422. };
  86423. }
  86424. }
  86425. declare module BABYLON {
  86426. /**
  86427. * A Condition applied to an Action
  86428. */
  86429. export class Condition {
  86430. /**
  86431. * Internal only - manager for action
  86432. * @hidden
  86433. */
  86434. _actionManager: ActionManager;
  86435. /**
  86436. * Internal only
  86437. * @hidden
  86438. */
  86439. _evaluationId: number;
  86440. /**
  86441. * Internal only
  86442. * @hidden
  86443. */
  86444. _currentResult: boolean;
  86445. /**
  86446. * Creates a new Condition
  86447. * @param actionManager the manager of the action the condition is applied to
  86448. */
  86449. constructor(actionManager: ActionManager);
  86450. /**
  86451. * Check if the current condition is valid
  86452. * @returns a boolean
  86453. */
  86454. isValid(): boolean;
  86455. /**
  86456. * Internal only
  86457. * @hidden
  86458. */
  86459. _getProperty(propertyPath: string): string;
  86460. /**
  86461. * Internal only
  86462. * @hidden
  86463. */
  86464. _getEffectiveTarget(target: any, propertyPath: string): any;
  86465. /**
  86466. * Serialize placeholder for child classes
  86467. * @returns the serialized object
  86468. */
  86469. serialize(): any;
  86470. /**
  86471. * Internal only
  86472. * @hidden
  86473. */
  86474. protected _serialize(serializedCondition: any): any;
  86475. }
  86476. /**
  86477. * Defines specific conditional operators as extensions of Condition
  86478. */
  86479. export class ValueCondition extends Condition {
  86480. /** path to specify the property of the target the conditional operator uses */
  86481. propertyPath: string;
  86482. /** the value compared by the conditional operator against the current value of the property */
  86483. value: any;
  86484. /** the conditional operator, default ValueCondition.IsEqual */
  86485. operator: number;
  86486. /**
  86487. * Internal only
  86488. * @hidden
  86489. */
  86490. private static _IsEqual;
  86491. /**
  86492. * Internal only
  86493. * @hidden
  86494. */
  86495. private static _IsDifferent;
  86496. /**
  86497. * Internal only
  86498. * @hidden
  86499. */
  86500. private static _IsGreater;
  86501. /**
  86502. * Internal only
  86503. * @hidden
  86504. */
  86505. private static _IsLesser;
  86506. /**
  86507. * returns the number for IsEqual
  86508. */
  86509. static get IsEqual(): number;
  86510. /**
  86511. * Returns the number for IsDifferent
  86512. */
  86513. static get IsDifferent(): number;
  86514. /**
  86515. * Returns the number for IsGreater
  86516. */
  86517. static get IsGreater(): number;
  86518. /**
  86519. * Returns the number for IsLesser
  86520. */
  86521. static get IsLesser(): number;
  86522. /**
  86523. * Internal only The action manager for the condition
  86524. * @hidden
  86525. */
  86526. _actionManager: ActionManager;
  86527. /**
  86528. * Internal only
  86529. * @hidden
  86530. */
  86531. private _target;
  86532. /**
  86533. * Internal only
  86534. * @hidden
  86535. */
  86536. private _effectiveTarget;
  86537. /**
  86538. * Internal only
  86539. * @hidden
  86540. */
  86541. private _property;
  86542. /**
  86543. * Creates a new ValueCondition
  86544. * @param actionManager manager for the action the condition applies to
  86545. * @param target for the action
  86546. * @param propertyPath path to specify the property of the target the conditional operator uses
  86547. * @param value the value compared by the conditional operator against the current value of the property
  86548. * @param operator the conditional operator, default ValueCondition.IsEqual
  86549. */
  86550. constructor(actionManager: ActionManager, target: any,
  86551. /** path to specify the property of the target the conditional operator uses */
  86552. propertyPath: string,
  86553. /** the value compared by the conditional operator against the current value of the property */
  86554. value: any,
  86555. /** the conditional operator, default ValueCondition.IsEqual */
  86556. operator?: number);
  86557. /**
  86558. * Compares the given value with the property value for the specified conditional operator
  86559. * @returns the result of the comparison
  86560. */
  86561. isValid(): boolean;
  86562. /**
  86563. * Serialize the ValueCondition into a JSON compatible object
  86564. * @returns serialization object
  86565. */
  86566. serialize(): any;
  86567. /**
  86568. * Gets the name of the conditional operator for the ValueCondition
  86569. * @param operator the conditional operator
  86570. * @returns the name
  86571. */
  86572. static GetOperatorName(operator: number): string;
  86573. }
  86574. /**
  86575. * Defines a predicate condition as an extension of Condition
  86576. */
  86577. export class PredicateCondition extends Condition {
  86578. /** defines the predicate function used to validate the condition */
  86579. predicate: () => boolean;
  86580. /**
  86581. * Internal only - manager for action
  86582. * @hidden
  86583. */
  86584. _actionManager: ActionManager;
  86585. /**
  86586. * Creates a new PredicateCondition
  86587. * @param actionManager manager for the action the condition applies to
  86588. * @param predicate defines the predicate function used to validate the condition
  86589. */
  86590. constructor(actionManager: ActionManager,
  86591. /** defines the predicate function used to validate the condition */
  86592. predicate: () => boolean);
  86593. /**
  86594. * @returns the validity of the predicate condition
  86595. */
  86596. isValid(): boolean;
  86597. }
  86598. /**
  86599. * Defines a state condition as an extension of Condition
  86600. */
  86601. export class StateCondition extends Condition {
  86602. /** Value to compare with target state */
  86603. value: string;
  86604. /**
  86605. * Internal only - manager for action
  86606. * @hidden
  86607. */
  86608. _actionManager: ActionManager;
  86609. /**
  86610. * Internal only
  86611. * @hidden
  86612. */
  86613. private _target;
  86614. /**
  86615. * Creates a new StateCondition
  86616. * @param actionManager manager for the action the condition applies to
  86617. * @param target of the condition
  86618. * @param value to compare with target state
  86619. */
  86620. constructor(actionManager: ActionManager, target: any,
  86621. /** Value to compare with target state */
  86622. value: string);
  86623. /**
  86624. * Gets a boolean indicating if the current condition is met
  86625. * @returns the validity of the state
  86626. */
  86627. isValid(): boolean;
  86628. /**
  86629. * Serialize the StateCondition into a JSON compatible object
  86630. * @returns serialization object
  86631. */
  86632. serialize(): any;
  86633. }
  86634. }
  86635. declare module BABYLON {
  86636. /**
  86637. * This defines an action responsible to toggle a boolean once triggered.
  86638. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  86639. */
  86640. export class SwitchBooleanAction extends Action {
  86641. /**
  86642. * The path to the boolean property in the target object
  86643. */
  86644. propertyPath: string;
  86645. private _target;
  86646. private _effectiveTarget;
  86647. private _property;
  86648. /**
  86649. * Instantiate the action
  86650. * @param triggerOptions defines the trigger options
  86651. * @param target defines the object containing the boolean
  86652. * @param propertyPath defines the path to the boolean property in the target object
  86653. * @param condition defines the trigger related conditions
  86654. */
  86655. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  86656. /** @hidden */
  86657. _prepare(): void;
  86658. /**
  86659. * Execute the action toggle the boolean value.
  86660. */
  86661. execute(): void;
  86662. /**
  86663. * Serializes the actions and its related information.
  86664. * @param parent defines the object to serialize in
  86665. * @returns the serialized object
  86666. */
  86667. serialize(parent: any): any;
  86668. }
  86669. /**
  86670. * This defines an action responsible to set a the state field of the target
  86671. * to a desired value once triggered.
  86672. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  86673. */
  86674. export class SetStateAction extends Action {
  86675. /**
  86676. * The value to store in the state field.
  86677. */
  86678. value: string;
  86679. private _target;
  86680. /**
  86681. * Instantiate the action
  86682. * @param triggerOptions defines the trigger options
  86683. * @param target defines the object containing the state property
  86684. * @param value defines the value to store in the state field
  86685. * @param condition defines the trigger related conditions
  86686. */
  86687. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  86688. /**
  86689. * Execute the action and store the value on the target state property.
  86690. */
  86691. execute(): void;
  86692. /**
  86693. * Serializes the actions and its related information.
  86694. * @param parent defines the object to serialize in
  86695. * @returns the serialized object
  86696. */
  86697. serialize(parent: any): any;
  86698. }
  86699. /**
  86700. * This defines an action responsible to set a property of the target
  86701. * to a desired value once triggered.
  86702. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  86703. */
  86704. export class SetValueAction extends Action {
  86705. /**
  86706. * The path of the property to set in the target.
  86707. */
  86708. propertyPath: string;
  86709. /**
  86710. * The value to set in the property
  86711. */
  86712. value: any;
  86713. private _target;
  86714. private _effectiveTarget;
  86715. private _property;
  86716. /**
  86717. * Instantiate the action
  86718. * @param triggerOptions defines the trigger options
  86719. * @param target defines the object containing the property
  86720. * @param propertyPath defines the path of the property to set in the target
  86721. * @param value defines the value to set in the property
  86722. * @param condition defines the trigger related conditions
  86723. */
  86724. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  86725. /** @hidden */
  86726. _prepare(): void;
  86727. /**
  86728. * Execute the action and set the targetted property to the desired value.
  86729. */
  86730. execute(): void;
  86731. /**
  86732. * Serializes the actions and its related information.
  86733. * @param parent defines the object to serialize in
  86734. * @returns the serialized object
  86735. */
  86736. serialize(parent: any): any;
  86737. }
  86738. /**
  86739. * This defines an action responsible to increment the target value
  86740. * to a desired value once triggered.
  86741. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  86742. */
  86743. export class IncrementValueAction extends Action {
  86744. /**
  86745. * The path of the property to increment in the target.
  86746. */
  86747. propertyPath: string;
  86748. /**
  86749. * The value we should increment the property by.
  86750. */
  86751. value: any;
  86752. private _target;
  86753. private _effectiveTarget;
  86754. private _property;
  86755. /**
  86756. * Instantiate the action
  86757. * @param triggerOptions defines the trigger options
  86758. * @param target defines the object containing the property
  86759. * @param propertyPath defines the path of the property to increment in the target
  86760. * @param value defines the value value we should increment the property by
  86761. * @param condition defines the trigger related conditions
  86762. */
  86763. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  86764. /** @hidden */
  86765. _prepare(): void;
  86766. /**
  86767. * Execute the action and increment the target of the value amount.
  86768. */
  86769. execute(): void;
  86770. /**
  86771. * Serializes the actions and its related information.
  86772. * @param parent defines the object to serialize in
  86773. * @returns the serialized object
  86774. */
  86775. serialize(parent: any): any;
  86776. }
  86777. /**
  86778. * This defines an action responsible to start an animation once triggered.
  86779. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  86780. */
  86781. export class PlayAnimationAction extends Action {
  86782. /**
  86783. * Where the animation should start (animation frame)
  86784. */
  86785. from: number;
  86786. /**
  86787. * Where the animation should stop (animation frame)
  86788. */
  86789. to: number;
  86790. /**
  86791. * Define if the animation should loop or stop after the first play.
  86792. */
  86793. loop?: boolean;
  86794. private _target;
  86795. /**
  86796. * Instantiate the action
  86797. * @param triggerOptions defines the trigger options
  86798. * @param target defines the target animation or animation name
  86799. * @param from defines from where the animation should start (animation frame)
  86800. * @param end defines where the animation should stop (animation frame)
  86801. * @param loop defines if the animation should loop or stop after the first play
  86802. * @param condition defines the trigger related conditions
  86803. */
  86804. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  86805. /** @hidden */
  86806. _prepare(): void;
  86807. /**
  86808. * Execute the action and play the animation.
  86809. */
  86810. execute(): void;
  86811. /**
  86812. * Serializes the actions and its related information.
  86813. * @param parent defines the object to serialize in
  86814. * @returns the serialized object
  86815. */
  86816. serialize(parent: any): any;
  86817. }
  86818. /**
  86819. * This defines an action responsible to stop an animation once triggered.
  86820. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  86821. */
  86822. export class StopAnimationAction extends Action {
  86823. private _target;
  86824. /**
  86825. * Instantiate the action
  86826. * @param triggerOptions defines the trigger options
  86827. * @param target defines the target animation or animation name
  86828. * @param condition defines the trigger related conditions
  86829. */
  86830. constructor(triggerOptions: any, target: any, condition?: Condition);
  86831. /** @hidden */
  86832. _prepare(): void;
  86833. /**
  86834. * Execute the action and stop the animation.
  86835. */
  86836. execute(): void;
  86837. /**
  86838. * Serializes the actions and its related information.
  86839. * @param parent defines the object to serialize in
  86840. * @returns the serialized object
  86841. */
  86842. serialize(parent: any): any;
  86843. }
  86844. /**
  86845. * This defines an action responsible that does nothing once triggered.
  86846. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  86847. */
  86848. export class DoNothingAction extends Action {
  86849. /**
  86850. * Instantiate the action
  86851. * @param triggerOptions defines the trigger options
  86852. * @param condition defines the trigger related conditions
  86853. */
  86854. constructor(triggerOptions?: any, condition?: Condition);
  86855. /**
  86856. * Execute the action and do nothing.
  86857. */
  86858. execute(): void;
  86859. /**
  86860. * Serializes the actions and its related information.
  86861. * @param parent defines the object to serialize in
  86862. * @returns the serialized object
  86863. */
  86864. serialize(parent: any): any;
  86865. }
  86866. /**
  86867. * This defines an action responsible to trigger several actions once triggered.
  86868. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  86869. */
  86870. export class CombineAction extends Action {
  86871. /**
  86872. * The list of aggregated animations to run.
  86873. */
  86874. children: Action[];
  86875. /**
  86876. * Instantiate the action
  86877. * @param triggerOptions defines the trigger options
  86878. * @param children defines the list of aggregated animations to run
  86879. * @param condition defines the trigger related conditions
  86880. */
  86881. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  86882. /** @hidden */
  86883. _prepare(): void;
  86884. /**
  86885. * Execute the action and executes all the aggregated actions.
  86886. */
  86887. execute(evt: ActionEvent): void;
  86888. /**
  86889. * Serializes the actions and its related information.
  86890. * @param parent defines the object to serialize in
  86891. * @returns the serialized object
  86892. */
  86893. serialize(parent: any): any;
  86894. }
  86895. /**
  86896. * This defines an action responsible to run code (external event) once triggered.
  86897. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  86898. */
  86899. export class ExecuteCodeAction extends Action {
  86900. /**
  86901. * The callback function to run.
  86902. */
  86903. func: (evt: ActionEvent) => void;
  86904. /**
  86905. * Instantiate the action
  86906. * @param triggerOptions defines the trigger options
  86907. * @param func defines the callback function to run
  86908. * @param condition defines the trigger related conditions
  86909. */
  86910. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  86911. /**
  86912. * Execute the action and run the attached code.
  86913. */
  86914. execute(evt: ActionEvent): void;
  86915. }
  86916. /**
  86917. * This defines an action responsible to set the parent property of the target once triggered.
  86918. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  86919. */
  86920. export class SetParentAction extends Action {
  86921. private _parent;
  86922. private _target;
  86923. /**
  86924. * Instantiate the action
  86925. * @param triggerOptions defines the trigger options
  86926. * @param target defines the target containing the parent property
  86927. * @param parent defines from where the animation should start (animation frame)
  86928. * @param condition defines the trigger related conditions
  86929. */
  86930. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  86931. /** @hidden */
  86932. _prepare(): void;
  86933. /**
  86934. * Execute the action and set the parent property.
  86935. */
  86936. execute(): void;
  86937. /**
  86938. * Serializes the actions and its related information.
  86939. * @param parent defines the object to serialize in
  86940. * @returns the serialized object
  86941. */
  86942. serialize(parent: any): any;
  86943. }
  86944. }
  86945. declare module BABYLON {
  86946. /**
  86947. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  86948. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  86949. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  86950. */
  86951. export class ActionManager extends AbstractActionManager {
  86952. /**
  86953. * Nothing
  86954. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  86955. */
  86956. static readonly NothingTrigger: number;
  86957. /**
  86958. * On pick
  86959. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  86960. */
  86961. static readonly OnPickTrigger: number;
  86962. /**
  86963. * On left pick
  86964. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  86965. */
  86966. static readonly OnLeftPickTrigger: number;
  86967. /**
  86968. * On right pick
  86969. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  86970. */
  86971. static readonly OnRightPickTrigger: number;
  86972. /**
  86973. * On center pick
  86974. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  86975. */
  86976. static readonly OnCenterPickTrigger: number;
  86977. /**
  86978. * On pick down
  86979. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  86980. */
  86981. static readonly OnPickDownTrigger: number;
  86982. /**
  86983. * On double pick
  86984. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  86985. */
  86986. static readonly OnDoublePickTrigger: number;
  86987. /**
  86988. * On pick up
  86989. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  86990. */
  86991. static readonly OnPickUpTrigger: number;
  86992. /**
  86993. * On pick out.
  86994. * This trigger will only be raised if you also declared a OnPickDown
  86995. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  86996. */
  86997. static readonly OnPickOutTrigger: number;
  86998. /**
  86999. * On long press
  87000. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87001. */
  87002. static readonly OnLongPressTrigger: number;
  87003. /**
  87004. * On pointer over
  87005. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87006. */
  87007. static readonly OnPointerOverTrigger: number;
  87008. /**
  87009. * On pointer out
  87010. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87011. */
  87012. static readonly OnPointerOutTrigger: number;
  87013. /**
  87014. * On every frame
  87015. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87016. */
  87017. static readonly OnEveryFrameTrigger: number;
  87018. /**
  87019. * On intersection enter
  87020. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87021. */
  87022. static readonly OnIntersectionEnterTrigger: number;
  87023. /**
  87024. * On intersection exit
  87025. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87026. */
  87027. static readonly OnIntersectionExitTrigger: number;
  87028. /**
  87029. * On key down
  87030. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87031. */
  87032. static readonly OnKeyDownTrigger: number;
  87033. /**
  87034. * On key up
  87035. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87036. */
  87037. static readonly OnKeyUpTrigger: number;
  87038. private _scene;
  87039. /**
  87040. * Creates a new action manager
  87041. * @param scene defines the hosting scene
  87042. */
  87043. constructor(scene: Scene);
  87044. /**
  87045. * Releases all associated resources
  87046. */
  87047. dispose(): void;
  87048. /**
  87049. * Gets hosting scene
  87050. * @returns the hosting scene
  87051. */
  87052. getScene(): Scene;
  87053. /**
  87054. * Does this action manager handles actions of any of the given triggers
  87055. * @param triggers defines the triggers to be tested
  87056. * @return a boolean indicating whether one (or more) of the triggers is handled
  87057. */
  87058. hasSpecificTriggers(triggers: number[]): boolean;
  87059. /**
  87060. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  87061. * speed.
  87062. * @param triggerA defines the trigger to be tested
  87063. * @param triggerB defines the trigger to be tested
  87064. * @return a boolean indicating whether one (or more) of the triggers is handled
  87065. */
  87066. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  87067. /**
  87068. * Does this action manager handles actions of a given trigger
  87069. * @param trigger defines the trigger to be tested
  87070. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  87071. * @return whether the trigger is handled
  87072. */
  87073. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  87074. /**
  87075. * Does this action manager has pointer triggers
  87076. */
  87077. get hasPointerTriggers(): boolean;
  87078. /**
  87079. * Does this action manager has pick triggers
  87080. */
  87081. get hasPickTriggers(): boolean;
  87082. /**
  87083. * Registers an action to this action manager
  87084. * @param action defines the action to be registered
  87085. * @return the action amended (prepared) after registration
  87086. */
  87087. registerAction(action: IAction): Nullable<IAction>;
  87088. /**
  87089. * Unregisters an action to this action manager
  87090. * @param action defines the action to be unregistered
  87091. * @return a boolean indicating whether the action has been unregistered
  87092. */
  87093. unregisterAction(action: IAction): Boolean;
  87094. /**
  87095. * Process a specific trigger
  87096. * @param trigger defines the trigger to process
  87097. * @param evt defines the event details to be processed
  87098. */
  87099. processTrigger(trigger: number, evt?: IActionEvent): void;
  87100. /** @hidden */
  87101. _getEffectiveTarget(target: any, propertyPath: string): any;
  87102. /** @hidden */
  87103. _getProperty(propertyPath: string): string;
  87104. /**
  87105. * Serialize this manager to a JSON object
  87106. * @param name defines the property name to store this manager
  87107. * @returns a JSON representation of this manager
  87108. */
  87109. serialize(name: string): any;
  87110. /**
  87111. * Creates a new ActionManager from a JSON data
  87112. * @param parsedActions defines the JSON data to read from
  87113. * @param object defines the hosting mesh
  87114. * @param scene defines the hosting scene
  87115. */
  87116. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  87117. /**
  87118. * Get a trigger name by index
  87119. * @param trigger defines the trigger index
  87120. * @returns a trigger name
  87121. */
  87122. static GetTriggerName(trigger: number): string;
  87123. }
  87124. }
  87125. declare module BABYLON {
  87126. /**
  87127. * Class used to represent a sprite
  87128. * @see http://doc.babylonjs.com/babylon101/sprites
  87129. */
  87130. export class Sprite implements IAnimatable {
  87131. /** defines the name */
  87132. name: string;
  87133. /** Gets or sets the current world position */
  87134. position: Vector3;
  87135. /** Gets or sets the main color */
  87136. color: Color4;
  87137. /** Gets or sets the width */
  87138. width: number;
  87139. /** Gets or sets the height */
  87140. height: number;
  87141. /** Gets or sets rotation angle */
  87142. angle: number;
  87143. /** Gets or sets the cell index in the sprite sheet */
  87144. cellIndex: number;
  87145. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  87146. cellRef: string;
  87147. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  87148. invertU: boolean;
  87149. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  87150. invertV: boolean;
  87151. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  87152. disposeWhenFinishedAnimating: boolean;
  87153. /** Gets the list of attached animations */
  87154. animations: Nullable<Array<Animation>>;
  87155. /** Gets or sets a boolean indicating if the sprite can be picked */
  87156. isPickable: boolean;
  87157. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  87158. useAlphaForPicking: boolean;
  87159. /** @hidden */
  87160. _xOffset: number;
  87161. /** @hidden */
  87162. _yOffset: number;
  87163. /** @hidden */
  87164. _xSize: number;
  87165. /** @hidden */
  87166. _ySize: number;
  87167. /**
  87168. * Gets or sets the associated action manager
  87169. */
  87170. actionManager: Nullable<ActionManager>;
  87171. /**
  87172. * An event triggered when the control has been disposed
  87173. */
  87174. onDisposeObservable: Observable<Sprite>;
  87175. private _animationStarted;
  87176. private _loopAnimation;
  87177. private _fromIndex;
  87178. private _toIndex;
  87179. private _delay;
  87180. private _direction;
  87181. private _manager;
  87182. private _time;
  87183. private _onAnimationEnd;
  87184. /**
  87185. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  87186. */
  87187. isVisible: boolean;
  87188. /**
  87189. * Gets or sets the sprite size
  87190. */
  87191. get size(): number;
  87192. set size(value: number);
  87193. /**
  87194. * Returns a boolean indicating if the animation is started
  87195. */
  87196. get animationStarted(): boolean;
  87197. /**
  87198. * Gets or sets the unique id of the sprite
  87199. */
  87200. uniqueId: number;
  87201. /**
  87202. * Gets the manager of this sprite
  87203. */
  87204. get manager(): ISpriteManager;
  87205. /**
  87206. * Creates a new Sprite
  87207. * @param name defines the name
  87208. * @param manager defines the manager
  87209. */
  87210. constructor(
  87211. /** defines the name */
  87212. name: string, manager: ISpriteManager);
  87213. /**
  87214. * Returns the string "Sprite"
  87215. * @returns "Sprite"
  87216. */
  87217. getClassName(): string;
  87218. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  87219. get fromIndex(): number;
  87220. set fromIndex(value: number);
  87221. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  87222. get toIndex(): number;
  87223. set toIndex(value: number);
  87224. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  87225. get loopAnimation(): boolean;
  87226. set loopAnimation(value: boolean);
  87227. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  87228. get delay(): number;
  87229. set delay(value: number);
  87230. /**
  87231. * Starts an animation
  87232. * @param from defines the initial key
  87233. * @param to defines the end key
  87234. * @param loop defines if the animation must loop
  87235. * @param delay defines the start delay (in ms)
  87236. * @param onAnimationEnd defines a callback to call when animation ends
  87237. */
  87238. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  87239. /** Stops current animation (if any) */
  87240. stopAnimation(): void;
  87241. /** @hidden */
  87242. _animate(deltaTime: number): void;
  87243. /** Release associated resources */
  87244. dispose(): void;
  87245. /**
  87246. * Serializes the sprite to a JSON object
  87247. * @returns the JSON object
  87248. */
  87249. serialize(): any;
  87250. /**
  87251. * Parses a JSON object to create a new sprite
  87252. * @param parsedSprite The JSON object to parse
  87253. * @param manager defines the hosting manager
  87254. * @returns the new sprite
  87255. */
  87256. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  87257. }
  87258. }
  87259. declare module BABYLON {
  87260. /**
  87261. * Information about the result of picking within a scene
  87262. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  87263. */
  87264. export class PickingInfo {
  87265. /** @hidden */
  87266. _pickingUnavailable: boolean;
  87267. /**
  87268. * If the pick collided with an object
  87269. */
  87270. hit: boolean;
  87271. /**
  87272. * Distance away where the pick collided
  87273. */
  87274. distance: number;
  87275. /**
  87276. * The location of pick collision
  87277. */
  87278. pickedPoint: Nullable<Vector3>;
  87279. /**
  87280. * The mesh corresponding the the pick collision
  87281. */
  87282. pickedMesh: Nullable<AbstractMesh>;
  87283. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  87284. bu: number;
  87285. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  87286. bv: number;
  87287. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  87288. faceId: number;
  87289. /** Id of the the submesh that was picked */
  87290. subMeshId: number;
  87291. /** If a sprite was picked, this will be the sprite the pick collided with */
  87292. pickedSprite: Nullable<Sprite>;
  87293. /**
  87294. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  87295. */
  87296. originMesh: Nullable<AbstractMesh>;
  87297. /**
  87298. * The ray that was used to perform the picking.
  87299. */
  87300. ray: Nullable<Ray>;
  87301. /**
  87302. * Gets the normal correspodning to the face the pick collided with
  87303. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  87304. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  87305. * @returns The normal correspodning to the face the pick collided with
  87306. */
  87307. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  87308. /**
  87309. * Gets the texture coordinates of where the pick occured
  87310. * @returns the vector containing the coordnates of the texture
  87311. */
  87312. getTextureCoordinates(): Nullable<Vector2>;
  87313. }
  87314. }
  87315. declare module BABYLON {
  87316. /**
  87317. * Class representing a ray with position and direction
  87318. */
  87319. export class Ray {
  87320. /** origin point */
  87321. origin: Vector3;
  87322. /** direction */
  87323. direction: Vector3;
  87324. /** length of the ray */
  87325. length: number;
  87326. private static readonly TmpVector3;
  87327. private _tmpRay;
  87328. /**
  87329. * Creates a new ray
  87330. * @param origin origin point
  87331. * @param direction direction
  87332. * @param length length of the ray
  87333. */
  87334. constructor(
  87335. /** origin point */
  87336. origin: Vector3,
  87337. /** direction */
  87338. direction: Vector3,
  87339. /** length of the ray */
  87340. length?: number);
  87341. /**
  87342. * Checks if the ray intersects a box
  87343. * This does not account for the ray lenght by design to improve perfs.
  87344. * @param minimum bound of the box
  87345. * @param maximum bound of the box
  87346. * @param intersectionTreshold extra extend to be added to the box in all direction
  87347. * @returns if the box was hit
  87348. */
  87349. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  87350. /**
  87351. * Checks if the ray intersects a box
  87352. * This does not account for the ray lenght by design to improve perfs.
  87353. * @param box the bounding box to check
  87354. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  87355. * @returns if the box was hit
  87356. */
  87357. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  87358. /**
  87359. * If the ray hits a sphere
  87360. * @param sphere the bounding sphere to check
  87361. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  87362. * @returns true if it hits the sphere
  87363. */
  87364. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  87365. /**
  87366. * If the ray hits a triange
  87367. * @param vertex0 triangle vertex
  87368. * @param vertex1 triangle vertex
  87369. * @param vertex2 triangle vertex
  87370. * @returns intersection information if hit
  87371. */
  87372. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  87373. /**
  87374. * Checks if ray intersects a plane
  87375. * @param plane the plane to check
  87376. * @returns the distance away it was hit
  87377. */
  87378. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  87379. /**
  87380. * Calculate the intercept of a ray on a given axis
  87381. * @param axis to check 'x' | 'y' | 'z'
  87382. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  87383. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  87384. */
  87385. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  87386. /**
  87387. * Checks if ray intersects a mesh
  87388. * @param mesh the mesh to check
  87389. * @param fastCheck defines if the first intersection will be used (and not the closest)
  87390. * @returns picking info of the intersecton
  87391. */
  87392. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  87393. /**
  87394. * Checks if ray intersects a mesh
  87395. * @param meshes the meshes to check
  87396. * @param fastCheck defines if the first intersection will be used (and not the closest)
  87397. * @param results array to store result in
  87398. * @returns Array of picking infos
  87399. */
  87400. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  87401. private _comparePickingInfo;
  87402. private static smallnum;
  87403. private static rayl;
  87404. /**
  87405. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  87406. * @param sega the first point of the segment to test the intersection against
  87407. * @param segb the second point of the segment to test the intersection against
  87408. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  87409. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  87410. */
  87411. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  87412. /**
  87413. * Update the ray from viewport position
  87414. * @param x position
  87415. * @param y y position
  87416. * @param viewportWidth viewport width
  87417. * @param viewportHeight viewport height
  87418. * @param world world matrix
  87419. * @param view view matrix
  87420. * @param projection projection matrix
  87421. * @returns this ray updated
  87422. */
  87423. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  87424. /**
  87425. * Creates a ray with origin and direction of 0,0,0
  87426. * @returns the new ray
  87427. */
  87428. static Zero(): Ray;
  87429. /**
  87430. * Creates a new ray from screen space and viewport
  87431. * @param x position
  87432. * @param y y position
  87433. * @param viewportWidth viewport width
  87434. * @param viewportHeight viewport height
  87435. * @param world world matrix
  87436. * @param view view matrix
  87437. * @param projection projection matrix
  87438. * @returns new ray
  87439. */
  87440. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  87441. /**
  87442. * 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
  87443. * transformed to the given world matrix.
  87444. * @param origin The origin point
  87445. * @param end The end point
  87446. * @param world a matrix to transform the ray to. Default is the identity matrix.
  87447. * @returns the new ray
  87448. */
  87449. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  87450. /**
  87451. * Transforms a ray by a matrix
  87452. * @param ray ray to transform
  87453. * @param matrix matrix to apply
  87454. * @returns the resulting new ray
  87455. */
  87456. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  87457. /**
  87458. * Transforms a ray by a matrix
  87459. * @param ray ray to transform
  87460. * @param matrix matrix to apply
  87461. * @param result ray to store result in
  87462. */
  87463. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  87464. /**
  87465. * Unproject a ray from screen space to object space
  87466. * @param sourceX defines the screen space x coordinate to use
  87467. * @param sourceY defines the screen space y coordinate to use
  87468. * @param viewportWidth defines the current width of the viewport
  87469. * @param viewportHeight defines the current height of the viewport
  87470. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  87471. * @param view defines the view matrix to use
  87472. * @param projection defines the projection matrix to use
  87473. */
  87474. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  87475. }
  87476. /**
  87477. * Type used to define predicate used to select faces when a mesh intersection is detected
  87478. */
  87479. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  87480. interface Scene {
  87481. /** @hidden */
  87482. _tempPickingRay: Nullable<Ray>;
  87483. /** @hidden */
  87484. _cachedRayForTransform: Ray;
  87485. /** @hidden */
  87486. _pickWithRayInverseMatrix: Matrix;
  87487. /** @hidden */
  87488. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  87489. /** @hidden */
  87490. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  87491. }
  87492. }
  87493. declare module BABYLON {
  87494. /**
  87495. * Groups all the scene component constants in one place to ease maintenance.
  87496. * @hidden
  87497. */
  87498. export class SceneComponentConstants {
  87499. static readonly NAME_EFFECTLAYER: string;
  87500. static readonly NAME_LAYER: string;
  87501. static readonly NAME_LENSFLARESYSTEM: string;
  87502. static readonly NAME_BOUNDINGBOXRENDERER: string;
  87503. static readonly NAME_PARTICLESYSTEM: string;
  87504. static readonly NAME_GAMEPAD: string;
  87505. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  87506. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  87507. static readonly NAME_DEPTHRENDERER: string;
  87508. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  87509. static readonly NAME_SPRITE: string;
  87510. static readonly NAME_OUTLINERENDERER: string;
  87511. static readonly NAME_PROCEDURALTEXTURE: string;
  87512. static readonly NAME_SHADOWGENERATOR: string;
  87513. static readonly NAME_OCTREE: string;
  87514. static readonly NAME_PHYSICSENGINE: string;
  87515. static readonly NAME_AUDIO: string;
  87516. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  87517. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  87518. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  87519. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  87520. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  87521. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  87522. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  87523. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  87524. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  87525. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  87526. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  87527. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  87528. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  87529. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  87530. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  87531. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  87532. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  87533. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  87534. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  87535. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  87536. static readonly STEP_AFTERRENDER_AUDIO: number;
  87537. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  87538. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  87539. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  87540. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  87541. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  87542. static readonly STEP_POINTERMOVE_SPRITE: number;
  87543. static readonly STEP_POINTERDOWN_SPRITE: number;
  87544. static readonly STEP_POINTERUP_SPRITE: number;
  87545. }
  87546. /**
  87547. * This represents a scene component.
  87548. *
  87549. * This is used to decouple the dependency the scene is having on the different workloads like
  87550. * layers, post processes...
  87551. */
  87552. export interface ISceneComponent {
  87553. /**
  87554. * The name of the component. Each component must have a unique name.
  87555. */
  87556. name: string;
  87557. /**
  87558. * The scene the component belongs to.
  87559. */
  87560. scene: Scene;
  87561. /**
  87562. * Register the component to one instance of a scene.
  87563. */
  87564. register(): void;
  87565. /**
  87566. * Rebuilds the elements related to this component in case of
  87567. * context lost for instance.
  87568. */
  87569. rebuild(): void;
  87570. /**
  87571. * Disposes the component and the associated ressources.
  87572. */
  87573. dispose(): void;
  87574. }
  87575. /**
  87576. * This represents a SERIALIZABLE scene component.
  87577. *
  87578. * This extends Scene Component to add Serialization methods on top.
  87579. */
  87580. export interface ISceneSerializableComponent extends ISceneComponent {
  87581. /**
  87582. * Adds all the elements from the container to the scene
  87583. * @param container the container holding the elements
  87584. */
  87585. addFromContainer(container: AbstractScene): void;
  87586. /**
  87587. * Removes all the elements in the container from the scene
  87588. * @param container contains the elements to remove
  87589. * @param dispose if the removed element should be disposed (default: false)
  87590. */
  87591. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  87592. /**
  87593. * Serializes the component data to the specified json object
  87594. * @param serializationObject The object to serialize to
  87595. */
  87596. serialize(serializationObject: any): void;
  87597. }
  87598. /**
  87599. * Strong typing of a Mesh related stage step action
  87600. */
  87601. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  87602. /**
  87603. * Strong typing of a Evaluate Sub Mesh related stage step action
  87604. */
  87605. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  87606. /**
  87607. * Strong typing of a Active Mesh related stage step action
  87608. */
  87609. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  87610. /**
  87611. * Strong typing of a Camera related stage step action
  87612. */
  87613. export type CameraStageAction = (camera: Camera) => void;
  87614. /**
  87615. * Strong typing of a Camera Frame buffer related stage step action
  87616. */
  87617. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  87618. /**
  87619. * Strong typing of a Render Target related stage step action
  87620. */
  87621. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  87622. /**
  87623. * Strong typing of a RenderingGroup related stage step action
  87624. */
  87625. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  87626. /**
  87627. * Strong typing of a Mesh Render related stage step action
  87628. */
  87629. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  87630. /**
  87631. * Strong typing of a simple stage step action
  87632. */
  87633. export type SimpleStageAction = () => void;
  87634. /**
  87635. * Strong typing of a render target action.
  87636. */
  87637. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  87638. /**
  87639. * Strong typing of a pointer move action.
  87640. */
  87641. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  87642. /**
  87643. * Strong typing of a pointer up/down action.
  87644. */
  87645. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  87646. /**
  87647. * Representation of a stage in the scene (Basically a list of ordered steps)
  87648. * @hidden
  87649. */
  87650. export class Stage<T extends Function> extends Array<{
  87651. index: number;
  87652. component: ISceneComponent;
  87653. action: T;
  87654. }> {
  87655. /**
  87656. * Hide ctor from the rest of the world.
  87657. * @param items The items to add.
  87658. */
  87659. private constructor();
  87660. /**
  87661. * Creates a new Stage.
  87662. * @returns A new instance of a Stage
  87663. */
  87664. static Create<T extends Function>(): Stage<T>;
  87665. /**
  87666. * Registers a step in an ordered way in the targeted stage.
  87667. * @param index Defines the position to register the step in
  87668. * @param component Defines the component attached to the step
  87669. * @param action Defines the action to launch during the step
  87670. */
  87671. registerStep(index: number, component: ISceneComponent, action: T): void;
  87672. /**
  87673. * Clears all the steps from the stage.
  87674. */
  87675. clear(): void;
  87676. }
  87677. }
  87678. declare module BABYLON {
  87679. interface Scene {
  87680. /** @hidden */
  87681. _pointerOverSprite: Nullable<Sprite>;
  87682. /** @hidden */
  87683. _pickedDownSprite: Nullable<Sprite>;
  87684. /** @hidden */
  87685. _tempSpritePickingRay: Nullable<Ray>;
  87686. /**
  87687. * All of the sprite managers added to this scene
  87688. * @see http://doc.babylonjs.com/babylon101/sprites
  87689. */
  87690. spriteManagers: Array<ISpriteManager>;
  87691. /**
  87692. * An event triggered when sprites rendering is about to start
  87693. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  87694. */
  87695. onBeforeSpritesRenderingObservable: Observable<Scene>;
  87696. /**
  87697. * An event triggered when sprites rendering is done
  87698. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  87699. */
  87700. onAfterSpritesRenderingObservable: Observable<Scene>;
  87701. /** @hidden */
  87702. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  87703. /** Launch a ray to try to pick a sprite in the scene
  87704. * @param x position on screen
  87705. * @param y position on screen
  87706. * @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
  87707. * @param fastCheck defines if the first intersection will be used (and not the closest)
  87708. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  87709. * @returns a PickingInfo
  87710. */
  87711. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  87712. /** Use the given ray to pick a sprite in the scene
  87713. * @param ray The ray (in world space) to use to pick meshes
  87714. * @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
  87715. * @param fastCheck defines if the first intersection will be used (and not the closest)
  87716. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  87717. * @returns a PickingInfo
  87718. */
  87719. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  87720. /** @hidden */
  87721. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  87722. /** Launch a ray to try to pick sprites in the scene
  87723. * @param x position on screen
  87724. * @param y position on screen
  87725. * @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
  87726. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  87727. * @returns a PickingInfo array
  87728. */
  87729. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  87730. /** Use the given ray to pick sprites in the scene
  87731. * @param ray The ray (in world space) to use to pick meshes
  87732. * @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
  87733. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  87734. * @returns a PickingInfo array
  87735. */
  87736. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  87737. /**
  87738. * Force the sprite under the pointer
  87739. * @param sprite defines the sprite to use
  87740. */
  87741. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  87742. /**
  87743. * Gets the sprite under the pointer
  87744. * @returns a Sprite or null if no sprite is under the pointer
  87745. */
  87746. getPointerOverSprite(): Nullable<Sprite>;
  87747. }
  87748. /**
  87749. * Defines the sprite scene component responsible to manage sprites
  87750. * in a given scene.
  87751. */
  87752. export class SpriteSceneComponent implements ISceneComponent {
  87753. /**
  87754. * The component name helpfull to identify the component in the list of scene components.
  87755. */
  87756. readonly name: string;
  87757. /**
  87758. * The scene the component belongs to.
  87759. */
  87760. scene: Scene;
  87761. /** @hidden */
  87762. private _spritePredicate;
  87763. /**
  87764. * Creates a new instance of the component for the given scene
  87765. * @param scene Defines the scene to register the component in
  87766. */
  87767. constructor(scene: Scene);
  87768. /**
  87769. * Registers the component in a given scene
  87770. */
  87771. register(): void;
  87772. /**
  87773. * Rebuilds the elements related to this component in case of
  87774. * context lost for instance.
  87775. */
  87776. rebuild(): void;
  87777. /**
  87778. * Disposes the component and the associated ressources.
  87779. */
  87780. dispose(): void;
  87781. private _pickSpriteButKeepRay;
  87782. private _pointerMove;
  87783. private _pointerDown;
  87784. private _pointerUp;
  87785. }
  87786. }
  87787. declare module BABYLON {
  87788. /** @hidden */
  87789. export var fogFragmentDeclaration: {
  87790. name: string;
  87791. shader: string;
  87792. };
  87793. }
  87794. declare module BABYLON {
  87795. /** @hidden */
  87796. export var fogFragment: {
  87797. name: string;
  87798. shader: string;
  87799. };
  87800. }
  87801. declare module BABYLON {
  87802. /** @hidden */
  87803. export var spritesPixelShader: {
  87804. name: string;
  87805. shader: string;
  87806. };
  87807. }
  87808. declare module BABYLON {
  87809. /** @hidden */
  87810. export var fogVertexDeclaration: {
  87811. name: string;
  87812. shader: string;
  87813. };
  87814. }
  87815. declare module BABYLON {
  87816. /** @hidden */
  87817. export var spritesVertexShader: {
  87818. name: string;
  87819. shader: string;
  87820. };
  87821. }
  87822. declare module BABYLON {
  87823. /**
  87824. * Defines the minimum interface to fullfil in order to be a sprite manager.
  87825. */
  87826. export interface ISpriteManager extends IDisposable {
  87827. /**
  87828. * Gets manager's name
  87829. */
  87830. name: string;
  87831. /**
  87832. * Restricts the camera to viewing objects with the same layerMask.
  87833. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  87834. */
  87835. layerMask: number;
  87836. /**
  87837. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  87838. */
  87839. isPickable: boolean;
  87840. /**
  87841. * Gets the hosting scene
  87842. */
  87843. scene: Scene;
  87844. /**
  87845. * Specifies the rendering group id for this mesh (0 by default)
  87846. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  87847. */
  87848. renderingGroupId: number;
  87849. /**
  87850. * Defines the list of sprites managed by the manager.
  87851. */
  87852. sprites: Array<Sprite>;
  87853. /**
  87854. * Gets or sets the spritesheet texture
  87855. */
  87856. texture: Texture;
  87857. /** Defines the default width of a cell in the spritesheet */
  87858. cellWidth: number;
  87859. /** Defines the default height of a cell in the spritesheet */
  87860. cellHeight: number;
  87861. /**
  87862. * Tests the intersection of a sprite with a specific ray.
  87863. * @param ray The ray we are sending to test the collision
  87864. * @param camera The camera space we are sending rays in
  87865. * @param predicate A predicate allowing excluding sprites from the list of object to test
  87866. * @param fastCheck defines if the first intersection will be used (and not the closest)
  87867. * @returns picking info or null.
  87868. */
  87869. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  87870. /**
  87871. * Intersects the sprites with a ray
  87872. * @param ray defines the ray to intersect with
  87873. * @param camera defines the current active camera
  87874. * @param predicate defines a predicate used to select candidate sprites
  87875. * @returns null if no hit or a PickingInfo array
  87876. */
  87877. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  87878. /**
  87879. * Renders the list of sprites on screen.
  87880. */
  87881. render(): void;
  87882. }
  87883. /**
  87884. * Class used to manage multiple sprites on the same spritesheet
  87885. * @see http://doc.babylonjs.com/babylon101/sprites
  87886. */
  87887. export class SpriteManager implements ISpriteManager {
  87888. /** defines the manager's name */
  87889. name: string;
  87890. /** Define the Url to load snippets */
  87891. static SnippetUrl: string;
  87892. /** Snippet ID if the manager was created from the snippet server */
  87893. snippetId: string;
  87894. /** Gets the list of sprites */
  87895. sprites: Sprite[];
  87896. /** Gets or sets the rendering group id (0 by default) */
  87897. renderingGroupId: number;
  87898. /** Gets or sets camera layer mask */
  87899. layerMask: number;
  87900. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  87901. fogEnabled: boolean;
  87902. /** Gets or sets a boolean indicating if the sprites are pickable */
  87903. isPickable: boolean;
  87904. /** Defines the default width of a cell in the spritesheet */
  87905. cellWidth: number;
  87906. /** Defines the default height of a cell in the spritesheet */
  87907. cellHeight: number;
  87908. /** Associative array from JSON sprite data file */
  87909. private _cellData;
  87910. /** Array of sprite names from JSON sprite data file */
  87911. private _spriteMap;
  87912. /** True when packed cell data from JSON file is ready*/
  87913. private _packedAndReady;
  87914. private _textureContent;
  87915. /**
  87916. * An event triggered when the manager is disposed.
  87917. */
  87918. onDisposeObservable: Observable<SpriteManager>;
  87919. private _onDisposeObserver;
  87920. /**
  87921. * Callback called when the manager is disposed
  87922. */
  87923. set onDispose(callback: () => void);
  87924. private _capacity;
  87925. private _fromPacked;
  87926. private _spriteTexture;
  87927. private _epsilon;
  87928. private _scene;
  87929. private _vertexData;
  87930. private _buffer;
  87931. private _vertexBuffers;
  87932. private _indexBuffer;
  87933. private _effectBase;
  87934. private _effectFog;
  87935. /**
  87936. * Gets or sets the unique id of the sprite
  87937. */
  87938. uniqueId: number;
  87939. /**
  87940. * Gets the array of sprites
  87941. */
  87942. get children(): Sprite[];
  87943. /**
  87944. * Gets the hosting scene
  87945. */
  87946. get scene(): Scene;
  87947. /**
  87948. * Gets the capacity of the manager
  87949. */
  87950. get capacity(): number;
  87951. /**
  87952. * Gets or sets the spritesheet texture
  87953. */
  87954. get texture(): Texture;
  87955. set texture(value: Texture);
  87956. private _blendMode;
  87957. /**
  87958. * Blend mode use to render the particle, it can be any of
  87959. * the static Constants.ALPHA_x properties provided in this class.
  87960. * Default value is Constants.ALPHA_COMBINE
  87961. */
  87962. get blendMode(): number;
  87963. set blendMode(blendMode: number);
  87964. /** Disables writing to the depth buffer when rendering the sprites.
  87965. * It can be handy to disable depth writing when using textures without alpha channel
  87966. * and setting some specific blend modes.
  87967. */
  87968. disableDepthWrite: boolean;
  87969. /**
  87970. * Creates a new sprite manager
  87971. * @param name defines the manager's name
  87972. * @param imgUrl defines the sprite sheet url
  87973. * @param capacity defines the maximum allowed number of sprites
  87974. * @param cellSize defines the size of a sprite cell
  87975. * @param scene defines the hosting scene
  87976. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  87977. * @param samplingMode defines the smapling mode to use with spritesheet
  87978. * @param fromPacked set to false; do not alter
  87979. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  87980. */
  87981. constructor(
  87982. /** defines the manager's name */
  87983. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  87984. /**
  87985. * Returns the string "SpriteManager"
  87986. * @returns "SpriteManager"
  87987. */
  87988. getClassName(): string;
  87989. private _makePacked;
  87990. private _appendSpriteVertex;
  87991. private _checkTextureAlpha;
  87992. /**
  87993. * Intersects the sprites with a ray
  87994. * @param ray defines the ray to intersect with
  87995. * @param camera defines the current active camera
  87996. * @param predicate defines a predicate used to select candidate sprites
  87997. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  87998. * @returns null if no hit or a PickingInfo
  87999. */
  88000. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  88001. /**
  88002. * Intersects the sprites with a ray
  88003. * @param ray defines the ray to intersect with
  88004. * @param camera defines the current active camera
  88005. * @param predicate defines a predicate used to select candidate sprites
  88006. * @returns null if no hit or a PickingInfo array
  88007. */
  88008. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  88009. /**
  88010. * Render all child sprites
  88011. */
  88012. render(): void;
  88013. /**
  88014. * Release associated resources
  88015. */
  88016. dispose(): void;
  88017. /**
  88018. * Serializes the sprite manager to a JSON object
  88019. * @param serializeTexture defines if the texture must be serialized as well
  88020. * @returns the JSON object
  88021. */
  88022. serialize(serializeTexture?: boolean): any;
  88023. /**
  88024. * Parses a JSON object to create a new sprite manager.
  88025. * @param parsedManager The JSON object to parse
  88026. * @param scene The scene to create the sprite managerin
  88027. * @param rootUrl The root url to use to load external dependencies like texture
  88028. * @returns the new sprite manager
  88029. */
  88030. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  88031. /**
  88032. * Creates a sprite manager from a snippet saved by the sprite editor
  88033. * @param snippetId defines the snippet to load
  88034. * @param scene defines the hosting scene
  88035. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  88036. * @returns a promise that will resolve to the new sprite manager
  88037. */
  88038. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  88039. }
  88040. }
  88041. declare module BABYLON {
  88042. /** Interface used by value gradients (color, factor, ...) */
  88043. export interface IValueGradient {
  88044. /**
  88045. * Gets or sets the gradient value (between 0 and 1)
  88046. */
  88047. gradient: number;
  88048. }
  88049. /** Class used to store color4 gradient */
  88050. export class ColorGradient implements IValueGradient {
  88051. /**
  88052. * Gets or sets the gradient value (between 0 and 1)
  88053. */
  88054. gradient: number;
  88055. /**
  88056. * Gets or sets first associated color
  88057. */
  88058. color1: Color4;
  88059. /**
  88060. * Gets or sets second associated color
  88061. */
  88062. color2?: Color4 | undefined;
  88063. /**
  88064. * Creates a new color4 gradient
  88065. * @param gradient gets or sets the gradient value (between 0 and 1)
  88066. * @param color1 gets or sets first associated color
  88067. * @param color2 gets or sets first second color
  88068. */
  88069. constructor(
  88070. /**
  88071. * Gets or sets the gradient value (between 0 and 1)
  88072. */
  88073. gradient: number,
  88074. /**
  88075. * Gets or sets first associated color
  88076. */
  88077. color1: Color4,
  88078. /**
  88079. * Gets or sets second associated color
  88080. */
  88081. color2?: Color4 | undefined);
  88082. /**
  88083. * Will get a color picked randomly between color1 and color2.
  88084. * If color2 is undefined then color1 will be used
  88085. * @param result defines the target Color4 to store the result in
  88086. */
  88087. getColorToRef(result: Color4): void;
  88088. }
  88089. /** Class used to store color 3 gradient */
  88090. export class Color3Gradient implements IValueGradient {
  88091. /**
  88092. * Gets or sets the gradient value (between 0 and 1)
  88093. */
  88094. gradient: number;
  88095. /**
  88096. * Gets or sets the associated color
  88097. */
  88098. color: Color3;
  88099. /**
  88100. * Creates a new color3 gradient
  88101. * @param gradient gets or sets the gradient value (between 0 and 1)
  88102. * @param color gets or sets associated color
  88103. */
  88104. constructor(
  88105. /**
  88106. * Gets or sets the gradient value (between 0 and 1)
  88107. */
  88108. gradient: number,
  88109. /**
  88110. * Gets or sets the associated color
  88111. */
  88112. color: Color3);
  88113. }
  88114. /** Class used to store factor gradient */
  88115. export class FactorGradient implements IValueGradient {
  88116. /**
  88117. * Gets or sets the gradient value (between 0 and 1)
  88118. */
  88119. gradient: number;
  88120. /**
  88121. * Gets or sets first associated factor
  88122. */
  88123. factor1: number;
  88124. /**
  88125. * Gets or sets second associated factor
  88126. */
  88127. factor2?: number | undefined;
  88128. /**
  88129. * Creates a new factor gradient
  88130. * @param gradient gets or sets the gradient value (between 0 and 1)
  88131. * @param factor1 gets or sets first associated factor
  88132. * @param factor2 gets or sets second associated factor
  88133. */
  88134. constructor(
  88135. /**
  88136. * Gets or sets the gradient value (between 0 and 1)
  88137. */
  88138. gradient: number,
  88139. /**
  88140. * Gets or sets first associated factor
  88141. */
  88142. factor1: number,
  88143. /**
  88144. * Gets or sets second associated factor
  88145. */
  88146. factor2?: number | undefined);
  88147. /**
  88148. * Will get a number picked randomly between factor1 and factor2.
  88149. * If factor2 is undefined then factor1 will be used
  88150. * @returns the picked number
  88151. */
  88152. getFactor(): number;
  88153. }
  88154. /**
  88155. * Helper used to simplify some generic gradient tasks
  88156. */
  88157. export class GradientHelper {
  88158. /**
  88159. * Gets the current gradient from an array of IValueGradient
  88160. * @param ratio defines the current ratio to get
  88161. * @param gradients defines the array of IValueGradient
  88162. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  88163. */
  88164. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  88165. }
  88166. }
  88167. declare module BABYLON {
  88168. interface ThinEngine {
  88169. /**
  88170. * Creates a dynamic texture
  88171. * @param width defines the width of the texture
  88172. * @param height defines the height of the texture
  88173. * @param generateMipMaps defines if the engine should generate the mip levels
  88174. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  88175. * @returns the dynamic texture inside an InternalTexture
  88176. */
  88177. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  88178. /**
  88179. * Update the content of a dynamic texture
  88180. * @param texture defines the texture to update
  88181. * @param canvas defines the canvas containing the source
  88182. * @param invertY defines if data must be stored with Y axis inverted
  88183. * @param premulAlpha defines if alpha is stored as premultiplied
  88184. * @param format defines the format of the data
  88185. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  88186. */
  88187. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  88188. }
  88189. }
  88190. declare module BABYLON {
  88191. /**
  88192. * Helper class used to generate a canvas to manipulate images
  88193. */
  88194. export class CanvasGenerator {
  88195. /**
  88196. * Create a new canvas (or offscreen canvas depending on the context)
  88197. * @param width defines the expected width
  88198. * @param height defines the expected height
  88199. * @return a new canvas or offscreen canvas
  88200. */
  88201. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  88202. }
  88203. }
  88204. declare module BABYLON {
  88205. /**
  88206. * A class extending Texture allowing drawing on a texture
  88207. * @see http://doc.babylonjs.com/how_to/dynamictexture
  88208. */
  88209. export class DynamicTexture extends Texture {
  88210. private _generateMipMaps;
  88211. private _canvas;
  88212. private _context;
  88213. /**
  88214. * Creates a DynamicTexture
  88215. * @param name defines the name of the texture
  88216. * @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
  88217. * @param scene defines the scene where you want the texture
  88218. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  88219. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  88220. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  88221. */
  88222. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  88223. /**
  88224. * Get the current class name of the texture useful for serialization or dynamic coding.
  88225. * @returns "DynamicTexture"
  88226. */
  88227. getClassName(): string;
  88228. /**
  88229. * Gets the current state of canRescale
  88230. */
  88231. get canRescale(): boolean;
  88232. private _recreate;
  88233. /**
  88234. * Scales the texture
  88235. * @param ratio the scale factor to apply to both width and height
  88236. */
  88237. scale(ratio: number): void;
  88238. /**
  88239. * Resizes the texture
  88240. * @param width the new width
  88241. * @param height the new height
  88242. */
  88243. scaleTo(width: number, height: number): void;
  88244. /**
  88245. * Gets the context of the canvas used by the texture
  88246. * @returns the canvas context of the dynamic texture
  88247. */
  88248. getContext(): CanvasRenderingContext2D;
  88249. /**
  88250. * Clears the texture
  88251. */
  88252. clear(): void;
  88253. /**
  88254. * Updates the texture
  88255. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  88256. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  88257. */
  88258. update(invertY?: boolean, premulAlpha?: boolean): void;
  88259. /**
  88260. * Draws text onto the texture
  88261. * @param text defines the text to be drawn
  88262. * @param x defines the placement of the text from the left
  88263. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  88264. * @param font defines the font to be used with font-style, font-size, font-name
  88265. * @param color defines the color used for the text
  88266. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  88267. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  88268. * @param update defines whether texture is immediately update (default is true)
  88269. */
  88270. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  88271. /**
  88272. * Clones the texture
  88273. * @returns the clone of the texture.
  88274. */
  88275. clone(): DynamicTexture;
  88276. /**
  88277. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  88278. * @returns a serialized dynamic texture object
  88279. */
  88280. serialize(): any;
  88281. /** @hidden */
  88282. _rebuild(): void;
  88283. }
  88284. }
  88285. declare module BABYLON {
  88286. interface ThinEngine {
  88287. /**
  88288. * Creates a raw texture
  88289. * @param data defines the data to store in the texture
  88290. * @param width defines the width of the texture
  88291. * @param height defines the height of the texture
  88292. * @param format defines the format of the data
  88293. * @param generateMipMaps defines if the engine should generate the mip levels
  88294. * @param invertY defines if data must be stored with Y axis inverted
  88295. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  88296. * @param compression defines the compression used (null by default)
  88297. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  88298. * @returns the raw texture inside an InternalTexture
  88299. */
  88300. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  88301. /**
  88302. * Update a raw texture
  88303. * @param texture defines the texture to update
  88304. * @param data defines the data to store in the texture
  88305. * @param format defines the format of the data
  88306. * @param invertY defines if data must be stored with Y axis inverted
  88307. */
  88308. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  88309. /**
  88310. * Update a raw texture
  88311. * @param texture defines the texture to update
  88312. * @param data defines the data to store in the texture
  88313. * @param format defines the format of the data
  88314. * @param invertY defines if data must be stored with Y axis inverted
  88315. * @param compression defines the compression used (null by default)
  88316. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  88317. */
  88318. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  88319. /**
  88320. * Creates a new raw cube texture
  88321. * @param data defines the array of data to use to create each face
  88322. * @param size defines the size of the textures
  88323. * @param format defines the format of the data
  88324. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  88325. * @param generateMipMaps defines if the engine should generate the mip levels
  88326. * @param invertY defines if data must be stored with Y axis inverted
  88327. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  88328. * @param compression defines the compression used (null by default)
  88329. * @returns the cube texture as an InternalTexture
  88330. */
  88331. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  88332. /**
  88333. * Update a raw cube texture
  88334. * @param texture defines the texture to udpdate
  88335. * @param data defines the data to store
  88336. * @param format defines the data format
  88337. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  88338. * @param invertY defines if data must be stored with Y axis inverted
  88339. */
  88340. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  88341. /**
  88342. * Update a raw cube texture
  88343. * @param texture defines the texture to udpdate
  88344. * @param data defines the data to store
  88345. * @param format defines the data format
  88346. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  88347. * @param invertY defines if data must be stored with Y axis inverted
  88348. * @param compression defines the compression used (null by default)
  88349. */
  88350. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  88351. /**
  88352. * Update a raw cube texture
  88353. * @param texture defines the texture to udpdate
  88354. * @param data defines the data to store
  88355. * @param format defines the data format
  88356. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  88357. * @param invertY defines if data must be stored with Y axis inverted
  88358. * @param compression defines the compression used (null by default)
  88359. * @param level defines which level of the texture to update
  88360. */
  88361. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  88362. /**
  88363. * Creates a new raw cube texture from a specified url
  88364. * @param url defines the url where the data is located
  88365. * @param scene defines the current scene
  88366. * @param size defines the size of the textures
  88367. * @param format defines the format of the data
  88368. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  88369. * @param noMipmap defines if the engine should avoid generating the mip levels
  88370. * @param callback defines a callback used to extract texture data from loaded data
  88371. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  88372. * @param onLoad defines a callback called when texture is loaded
  88373. * @param onError defines a callback called if there is an error
  88374. * @returns the cube texture as an InternalTexture
  88375. */
  88376. 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;
  88377. /**
  88378. * Creates a new raw cube texture from a specified url
  88379. * @param url defines the url where the data is located
  88380. * @param scene defines the current scene
  88381. * @param size defines the size of the textures
  88382. * @param format defines the format of the data
  88383. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  88384. * @param noMipmap defines if the engine should avoid generating the mip levels
  88385. * @param callback defines a callback used to extract texture data from loaded data
  88386. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  88387. * @param onLoad defines a callback called when texture is loaded
  88388. * @param onError defines a callback called if there is an error
  88389. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  88390. * @param invertY defines if data must be stored with Y axis inverted
  88391. * @returns the cube texture as an InternalTexture
  88392. */
  88393. 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;
  88394. /**
  88395. * Creates a new raw 3D texture
  88396. * @param data defines the data used to create the texture
  88397. * @param width defines the width of the texture
  88398. * @param height defines the height of the texture
  88399. * @param depth defines the depth of the texture
  88400. * @param format defines the format of the texture
  88401. * @param generateMipMaps defines if the engine must generate mip levels
  88402. * @param invertY defines if data must be stored with Y axis inverted
  88403. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  88404. * @param compression defines the compressed used (can be null)
  88405. * @param textureType defines the compressed used (can be null)
  88406. * @returns a new raw 3D texture (stored in an InternalTexture)
  88407. */
  88408. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  88409. /**
  88410. * Update a raw 3D texture
  88411. * @param texture defines the texture to update
  88412. * @param data defines the data to store
  88413. * @param format defines the data format
  88414. * @param invertY defines if data must be stored with Y axis inverted
  88415. */
  88416. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  88417. /**
  88418. * Update a raw 3D texture
  88419. * @param texture defines the texture to update
  88420. * @param data defines the data to store
  88421. * @param format defines the data format
  88422. * @param invertY defines if data must be stored with Y axis inverted
  88423. * @param compression defines the used compression (can be null)
  88424. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  88425. */
  88426. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  88427. /**
  88428. * Creates a new raw 2D array texture
  88429. * @param data defines the data used to create the texture
  88430. * @param width defines the width of the texture
  88431. * @param height defines the height of the texture
  88432. * @param depth defines the number of layers of the texture
  88433. * @param format defines the format of the texture
  88434. * @param generateMipMaps defines if the engine must generate mip levels
  88435. * @param invertY defines if data must be stored with Y axis inverted
  88436. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  88437. * @param compression defines the compressed used (can be null)
  88438. * @param textureType defines the compressed used (can be null)
  88439. * @returns a new raw 2D array texture (stored in an InternalTexture)
  88440. */
  88441. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  88442. /**
  88443. * Update a raw 2D array texture
  88444. * @param texture defines the texture to update
  88445. * @param data defines the data to store
  88446. * @param format defines the data format
  88447. * @param invertY defines if data must be stored with Y axis inverted
  88448. */
  88449. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  88450. /**
  88451. * Update a raw 2D array texture
  88452. * @param texture defines the texture to update
  88453. * @param data defines the data to store
  88454. * @param format defines the data format
  88455. * @param invertY defines if data must be stored with Y axis inverted
  88456. * @param compression defines the used compression (can be null)
  88457. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  88458. */
  88459. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  88460. }
  88461. }
  88462. declare module BABYLON {
  88463. /**
  88464. * Raw texture can help creating a texture directly from an array of data.
  88465. * This can be super useful if you either get the data from an uncompressed source or
  88466. * if you wish to create your texture pixel by pixel.
  88467. */
  88468. export class RawTexture extends Texture {
  88469. /**
  88470. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  88471. */
  88472. format: number;
  88473. /**
  88474. * Instantiates a new RawTexture.
  88475. * Raw texture can help creating a texture directly from an array of data.
  88476. * This can be super useful if you either get the data from an uncompressed source or
  88477. * if you wish to create your texture pixel by pixel.
  88478. * @param data define the array of data to use to create the texture
  88479. * @param width define the width of the texture
  88480. * @param height define the height of the texture
  88481. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  88482. * @param scene define the scene the texture belongs to
  88483. * @param generateMipMaps define whether mip maps should be generated or not
  88484. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  88485. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  88486. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  88487. */
  88488. constructor(data: ArrayBufferView, width: number, height: number,
  88489. /**
  88490. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  88491. */
  88492. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  88493. /**
  88494. * Updates the texture underlying data.
  88495. * @param data Define the new data of the texture
  88496. */
  88497. update(data: ArrayBufferView): void;
  88498. /**
  88499. * Creates a luminance texture from some data.
  88500. * @param data Define the texture data
  88501. * @param width Define the width of the texture
  88502. * @param height Define the height of the texture
  88503. * @param scene Define the scene the texture belongs to
  88504. * @param generateMipMaps Define whether or not to create mip maps for the texture
  88505. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  88506. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  88507. * @returns the luminance texture
  88508. */
  88509. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  88510. /**
  88511. * Creates a luminance alpha texture from some data.
  88512. * @param data Define the texture data
  88513. * @param width Define the width of the texture
  88514. * @param height Define the height of the texture
  88515. * @param scene Define the scene the texture belongs to
  88516. * @param generateMipMaps Define whether or not to create mip maps for the texture
  88517. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  88518. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  88519. * @returns the luminance alpha texture
  88520. */
  88521. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  88522. /**
  88523. * Creates an alpha texture from some data.
  88524. * @param data Define the texture data
  88525. * @param width Define the width of the texture
  88526. * @param height Define the height of the texture
  88527. * @param scene Define the scene the texture belongs to
  88528. * @param generateMipMaps Define whether or not to create mip maps for the texture
  88529. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  88530. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  88531. * @returns the alpha texture
  88532. */
  88533. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  88534. /**
  88535. * Creates a RGB texture from some data.
  88536. * @param data Define the texture data
  88537. * @param width Define the width of the texture
  88538. * @param height Define the height of the texture
  88539. * @param scene Define the scene the texture belongs to
  88540. * @param generateMipMaps Define whether or not to create mip maps for the texture
  88541. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  88542. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  88543. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  88544. * @returns the RGB alpha texture
  88545. */
  88546. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  88547. /**
  88548. * Creates a RGBA texture from some data.
  88549. * @param data Define the texture data
  88550. * @param width Define the width of the texture
  88551. * @param height Define the height of the texture
  88552. * @param scene Define the scene the texture belongs to
  88553. * @param generateMipMaps Define whether or not to create mip maps for the texture
  88554. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  88555. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  88556. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  88557. * @returns the RGBA texture
  88558. */
  88559. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  88560. /**
  88561. * Creates a R texture from some data.
  88562. * @param data Define the texture data
  88563. * @param width Define the width of the texture
  88564. * @param height Define the height of the texture
  88565. * @param scene Define the scene the texture belongs to
  88566. * @param generateMipMaps Define whether or not to create mip maps for the texture
  88567. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  88568. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  88569. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  88570. * @returns the R texture
  88571. */
  88572. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  88573. }
  88574. }
  88575. declare module BABYLON {
  88576. interface AbstractScene {
  88577. /**
  88578. * The list of procedural textures added to the scene
  88579. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  88580. */
  88581. proceduralTextures: Array<ProceduralTexture>;
  88582. }
  88583. /**
  88584. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  88585. * in a given scene.
  88586. */
  88587. export class ProceduralTextureSceneComponent implements ISceneComponent {
  88588. /**
  88589. * The component name helpfull to identify the component in the list of scene components.
  88590. */
  88591. readonly name: string;
  88592. /**
  88593. * The scene the component belongs to.
  88594. */
  88595. scene: Scene;
  88596. /**
  88597. * Creates a new instance of the component for the given scene
  88598. * @param scene Defines the scene to register the component in
  88599. */
  88600. constructor(scene: Scene);
  88601. /**
  88602. * Registers the component in a given scene
  88603. */
  88604. register(): void;
  88605. /**
  88606. * Rebuilds the elements related to this component in case of
  88607. * context lost for instance.
  88608. */
  88609. rebuild(): void;
  88610. /**
  88611. * Disposes the component and the associated ressources.
  88612. */
  88613. dispose(): void;
  88614. private _beforeClear;
  88615. }
  88616. }
  88617. declare module BABYLON {
  88618. interface ThinEngine {
  88619. /**
  88620. * Creates a new render target cube texture
  88621. * @param size defines the size of the texture
  88622. * @param options defines the options used to create the texture
  88623. * @returns a new render target cube texture stored in an InternalTexture
  88624. */
  88625. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  88626. }
  88627. }
  88628. declare module BABYLON {
  88629. /** @hidden */
  88630. export var proceduralVertexShader: {
  88631. name: string;
  88632. shader: string;
  88633. };
  88634. }
  88635. declare module BABYLON {
  88636. /**
  88637. * 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.
  88638. * This is the base class of any Procedural texture and contains most of the shareable code.
  88639. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  88640. */
  88641. export class ProceduralTexture extends Texture {
  88642. isCube: boolean;
  88643. /**
  88644. * Define if the texture is enabled or not (disabled texture will not render)
  88645. */
  88646. isEnabled: boolean;
  88647. /**
  88648. * Define if the texture must be cleared before rendering (default is true)
  88649. */
  88650. autoClear: boolean;
  88651. /**
  88652. * Callback called when the texture is generated
  88653. */
  88654. onGenerated: () => void;
  88655. /**
  88656. * Event raised when the texture is generated
  88657. */
  88658. onGeneratedObservable: Observable<ProceduralTexture>;
  88659. /** @hidden */
  88660. _generateMipMaps: boolean;
  88661. /** @hidden **/
  88662. _effect: Effect;
  88663. /** @hidden */
  88664. _textures: {
  88665. [key: string]: Texture;
  88666. };
  88667. /** @hidden */
  88668. protected _fallbackTexture: Nullable<Texture>;
  88669. private _size;
  88670. private _currentRefreshId;
  88671. private _frameId;
  88672. private _refreshRate;
  88673. private _vertexBuffers;
  88674. private _indexBuffer;
  88675. private _uniforms;
  88676. private _samplers;
  88677. private _fragment;
  88678. private _floats;
  88679. private _ints;
  88680. private _floatsArrays;
  88681. private _colors3;
  88682. private _colors4;
  88683. private _vectors2;
  88684. private _vectors3;
  88685. private _matrices;
  88686. private _fallbackTextureUsed;
  88687. private _fullEngine;
  88688. private _cachedDefines;
  88689. private _contentUpdateId;
  88690. private _contentData;
  88691. /**
  88692. * Instantiates a new procedural texture.
  88693. * 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.
  88694. * This is the base class of any Procedural texture and contains most of the shareable code.
  88695. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  88696. * @param name Define the name of the texture
  88697. * @param size Define the size of the texture to create
  88698. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  88699. * @param scene Define the scene the texture belongs to
  88700. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  88701. * @param generateMipMaps Define if the texture should creates mip maps or not
  88702. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  88703. */
  88704. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  88705. /**
  88706. * The effect that is created when initializing the post process.
  88707. * @returns The created effect corresponding the the postprocess.
  88708. */
  88709. getEffect(): Effect;
  88710. /**
  88711. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  88712. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  88713. */
  88714. getContent(): Nullable<ArrayBufferView>;
  88715. private _createIndexBuffer;
  88716. /** @hidden */
  88717. _rebuild(): void;
  88718. /**
  88719. * Resets the texture in order to recreate its associated resources.
  88720. * This can be called in case of context loss
  88721. */
  88722. reset(): void;
  88723. protected _getDefines(): string;
  88724. /**
  88725. * Is the texture ready to be used ? (rendered at least once)
  88726. * @returns true if ready, otherwise, false.
  88727. */
  88728. isReady(): boolean;
  88729. /**
  88730. * Resets the refresh counter of the texture and start bak from scratch.
  88731. * Could be useful to regenerate the texture if it is setup to render only once.
  88732. */
  88733. resetRefreshCounter(): void;
  88734. /**
  88735. * Set the fragment shader to use in order to render the texture.
  88736. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  88737. */
  88738. setFragment(fragment: any): void;
  88739. /**
  88740. * Define the refresh rate of the texture or the rendering frequency.
  88741. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  88742. */
  88743. get refreshRate(): number;
  88744. set refreshRate(value: number);
  88745. /** @hidden */
  88746. _shouldRender(): boolean;
  88747. /**
  88748. * Get the size the texture is rendering at.
  88749. * @returns the size (texture is always squared)
  88750. */
  88751. getRenderSize(): number;
  88752. /**
  88753. * Resize the texture to new value.
  88754. * @param size Define the new size the texture should have
  88755. * @param generateMipMaps Define whether the new texture should create mip maps
  88756. */
  88757. resize(size: number, generateMipMaps: boolean): void;
  88758. private _checkUniform;
  88759. /**
  88760. * Set a texture in the shader program used to render.
  88761. * @param name Define the name of the uniform samplers as defined in the shader
  88762. * @param texture Define the texture to bind to this sampler
  88763. * @return the texture itself allowing "fluent" like uniform updates
  88764. */
  88765. setTexture(name: string, texture: Texture): ProceduralTexture;
  88766. /**
  88767. * Set a float in the shader.
  88768. * @param name Define the name of the uniform as defined in the shader
  88769. * @param value Define the value to give to the uniform
  88770. * @return the texture itself allowing "fluent" like uniform updates
  88771. */
  88772. setFloat(name: string, value: number): ProceduralTexture;
  88773. /**
  88774. * Set a int in the shader.
  88775. * @param name Define the name of the uniform as defined in the shader
  88776. * @param value Define the value to give to the uniform
  88777. * @return the texture itself allowing "fluent" like uniform updates
  88778. */
  88779. setInt(name: string, value: number): ProceduralTexture;
  88780. /**
  88781. * Set an array of floats in the shader.
  88782. * @param name Define the name of the uniform as defined in the shader
  88783. * @param value Define the value to give to the uniform
  88784. * @return the texture itself allowing "fluent" like uniform updates
  88785. */
  88786. setFloats(name: string, value: number[]): ProceduralTexture;
  88787. /**
  88788. * Set a vec3 in the shader from a Color3.
  88789. * @param name Define the name of the uniform as defined in the shader
  88790. * @param value Define the value to give to the uniform
  88791. * @return the texture itself allowing "fluent" like uniform updates
  88792. */
  88793. setColor3(name: string, value: Color3): ProceduralTexture;
  88794. /**
  88795. * Set a vec4 in the shader from a Color4.
  88796. * @param name Define the name of the uniform as defined in the shader
  88797. * @param value Define the value to give to the uniform
  88798. * @return the texture itself allowing "fluent" like uniform updates
  88799. */
  88800. setColor4(name: string, value: Color4): ProceduralTexture;
  88801. /**
  88802. * Set a vec2 in the shader from a Vector2.
  88803. * @param name Define the name of the uniform as defined in the shader
  88804. * @param value Define the value to give to the uniform
  88805. * @return the texture itself allowing "fluent" like uniform updates
  88806. */
  88807. setVector2(name: string, value: Vector2): ProceduralTexture;
  88808. /**
  88809. * Set a vec3 in the shader from a Vector3.
  88810. * @param name Define the name of the uniform as defined in the shader
  88811. * @param value Define the value to give to the uniform
  88812. * @return the texture itself allowing "fluent" like uniform updates
  88813. */
  88814. setVector3(name: string, value: Vector3): ProceduralTexture;
  88815. /**
  88816. * Set a mat4 in the shader from a MAtrix.
  88817. * @param name Define the name of the uniform as defined in the shader
  88818. * @param value Define the value to give to the uniform
  88819. * @return the texture itself allowing "fluent" like uniform updates
  88820. */
  88821. setMatrix(name: string, value: Matrix): ProceduralTexture;
  88822. /**
  88823. * Render the texture to its associated render target.
  88824. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  88825. */
  88826. render(useCameraPostProcess?: boolean): void;
  88827. /**
  88828. * Clone the texture.
  88829. * @returns the cloned texture
  88830. */
  88831. clone(): ProceduralTexture;
  88832. /**
  88833. * Dispose the texture and release its asoociated resources.
  88834. */
  88835. dispose(): void;
  88836. }
  88837. }
  88838. declare module BABYLON {
  88839. /**
  88840. * This represents the base class for particle system in Babylon.
  88841. * 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.
  88842. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  88843. * @example https://doc.babylonjs.com/babylon101/particles
  88844. */
  88845. export class BaseParticleSystem {
  88846. /**
  88847. * Source color is added to the destination color without alpha affecting the result
  88848. */
  88849. static BLENDMODE_ONEONE: number;
  88850. /**
  88851. * Blend current color and particle color using particle’s alpha
  88852. */
  88853. static BLENDMODE_STANDARD: number;
  88854. /**
  88855. * Add current color and particle color multiplied by particle’s alpha
  88856. */
  88857. static BLENDMODE_ADD: number;
  88858. /**
  88859. * Multiply current color with particle color
  88860. */
  88861. static BLENDMODE_MULTIPLY: number;
  88862. /**
  88863. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  88864. */
  88865. static BLENDMODE_MULTIPLYADD: number;
  88866. /**
  88867. * List of animations used by the particle system.
  88868. */
  88869. animations: Animation[];
  88870. /**
  88871. * Gets or sets the unique id of the particle system
  88872. */
  88873. uniqueId: number;
  88874. /**
  88875. * The id of the Particle system.
  88876. */
  88877. id: string;
  88878. /**
  88879. * The friendly name of the Particle system.
  88880. */
  88881. name: string;
  88882. /**
  88883. * Snippet ID if the particle system was created from the snippet server
  88884. */
  88885. snippetId: string;
  88886. /**
  88887. * The rendering group used by the Particle system to chose when to render.
  88888. */
  88889. renderingGroupId: number;
  88890. /**
  88891. * The emitter represents the Mesh or position we are attaching the particle system to.
  88892. */
  88893. emitter: Nullable<AbstractMesh | Vector3>;
  88894. /**
  88895. * The maximum number of particles to emit per frame
  88896. */
  88897. emitRate: number;
  88898. /**
  88899. * If you want to launch only a few particles at once, that can be done, as well.
  88900. */
  88901. manualEmitCount: number;
  88902. /**
  88903. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  88904. */
  88905. updateSpeed: number;
  88906. /**
  88907. * The amount of time the particle system is running (depends of the overall update speed).
  88908. */
  88909. targetStopDuration: number;
  88910. /**
  88911. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  88912. */
  88913. disposeOnStop: boolean;
  88914. /**
  88915. * Minimum power of emitting particles.
  88916. */
  88917. minEmitPower: number;
  88918. /**
  88919. * Maximum power of emitting particles.
  88920. */
  88921. maxEmitPower: number;
  88922. /**
  88923. * Minimum life time of emitting particles.
  88924. */
  88925. minLifeTime: number;
  88926. /**
  88927. * Maximum life time of emitting particles.
  88928. */
  88929. maxLifeTime: number;
  88930. /**
  88931. * Minimum Size of emitting particles.
  88932. */
  88933. minSize: number;
  88934. /**
  88935. * Maximum Size of emitting particles.
  88936. */
  88937. maxSize: number;
  88938. /**
  88939. * Minimum scale of emitting particles on X axis.
  88940. */
  88941. minScaleX: number;
  88942. /**
  88943. * Maximum scale of emitting particles on X axis.
  88944. */
  88945. maxScaleX: number;
  88946. /**
  88947. * Minimum scale of emitting particles on Y axis.
  88948. */
  88949. minScaleY: number;
  88950. /**
  88951. * Maximum scale of emitting particles on Y axis.
  88952. */
  88953. maxScaleY: number;
  88954. /**
  88955. * Gets or sets the minimal initial rotation in radians.
  88956. */
  88957. minInitialRotation: number;
  88958. /**
  88959. * Gets or sets the maximal initial rotation in radians.
  88960. */
  88961. maxInitialRotation: number;
  88962. /**
  88963. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  88964. */
  88965. minAngularSpeed: number;
  88966. /**
  88967. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  88968. */
  88969. maxAngularSpeed: number;
  88970. /**
  88971. * The texture used to render each particle. (this can be a spritesheet)
  88972. */
  88973. particleTexture: Nullable<Texture>;
  88974. /**
  88975. * The layer mask we are rendering the particles through.
  88976. */
  88977. layerMask: number;
  88978. /**
  88979. * This can help using your own shader to render the particle system.
  88980. * The according effect will be created
  88981. */
  88982. customShader: any;
  88983. /**
  88984. * By default particle system starts as soon as they are created. This prevents the
  88985. * automatic start to happen and let you decide when to start emitting particles.
  88986. */
  88987. preventAutoStart: boolean;
  88988. private _noiseTexture;
  88989. /**
  88990. * Gets or sets a texture used to add random noise to particle positions
  88991. */
  88992. get noiseTexture(): Nullable<ProceduralTexture>;
  88993. set noiseTexture(value: Nullable<ProceduralTexture>);
  88994. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  88995. noiseStrength: Vector3;
  88996. /**
  88997. * Callback triggered when the particle animation is ending.
  88998. */
  88999. onAnimationEnd: Nullable<() => void>;
  89000. /**
  89001. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  89002. */
  89003. blendMode: number;
  89004. /**
  89005. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  89006. * to override the particles.
  89007. */
  89008. forceDepthWrite: boolean;
  89009. /** 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 */
  89010. preWarmCycles: number;
  89011. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  89012. preWarmStepOffset: number;
  89013. /**
  89014. * 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)
  89015. */
  89016. spriteCellChangeSpeed: number;
  89017. /**
  89018. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  89019. */
  89020. startSpriteCellID: number;
  89021. /**
  89022. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  89023. */
  89024. endSpriteCellID: number;
  89025. /**
  89026. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  89027. */
  89028. spriteCellWidth: number;
  89029. /**
  89030. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  89031. */
  89032. spriteCellHeight: number;
  89033. /**
  89034. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  89035. */
  89036. spriteRandomStartCell: boolean;
  89037. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  89038. translationPivot: Vector2;
  89039. /** @hidden */
  89040. protected _isAnimationSheetEnabled: boolean;
  89041. /**
  89042. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  89043. */
  89044. beginAnimationOnStart: boolean;
  89045. /**
  89046. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  89047. */
  89048. beginAnimationFrom: number;
  89049. /**
  89050. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  89051. */
  89052. beginAnimationTo: number;
  89053. /**
  89054. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  89055. */
  89056. beginAnimationLoop: boolean;
  89057. /**
  89058. * Gets or sets a world offset applied to all particles
  89059. */
  89060. worldOffset: Vector3;
  89061. /**
  89062. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  89063. */
  89064. get isAnimationSheetEnabled(): boolean;
  89065. set isAnimationSheetEnabled(value: boolean);
  89066. /**
  89067. * Get hosting scene
  89068. * @returns the scene
  89069. */
  89070. getScene(): Scene;
  89071. /**
  89072. * You can use gravity if you want to give an orientation to your particles.
  89073. */
  89074. gravity: Vector3;
  89075. protected _colorGradients: Nullable<Array<ColorGradient>>;
  89076. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  89077. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  89078. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  89079. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  89080. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  89081. protected _dragGradients: Nullable<Array<FactorGradient>>;
  89082. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  89083. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  89084. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  89085. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  89086. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  89087. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  89088. /**
  89089. * Defines the delay in milliseconds before starting the system (0 by default)
  89090. */
  89091. startDelay: number;
  89092. /**
  89093. * Gets the current list of drag gradients.
  89094. * You must use addDragGradient and removeDragGradient to udpate this list
  89095. * @returns the list of drag gradients
  89096. */
  89097. getDragGradients(): Nullable<Array<FactorGradient>>;
  89098. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  89099. limitVelocityDamping: number;
  89100. /**
  89101. * Gets the current list of limit velocity gradients.
  89102. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  89103. * @returns the list of limit velocity gradients
  89104. */
  89105. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  89106. /**
  89107. * Gets the current list of color gradients.
  89108. * You must use addColorGradient and removeColorGradient to udpate this list
  89109. * @returns the list of color gradients
  89110. */
  89111. getColorGradients(): Nullable<Array<ColorGradient>>;
  89112. /**
  89113. * Gets the current list of size gradients.
  89114. * You must use addSizeGradient and removeSizeGradient to udpate this list
  89115. * @returns the list of size gradients
  89116. */
  89117. getSizeGradients(): Nullable<Array<FactorGradient>>;
  89118. /**
  89119. * Gets the current list of color remap gradients.
  89120. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  89121. * @returns the list of color remap gradients
  89122. */
  89123. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  89124. /**
  89125. * Gets the current list of alpha remap gradients.
  89126. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  89127. * @returns the list of alpha remap gradients
  89128. */
  89129. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  89130. /**
  89131. * Gets the current list of life time gradients.
  89132. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  89133. * @returns the list of life time gradients
  89134. */
  89135. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  89136. /**
  89137. * Gets the current list of angular speed gradients.
  89138. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  89139. * @returns the list of angular speed gradients
  89140. */
  89141. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  89142. /**
  89143. * Gets the current list of velocity gradients.
  89144. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  89145. * @returns the list of velocity gradients
  89146. */
  89147. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  89148. /**
  89149. * Gets the current list of start size gradients.
  89150. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  89151. * @returns the list of start size gradients
  89152. */
  89153. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  89154. /**
  89155. * Gets the current list of emit rate gradients.
  89156. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  89157. * @returns the list of emit rate gradients
  89158. */
  89159. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  89160. /**
  89161. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  89162. * This only works when particleEmitterTyps is a BoxParticleEmitter
  89163. */
  89164. get direction1(): Vector3;
  89165. set direction1(value: Vector3);
  89166. /**
  89167. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  89168. * This only works when particleEmitterTyps is a BoxParticleEmitter
  89169. */
  89170. get direction2(): Vector3;
  89171. set direction2(value: Vector3);
  89172. /**
  89173. * 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.
  89174. * This only works when particleEmitterTyps is a BoxParticleEmitter
  89175. */
  89176. get minEmitBox(): Vector3;
  89177. set minEmitBox(value: Vector3);
  89178. /**
  89179. * 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.
  89180. * This only works when particleEmitterTyps is a BoxParticleEmitter
  89181. */
  89182. get maxEmitBox(): Vector3;
  89183. set maxEmitBox(value: Vector3);
  89184. /**
  89185. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  89186. */
  89187. color1: Color4;
  89188. /**
  89189. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  89190. */
  89191. color2: Color4;
  89192. /**
  89193. * Color the particle will have at the end of its lifetime
  89194. */
  89195. colorDead: Color4;
  89196. /**
  89197. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  89198. */
  89199. textureMask: Color4;
  89200. /**
  89201. * The particle emitter type defines the emitter used by the particle system.
  89202. * It can be for example box, sphere, or cone...
  89203. */
  89204. particleEmitterType: IParticleEmitterType;
  89205. /** @hidden */
  89206. _isSubEmitter: boolean;
  89207. /**
  89208. * Gets or sets the billboard mode to use when isBillboardBased = true.
  89209. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  89210. */
  89211. billboardMode: number;
  89212. protected _isBillboardBased: boolean;
  89213. /**
  89214. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  89215. */
  89216. get isBillboardBased(): boolean;
  89217. set isBillboardBased(value: boolean);
  89218. /**
  89219. * The scene the particle system belongs to.
  89220. */
  89221. protected _scene: Scene;
  89222. /**
  89223. * Local cache of defines for image processing.
  89224. */
  89225. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  89226. /**
  89227. * Default configuration related to image processing available in the standard Material.
  89228. */
  89229. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  89230. /**
  89231. * Gets the image processing configuration used either in this material.
  89232. */
  89233. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  89234. /**
  89235. * Sets the Default image processing configuration used either in the this material.
  89236. *
  89237. * If sets to null, the scene one is in use.
  89238. */
  89239. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  89240. /**
  89241. * Attaches a new image processing configuration to the Standard Material.
  89242. * @param configuration
  89243. */
  89244. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  89245. /** @hidden */
  89246. protected _reset(): void;
  89247. /** @hidden */
  89248. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  89249. /**
  89250. * Instantiates a particle system.
  89251. * 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.
  89252. * @param name The name of the particle system
  89253. */
  89254. constructor(name: string);
  89255. /**
  89256. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  89257. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  89258. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  89259. * @returns the emitter
  89260. */
  89261. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  89262. /**
  89263. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  89264. * @param radius The radius of the hemisphere to emit from
  89265. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  89266. * @returns the emitter
  89267. */
  89268. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  89269. /**
  89270. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  89271. * @param radius The radius of the sphere to emit from
  89272. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  89273. * @returns the emitter
  89274. */
  89275. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  89276. /**
  89277. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  89278. * @param radius The radius of the sphere to emit from
  89279. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  89280. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  89281. * @returns the emitter
  89282. */
  89283. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  89284. /**
  89285. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  89286. * @param radius The radius of the emission cylinder
  89287. * @param height The height of the emission cylinder
  89288. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  89289. * @param directionRandomizer How much to randomize the particle direction [0-1]
  89290. * @returns the emitter
  89291. */
  89292. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  89293. /**
  89294. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  89295. * @param radius The radius of the cylinder to emit from
  89296. * @param height The height of the emission cylinder
  89297. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  89298. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  89299. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  89300. * @returns the emitter
  89301. */
  89302. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  89303. /**
  89304. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  89305. * @param radius The radius of the cone to emit from
  89306. * @param angle The base angle of the cone
  89307. * @returns the emitter
  89308. */
  89309. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  89310. /**
  89311. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  89312. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  89313. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  89314. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  89315. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  89316. * @returns the emitter
  89317. */
  89318. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  89319. }
  89320. }
  89321. declare module BABYLON {
  89322. /**
  89323. * Type of sub emitter
  89324. */
  89325. export enum SubEmitterType {
  89326. /**
  89327. * Attached to the particle over it's lifetime
  89328. */
  89329. ATTACHED = 0,
  89330. /**
  89331. * Created when the particle dies
  89332. */
  89333. END = 1
  89334. }
  89335. /**
  89336. * Sub emitter class used to emit particles from an existing particle
  89337. */
  89338. export class SubEmitter {
  89339. /**
  89340. * the particle system to be used by the sub emitter
  89341. */
  89342. particleSystem: ParticleSystem;
  89343. /**
  89344. * Type of the submitter (Default: END)
  89345. */
  89346. type: SubEmitterType;
  89347. /**
  89348. * 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)
  89349. * Note: This only is supported when using an emitter of type Mesh
  89350. */
  89351. inheritDirection: boolean;
  89352. /**
  89353. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  89354. */
  89355. inheritedVelocityAmount: number;
  89356. /**
  89357. * Creates a sub emitter
  89358. * @param particleSystem the particle system to be used by the sub emitter
  89359. */
  89360. constructor(
  89361. /**
  89362. * the particle system to be used by the sub emitter
  89363. */
  89364. particleSystem: ParticleSystem);
  89365. /**
  89366. * Clones the sub emitter
  89367. * @returns the cloned sub emitter
  89368. */
  89369. clone(): SubEmitter;
  89370. /**
  89371. * Serialize current object to a JSON object
  89372. * @returns the serialized object
  89373. */
  89374. serialize(): any;
  89375. /** @hidden */
  89376. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  89377. /**
  89378. * Creates a new SubEmitter from a serialized JSON version
  89379. * @param serializationObject defines the JSON object to read from
  89380. * @param scene defines the hosting scene
  89381. * @param rootUrl defines the rootUrl for data loading
  89382. * @returns a new SubEmitter
  89383. */
  89384. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  89385. /** Release associated resources */
  89386. dispose(): void;
  89387. }
  89388. }
  89389. declare module BABYLON {
  89390. /** @hidden */
  89391. export var imageProcessingDeclaration: {
  89392. name: string;
  89393. shader: string;
  89394. };
  89395. }
  89396. declare module BABYLON {
  89397. /** @hidden */
  89398. export var imageProcessingFunctions: {
  89399. name: string;
  89400. shader: string;
  89401. };
  89402. }
  89403. declare module BABYLON {
  89404. /** @hidden */
  89405. export var particlesPixelShader: {
  89406. name: string;
  89407. shader: string;
  89408. };
  89409. }
  89410. declare module BABYLON {
  89411. /** @hidden */
  89412. export var particlesVertexShader: {
  89413. name: string;
  89414. shader: string;
  89415. };
  89416. }
  89417. declare module BABYLON {
  89418. /**
  89419. * This represents a particle system in Babylon.
  89420. * 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.
  89421. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  89422. * @example https://doc.babylonjs.com/babylon101/particles
  89423. */
  89424. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  89425. /**
  89426. * Billboard mode will only apply to Y axis
  89427. */
  89428. static readonly BILLBOARDMODE_Y: number;
  89429. /**
  89430. * Billboard mode will apply to all axes
  89431. */
  89432. static readonly BILLBOARDMODE_ALL: number;
  89433. /**
  89434. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  89435. */
  89436. static readonly BILLBOARDMODE_STRETCHED: number;
  89437. /**
  89438. * This function can be defined to provide custom update for active particles.
  89439. * This function will be called instead of regular update (age, position, color, etc.).
  89440. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  89441. */
  89442. updateFunction: (particles: Particle[]) => void;
  89443. private _emitterWorldMatrix;
  89444. /**
  89445. * This function can be defined to specify initial direction for every new particle.
  89446. * It by default use the emitterType defined function
  89447. */
  89448. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  89449. /**
  89450. * This function can be defined to specify initial position for every new particle.
  89451. * It by default use the emitterType defined function
  89452. */
  89453. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  89454. /**
  89455. * @hidden
  89456. */
  89457. _inheritedVelocityOffset: Vector3;
  89458. /**
  89459. * An event triggered when the system is disposed
  89460. */
  89461. onDisposeObservable: Observable<IParticleSystem>;
  89462. private _onDisposeObserver;
  89463. /**
  89464. * Sets a callback that will be triggered when the system is disposed
  89465. */
  89466. set onDispose(callback: () => void);
  89467. private _particles;
  89468. private _epsilon;
  89469. private _capacity;
  89470. private _stockParticles;
  89471. private _newPartsExcess;
  89472. private _vertexData;
  89473. private _vertexBuffer;
  89474. private _vertexBuffers;
  89475. private _spriteBuffer;
  89476. private _indexBuffer;
  89477. private _effect;
  89478. private _customEffect;
  89479. private _cachedDefines;
  89480. private _scaledColorStep;
  89481. private _colorDiff;
  89482. private _scaledDirection;
  89483. private _scaledGravity;
  89484. private _currentRenderId;
  89485. private _alive;
  89486. private _useInstancing;
  89487. private _started;
  89488. private _stopped;
  89489. private _actualFrame;
  89490. private _scaledUpdateSpeed;
  89491. private _vertexBufferSize;
  89492. /** @hidden */
  89493. _currentEmitRateGradient: Nullable<FactorGradient>;
  89494. /** @hidden */
  89495. _currentEmitRate1: number;
  89496. /** @hidden */
  89497. _currentEmitRate2: number;
  89498. /** @hidden */
  89499. _currentStartSizeGradient: Nullable<FactorGradient>;
  89500. /** @hidden */
  89501. _currentStartSize1: number;
  89502. /** @hidden */
  89503. _currentStartSize2: number;
  89504. private readonly _rawTextureWidth;
  89505. private _rampGradientsTexture;
  89506. private _useRampGradients;
  89507. /** Gets or sets a boolean indicating that ramp gradients must be used
  89508. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  89509. */
  89510. get useRampGradients(): boolean;
  89511. set useRampGradients(value: boolean);
  89512. /**
  89513. * 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.
  89514. * 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: [])
  89515. */
  89516. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  89517. private _subEmitters;
  89518. /**
  89519. * @hidden
  89520. * If the particle systems emitter should be disposed when the particle system is disposed
  89521. */
  89522. _disposeEmitterOnDispose: boolean;
  89523. /**
  89524. * The current active Sub-systems, this property is used by the root particle system only.
  89525. */
  89526. activeSubSystems: Array<ParticleSystem>;
  89527. /**
  89528. * Specifies if the particles are updated in emitter local space or world space
  89529. */
  89530. isLocal: boolean;
  89531. private _rootParticleSystem;
  89532. /**
  89533. * Gets the current list of active particles
  89534. */
  89535. get particles(): Particle[];
  89536. /**
  89537. * Gets the number of particles active at the same time.
  89538. * @returns The number of active particles.
  89539. */
  89540. getActiveCount(): number;
  89541. /**
  89542. * Returns the string "ParticleSystem"
  89543. * @returns a string containing the class name
  89544. */
  89545. getClassName(): string;
  89546. /**
  89547. * Gets a boolean indicating that the system is stopping
  89548. * @returns true if the system is currently stopping
  89549. */
  89550. isStopping(): boolean;
  89551. /**
  89552. * Gets the custom effect used to render the particles
  89553. * @param blendMode Blend mode for which the effect should be retrieved
  89554. * @returns The effect
  89555. */
  89556. getCustomEffect(blendMode?: number): Nullable<Effect>;
  89557. /**
  89558. * Sets the custom effect used to render the particles
  89559. * @param effect The effect to set
  89560. * @param blendMode Blend mode for which the effect should be set
  89561. */
  89562. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  89563. /** @hidden */
  89564. private _onBeforeDrawParticlesObservable;
  89565. /**
  89566. * Observable that will be called just before the particles are drawn
  89567. */
  89568. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  89569. /**
  89570. * Gets the name of the particle vertex shader
  89571. */
  89572. get vertexShaderName(): string;
  89573. /**
  89574. * Instantiates a particle system.
  89575. * 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.
  89576. * @param name The name of the particle system
  89577. * @param capacity The max number of particles alive at the same time
  89578. * @param scene The scene the particle system belongs to
  89579. * @param customEffect a custom effect used to change the way particles are rendered by default
  89580. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  89581. * @param epsilon Offset used to render the particles
  89582. */
  89583. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  89584. private _addFactorGradient;
  89585. private _removeFactorGradient;
  89586. /**
  89587. * Adds a new life time gradient
  89588. * @param gradient defines the gradient to use (between 0 and 1)
  89589. * @param factor defines the life time factor to affect to the specified gradient
  89590. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89591. * @returns the current particle system
  89592. */
  89593. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89594. /**
  89595. * Remove a specific life time gradient
  89596. * @param gradient defines the gradient to remove
  89597. * @returns the current particle system
  89598. */
  89599. removeLifeTimeGradient(gradient: number): IParticleSystem;
  89600. /**
  89601. * Adds a new size gradient
  89602. * @param gradient defines the gradient to use (between 0 and 1)
  89603. * @param factor defines the size factor to affect to the specified gradient
  89604. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89605. * @returns the current particle system
  89606. */
  89607. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89608. /**
  89609. * Remove a specific size gradient
  89610. * @param gradient defines the gradient to remove
  89611. * @returns the current particle system
  89612. */
  89613. removeSizeGradient(gradient: number): IParticleSystem;
  89614. /**
  89615. * Adds a new color remap gradient
  89616. * @param gradient defines the gradient to use (between 0 and 1)
  89617. * @param min defines the color remap minimal range
  89618. * @param max defines the color remap maximal range
  89619. * @returns the current particle system
  89620. */
  89621. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  89622. /**
  89623. * Remove a specific color remap gradient
  89624. * @param gradient defines the gradient to remove
  89625. * @returns the current particle system
  89626. */
  89627. removeColorRemapGradient(gradient: number): IParticleSystem;
  89628. /**
  89629. * Adds a new alpha remap gradient
  89630. * @param gradient defines the gradient to use (between 0 and 1)
  89631. * @param min defines the alpha remap minimal range
  89632. * @param max defines the alpha remap maximal range
  89633. * @returns the current particle system
  89634. */
  89635. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  89636. /**
  89637. * Remove a specific alpha remap gradient
  89638. * @param gradient defines the gradient to remove
  89639. * @returns the current particle system
  89640. */
  89641. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  89642. /**
  89643. * Adds a new angular speed gradient
  89644. * @param gradient defines the gradient to use (between 0 and 1)
  89645. * @param factor defines the angular speed to affect to the specified gradient
  89646. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89647. * @returns the current particle system
  89648. */
  89649. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89650. /**
  89651. * Remove a specific angular speed gradient
  89652. * @param gradient defines the gradient to remove
  89653. * @returns the current particle system
  89654. */
  89655. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  89656. /**
  89657. * Adds a new velocity gradient
  89658. * @param gradient defines the gradient to use (between 0 and 1)
  89659. * @param factor defines the velocity to affect to the specified gradient
  89660. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89661. * @returns the current particle system
  89662. */
  89663. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89664. /**
  89665. * Remove a specific velocity gradient
  89666. * @param gradient defines the gradient to remove
  89667. * @returns the current particle system
  89668. */
  89669. removeVelocityGradient(gradient: number): IParticleSystem;
  89670. /**
  89671. * Adds a new limit velocity gradient
  89672. * @param gradient defines the gradient to use (between 0 and 1)
  89673. * @param factor defines the limit velocity value to affect to the specified gradient
  89674. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89675. * @returns the current particle system
  89676. */
  89677. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89678. /**
  89679. * Remove a specific limit velocity gradient
  89680. * @param gradient defines the gradient to remove
  89681. * @returns the current particle system
  89682. */
  89683. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  89684. /**
  89685. * Adds a new drag gradient
  89686. * @param gradient defines the gradient to use (between 0 and 1)
  89687. * @param factor defines the drag value to affect to the specified gradient
  89688. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89689. * @returns the current particle system
  89690. */
  89691. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89692. /**
  89693. * Remove a specific drag gradient
  89694. * @param gradient defines the gradient to remove
  89695. * @returns the current particle system
  89696. */
  89697. removeDragGradient(gradient: number): IParticleSystem;
  89698. /**
  89699. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  89700. * @param gradient defines the gradient to use (between 0 and 1)
  89701. * @param factor defines the emit rate value to affect to the specified gradient
  89702. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89703. * @returns the current particle system
  89704. */
  89705. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89706. /**
  89707. * Remove a specific emit rate gradient
  89708. * @param gradient defines the gradient to remove
  89709. * @returns the current particle system
  89710. */
  89711. removeEmitRateGradient(gradient: number): IParticleSystem;
  89712. /**
  89713. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  89714. * @param gradient defines the gradient to use (between 0 and 1)
  89715. * @param factor defines the start size value to affect to the specified gradient
  89716. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89717. * @returns the current particle system
  89718. */
  89719. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89720. /**
  89721. * Remove a specific start size gradient
  89722. * @param gradient defines the gradient to remove
  89723. * @returns the current particle system
  89724. */
  89725. removeStartSizeGradient(gradient: number): IParticleSystem;
  89726. private _createRampGradientTexture;
  89727. /**
  89728. * Gets the current list of ramp gradients.
  89729. * You must use addRampGradient and removeRampGradient to udpate this list
  89730. * @returns the list of ramp gradients
  89731. */
  89732. getRampGradients(): Nullable<Array<Color3Gradient>>;
  89733. /** Force the system to rebuild all gradients that need to be resync */
  89734. forceRefreshGradients(): void;
  89735. private _syncRampGradientTexture;
  89736. /**
  89737. * Adds a new ramp gradient used to remap particle colors
  89738. * @param gradient defines the gradient to use (between 0 and 1)
  89739. * @param color defines the color to affect to the specified gradient
  89740. * @returns the current particle system
  89741. */
  89742. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  89743. /**
  89744. * Remove a specific ramp gradient
  89745. * @param gradient defines the gradient to remove
  89746. * @returns the current particle system
  89747. */
  89748. removeRampGradient(gradient: number): ParticleSystem;
  89749. /**
  89750. * Adds a new color gradient
  89751. * @param gradient defines the gradient to use (between 0 and 1)
  89752. * @param color1 defines the color to affect to the specified gradient
  89753. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  89754. * @returns this particle system
  89755. */
  89756. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  89757. /**
  89758. * Remove a specific color gradient
  89759. * @param gradient defines the gradient to remove
  89760. * @returns this particle system
  89761. */
  89762. removeColorGradient(gradient: number): IParticleSystem;
  89763. private _fetchR;
  89764. protected _reset(): void;
  89765. private _resetEffect;
  89766. private _createVertexBuffers;
  89767. private _createIndexBuffer;
  89768. /**
  89769. * Gets the maximum number of particles active at the same time.
  89770. * @returns The max number of active particles.
  89771. */
  89772. getCapacity(): number;
  89773. /**
  89774. * Gets whether there are still active particles in the system.
  89775. * @returns True if it is alive, otherwise false.
  89776. */
  89777. isAlive(): boolean;
  89778. /**
  89779. * Gets if the system has been started. (Note: this will still be true after stop is called)
  89780. * @returns True if it has been started, otherwise false.
  89781. */
  89782. isStarted(): boolean;
  89783. private _prepareSubEmitterInternalArray;
  89784. /**
  89785. * Starts the particle system and begins to emit
  89786. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  89787. */
  89788. start(delay?: number): void;
  89789. /**
  89790. * Stops the particle system.
  89791. * @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.
  89792. */
  89793. stop(stopSubEmitters?: boolean): void;
  89794. /**
  89795. * Remove all active particles
  89796. */
  89797. reset(): void;
  89798. /**
  89799. * @hidden (for internal use only)
  89800. */
  89801. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  89802. /**
  89803. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  89804. * Its lifetime will start back at 0.
  89805. */
  89806. recycleParticle: (particle: Particle) => void;
  89807. private _stopSubEmitters;
  89808. private _createParticle;
  89809. private _removeFromRoot;
  89810. private _emitFromParticle;
  89811. private _update;
  89812. /** @hidden */
  89813. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  89814. /** @hidden */
  89815. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  89816. /**
  89817. * Fill the defines array according to the current settings of the particle system
  89818. * @param defines Array to be updated
  89819. * @param blendMode blend mode to take into account when updating the array
  89820. */
  89821. fillDefines(defines: Array<string>, blendMode: number): void;
  89822. /**
  89823. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  89824. * @param uniforms Uniforms array to fill
  89825. * @param attributes Attributes array to fill
  89826. * @param samplers Samplers array to fill
  89827. */
  89828. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  89829. /** @hidden */
  89830. private _getEffect;
  89831. /**
  89832. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  89833. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  89834. */
  89835. animate(preWarmOnly?: boolean): void;
  89836. private _appendParticleVertices;
  89837. /**
  89838. * Rebuilds the particle system.
  89839. */
  89840. rebuild(): void;
  89841. /**
  89842. * Is this system ready to be used/rendered
  89843. * @return true if the system is ready
  89844. */
  89845. isReady(): boolean;
  89846. private _render;
  89847. /**
  89848. * Renders the particle system in its current state.
  89849. * @returns the current number of particles
  89850. */
  89851. render(): number;
  89852. /**
  89853. * Disposes the particle system and free the associated resources
  89854. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  89855. */
  89856. dispose(disposeTexture?: boolean): void;
  89857. /**
  89858. * Clones the particle system.
  89859. * @param name The name of the cloned object
  89860. * @param newEmitter The new emitter to use
  89861. * @returns the cloned particle system
  89862. */
  89863. clone(name: string, newEmitter: any): ParticleSystem;
  89864. /**
  89865. * Serializes the particle system to a JSON object
  89866. * @param serializeTexture defines if the texture must be serialized as well
  89867. * @returns the JSON object
  89868. */
  89869. serialize(serializeTexture?: boolean): any;
  89870. /** @hidden */
  89871. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  89872. /** @hidden */
  89873. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  89874. /**
  89875. * Parses a JSON object to create a particle system.
  89876. * @param parsedParticleSystem The JSON object to parse
  89877. * @param scene The scene to create the particle system in
  89878. * @param rootUrl The root url to use to load external dependencies like texture
  89879. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  89880. * @returns the Parsed particle system
  89881. */
  89882. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  89883. }
  89884. }
  89885. declare module BABYLON {
  89886. /**
  89887. * A particle represents one of the element emitted by a particle system.
  89888. * This is mainly define by its coordinates, direction, velocity and age.
  89889. */
  89890. export class Particle {
  89891. /**
  89892. * The particle system the particle belongs to.
  89893. */
  89894. particleSystem: ParticleSystem;
  89895. private static _Count;
  89896. /**
  89897. * Unique ID of the particle
  89898. */
  89899. id: number;
  89900. /**
  89901. * The world position of the particle in the scene.
  89902. */
  89903. position: Vector3;
  89904. /**
  89905. * The world direction of the particle in the scene.
  89906. */
  89907. direction: Vector3;
  89908. /**
  89909. * The color of the particle.
  89910. */
  89911. color: Color4;
  89912. /**
  89913. * The color change of the particle per step.
  89914. */
  89915. colorStep: Color4;
  89916. /**
  89917. * Defines how long will the life of the particle be.
  89918. */
  89919. lifeTime: number;
  89920. /**
  89921. * The current age of the particle.
  89922. */
  89923. age: number;
  89924. /**
  89925. * The current size of the particle.
  89926. */
  89927. size: number;
  89928. /**
  89929. * The current scale of the particle.
  89930. */
  89931. scale: Vector2;
  89932. /**
  89933. * The current angle of the particle.
  89934. */
  89935. angle: number;
  89936. /**
  89937. * Defines how fast is the angle changing.
  89938. */
  89939. angularSpeed: number;
  89940. /**
  89941. * Defines the cell index used by the particle to be rendered from a sprite.
  89942. */
  89943. cellIndex: number;
  89944. /**
  89945. * The information required to support color remapping
  89946. */
  89947. remapData: Vector4;
  89948. /** @hidden */
  89949. _randomCellOffset?: number;
  89950. /** @hidden */
  89951. _initialDirection: Nullable<Vector3>;
  89952. /** @hidden */
  89953. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  89954. /** @hidden */
  89955. _initialStartSpriteCellID: number;
  89956. /** @hidden */
  89957. _initialEndSpriteCellID: number;
  89958. /** @hidden */
  89959. _currentColorGradient: Nullable<ColorGradient>;
  89960. /** @hidden */
  89961. _currentColor1: Color4;
  89962. /** @hidden */
  89963. _currentColor2: Color4;
  89964. /** @hidden */
  89965. _currentSizeGradient: Nullable<FactorGradient>;
  89966. /** @hidden */
  89967. _currentSize1: number;
  89968. /** @hidden */
  89969. _currentSize2: number;
  89970. /** @hidden */
  89971. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  89972. /** @hidden */
  89973. _currentAngularSpeed1: number;
  89974. /** @hidden */
  89975. _currentAngularSpeed2: number;
  89976. /** @hidden */
  89977. _currentVelocityGradient: Nullable<FactorGradient>;
  89978. /** @hidden */
  89979. _currentVelocity1: number;
  89980. /** @hidden */
  89981. _currentVelocity2: number;
  89982. /** @hidden */
  89983. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  89984. /** @hidden */
  89985. _currentLimitVelocity1: number;
  89986. /** @hidden */
  89987. _currentLimitVelocity2: number;
  89988. /** @hidden */
  89989. _currentDragGradient: Nullable<FactorGradient>;
  89990. /** @hidden */
  89991. _currentDrag1: number;
  89992. /** @hidden */
  89993. _currentDrag2: number;
  89994. /** @hidden */
  89995. _randomNoiseCoordinates1: Vector3;
  89996. /** @hidden */
  89997. _randomNoiseCoordinates2: Vector3;
  89998. /** @hidden */
  89999. _localPosition?: Vector3;
  90000. /**
  90001. * Creates a new instance Particle
  90002. * @param particleSystem the particle system the particle belongs to
  90003. */
  90004. constructor(
  90005. /**
  90006. * The particle system the particle belongs to.
  90007. */
  90008. particleSystem: ParticleSystem);
  90009. private updateCellInfoFromSystem;
  90010. /**
  90011. * Defines how the sprite cell index is updated for the particle
  90012. */
  90013. updateCellIndex(): void;
  90014. /** @hidden */
  90015. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  90016. /** @hidden */
  90017. _inheritParticleInfoToSubEmitters(): void;
  90018. /** @hidden */
  90019. _reset(): void;
  90020. /**
  90021. * Copy the properties of particle to another one.
  90022. * @param other the particle to copy the information to.
  90023. */
  90024. copyTo(other: Particle): void;
  90025. }
  90026. }
  90027. declare module BABYLON {
  90028. /**
  90029. * Particle emitter represents a volume emitting particles.
  90030. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  90031. */
  90032. export interface IParticleEmitterType {
  90033. /**
  90034. * Called by the particle System when the direction is computed for the created particle.
  90035. * @param worldMatrix is the world matrix of the particle system
  90036. * @param directionToUpdate is the direction vector to update with the result
  90037. * @param particle is the particle we are computed the direction for
  90038. * @param isLocal defines if the direction should be set in local space
  90039. */
  90040. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  90041. /**
  90042. * Called by the particle System when the position is computed for the created particle.
  90043. * @param worldMatrix is the world matrix of the particle system
  90044. * @param positionToUpdate is the position vector to update with the result
  90045. * @param particle is the particle we are computed the position for
  90046. * @param isLocal defines if the position should be set in local space
  90047. */
  90048. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  90049. /**
  90050. * Clones the current emitter and returns a copy of it
  90051. * @returns the new emitter
  90052. */
  90053. clone(): IParticleEmitterType;
  90054. /**
  90055. * Called by the GPUParticleSystem to setup the update shader
  90056. * @param effect defines the update shader
  90057. */
  90058. applyToShader(effect: Effect): void;
  90059. /**
  90060. * Returns a string to use to update the GPU particles update shader
  90061. * @returns the effect defines string
  90062. */
  90063. getEffectDefines(): string;
  90064. /**
  90065. * Returns a string representing the class name
  90066. * @returns a string containing the class name
  90067. */
  90068. getClassName(): string;
  90069. /**
  90070. * Serializes the particle system to a JSON object.
  90071. * @returns the JSON object
  90072. */
  90073. serialize(): any;
  90074. /**
  90075. * Parse properties from a JSON object
  90076. * @param serializationObject defines the JSON object
  90077. * @param scene defines the hosting scene
  90078. */
  90079. parse(serializationObject: any, scene: Scene): void;
  90080. }
  90081. }
  90082. declare module BABYLON {
  90083. /**
  90084. * Particle emitter emitting particles from the inside of a box.
  90085. * It emits the particles randomly between 2 given directions.
  90086. */
  90087. export class BoxParticleEmitter implements IParticleEmitterType {
  90088. /**
  90089. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  90090. */
  90091. direction1: Vector3;
  90092. /**
  90093. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  90094. */
  90095. direction2: Vector3;
  90096. /**
  90097. * 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.
  90098. */
  90099. minEmitBox: Vector3;
  90100. /**
  90101. * 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.
  90102. */
  90103. maxEmitBox: Vector3;
  90104. /**
  90105. * Creates a new instance BoxParticleEmitter
  90106. */
  90107. constructor();
  90108. /**
  90109. * Called by the particle System when the direction is computed for the created particle.
  90110. * @param worldMatrix is the world matrix of the particle system
  90111. * @param directionToUpdate is the direction vector to update with the result
  90112. * @param particle is the particle we are computed the direction for
  90113. * @param isLocal defines if the direction should be set in local space
  90114. */
  90115. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  90116. /**
  90117. * Called by the particle System when the position is computed for the created particle.
  90118. * @param worldMatrix is the world matrix of the particle system
  90119. * @param positionToUpdate is the position vector to update with the result
  90120. * @param particle is the particle we are computed the position for
  90121. * @param isLocal defines if the position should be set in local space
  90122. */
  90123. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  90124. /**
  90125. * Clones the current emitter and returns a copy of it
  90126. * @returns the new emitter
  90127. */
  90128. clone(): BoxParticleEmitter;
  90129. /**
  90130. * Called by the GPUParticleSystem to setup the update shader
  90131. * @param effect defines the update shader
  90132. */
  90133. applyToShader(effect: Effect): void;
  90134. /**
  90135. * Returns a string to use to update the GPU particles update shader
  90136. * @returns a string containng the defines string
  90137. */
  90138. getEffectDefines(): string;
  90139. /**
  90140. * Returns the string "BoxParticleEmitter"
  90141. * @returns a string containing the class name
  90142. */
  90143. getClassName(): string;
  90144. /**
  90145. * Serializes the particle system to a JSON object.
  90146. * @returns the JSON object
  90147. */
  90148. serialize(): any;
  90149. /**
  90150. * Parse properties from a JSON object
  90151. * @param serializationObject defines the JSON object
  90152. */
  90153. parse(serializationObject: any): void;
  90154. }
  90155. }
  90156. declare module BABYLON {
  90157. /**
  90158. * Particle emitter emitting particles from the inside of a cone.
  90159. * It emits the particles alongside the cone volume from the base to the particle.
  90160. * The emission direction might be randomized.
  90161. */
  90162. export class ConeParticleEmitter implements IParticleEmitterType {
  90163. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  90164. directionRandomizer: number;
  90165. private _radius;
  90166. private _angle;
  90167. private _height;
  90168. /**
  90169. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  90170. */
  90171. radiusRange: number;
  90172. /**
  90173. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  90174. */
  90175. heightRange: number;
  90176. /**
  90177. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  90178. */
  90179. emitFromSpawnPointOnly: boolean;
  90180. /**
  90181. * Gets or sets the radius of the emission cone
  90182. */
  90183. get radius(): number;
  90184. set radius(value: number);
  90185. /**
  90186. * Gets or sets the angle of the emission cone
  90187. */
  90188. get angle(): number;
  90189. set angle(value: number);
  90190. private _buildHeight;
  90191. /**
  90192. * Creates a new instance ConeParticleEmitter
  90193. * @param radius the radius of the emission cone (1 by default)
  90194. * @param angle the cone base angle (PI by default)
  90195. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  90196. */
  90197. constructor(radius?: number, angle?: number,
  90198. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  90199. directionRandomizer?: number);
  90200. /**
  90201. * Called by the particle System when the direction is computed for the created particle.
  90202. * @param worldMatrix is the world matrix of the particle system
  90203. * @param directionToUpdate is the direction vector to update with the result
  90204. * @param particle is the particle we are computed the direction for
  90205. * @param isLocal defines if the direction should be set in local space
  90206. */
  90207. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  90208. /**
  90209. * Called by the particle System when the position is computed for the created particle.
  90210. * @param worldMatrix is the world matrix of the particle system
  90211. * @param positionToUpdate is the position vector to update with the result
  90212. * @param particle is the particle we are computed the position for
  90213. * @param isLocal defines if the position should be set in local space
  90214. */
  90215. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  90216. /**
  90217. * Clones the current emitter and returns a copy of it
  90218. * @returns the new emitter
  90219. */
  90220. clone(): ConeParticleEmitter;
  90221. /**
  90222. * Called by the GPUParticleSystem to setup the update shader
  90223. * @param effect defines the update shader
  90224. */
  90225. applyToShader(effect: Effect): void;
  90226. /**
  90227. * Returns a string to use to update the GPU particles update shader
  90228. * @returns a string containng the defines string
  90229. */
  90230. getEffectDefines(): string;
  90231. /**
  90232. * Returns the string "ConeParticleEmitter"
  90233. * @returns a string containing the class name
  90234. */
  90235. getClassName(): string;
  90236. /**
  90237. * Serializes the particle system to a JSON object.
  90238. * @returns the JSON object
  90239. */
  90240. serialize(): any;
  90241. /**
  90242. * Parse properties from a JSON object
  90243. * @param serializationObject defines the JSON object
  90244. */
  90245. parse(serializationObject: any): void;
  90246. }
  90247. }
  90248. declare module BABYLON {
  90249. /**
  90250. * Particle emitter emitting particles from the inside of a cylinder.
  90251. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  90252. */
  90253. export class CylinderParticleEmitter implements IParticleEmitterType {
  90254. /**
  90255. * The radius of the emission cylinder.
  90256. */
  90257. radius: number;
  90258. /**
  90259. * The height of the emission cylinder.
  90260. */
  90261. height: number;
  90262. /**
  90263. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  90264. */
  90265. radiusRange: number;
  90266. /**
  90267. * How much to randomize the particle direction [0-1].
  90268. */
  90269. directionRandomizer: number;
  90270. /**
  90271. * Creates a new instance CylinderParticleEmitter
  90272. * @param radius the radius of the emission cylinder (1 by default)
  90273. * @param height the height of the emission cylinder (1 by default)
  90274. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  90275. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  90276. */
  90277. constructor(
  90278. /**
  90279. * The radius of the emission cylinder.
  90280. */
  90281. radius?: number,
  90282. /**
  90283. * The height of the emission cylinder.
  90284. */
  90285. height?: number,
  90286. /**
  90287. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  90288. */
  90289. radiusRange?: number,
  90290. /**
  90291. * How much to randomize the particle direction [0-1].
  90292. */
  90293. directionRandomizer?: number);
  90294. /**
  90295. * Called by the particle System when the direction is computed for the created particle.
  90296. * @param worldMatrix is the world matrix of the particle system
  90297. * @param directionToUpdate is the direction vector to update with the result
  90298. * @param particle is the particle we are computed the direction for
  90299. * @param isLocal defines if the direction should be set in local space
  90300. */
  90301. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  90302. /**
  90303. * Called by the particle System when the position is computed for the created particle.
  90304. * @param worldMatrix is the world matrix of the particle system
  90305. * @param positionToUpdate is the position vector to update with the result
  90306. * @param particle is the particle we are computed the position for
  90307. * @param isLocal defines if the position should be set in local space
  90308. */
  90309. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  90310. /**
  90311. * Clones the current emitter and returns a copy of it
  90312. * @returns the new emitter
  90313. */
  90314. clone(): CylinderParticleEmitter;
  90315. /**
  90316. * Called by the GPUParticleSystem to setup the update shader
  90317. * @param effect defines the update shader
  90318. */
  90319. applyToShader(effect: Effect): void;
  90320. /**
  90321. * Returns a string to use to update the GPU particles update shader
  90322. * @returns a string containng the defines string
  90323. */
  90324. getEffectDefines(): string;
  90325. /**
  90326. * Returns the string "CylinderParticleEmitter"
  90327. * @returns a string containing the class name
  90328. */
  90329. getClassName(): string;
  90330. /**
  90331. * Serializes the particle system to a JSON object.
  90332. * @returns the JSON object
  90333. */
  90334. serialize(): any;
  90335. /**
  90336. * Parse properties from a JSON object
  90337. * @param serializationObject defines the JSON object
  90338. */
  90339. parse(serializationObject: any): void;
  90340. }
  90341. /**
  90342. * Particle emitter emitting particles from the inside of a cylinder.
  90343. * It emits the particles randomly between two vectors.
  90344. */
  90345. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  90346. /**
  90347. * The min limit of the emission direction.
  90348. */
  90349. direction1: Vector3;
  90350. /**
  90351. * The max limit of the emission direction.
  90352. */
  90353. direction2: Vector3;
  90354. /**
  90355. * Creates a new instance CylinderDirectedParticleEmitter
  90356. * @param radius the radius of the emission cylinder (1 by default)
  90357. * @param height the height of the emission cylinder (1 by default)
  90358. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  90359. * @param direction1 the min limit of the emission direction (up vector by default)
  90360. * @param direction2 the max limit of the emission direction (up vector by default)
  90361. */
  90362. constructor(radius?: number, height?: number, radiusRange?: number,
  90363. /**
  90364. * The min limit of the emission direction.
  90365. */
  90366. direction1?: Vector3,
  90367. /**
  90368. * The max limit of the emission direction.
  90369. */
  90370. direction2?: Vector3);
  90371. /**
  90372. * Called by the particle System when the direction is computed for the created particle.
  90373. * @param worldMatrix is the world matrix of the particle system
  90374. * @param directionToUpdate is the direction vector to update with the result
  90375. * @param particle is the particle we are computed the direction for
  90376. */
  90377. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  90378. /**
  90379. * Clones the current emitter and returns a copy of it
  90380. * @returns the new emitter
  90381. */
  90382. clone(): CylinderDirectedParticleEmitter;
  90383. /**
  90384. * Called by the GPUParticleSystem to setup the update shader
  90385. * @param effect defines the update shader
  90386. */
  90387. applyToShader(effect: Effect): void;
  90388. /**
  90389. * Returns a string to use to update the GPU particles update shader
  90390. * @returns a string containng the defines string
  90391. */
  90392. getEffectDefines(): string;
  90393. /**
  90394. * Returns the string "CylinderDirectedParticleEmitter"
  90395. * @returns a string containing the class name
  90396. */
  90397. getClassName(): string;
  90398. /**
  90399. * Serializes the particle system to a JSON object.
  90400. * @returns the JSON object
  90401. */
  90402. serialize(): any;
  90403. /**
  90404. * Parse properties from a JSON object
  90405. * @param serializationObject defines the JSON object
  90406. */
  90407. parse(serializationObject: any): void;
  90408. }
  90409. }
  90410. declare module BABYLON {
  90411. /**
  90412. * Particle emitter emitting particles from the inside of a hemisphere.
  90413. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  90414. */
  90415. export class HemisphericParticleEmitter implements IParticleEmitterType {
  90416. /**
  90417. * The radius of the emission hemisphere.
  90418. */
  90419. radius: number;
  90420. /**
  90421. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  90422. */
  90423. radiusRange: number;
  90424. /**
  90425. * How much to randomize the particle direction [0-1].
  90426. */
  90427. directionRandomizer: number;
  90428. /**
  90429. * Creates a new instance HemisphericParticleEmitter
  90430. * @param radius the radius of the emission hemisphere (1 by default)
  90431. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  90432. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  90433. */
  90434. constructor(
  90435. /**
  90436. * The radius of the emission hemisphere.
  90437. */
  90438. radius?: number,
  90439. /**
  90440. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  90441. */
  90442. radiusRange?: number,
  90443. /**
  90444. * How much to randomize the particle direction [0-1].
  90445. */
  90446. directionRandomizer?: number);
  90447. /**
  90448. * Called by the particle System when the direction is computed for the created particle.
  90449. * @param worldMatrix is the world matrix of the particle system
  90450. * @param directionToUpdate is the direction vector to update with the result
  90451. * @param particle is the particle we are computed the direction for
  90452. * @param isLocal defines if the direction should be set in local space
  90453. */
  90454. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  90455. /**
  90456. * Called by the particle System when the position is computed for the created particle.
  90457. * @param worldMatrix is the world matrix of the particle system
  90458. * @param positionToUpdate is the position vector to update with the result
  90459. * @param particle is the particle we are computed the position for
  90460. * @param isLocal defines if the position should be set in local space
  90461. */
  90462. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  90463. /**
  90464. * Clones the current emitter and returns a copy of it
  90465. * @returns the new emitter
  90466. */
  90467. clone(): HemisphericParticleEmitter;
  90468. /**
  90469. * Called by the GPUParticleSystem to setup the update shader
  90470. * @param effect defines the update shader
  90471. */
  90472. applyToShader(effect: Effect): void;
  90473. /**
  90474. * Returns a string to use to update the GPU particles update shader
  90475. * @returns a string containng the defines string
  90476. */
  90477. getEffectDefines(): string;
  90478. /**
  90479. * Returns the string "HemisphericParticleEmitter"
  90480. * @returns a string containing the class name
  90481. */
  90482. getClassName(): string;
  90483. /**
  90484. * Serializes the particle system to a JSON object.
  90485. * @returns the JSON object
  90486. */
  90487. serialize(): any;
  90488. /**
  90489. * Parse properties from a JSON object
  90490. * @param serializationObject defines the JSON object
  90491. */
  90492. parse(serializationObject: any): void;
  90493. }
  90494. }
  90495. declare module BABYLON {
  90496. /**
  90497. * Particle emitter emitting particles from a point.
  90498. * It emits the particles randomly between 2 given directions.
  90499. */
  90500. export class PointParticleEmitter implements IParticleEmitterType {
  90501. /**
  90502. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  90503. */
  90504. direction1: Vector3;
  90505. /**
  90506. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  90507. */
  90508. direction2: Vector3;
  90509. /**
  90510. * Creates a new instance PointParticleEmitter
  90511. */
  90512. constructor();
  90513. /**
  90514. * Called by the particle System when the direction is computed for the created particle.
  90515. * @param worldMatrix is the world matrix of the particle system
  90516. * @param directionToUpdate is the direction vector to update with the result
  90517. * @param particle is the particle we are computed the direction for
  90518. * @param isLocal defines if the direction should be set in local space
  90519. */
  90520. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  90521. /**
  90522. * Called by the particle System when the position is computed for the created particle.
  90523. * @param worldMatrix is the world matrix of the particle system
  90524. * @param positionToUpdate is the position vector to update with the result
  90525. * @param particle is the particle we are computed the position for
  90526. * @param isLocal defines if the position should be set in local space
  90527. */
  90528. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  90529. /**
  90530. * Clones the current emitter and returns a copy of it
  90531. * @returns the new emitter
  90532. */
  90533. clone(): PointParticleEmitter;
  90534. /**
  90535. * Called by the GPUParticleSystem to setup the update shader
  90536. * @param effect defines the update shader
  90537. */
  90538. applyToShader(effect: Effect): void;
  90539. /**
  90540. * Returns a string to use to update the GPU particles update shader
  90541. * @returns a string containng the defines string
  90542. */
  90543. getEffectDefines(): string;
  90544. /**
  90545. * Returns the string "PointParticleEmitter"
  90546. * @returns a string containing the class name
  90547. */
  90548. getClassName(): string;
  90549. /**
  90550. * Serializes the particle system to a JSON object.
  90551. * @returns the JSON object
  90552. */
  90553. serialize(): any;
  90554. /**
  90555. * Parse properties from a JSON object
  90556. * @param serializationObject defines the JSON object
  90557. */
  90558. parse(serializationObject: any): void;
  90559. }
  90560. }
  90561. declare module BABYLON {
  90562. /**
  90563. * Particle emitter emitting particles from the inside of a sphere.
  90564. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  90565. */
  90566. export class SphereParticleEmitter implements IParticleEmitterType {
  90567. /**
  90568. * The radius of the emission sphere.
  90569. */
  90570. radius: number;
  90571. /**
  90572. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  90573. */
  90574. radiusRange: number;
  90575. /**
  90576. * How much to randomize the particle direction [0-1].
  90577. */
  90578. directionRandomizer: number;
  90579. /**
  90580. * Creates a new instance SphereParticleEmitter
  90581. * @param radius the radius of the emission sphere (1 by default)
  90582. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  90583. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  90584. */
  90585. constructor(
  90586. /**
  90587. * The radius of the emission sphere.
  90588. */
  90589. radius?: number,
  90590. /**
  90591. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  90592. */
  90593. radiusRange?: number,
  90594. /**
  90595. * How much to randomize the particle direction [0-1].
  90596. */
  90597. directionRandomizer?: number);
  90598. /**
  90599. * Called by the particle System when the direction is computed for the created particle.
  90600. * @param worldMatrix is the world matrix of the particle system
  90601. * @param directionToUpdate is the direction vector to update with the result
  90602. * @param particle is the particle we are computed the direction for
  90603. * @param isLocal defines if the direction should be set in local space
  90604. */
  90605. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  90606. /**
  90607. * Called by the particle System when the position is computed for the created particle.
  90608. * @param worldMatrix is the world matrix of the particle system
  90609. * @param positionToUpdate is the position vector to update with the result
  90610. * @param particle is the particle we are computed the position for
  90611. * @param isLocal defines if the position should be set in local space
  90612. */
  90613. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  90614. /**
  90615. * Clones the current emitter and returns a copy of it
  90616. * @returns the new emitter
  90617. */
  90618. clone(): SphereParticleEmitter;
  90619. /**
  90620. * Called by the GPUParticleSystem to setup the update shader
  90621. * @param effect defines the update shader
  90622. */
  90623. applyToShader(effect: Effect): void;
  90624. /**
  90625. * Returns a string to use to update the GPU particles update shader
  90626. * @returns a string containng the defines string
  90627. */
  90628. getEffectDefines(): string;
  90629. /**
  90630. * Returns the string "SphereParticleEmitter"
  90631. * @returns a string containing the class name
  90632. */
  90633. getClassName(): string;
  90634. /**
  90635. * Serializes the particle system to a JSON object.
  90636. * @returns the JSON object
  90637. */
  90638. serialize(): any;
  90639. /**
  90640. * Parse properties from a JSON object
  90641. * @param serializationObject defines the JSON object
  90642. */
  90643. parse(serializationObject: any): void;
  90644. }
  90645. /**
  90646. * Particle emitter emitting particles from the inside of a sphere.
  90647. * It emits the particles randomly between two vectors.
  90648. */
  90649. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  90650. /**
  90651. * The min limit of the emission direction.
  90652. */
  90653. direction1: Vector3;
  90654. /**
  90655. * The max limit of the emission direction.
  90656. */
  90657. direction2: Vector3;
  90658. /**
  90659. * Creates a new instance SphereDirectedParticleEmitter
  90660. * @param radius the radius of the emission sphere (1 by default)
  90661. * @param direction1 the min limit of the emission direction (up vector by default)
  90662. * @param direction2 the max limit of the emission direction (up vector by default)
  90663. */
  90664. constructor(radius?: number,
  90665. /**
  90666. * The min limit of the emission direction.
  90667. */
  90668. direction1?: Vector3,
  90669. /**
  90670. * The max limit of the emission direction.
  90671. */
  90672. direction2?: Vector3);
  90673. /**
  90674. * Called by the particle System when the direction is computed for the created particle.
  90675. * @param worldMatrix is the world matrix of the particle system
  90676. * @param directionToUpdate is the direction vector to update with the result
  90677. * @param particle is the particle we are computed the direction for
  90678. */
  90679. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  90680. /**
  90681. * Clones the current emitter and returns a copy of it
  90682. * @returns the new emitter
  90683. */
  90684. clone(): SphereDirectedParticleEmitter;
  90685. /**
  90686. * Called by the GPUParticleSystem to setup the update shader
  90687. * @param effect defines the update shader
  90688. */
  90689. applyToShader(effect: Effect): void;
  90690. /**
  90691. * Returns a string to use to update the GPU particles update shader
  90692. * @returns a string containng the defines string
  90693. */
  90694. getEffectDefines(): string;
  90695. /**
  90696. * Returns the string "SphereDirectedParticleEmitter"
  90697. * @returns a string containing the class name
  90698. */
  90699. getClassName(): string;
  90700. /**
  90701. * Serializes the particle system to a JSON object.
  90702. * @returns the JSON object
  90703. */
  90704. serialize(): any;
  90705. /**
  90706. * Parse properties from a JSON object
  90707. * @param serializationObject defines the JSON object
  90708. */
  90709. parse(serializationObject: any): void;
  90710. }
  90711. }
  90712. declare module BABYLON {
  90713. /**
  90714. * Particle emitter emitting particles from a custom list of positions.
  90715. */
  90716. export class CustomParticleEmitter implements IParticleEmitterType {
  90717. /**
  90718. * Gets or sets the position generator that will create the inital position of each particle.
  90719. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  90720. */
  90721. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  90722. /**
  90723. * Gets or sets the destination generator that will create the final destination of each particle.
  90724. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  90725. */
  90726. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  90727. /**
  90728. * Creates a new instance CustomParticleEmitter
  90729. */
  90730. constructor();
  90731. /**
  90732. * Called by the particle System when the direction is computed for the created particle.
  90733. * @param worldMatrix is the world matrix of the particle system
  90734. * @param directionToUpdate is the direction vector to update with the result
  90735. * @param particle is the particle we are computed the direction for
  90736. * @param isLocal defines if the direction should be set in local space
  90737. */
  90738. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  90739. /**
  90740. * Called by the particle System when the position is computed for the created particle.
  90741. * @param worldMatrix is the world matrix of the particle system
  90742. * @param positionToUpdate is the position vector to update with the result
  90743. * @param particle is the particle we are computed the position for
  90744. * @param isLocal defines if the position should be set in local space
  90745. */
  90746. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  90747. /**
  90748. * Clones the current emitter and returns a copy of it
  90749. * @returns the new emitter
  90750. */
  90751. clone(): CustomParticleEmitter;
  90752. /**
  90753. * Called by the GPUParticleSystem to setup the update shader
  90754. * @param effect defines the update shader
  90755. */
  90756. applyToShader(effect: Effect): void;
  90757. /**
  90758. * Returns a string to use to update the GPU particles update shader
  90759. * @returns a string containng the defines string
  90760. */
  90761. getEffectDefines(): string;
  90762. /**
  90763. * Returns the string "PointParticleEmitter"
  90764. * @returns a string containing the class name
  90765. */
  90766. getClassName(): string;
  90767. /**
  90768. * Serializes the particle system to a JSON object.
  90769. * @returns the JSON object
  90770. */
  90771. serialize(): any;
  90772. /**
  90773. * Parse properties from a JSON object
  90774. * @param serializationObject defines the JSON object
  90775. */
  90776. parse(serializationObject: any): void;
  90777. }
  90778. }
  90779. declare module BABYLON {
  90780. /**
  90781. * Particle emitter emitting particles from the inside of a box.
  90782. * It emits the particles randomly between 2 given directions.
  90783. */
  90784. export class MeshParticleEmitter implements IParticleEmitterType {
  90785. private _indices;
  90786. private _positions;
  90787. private _normals;
  90788. private _storedNormal;
  90789. private _mesh;
  90790. /**
  90791. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  90792. */
  90793. direction1: Vector3;
  90794. /**
  90795. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  90796. */
  90797. direction2: Vector3;
  90798. /**
  90799. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  90800. */
  90801. useMeshNormalsForDirection: boolean;
  90802. /** Defines the mesh to use as source */
  90803. get mesh(): Nullable<AbstractMesh>;
  90804. set mesh(value: Nullable<AbstractMesh>);
  90805. /**
  90806. * Creates a new instance MeshParticleEmitter
  90807. * @param mesh defines the mesh to use as source
  90808. */
  90809. constructor(mesh?: Nullable<AbstractMesh>);
  90810. /**
  90811. * Called by the particle System when the direction is computed for the created particle.
  90812. * @param worldMatrix is the world matrix of the particle system
  90813. * @param directionToUpdate is the direction vector to update with the result
  90814. * @param particle is the particle we are computed the direction for
  90815. * @param isLocal defines if the direction should be set in local space
  90816. */
  90817. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  90818. /**
  90819. * Called by the particle System when the position is computed for the created particle.
  90820. * @param worldMatrix is the world matrix of the particle system
  90821. * @param positionToUpdate is the position vector to update with the result
  90822. * @param particle is the particle we are computed the position for
  90823. * @param isLocal defines if the position should be set in local space
  90824. */
  90825. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  90826. /**
  90827. * Clones the current emitter and returns a copy of it
  90828. * @returns the new emitter
  90829. */
  90830. clone(): MeshParticleEmitter;
  90831. /**
  90832. * Called by the GPUParticleSystem to setup the update shader
  90833. * @param effect defines the update shader
  90834. */
  90835. applyToShader(effect: Effect): void;
  90836. /**
  90837. * Returns a string to use to update the GPU particles update shader
  90838. * @returns a string containng the defines string
  90839. */
  90840. getEffectDefines(): string;
  90841. /**
  90842. * Returns the string "BoxParticleEmitter"
  90843. * @returns a string containing the class name
  90844. */
  90845. getClassName(): string;
  90846. /**
  90847. * Serializes the particle system to a JSON object.
  90848. * @returns the JSON object
  90849. */
  90850. serialize(): any;
  90851. /**
  90852. * Parse properties from a JSON object
  90853. * @param serializationObject defines the JSON object
  90854. * @param scene defines the hosting scene
  90855. */
  90856. parse(serializationObject: any, scene: Scene): void;
  90857. }
  90858. }
  90859. declare module BABYLON {
  90860. /**
  90861. * Interface representing a particle system in Babylon.js.
  90862. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  90863. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  90864. */
  90865. export interface IParticleSystem {
  90866. /**
  90867. * List of animations used by the particle system.
  90868. */
  90869. animations: Animation[];
  90870. /**
  90871. * The id of the Particle system.
  90872. */
  90873. id: string;
  90874. /**
  90875. * The name of the Particle system.
  90876. */
  90877. name: string;
  90878. /**
  90879. * The emitter represents the Mesh or position we are attaching the particle system to.
  90880. */
  90881. emitter: Nullable<AbstractMesh | Vector3>;
  90882. /**
  90883. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  90884. */
  90885. isBillboardBased: boolean;
  90886. /**
  90887. * The rendering group used by the Particle system to chose when to render.
  90888. */
  90889. renderingGroupId: number;
  90890. /**
  90891. * The layer mask we are rendering the particles through.
  90892. */
  90893. layerMask: number;
  90894. /**
  90895. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  90896. */
  90897. updateSpeed: number;
  90898. /**
  90899. * The amount of time the particle system is running (depends of the overall update speed).
  90900. */
  90901. targetStopDuration: number;
  90902. /**
  90903. * The texture used to render each particle. (this can be a spritesheet)
  90904. */
  90905. particleTexture: Nullable<Texture>;
  90906. /**
  90907. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  90908. */
  90909. blendMode: number;
  90910. /**
  90911. * Minimum life time of emitting particles.
  90912. */
  90913. minLifeTime: number;
  90914. /**
  90915. * Maximum life time of emitting particles.
  90916. */
  90917. maxLifeTime: number;
  90918. /**
  90919. * Minimum Size of emitting particles.
  90920. */
  90921. minSize: number;
  90922. /**
  90923. * Maximum Size of emitting particles.
  90924. */
  90925. maxSize: number;
  90926. /**
  90927. * Minimum scale of emitting particles on X axis.
  90928. */
  90929. minScaleX: number;
  90930. /**
  90931. * Maximum scale of emitting particles on X axis.
  90932. */
  90933. maxScaleX: number;
  90934. /**
  90935. * Minimum scale of emitting particles on Y axis.
  90936. */
  90937. minScaleY: number;
  90938. /**
  90939. * Maximum scale of emitting particles on Y axis.
  90940. */
  90941. maxScaleY: number;
  90942. /**
  90943. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  90944. */
  90945. color1: Color4;
  90946. /**
  90947. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  90948. */
  90949. color2: Color4;
  90950. /**
  90951. * Color the particle will have at the end of its lifetime.
  90952. */
  90953. colorDead: Color4;
  90954. /**
  90955. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  90956. */
  90957. emitRate: number;
  90958. /**
  90959. * You can use gravity if you want to give an orientation to your particles.
  90960. */
  90961. gravity: Vector3;
  90962. /**
  90963. * Minimum power of emitting particles.
  90964. */
  90965. minEmitPower: number;
  90966. /**
  90967. * Maximum power of emitting particles.
  90968. */
  90969. maxEmitPower: number;
  90970. /**
  90971. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  90972. */
  90973. minAngularSpeed: number;
  90974. /**
  90975. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  90976. */
  90977. maxAngularSpeed: number;
  90978. /**
  90979. * Gets or sets the minimal initial rotation in radians.
  90980. */
  90981. minInitialRotation: number;
  90982. /**
  90983. * Gets or sets the maximal initial rotation in radians.
  90984. */
  90985. maxInitialRotation: number;
  90986. /**
  90987. * The particle emitter type defines the emitter used by the particle system.
  90988. * It can be for example box, sphere, or cone...
  90989. */
  90990. particleEmitterType: Nullable<IParticleEmitterType>;
  90991. /**
  90992. * Defines the delay in milliseconds before starting the system (0 by default)
  90993. */
  90994. startDelay: number;
  90995. /**
  90996. * 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
  90997. */
  90998. preWarmCycles: number;
  90999. /**
  91000. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  91001. */
  91002. preWarmStepOffset: number;
  91003. /**
  91004. * 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)
  91005. */
  91006. spriteCellChangeSpeed: number;
  91007. /**
  91008. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  91009. */
  91010. startSpriteCellID: number;
  91011. /**
  91012. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  91013. */
  91014. endSpriteCellID: number;
  91015. /**
  91016. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  91017. */
  91018. spriteCellWidth: number;
  91019. /**
  91020. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  91021. */
  91022. spriteCellHeight: number;
  91023. /**
  91024. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  91025. */
  91026. spriteRandomStartCell: boolean;
  91027. /**
  91028. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  91029. */
  91030. isAnimationSheetEnabled: boolean;
  91031. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  91032. translationPivot: Vector2;
  91033. /**
  91034. * Gets or sets a texture used to add random noise to particle positions
  91035. */
  91036. noiseTexture: Nullable<BaseTexture>;
  91037. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  91038. noiseStrength: Vector3;
  91039. /**
  91040. * Gets or sets the billboard mode to use when isBillboardBased = true.
  91041. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  91042. */
  91043. billboardMode: number;
  91044. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  91045. limitVelocityDamping: number;
  91046. /**
  91047. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  91048. */
  91049. beginAnimationOnStart: boolean;
  91050. /**
  91051. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  91052. */
  91053. beginAnimationFrom: number;
  91054. /**
  91055. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  91056. */
  91057. beginAnimationTo: number;
  91058. /**
  91059. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  91060. */
  91061. beginAnimationLoop: boolean;
  91062. /**
  91063. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  91064. */
  91065. disposeOnStop: boolean;
  91066. /**
  91067. * Specifies if the particles are updated in emitter local space or world space
  91068. */
  91069. isLocal: boolean;
  91070. /** Snippet ID if the particle system was created from the snippet server */
  91071. snippetId: string;
  91072. /**
  91073. * Gets the maximum number of particles active at the same time.
  91074. * @returns The max number of active particles.
  91075. */
  91076. getCapacity(): number;
  91077. /**
  91078. * Gets the number of particles active at the same time.
  91079. * @returns The number of active particles.
  91080. */
  91081. getActiveCount(): number;
  91082. /**
  91083. * Gets if the system has been started. (Note: this will still be true after stop is called)
  91084. * @returns True if it has been started, otherwise false.
  91085. */
  91086. isStarted(): boolean;
  91087. /**
  91088. * Animates the particle system for this frame.
  91089. */
  91090. animate(): void;
  91091. /**
  91092. * Renders the particle system in its current state.
  91093. * @returns the current number of particles
  91094. */
  91095. render(): number;
  91096. /**
  91097. * Dispose the particle system and frees its associated resources.
  91098. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  91099. */
  91100. dispose(disposeTexture?: boolean): void;
  91101. /**
  91102. * An event triggered when the system is disposed
  91103. */
  91104. onDisposeObservable: Observable<IParticleSystem>;
  91105. /**
  91106. * Clones the particle system.
  91107. * @param name The name of the cloned object
  91108. * @param newEmitter The new emitter to use
  91109. * @returns the cloned particle system
  91110. */
  91111. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  91112. /**
  91113. * Serializes the particle system to a JSON object
  91114. * @param serializeTexture defines if the texture must be serialized as well
  91115. * @returns the JSON object
  91116. */
  91117. serialize(serializeTexture: boolean): any;
  91118. /**
  91119. * Rebuild the particle system
  91120. */
  91121. rebuild(): void;
  91122. /** Force the system to rebuild all gradients that need to be resync */
  91123. forceRefreshGradients(): void;
  91124. /**
  91125. * Starts the particle system and begins to emit
  91126. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  91127. */
  91128. start(delay?: number): void;
  91129. /**
  91130. * Stops the particle system.
  91131. */
  91132. stop(): void;
  91133. /**
  91134. * Remove all active particles
  91135. */
  91136. reset(): void;
  91137. /**
  91138. * Gets a boolean indicating that the system is stopping
  91139. * @returns true if the system is currently stopping
  91140. */
  91141. isStopping(): boolean;
  91142. /**
  91143. * Is this system ready to be used/rendered
  91144. * @return true if the system is ready
  91145. */
  91146. isReady(): boolean;
  91147. /**
  91148. * Returns the string "ParticleSystem"
  91149. * @returns a string containing the class name
  91150. */
  91151. getClassName(): string;
  91152. /**
  91153. * Gets the custom effect used to render the particles
  91154. * @param blendMode Blend mode for which the effect should be retrieved
  91155. * @returns The effect
  91156. */
  91157. getCustomEffect(blendMode: number): Nullable<Effect>;
  91158. /**
  91159. * Sets the custom effect used to render the particles
  91160. * @param effect The effect to set
  91161. * @param blendMode Blend mode for which the effect should be set
  91162. */
  91163. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  91164. /**
  91165. * Fill the defines array according to the current settings of the particle system
  91166. * @param defines Array to be updated
  91167. * @param blendMode blend mode to take into account when updating the array
  91168. */
  91169. fillDefines(defines: Array<string>, blendMode: number): void;
  91170. /**
  91171. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  91172. * @param uniforms Uniforms array to fill
  91173. * @param attributes Attributes array to fill
  91174. * @param samplers Samplers array to fill
  91175. */
  91176. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  91177. /**
  91178. * Observable that will be called just before the particles are drawn
  91179. */
  91180. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  91181. /**
  91182. * Gets the name of the particle vertex shader
  91183. */
  91184. vertexShaderName: string;
  91185. /**
  91186. * Adds a new color gradient
  91187. * @param gradient defines the gradient to use (between 0 and 1)
  91188. * @param color1 defines the color to affect to the specified gradient
  91189. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  91190. * @returns the current particle system
  91191. */
  91192. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  91193. /**
  91194. * Remove a specific color gradient
  91195. * @param gradient defines the gradient to remove
  91196. * @returns the current particle system
  91197. */
  91198. removeColorGradient(gradient: number): IParticleSystem;
  91199. /**
  91200. * Adds a new size gradient
  91201. * @param gradient defines the gradient to use (between 0 and 1)
  91202. * @param factor defines the size factor to affect to the specified gradient
  91203. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91204. * @returns the current particle system
  91205. */
  91206. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91207. /**
  91208. * Remove a specific size gradient
  91209. * @param gradient defines the gradient to remove
  91210. * @returns the current particle system
  91211. */
  91212. removeSizeGradient(gradient: number): IParticleSystem;
  91213. /**
  91214. * Gets the current list of color gradients.
  91215. * You must use addColorGradient and removeColorGradient to udpate this list
  91216. * @returns the list of color gradients
  91217. */
  91218. getColorGradients(): Nullable<Array<ColorGradient>>;
  91219. /**
  91220. * Gets the current list of size gradients.
  91221. * You must use addSizeGradient and removeSizeGradient to udpate this list
  91222. * @returns the list of size gradients
  91223. */
  91224. getSizeGradients(): Nullable<Array<FactorGradient>>;
  91225. /**
  91226. * Gets the current list of angular speed gradients.
  91227. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  91228. * @returns the list of angular speed gradients
  91229. */
  91230. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  91231. /**
  91232. * Adds a new angular speed gradient
  91233. * @param gradient defines the gradient to use (between 0 and 1)
  91234. * @param factor defines the angular speed to affect to the specified gradient
  91235. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91236. * @returns the current particle system
  91237. */
  91238. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91239. /**
  91240. * Remove a specific angular speed gradient
  91241. * @param gradient defines the gradient to remove
  91242. * @returns the current particle system
  91243. */
  91244. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  91245. /**
  91246. * Gets the current list of velocity gradients.
  91247. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  91248. * @returns the list of velocity gradients
  91249. */
  91250. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  91251. /**
  91252. * Adds a new velocity gradient
  91253. * @param gradient defines the gradient to use (between 0 and 1)
  91254. * @param factor defines the velocity to affect to the specified gradient
  91255. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91256. * @returns the current particle system
  91257. */
  91258. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91259. /**
  91260. * Remove a specific velocity gradient
  91261. * @param gradient defines the gradient to remove
  91262. * @returns the current particle system
  91263. */
  91264. removeVelocityGradient(gradient: number): IParticleSystem;
  91265. /**
  91266. * Gets the current list of limit velocity gradients.
  91267. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  91268. * @returns the list of limit velocity gradients
  91269. */
  91270. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  91271. /**
  91272. * Adds a new limit velocity gradient
  91273. * @param gradient defines the gradient to use (between 0 and 1)
  91274. * @param factor defines the limit velocity to affect to the specified gradient
  91275. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91276. * @returns the current particle system
  91277. */
  91278. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91279. /**
  91280. * Remove a specific limit velocity gradient
  91281. * @param gradient defines the gradient to remove
  91282. * @returns the current particle system
  91283. */
  91284. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  91285. /**
  91286. * Adds a new drag gradient
  91287. * @param gradient defines the gradient to use (between 0 and 1)
  91288. * @param factor defines the drag to affect to the specified gradient
  91289. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91290. * @returns the current particle system
  91291. */
  91292. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91293. /**
  91294. * Remove a specific drag gradient
  91295. * @param gradient defines the gradient to remove
  91296. * @returns the current particle system
  91297. */
  91298. removeDragGradient(gradient: number): IParticleSystem;
  91299. /**
  91300. * Gets the current list of drag gradients.
  91301. * You must use addDragGradient and removeDragGradient to udpate this list
  91302. * @returns the list of drag gradients
  91303. */
  91304. getDragGradients(): Nullable<Array<FactorGradient>>;
  91305. /**
  91306. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  91307. * @param gradient defines the gradient to use (between 0 and 1)
  91308. * @param factor defines the emit rate to affect to the specified gradient
  91309. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91310. * @returns the current particle system
  91311. */
  91312. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91313. /**
  91314. * Remove a specific emit rate gradient
  91315. * @param gradient defines the gradient to remove
  91316. * @returns the current particle system
  91317. */
  91318. removeEmitRateGradient(gradient: number): IParticleSystem;
  91319. /**
  91320. * Gets the current list of emit rate gradients.
  91321. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  91322. * @returns the list of emit rate gradients
  91323. */
  91324. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  91325. /**
  91326. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  91327. * @param gradient defines the gradient to use (between 0 and 1)
  91328. * @param factor defines the start size to affect to the specified gradient
  91329. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91330. * @returns the current particle system
  91331. */
  91332. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91333. /**
  91334. * Remove a specific start size gradient
  91335. * @param gradient defines the gradient to remove
  91336. * @returns the current particle system
  91337. */
  91338. removeStartSizeGradient(gradient: number): IParticleSystem;
  91339. /**
  91340. * Gets the current list of start size gradients.
  91341. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  91342. * @returns the list of start size gradients
  91343. */
  91344. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  91345. /**
  91346. * Adds a new life time gradient
  91347. * @param gradient defines the gradient to use (between 0 and 1)
  91348. * @param factor defines the life time factor to affect to the specified gradient
  91349. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91350. * @returns the current particle system
  91351. */
  91352. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91353. /**
  91354. * Remove a specific life time gradient
  91355. * @param gradient defines the gradient to remove
  91356. * @returns the current particle system
  91357. */
  91358. removeLifeTimeGradient(gradient: number): IParticleSystem;
  91359. /**
  91360. * Gets the current list of life time gradients.
  91361. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  91362. * @returns the list of life time gradients
  91363. */
  91364. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  91365. /**
  91366. * Gets the current list of color gradients.
  91367. * You must use addColorGradient and removeColorGradient to udpate this list
  91368. * @returns the list of color gradients
  91369. */
  91370. getColorGradients(): Nullable<Array<ColorGradient>>;
  91371. /**
  91372. * Adds a new ramp gradient used to remap particle colors
  91373. * @param gradient defines the gradient to use (between 0 and 1)
  91374. * @param color defines the color to affect to the specified gradient
  91375. * @returns the current particle system
  91376. */
  91377. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  91378. /**
  91379. * Gets the current list of ramp gradients.
  91380. * You must use addRampGradient and removeRampGradient to udpate this list
  91381. * @returns the list of ramp gradients
  91382. */
  91383. getRampGradients(): Nullable<Array<Color3Gradient>>;
  91384. /** Gets or sets a boolean indicating that ramp gradients must be used
  91385. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  91386. */
  91387. useRampGradients: boolean;
  91388. /**
  91389. * Adds a new color remap gradient
  91390. * @param gradient defines the gradient to use (between 0 and 1)
  91391. * @param min defines the color remap minimal range
  91392. * @param max defines the color remap maximal range
  91393. * @returns the current particle system
  91394. */
  91395. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  91396. /**
  91397. * Gets the current list of color remap gradients.
  91398. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  91399. * @returns the list of color remap gradients
  91400. */
  91401. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  91402. /**
  91403. * Adds a new alpha remap gradient
  91404. * @param gradient defines the gradient to use (between 0 and 1)
  91405. * @param min defines the alpha remap minimal range
  91406. * @param max defines the alpha remap maximal range
  91407. * @returns the current particle system
  91408. */
  91409. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  91410. /**
  91411. * Gets the current list of alpha remap gradients.
  91412. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  91413. * @returns the list of alpha remap gradients
  91414. */
  91415. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  91416. /**
  91417. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  91418. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  91419. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  91420. * @returns the emitter
  91421. */
  91422. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  91423. /**
  91424. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  91425. * @param radius The radius of the hemisphere to emit from
  91426. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  91427. * @returns the emitter
  91428. */
  91429. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  91430. /**
  91431. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  91432. * @param radius The radius of the sphere to emit from
  91433. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  91434. * @returns the emitter
  91435. */
  91436. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  91437. /**
  91438. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  91439. * @param radius The radius of the sphere to emit from
  91440. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  91441. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  91442. * @returns the emitter
  91443. */
  91444. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  91445. /**
  91446. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  91447. * @param radius The radius of the emission cylinder
  91448. * @param height The height of the emission cylinder
  91449. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  91450. * @param directionRandomizer How much to randomize the particle direction [0-1]
  91451. * @returns the emitter
  91452. */
  91453. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  91454. /**
  91455. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  91456. * @param radius The radius of the cylinder to emit from
  91457. * @param height The height of the emission cylinder
  91458. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  91459. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  91460. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  91461. * @returns the emitter
  91462. */
  91463. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  91464. /**
  91465. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  91466. * @param radius The radius of the cone to emit from
  91467. * @param angle The base angle of the cone
  91468. * @returns the emitter
  91469. */
  91470. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  91471. /**
  91472. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  91473. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  91474. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  91475. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  91476. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  91477. * @returns the emitter
  91478. */
  91479. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  91480. /**
  91481. * Get hosting scene
  91482. * @returns the scene
  91483. */
  91484. getScene(): Scene;
  91485. }
  91486. }
  91487. declare module BABYLON {
  91488. /**
  91489. * 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.
  91490. * @see https://doc.babylonjs.com/how_to/transformnode
  91491. */
  91492. export class TransformNode extends Node {
  91493. /**
  91494. * Object will not rotate to face the camera
  91495. */
  91496. static BILLBOARDMODE_NONE: number;
  91497. /**
  91498. * Object will rotate to face the camera but only on the x axis
  91499. */
  91500. static BILLBOARDMODE_X: number;
  91501. /**
  91502. * Object will rotate to face the camera but only on the y axis
  91503. */
  91504. static BILLBOARDMODE_Y: number;
  91505. /**
  91506. * Object will rotate to face the camera but only on the z axis
  91507. */
  91508. static BILLBOARDMODE_Z: number;
  91509. /**
  91510. * Object will rotate to face the camera
  91511. */
  91512. static BILLBOARDMODE_ALL: number;
  91513. /**
  91514. * Object will rotate to face the camera's position instead of orientation
  91515. */
  91516. static BILLBOARDMODE_USE_POSITION: number;
  91517. private _forward;
  91518. private _forwardInverted;
  91519. private _up;
  91520. private _right;
  91521. private _rightInverted;
  91522. private _position;
  91523. private _rotation;
  91524. private _rotationQuaternion;
  91525. protected _scaling: Vector3;
  91526. protected _isDirty: boolean;
  91527. private _transformToBoneReferal;
  91528. private _isAbsoluteSynced;
  91529. private _billboardMode;
  91530. /**
  91531. * Gets or sets the billboard mode. Default is 0.
  91532. *
  91533. * | Value | Type | Description |
  91534. * | --- | --- | --- |
  91535. * | 0 | BILLBOARDMODE_NONE | |
  91536. * | 1 | BILLBOARDMODE_X | |
  91537. * | 2 | BILLBOARDMODE_Y | |
  91538. * | 4 | BILLBOARDMODE_Z | |
  91539. * | 7 | BILLBOARDMODE_ALL | |
  91540. *
  91541. */
  91542. get billboardMode(): number;
  91543. set billboardMode(value: number);
  91544. private _preserveParentRotationForBillboard;
  91545. /**
  91546. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  91547. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  91548. */
  91549. get preserveParentRotationForBillboard(): boolean;
  91550. set preserveParentRotationForBillboard(value: boolean);
  91551. /**
  91552. * 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
  91553. */
  91554. scalingDeterminant: number;
  91555. private _infiniteDistance;
  91556. /**
  91557. * Gets or sets the distance of the object to max, often used by skybox
  91558. */
  91559. get infiniteDistance(): boolean;
  91560. set infiniteDistance(value: boolean);
  91561. /**
  91562. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  91563. * By default the system will update normals to compensate
  91564. */
  91565. ignoreNonUniformScaling: boolean;
  91566. /**
  91567. * 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
  91568. */
  91569. reIntegrateRotationIntoRotationQuaternion: boolean;
  91570. /** @hidden */
  91571. _poseMatrix: Nullable<Matrix>;
  91572. /** @hidden */
  91573. _localMatrix: Matrix;
  91574. private _usePivotMatrix;
  91575. private _absolutePosition;
  91576. private _absoluteScaling;
  91577. private _absoluteRotationQuaternion;
  91578. private _pivotMatrix;
  91579. private _pivotMatrixInverse;
  91580. protected _postMultiplyPivotMatrix: boolean;
  91581. protected _isWorldMatrixFrozen: boolean;
  91582. /** @hidden */
  91583. _indexInSceneTransformNodesArray: number;
  91584. /**
  91585. * An event triggered after the world matrix is updated
  91586. */
  91587. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  91588. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  91589. /**
  91590. * Gets a string identifying the name of the class
  91591. * @returns "TransformNode" string
  91592. */
  91593. getClassName(): string;
  91594. /**
  91595. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  91596. */
  91597. get position(): Vector3;
  91598. set position(newPosition: Vector3);
  91599. /**
  91600. * 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)).
  91601. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  91602. */
  91603. get rotation(): Vector3;
  91604. set rotation(newRotation: Vector3);
  91605. /**
  91606. * 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)).
  91607. */
  91608. get scaling(): Vector3;
  91609. set scaling(newScaling: Vector3);
  91610. /**
  91611. * 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).
  91612. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  91613. */
  91614. get rotationQuaternion(): Nullable<Quaternion>;
  91615. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  91616. /**
  91617. * The forward direction of that transform in world space.
  91618. */
  91619. get forward(): Vector3;
  91620. /**
  91621. * The up direction of that transform in world space.
  91622. */
  91623. get up(): Vector3;
  91624. /**
  91625. * The right direction of that transform in world space.
  91626. */
  91627. get right(): Vector3;
  91628. /**
  91629. * Copies the parameter passed Matrix into the mesh Pose matrix.
  91630. * @param matrix the matrix to copy the pose from
  91631. * @returns this TransformNode.
  91632. */
  91633. updatePoseMatrix(matrix: Matrix): TransformNode;
  91634. /**
  91635. * Returns the mesh Pose matrix.
  91636. * @returns the pose matrix
  91637. */
  91638. getPoseMatrix(): Matrix;
  91639. /** @hidden */
  91640. _isSynchronized(): boolean;
  91641. /** @hidden */
  91642. _initCache(): void;
  91643. /**
  91644. * Flag the transform node as dirty (Forcing it to update everything)
  91645. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  91646. * @returns this transform node
  91647. */
  91648. markAsDirty(property: string): TransformNode;
  91649. /**
  91650. * Returns the current mesh absolute position.
  91651. * Returns a Vector3.
  91652. */
  91653. get absolutePosition(): Vector3;
  91654. /**
  91655. * Returns the current mesh absolute scaling.
  91656. * Returns a Vector3.
  91657. */
  91658. get absoluteScaling(): Vector3;
  91659. /**
  91660. * Returns the current mesh absolute rotation.
  91661. * Returns a Quaternion.
  91662. */
  91663. get absoluteRotationQuaternion(): Quaternion;
  91664. /**
  91665. * Sets a new matrix to apply before all other transformation
  91666. * @param matrix defines the transform matrix
  91667. * @returns the current TransformNode
  91668. */
  91669. setPreTransformMatrix(matrix: Matrix): TransformNode;
  91670. /**
  91671. * Sets a new pivot matrix to the current node
  91672. * @param matrix defines the new pivot matrix to use
  91673. * @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
  91674. * @returns the current TransformNode
  91675. */
  91676. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  91677. /**
  91678. * Returns the mesh pivot matrix.
  91679. * Default : Identity.
  91680. * @returns the matrix
  91681. */
  91682. getPivotMatrix(): Matrix;
  91683. /**
  91684. * Instantiate (when possible) or clone that node with its hierarchy
  91685. * @param newParent defines the new parent to use for the instance (or clone)
  91686. * @param options defines options to configure how copy is done
  91687. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  91688. * @returns an instance (or a clone) of the current node with its hiearchy
  91689. */
  91690. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  91691. doNotInstantiate: boolean;
  91692. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  91693. /**
  91694. * Prevents the World matrix to be computed any longer
  91695. * @param newWorldMatrix defines an optional matrix to use as world matrix
  91696. * @returns the TransformNode.
  91697. */
  91698. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  91699. /**
  91700. * Allows back the World matrix computation.
  91701. * @returns the TransformNode.
  91702. */
  91703. unfreezeWorldMatrix(): this;
  91704. /**
  91705. * True if the World matrix has been frozen.
  91706. */
  91707. get isWorldMatrixFrozen(): boolean;
  91708. /**
  91709. * Retuns the mesh absolute position in the World.
  91710. * @returns a Vector3.
  91711. */
  91712. getAbsolutePosition(): Vector3;
  91713. /**
  91714. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  91715. * @param absolutePosition the absolute position to set
  91716. * @returns the TransformNode.
  91717. */
  91718. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  91719. /**
  91720. * Sets the mesh position in its local space.
  91721. * @param vector3 the position to set in localspace
  91722. * @returns the TransformNode.
  91723. */
  91724. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  91725. /**
  91726. * Returns the mesh position in the local space from the current World matrix values.
  91727. * @returns a new Vector3.
  91728. */
  91729. getPositionExpressedInLocalSpace(): Vector3;
  91730. /**
  91731. * Translates the mesh along the passed Vector3 in its local space.
  91732. * @param vector3 the distance to translate in localspace
  91733. * @returns the TransformNode.
  91734. */
  91735. locallyTranslate(vector3: Vector3): TransformNode;
  91736. private static _lookAtVectorCache;
  91737. /**
  91738. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  91739. * @param targetPoint the position (must be in same space as current mesh) to look at
  91740. * @param yawCor optional yaw (y-axis) correction in radians
  91741. * @param pitchCor optional pitch (x-axis) correction in radians
  91742. * @param rollCor optional roll (z-axis) correction in radians
  91743. * @param space the choosen space of the target
  91744. * @returns the TransformNode.
  91745. */
  91746. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  91747. /**
  91748. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  91749. * This Vector3 is expressed in the World space.
  91750. * @param localAxis axis to rotate
  91751. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  91752. */
  91753. getDirection(localAxis: Vector3): Vector3;
  91754. /**
  91755. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  91756. * localAxis is expressed in the mesh local space.
  91757. * result is computed in the Wordl space from the mesh World matrix.
  91758. * @param localAxis axis to rotate
  91759. * @param result the resulting transformnode
  91760. * @returns this TransformNode.
  91761. */
  91762. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  91763. /**
  91764. * Sets this transform node rotation to the given local axis.
  91765. * @param localAxis the axis in local space
  91766. * @param yawCor optional yaw (y-axis) correction in radians
  91767. * @param pitchCor optional pitch (x-axis) correction in radians
  91768. * @param rollCor optional roll (z-axis) correction in radians
  91769. * @returns this TransformNode
  91770. */
  91771. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  91772. /**
  91773. * Sets a new pivot point to the current node
  91774. * @param point defines the new pivot point to use
  91775. * @param space defines if the point is in world or local space (local by default)
  91776. * @returns the current TransformNode
  91777. */
  91778. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  91779. /**
  91780. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  91781. * @returns the pivot point
  91782. */
  91783. getPivotPoint(): Vector3;
  91784. /**
  91785. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  91786. * @param result the vector3 to store the result
  91787. * @returns this TransformNode.
  91788. */
  91789. getPivotPointToRef(result: Vector3): TransformNode;
  91790. /**
  91791. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  91792. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  91793. */
  91794. getAbsolutePivotPoint(): Vector3;
  91795. /**
  91796. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  91797. * @param result vector3 to store the result
  91798. * @returns this TransformNode.
  91799. */
  91800. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  91801. /**
  91802. * Defines the passed node as the parent of the current node.
  91803. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  91804. * @see https://doc.babylonjs.com/how_to/parenting
  91805. * @param node the node ot set as the parent
  91806. * @returns this TransformNode.
  91807. */
  91808. setParent(node: Nullable<Node>): TransformNode;
  91809. private _nonUniformScaling;
  91810. /**
  91811. * True if the scaling property of this object is non uniform eg. (1,2,1)
  91812. */
  91813. get nonUniformScaling(): boolean;
  91814. /** @hidden */
  91815. _updateNonUniformScalingState(value: boolean): boolean;
  91816. /**
  91817. * Attach the current TransformNode to another TransformNode associated with a bone
  91818. * @param bone Bone affecting the TransformNode
  91819. * @param affectedTransformNode TransformNode associated with the bone
  91820. * @returns this object
  91821. */
  91822. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  91823. /**
  91824. * Detach the transform node if its associated with a bone
  91825. * @returns this object
  91826. */
  91827. detachFromBone(): TransformNode;
  91828. private static _rotationAxisCache;
  91829. /**
  91830. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  91831. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  91832. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  91833. * The passed axis is also normalized.
  91834. * @param axis the axis to rotate around
  91835. * @param amount the amount to rotate in radians
  91836. * @param space Space to rotate in (Default: local)
  91837. * @returns the TransformNode.
  91838. */
  91839. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  91840. /**
  91841. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  91842. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  91843. * The passed axis is also normalized. .
  91844. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  91845. * @param point the point to rotate around
  91846. * @param axis the axis to rotate around
  91847. * @param amount the amount to rotate in radians
  91848. * @returns the TransformNode
  91849. */
  91850. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  91851. /**
  91852. * Translates the mesh along the axis vector for the passed distance in the given space.
  91853. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  91854. * @param axis the axis to translate in
  91855. * @param distance the distance to translate
  91856. * @param space Space to rotate in (Default: local)
  91857. * @returns the TransformNode.
  91858. */
  91859. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  91860. /**
  91861. * Adds a rotation step to the mesh current rotation.
  91862. * x, y, z are Euler angles expressed in radians.
  91863. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  91864. * This means this rotation is made in the mesh local space only.
  91865. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  91866. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  91867. * ```javascript
  91868. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  91869. * ```
  91870. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  91871. * 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.
  91872. * @param x Rotation to add
  91873. * @param y Rotation to add
  91874. * @param z Rotation to add
  91875. * @returns the TransformNode.
  91876. */
  91877. addRotation(x: number, y: number, z: number): TransformNode;
  91878. /**
  91879. * @hidden
  91880. */
  91881. protected _getEffectiveParent(): Nullable<Node>;
  91882. /**
  91883. * Computes the world matrix of the node
  91884. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  91885. * @returns the world matrix
  91886. */
  91887. computeWorldMatrix(force?: boolean): Matrix;
  91888. /**
  91889. * Resets this nodeTransform's local matrix to Matrix.Identity().
  91890. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  91891. */
  91892. resetLocalMatrix(independentOfChildren?: boolean): void;
  91893. protected _afterComputeWorldMatrix(): void;
  91894. /**
  91895. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  91896. * @param func callback function to add
  91897. *
  91898. * @returns the TransformNode.
  91899. */
  91900. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  91901. /**
  91902. * Removes a registered callback function.
  91903. * @param func callback function to remove
  91904. * @returns the TransformNode.
  91905. */
  91906. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  91907. /**
  91908. * Gets the position of the current mesh in camera space
  91909. * @param camera defines the camera to use
  91910. * @returns a position
  91911. */
  91912. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  91913. /**
  91914. * Returns the distance from the mesh to the active camera
  91915. * @param camera defines the camera to use
  91916. * @returns the distance
  91917. */
  91918. getDistanceToCamera(camera?: Nullable<Camera>): number;
  91919. /**
  91920. * Clone the current transform node
  91921. * @param name Name of the new clone
  91922. * @param newParent New parent for the clone
  91923. * @param doNotCloneChildren Do not clone children hierarchy
  91924. * @returns the new transform node
  91925. */
  91926. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  91927. /**
  91928. * Serializes the objects information.
  91929. * @param currentSerializationObject defines the object to serialize in
  91930. * @returns the serialized object
  91931. */
  91932. serialize(currentSerializationObject?: any): any;
  91933. /**
  91934. * Returns a new TransformNode object parsed from the source provided.
  91935. * @param parsedTransformNode is the source.
  91936. * @param scene the scne the object belongs to
  91937. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  91938. * @returns a new TransformNode object parsed from the source provided.
  91939. */
  91940. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  91941. /**
  91942. * Get all child-transformNodes of this node
  91943. * @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
  91944. * @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
  91945. * @returns an array of TransformNode
  91946. */
  91947. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  91948. /**
  91949. * Releases resources associated with this transform node.
  91950. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  91951. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  91952. */
  91953. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  91954. /**
  91955. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  91956. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  91957. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  91958. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  91959. * @returns the current mesh
  91960. */
  91961. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  91962. private _syncAbsoluteScalingAndRotation;
  91963. }
  91964. }
  91965. declare module BABYLON {
  91966. /**
  91967. * Class used to override all child animations of a given target
  91968. */
  91969. export class AnimationPropertiesOverride {
  91970. /**
  91971. * Gets or sets a value indicating if animation blending must be used
  91972. */
  91973. enableBlending: boolean;
  91974. /**
  91975. * Gets or sets the blending speed to use when enableBlending is true
  91976. */
  91977. blendingSpeed: number;
  91978. /**
  91979. * Gets or sets the default loop mode to use
  91980. */
  91981. loopMode: number;
  91982. }
  91983. }
  91984. declare module BABYLON {
  91985. /**
  91986. * Class used to store bone information
  91987. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  91988. */
  91989. export class Bone extends Node {
  91990. /**
  91991. * defines the bone name
  91992. */
  91993. name: string;
  91994. private static _tmpVecs;
  91995. private static _tmpQuat;
  91996. private static _tmpMats;
  91997. /**
  91998. * Gets the list of child bones
  91999. */
  92000. children: Bone[];
  92001. /** Gets the animations associated with this bone */
  92002. animations: Animation[];
  92003. /**
  92004. * Gets or sets bone length
  92005. */
  92006. length: number;
  92007. /**
  92008. * @hidden Internal only
  92009. * Set this value to map this bone to a different index in the transform matrices
  92010. * Set this value to -1 to exclude the bone from the transform matrices
  92011. */
  92012. _index: Nullable<number>;
  92013. private _skeleton;
  92014. private _localMatrix;
  92015. private _restPose;
  92016. private _baseMatrix;
  92017. private _absoluteTransform;
  92018. private _invertedAbsoluteTransform;
  92019. private _parent;
  92020. private _scalingDeterminant;
  92021. private _worldTransform;
  92022. private _localScaling;
  92023. private _localRotation;
  92024. private _localPosition;
  92025. private _needToDecompose;
  92026. private _needToCompose;
  92027. /** @hidden */
  92028. _linkedTransformNode: Nullable<TransformNode>;
  92029. /** @hidden */
  92030. _waitingTransformNodeId: Nullable<string>;
  92031. /** @hidden */
  92032. get _matrix(): Matrix;
  92033. /** @hidden */
  92034. set _matrix(value: Matrix);
  92035. /**
  92036. * Create a new bone
  92037. * @param name defines the bone name
  92038. * @param skeleton defines the parent skeleton
  92039. * @param parentBone defines the parent (can be null if the bone is the root)
  92040. * @param localMatrix defines the local matrix
  92041. * @param restPose defines the rest pose matrix
  92042. * @param baseMatrix defines the base matrix
  92043. * @param index defines index of the bone in the hiearchy
  92044. */
  92045. constructor(
  92046. /**
  92047. * defines the bone name
  92048. */
  92049. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  92050. /**
  92051. * Gets the current object class name.
  92052. * @return the class name
  92053. */
  92054. getClassName(): string;
  92055. /**
  92056. * Gets the parent skeleton
  92057. * @returns a skeleton
  92058. */
  92059. getSkeleton(): Skeleton;
  92060. /**
  92061. * Gets parent bone
  92062. * @returns a bone or null if the bone is the root of the bone hierarchy
  92063. */
  92064. getParent(): Nullable<Bone>;
  92065. /**
  92066. * Returns an array containing the root bones
  92067. * @returns an array containing the root bones
  92068. */
  92069. getChildren(): Array<Bone>;
  92070. /**
  92071. * Gets the node index in matrix array generated for rendering
  92072. * @returns the node index
  92073. */
  92074. getIndex(): number;
  92075. /**
  92076. * Sets the parent bone
  92077. * @param parent defines the parent (can be null if the bone is the root)
  92078. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  92079. */
  92080. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  92081. /**
  92082. * Gets the local matrix
  92083. * @returns a matrix
  92084. */
  92085. getLocalMatrix(): Matrix;
  92086. /**
  92087. * Gets the base matrix (initial matrix which remains unchanged)
  92088. * @returns a matrix
  92089. */
  92090. getBaseMatrix(): Matrix;
  92091. /**
  92092. * Gets the rest pose matrix
  92093. * @returns a matrix
  92094. */
  92095. getRestPose(): Matrix;
  92096. /**
  92097. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  92098. */
  92099. getWorldMatrix(): Matrix;
  92100. /**
  92101. * Sets the local matrix to rest pose matrix
  92102. */
  92103. returnToRest(): void;
  92104. /**
  92105. * Gets the inverse of the absolute transform matrix.
  92106. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  92107. * @returns a matrix
  92108. */
  92109. getInvertedAbsoluteTransform(): Matrix;
  92110. /**
  92111. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  92112. * @returns a matrix
  92113. */
  92114. getAbsoluteTransform(): Matrix;
  92115. /**
  92116. * Links with the given transform node.
  92117. * The local matrix of this bone is copied from the transform node every frame.
  92118. * @param transformNode defines the transform node to link to
  92119. */
  92120. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  92121. /**
  92122. * Gets the node used to drive the bone's transformation
  92123. * @returns a transform node or null
  92124. */
  92125. getTransformNode(): Nullable<TransformNode>;
  92126. /** Gets or sets current position (in local space) */
  92127. get position(): Vector3;
  92128. set position(newPosition: Vector3);
  92129. /** Gets or sets current rotation (in local space) */
  92130. get rotation(): Vector3;
  92131. set rotation(newRotation: Vector3);
  92132. /** Gets or sets current rotation quaternion (in local space) */
  92133. get rotationQuaternion(): Quaternion;
  92134. set rotationQuaternion(newRotation: Quaternion);
  92135. /** Gets or sets current scaling (in local space) */
  92136. get scaling(): Vector3;
  92137. set scaling(newScaling: Vector3);
  92138. /**
  92139. * Gets the animation properties override
  92140. */
  92141. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  92142. private _decompose;
  92143. private _compose;
  92144. /**
  92145. * Update the base and local matrices
  92146. * @param matrix defines the new base or local matrix
  92147. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  92148. * @param updateLocalMatrix defines if the local matrix should be updated
  92149. */
  92150. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  92151. /** @hidden */
  92152. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  92153. /**
  92154. * Flag the bone as dirty (Forcing it to update everything)
  92155. */
  92156. markAsDirty(): void;
  92157. /** @hidden */
  92158. _markAsDirtyAndCompose(): void;
  92159. private _markAsDirtyAndDecompose;
  92160. /**
  92161. * Translate the bone in local or world space
  92162. * @param vec The amount to translate the bone
  92163. * @param space The space that the translation is in
  92164. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92165. */
  92166. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  92167. /**
  92168. * Set the postion of the bone in local or world space
  92169. * @param position The position to set the bone
  92170. * @param space The space that the position is in
  92171. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92172. */
  92173. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  92174. /**
  92175. * Set the absolute position of the bone (world space)
  92176. * @param position The position to set the bone
  92177. * @param mesh The mesh that this bone is attached to
  92178. */
  92179. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  92180. /**
  92181. * Scale the bone on the x, y and z axes (in local space)
  92182. * @param x The amount to scale the bone on the x axis
  92183. * @param y The amount to scale the bone on the y axis
  92184. * @param z The amount to scale the bone on the z axis
  92185. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  92186. */
  92187. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  92188. /**
  92189. * Set the bone scaling in local space
  92190. * @param scale defines the scaling vector
  92191. */
  92192. setScale(scale: Vector3): void;
  92193. /**
  92194. * Gets the current scaling in local space
  92195. * @returns the current scaling vector
  92196. */
  92197. getScale(): Vector3;
  92198. /**
  92199. * Gets the current scaling in local space and stores it in a target vector
  92200. * @param result defines the target vector
  92201. */
  92202. getScaleToRef(result: Vector3): void;
  92203. /**
  92204. * Set the yaw, pitch, and roll of the bone in local or world space
  92205. * @param yaw The rotation of the bone on the y axis
  92206. * @param pitch The rotation of the bone on the x axis
  92207. * @param roll The rotation of the bone on the z axis
  92208. * @param space The space that the axes of rotation are in
  92209. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92210. */
  92211. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  92212. /**
  92213. * Add a rotation to the bone on an axis in local or world space
  92214. * @param axis The axis to rotate the bone on
  92215. * @param amount The amount to rotate the bone
  92216. * @param space The space that the axis is in
  92217. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92218. */
  92219. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  92220. /**
  92221. * Set the rotation of the bone to a particular axis angle in local or world space
  92222. * @param axis The axis to rotate the bone on
  92223. * @param angle The angle that the bone should be rotated to
  92224. * @param space The space that the axis is in
  92225. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92226. */
  92227. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  92228. /**
  92229. * Set the euler rotation of the bone in local of world space
  92230. * @param rotation The euler rotation that the bone should be set to
  92231. * @param space The space that the rotation is in
  92232. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92233. */
  92234. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  92235. /**
  92236. * Set the quaternion rotation of the bone in local of world space
  92237. * @param quat The quaternion rotation that the bone should be set to
  92238. * @param space The space that the rotation is in
  92239. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92240. */
  92241. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  92242. /**
  92243. * Set the rotation matrix of the bone in local of world space
  92244. * @param rotMat The rotation matrix that the bone should be set to
  92245. * @param space The space that the rotation is in
  92246. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92247. */
  92248. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  92249. private _rotateWithMatrix;
  92250. private _getNegativeRotationToRef;
  92251. /**
  92252. * Get the position of the bone in local or world space
  92253. * @param space The space that the returned position is in
  92254. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92255. * @returns The position of the bone
  92256. */
  92257. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  92258. /**
  92259. * Copy the position of the bone to a vector3 in local or world space
  92260. * @param space The space that the returned position is in
  92261. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92262. * @param result The vector3 to copy the position to
  92263. */
  92264. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  92265. /**
  92266. * Get the absolute position of the bone (world space)
  92267. * @param mesh The mesh that this bone is attached to
  92268. * @returns The absolute position of the bone
  92269. */
  92270. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  92271. /**
  92272. * Copy the absolute position of the bone (world space) to the result param
  92273. * @param mesh The mesh that this bone is attached to
  92274. * @param result The vector3 to copy the absolute position to
  92275. */
  92276. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  92277. /**
  92278. * Compute the absolute transforms of this bone and its children
  92279. */
  92280. computeAbsoluteTransforms(): void;
  92281. /**
  92282. * Get the world direction from an axis that is in the local space of the bone
  92283. * @param localAxis The local direction that is used to compute the world direction
  92284. * @param mesh The mesh that this bone is attached to
  92285. * @returns The world direction
  92286. */
  92287. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  92288. /**
  92289. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  92290. * @param localAxis The local direction that is used to compute the world direction
  92291. * @param mesh The mesh that this bone is attached to
  92292. * @param result The vector3 that the world direction will be copied to
  92293. */
  92294. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  92295. /**
  92296. * Get the euler rotation of the bone in local or world space
  92297. * @param space The space that the rotation should be in
  92298. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92299. * @returns The euler rotation
  92300. */
  92301. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  92302. /**
  92303. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  92304. * @param space The space that the rotation should be in
  92305. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92306. * @param result The vector3 that the rotation should be copied to
  92307. */
  92308. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  92309. /**
  92310. * Get the quaternion rotation of the bone in either local or world space
  92311. * @param space The space that the rotation should be in
  92312. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92313. * @returns The quaternion rotation
  92314. */
  92315. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  92316. /**
  92317. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  92318. * @param space The space that the rotation should be in
  92319. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92320. * @param result The quaternion that the rotation should be copied to
  92321. */
  92322. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  92323. /**
  92324. * Get the rotation matrix of the bone in local or world space
  92325. * @param space The space that the rotation should be in
  92326. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92327. * @returns The rotation matrix
  92328. */
  92329. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  92330. /**
  92331. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  92332. * @param space The space that the rotation should be in
  92333. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92334. * @param result The quaternion that the rotation should be copied to
  92335. */
  92336. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  92337. /**
  92338. * Get the world position of a point that is in the local space of the bone
  92339. * @param position The local position
  92340. * @param mesh The mesh that this bone is attached to
  92341. * @returns The world position
  92342. */
  92343. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  92344. /**
  92345. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  92346. * @param position The local position
  92347. * @param mesh The mesh that this bone is attached to
  92348. * @param result The vector3 that the world position should be copied to
  92349. */
  92350. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  92351. /**
  92352. * Get the local position of a point that is in world space
  92353. * @param position The world position
  92354. * @param mesh The mesh that this bone is attached to
  92355. * @returns The local position
  92356. */
  92357. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  92358. /**
  92359. * Get the local position of a point that is in world space and copy it to the result param
  92360. * @param position The world position
  92361. * @param mesh The mesh that this bone is attached to
  92362. * @param result The vector3 that the local position should be copied to
  92363. */
  92364. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  92365. }
  92366. }
  92367. declare module BABYLON {
  92368. /**
  92369. * Defines a runtime animation
  92370. */
  92371. export class RuntimeAnimation {
  92372. private _events;
  92373. /**
  92374. * The current frame of the runtime animation
  92375. */
  92376. private _currentFrame;
  92377. /**
  92378. * The animation used by the runtime animation
  92379. */
  92380. private _animation;
  92381. /**
  92382. * The target of the runtime animation
  92383. */
  92384. private _target;
  92385. /**
  92386. * The initiating animatable
  92387. */
  92388. private _host;
  92389. /**
  92390. * The original value of the runtime animation
  92391. */
  92392. private _originalValue;
  92393. /**
  92394. * The original blend value of the runtime animation
  92395. */
  92396. private _originalBlendValue;
  92397. /**
  92398. * The offsets cache of the runtime animation
  92399. */
  92400. private _offsetsCache;
  92401. /**
  92402. * The high limits cache of the runtime animation
  92403. */
  92404. private _highLimitsCache;
  92405. /**
  92406. * Specifies if the runtime animation has been stopped
  92407. */
  92408. private _stopped;
  92409. /**
  92410. * The blending factor of the runtime animation
  92411. */
  92412. private _blendingFactor;
  92413. /**
  92414. * The BabylonJS scene
  92415. */
  92416. private _scene;
  92417. /**
  92418. * The current value of the runtime animation
  92419. */
  92420. private _currentValue;
  92421. /** @hidden */
  92422. _animationState: _IAnimationState;
  92423. /**
  92424. * The active target of the runtime animation
  92425. */
  92426. private _activeTargets;
  92427. private _currentActiveTarget;
  92428. private _directTarget;
  92429. /**
  92430. * The target path of the runtime animation
  92431. */
  92432. private _targetPath;
  92433. /**
  92434. * The weight of the runtime animation
  92435. */
  92436. private _weight;
  92437. /**
  92438. * The ratio offset of the runtime animation
  92439. */
  92440. private _ratioOffset;
  92441. /**
  92442. * The previous delay of the runtime animation
  92443. */
  92444. private _previousDelay;
  92445. /**
  92446. * The previous ratio of the runtime animation
  92447. */
  92448. private _previousRatio;
  92449. private _enableBlending;
  92450. private _keys;
  92451. private _minFrame;
  92452. private _maxFrame;
  92453. private _minValue;
  92454. private _maxValue;
  92455. private _targetIsArray;
  92456. /**
  92457. * Gets the current frame of the runtime animation
  92458. */
  92459. get currentFrame(): number;
  92460. /**
  92461. * Gets the weight of the runtime animation
  92462. */
  92463. get weight(): number;
  92464. /**
  92465. * Gets the current value of the runtime animation
  92466. */
  92467. get currentValue(): any;
  92468. /**
  92469. * Gets the target path of the runtime animation
  92470. */
  92471. get targetPath(): string;
  92472. /**
  92473. * Gets the actual target of the runtime animation
  92474. */
  92475. get target(): any;
  92476. /**
  92477. * Gets the additive state of the runtime animation
  92478. */
  92479. get isAdditive(): boolean;
  92480. /** @hidden */
  92481. _onLoop: () => void;
  92482. /**
  92483. * Create a new RuntimeAnimation object
  92484. * @param target defines the target of the animation
  92485. * @param animation defines the source animation object
  92486. * @param scene defines the hosting scene
  92487. * @param host defines the initiating Animatable
  92488. */
  92489. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  92490. private _preparePath;
  92491. /**
  92492. * Gets the animation from the runtime animation
  92493. */
  92494. get animation(): Animation;
  92495. /**
  92496. * Resets the runtime animation to the beginning
  92497. * @param restoreOriginal defines whether to restore the target property to the original value
  92498. */
  92499. reset(restoreOriginal?: boolean): void;
  92500. /**
  92501. * Specifies if the runtime animation is stopped
  92502. * @returns Boolean specifying if the runtime animation is stopped
  92503. */
  92504. isStopped(): boolean;
  92505. /**
  92506. * Disposes of the runtime animation
  92507. */
  92508. dispose(): void;
  92509. /**
  92510. * Apply the interpolated value to the target
  92511. * @param currentValue defines the value computed by the animation
  92512. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  92513. */
  92514. setValue(currentValue: any, weight: number): void;
  92515. private _getOriginalValues;
  92516. private _setValue;
  92517. /**
  92518. * Gets the loop pmode of the runtime animation
  92519. * @returns Loop Mode
  92520. */
  92521. private _getCorrectLoopMode;
  92522. /**
  92523. * Move the current animation to a given frame
  92524. * @param frame defines the frame to move to
  92525. */
  92526. goToFrame(frame: number): void;
  92527. /**
  92528. * @hidden Internal use only
  92529. */
  92530. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  92531. /**
  92532. * Execute the current animation
  92533. * @param delay defines the delay to add to the current frame
  92534. * @param from defines the lower bound of the animation range
  92535. * @param to defines the upper bound of the animation range
  92536. * @param loop defines if the current animation must loop
  92537. * @param speedRatio defines the current speed ratio
  92538. * @param weight defines the weight of the animation (default is -1 so no weight)
  92539. * @param onLoop optional callback called when animation loops
  92540. * @returns a boolean indicating if the animation is running
  92541. */
  92542. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  92543. }
  92544. }
  92545. declare module BABYLON {
  92546. /**
  92547. * Class used to store an actual running animation
  92548. */
  92549. export class Animatable {
  92550. /** defines the target object */
  92551. target: any;
  92552. /** defines the starting frame number (default is 0) */
  92553. fromFrame: number;
  92554. /** defines the ending frame number (default is 100) */
  92555. toFrame: number;
  92556. /** defines if the animation must loop (default is false) */
  92557. loopAnimation: boolean;
  92558. /** defines a callback to call when animation ends if it is not looping */
  92559. onAnimationEnd?: (() => void) | null | undefined;
  92560. /** defines a callback to call when animation loops */
  92561. onAnimationLoop?: (() => void) | null | undefined;
  92562. /** defines whether the animation should be evaluated additively */
  92563. isAdditive: boolean;
  92564. private _localDelayOffset;
  92565. private _pausedDelay;
  92566. private _runtimeAnimations;
  92567. private _paused;
  92568. private _scene;
  92569. private _speedRatio;
  92570. private _weight;
  92571. private _syncRoot;
  92572. /**
  92573. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  92574. * This will only apply for non looping animation (default is true)
  92575. */
  92576. disposeOnEnd: boolean;
  92577. /**
  92578. * Gets a boolean indicating if the animation has started
  92579. */
  92580. animationStarted: boolean;
  92581. /**
  92582. * Observer raised when the animation ends
  92583. */
  92584. onAnimationEndObservable: Observable<Animatable>;
  92585. /**
  92586. * Observer raised when the animation loops
  92587. */
  92588. onAnimationLoopObservable: Observable<Animatable>;
  92589. /**
  92590. * Gets the root Animatable used to synchronize and normalize animations
  92591. */
  92592. get syncRoot(): Nullable<Animatable>;
  92593. /**
  92594. * Gets the current frame of the first RuntimeAnimation
  92595. * Used to synchronize Animatables
  92596. */
  92597. get masterFrame(): number;
  92598. /**
  92599. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  92600. */
  92601. get weight(): number;
  92602. set weight(value: number);
  92603. /**
  92604. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  92605. */
  92606. get speedRatio(): number;
  92607. set speedRatio(value: number);
  92608. /**
  92609. * Creates a new Animatable
  92610. * @param scene defines the hosting scene
  92611. * @param target defines the target object
  92612. * @param fromFrame defines the starting frame number (default is 0)
  92613. * @param toFrame defines the ending frame number (default is 100)
  92614. * @param loopAnimation defines if the animation must loop (default is false)
  92615. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  92616. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  92617. * @param animations defines a group of animation to add to the new Animatable
  92618. * @param onAnimationLoop defines a callback to call when animation loops
  92619. * @param isAdditive defines whether the animation should be evaluated additively
  92620. */
  92621. constructor(scene: Scene,
  92622. /** defines the target object */
  92623. target: any,
  92624. /** defines the starting frame number (default is 0) */
  92625. fromFrame?: number,
  92626. /** defines the ending frame number (default is 100) */
  92627. toFrame?: number,
  92628. /** defines if the animation must loop (default is false) */
  92629. loopAnimation?: boolean, speedRatio?: number,
  92630. /** defines a callback to call when animation ends if it is not looping */
  92631. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  92632. /** defines a callback to call when animation loops */
  92633. onAnimationLoop?: (() => void) | null | undefined,
  92634. /** defines whether the animation should be evaluated additively */
  92635. isAdditive?: boolean);
  92636. /**
  92637. * Synchronize and normalize current Animatable with a source Animatable
  92638. * This is useful when using animation weights and when animations are not of the same length
  92639. * @param root defines the root Animatable to synchronize with
  92640. * @returns the current Animatable
  92641. */
  92642. syncWith(root: Animatable): Animatable;
  92643. /**
  92644. * Gets the list of runtime animations
  92645. * @returns an array of RuntimeAnimation
  92646. */
  92647. getAnimations(): RuntimeAnimation[];
  92648. /**
  92649. * Adds more animations to the current animatable
  92650. * @param target defines the target of the animations
  92651. * @param animations defines the new animations to add
  92652. */
  92653. appendAnimations(target: any, animations: Animation[]): void;
  92654. /**
  92655. * Gets the source animation for a specific property
  92656. * @param property defines the propertyu to look for
  92657. * @returns null or the source animation for the given property
  92658. */
  92659. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  92660. /**
  92661. * Gets the runtime animation for a specific property
  92662. * @param property defines the propertyu to look for
  92663. * @returns null or the runtime animation for the given property
  92664. */
  92665. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  92666. /**
  92667. * Resets the animatable to its original state
  92668. */
  92669. reset(): void;
  92670. /**
  92671. * Allows the animatable to blend with current running animations
  92672. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  92673. * @param blendingSpeed defines the blending speed to use
  92674. */
  92675. enableBlending(blendingSpeed: number): void;
  92676. /**
  92677. * Disable animation blending
  92678. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  92679. */
  92680. disableBlending(): void;
  92681. /**
  92682. * Jump directly to a given frame
  92683. * @param frame defines the frame to jump to
  92684. */
  92685. goToFrame(frame: number): void;
  92686. /**
  92687. * Pause the animation
  92688. */
  92689. pause(): void;
  92690. /**
  92691. * Restart the animation
  92692. */
  92693. restart(): void;
  92694. private _raiseOnAnimationEnd;
  92695. /**
  92696. * Stop and delete the current animation
  92697. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  92698. * @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)
  92699. */
  92700. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  92701. /**
  92702. * Wait asynchronously for the animation to end
  92703. * @returns a promise which will be fullfilled when the animation ends
  92704. */
  92705. waitAsync(): Promise<Animatable>;
  92706. /** @hidden */
  92707. _animate(delay: number): boolean;
  92708. }
  92709. interface Scene {
  92710. /** @hidden */
  92711. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  92712. /** @hidden */
  92713. _processLateAnimationBindingsForMatrices(holder: {
  92714. totalWeight: number;
  92715. totalAdditiveWeight: number;
  92716. animations: RuntimeAnimation[];
  92717. additiveAnimations: RuntimeAnimation[];
  92718. originalValue: Matrix;
  92719. }): any;
  92720. /** @hidden */
  92721. _processLateAnimationBindingsForQuaternions(holder: {
  92722. totalWeight: number;
  92723. totalAdditiveWeight: number;
  92724. animations: RuntimeAnimation[];
  92725. additiveAnimations: RuntimeAnimation[];
  92726. originalValue: Quaternion;
  92727. }, refQuaternion: Quaternion): Quaternion;
  92728. /** @hidden */
  92729. _processLateAnimationBindings(): void;
  92730. /**
  92731. * Will start the animation sequence of a given target
  92732. * @param target defines the target
  92733. * @param from defines from which frame should animation start
  92734. * @param to defines until which frame should animation run.
  92735. * @param weight defines the weight to apply to the animation (1.0 by default)
  92736. * @param loop defines if the animation loops
  92737. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  92738. * @param onAnimationEnd defines the function to be executed when the animation ends
  92739. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  92740. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  92741. * @param onAnimationLoop defines the callback to call when an animation loops
  92742. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  92743. * @returns the animatable object created for this animation
  92744. */
  92745. 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;
  92746. /**
  92747. * Will start the animation sequence of a given target
  92748. * @param target defines the target
  92749. * @param from defines from which frame should animation start
  92750. * @param to defines until which frame should animation run.
  92751. * @param loop defines if the animation loops
  92752. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  92753. * @param onAnimationEnd defines the function to be executed when the animation ends
  92754. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  92755. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  92756. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  92757. * @param onAnimationLoop defines the callback to call when an animation loops
  92758. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  92759. * @returns the animatable object created for this animation
  92760. */
  92761. 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;
  92762. /**
  92763. * Will start the animation sequence of a given target and its hierarchy
  92764. * @param target defines the target
  92765. * @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.
  92766. * @param from defines from which frame should animation start
  92767. * @param to defines until which frame should animation run.
  92768. * @param loop defines if the animation loops
  92769. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  92770. * @param onAnimationEnd defines the function to be executed when the animation ends
  92771. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  92772. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  92773. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  92774. * @param onAnimationLoop defines the callback to call when an animation loops
  92775. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  92776. * @returns the list of created animatables
  92777. */
  92778. 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[];
  92779. /**
  92780. * Begin a new animation on a given node
  92781. * @param target defines the target where the animation will take place
  92782. * @param animations defines the list of animations to start
  92783. * @param from defines the initial value
  92784. * @param to defines the final value
  92785. * @param loop defines if you want animation to loop (off by default)
  92786. * @param speedRatio defines the speed ratio to apply to all animations
  92787. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  92788. * @param onAnimationLoop defines the callback to call when an animation loops
  92789. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  92790. * @returns the list of created animatables
  92791. */
  92792. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  92793. /**
  92794. * Begin a new animation on a given node and its hierarchy
  92795. * @param target defines the root node where the animation will take place
  92796. * @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.
  92797. * @param animations defines the list of animations to start
  92798. * @param from defines the initial value
  92799. * @param to defines the final value
  92800. * @param loop defines if you want animation to loop (off by default)
  92801. * @param speedRatio defines the speed ratio to apply to all animations
  92802. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  92803. * @param onAnimationLoop defines the callback to call when an animation loops
  92804. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  92805. * @returns the list of animatables created for all nodes
  92806. */
  92807. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  92808. /**
  92809. * Gets the animatable associated with a specific target
  92810. * @param target defines the target of the animatable
  92811. * @returns the required animatable if found
  92812. */
  92813. getAnimatableByTarget(target: any): Nullable<Animatable>;
  92814. /**
  92815. * Gets all animatables associated with a given target
  92816. * @param target defines the target to look animatables for
  92817. * @returns an array of Animatables
  92818. */
  92819. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  92820. /**
  92821. * Stops and removes all animations that have been applied to the scene
  92822. */
  92823. stopAllAnimations(): void;
  92824. /**
  92825. * Gets the current delta time used by animation engine
  92826. */
  92827. deltaTime: number;
  92828. }
  92829. interface Bone {
  92830. /**
  92831. * Copy an animation range from another bone
  92832. * @param source defines the source bone
  92833. * @param rangeName defines the range name to copy
  92834. * @param frameOffset defines the frame offset
  92835. * @param rescaleAsRequired defines if rescaling must be applied if required
  92836. * @param skelDimensionsRatio defines the scaling ratio
  92837. * @returns true if operation was successful
  92838. */
  92839. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  92840. }
  92841. }
  92842. declare module BABYLON {
  92843. /**
  92844. * Class used to handle skinning animations
  92845. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  92846. */
  92847. export class Skeleton implements IAnimatable {
  92848. /** defines the skeleton name */
  92849. name: string;
  92850. /** defines the skeleton Id */
  92851. id: string;
  92852. /**
  92853. * Defines the list of child bones
  92854. */
  92855. bones: Bone[];
  92856. /**
  92857. * Defines an estimate of the dimension of the skeleton at rest
  92858. */
  92859. dimensionsAtRest: Vector3;
  92860. /**
  92861. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  92862. */
  92863. needInitialSkinMatrix: boolean;
  92864. /**
  92865. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  92866. */
  92867. overrideMesh: Nullable<AbstractMesh>;
  92868. /**
  92869. * Gets the list of animations attached to this skeleton
  92870. */
  92871. animations: Array<Animation>;
  92872. private _scene;
  92873. private _isDirty;
  92874. private _transformMatrices;
  92875. private _transformMatrixTexture;
  92876. private _meshesWithPoseMatrix;
  92877. private _animatables;
  92878. private _identity;
  92879. private _synchronizedWithMesh;
  92880. private _ranges;
  92881. private _lastAbsoluteTransformsUpdateId;
  92882. private _canUseTextureForBones;
  92883. private _uniqueId;
  92884. /** @hidden */
  92885. _numBonesWithLinkedTransformNode: number;
  92886. /** @hidden */
  92887. _hasWaitingData: Nullable<boolean>;
  92888. /**
  92889. * Specifies if the skeleton should be serialized
  92890. */
  92891. doNotSerialize: boolean;
  92892. private _useTextureToStoreBoneMatrices;
  92893. /**
  92894. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  92895. * Please note that this option is not available if the hardware does not support it
  92896. */
  92897. get useTextureToStoreBoneMatrices(): boolean;
  92898. set useTextureToStoreBoneMatrices(value: boolean);
  92899. private _animationPropertiesOverride;
  92900. /**
  92901. * Gets or sets the animation properties override
  92902. */
  92903. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  92904. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  92905. /**
  92906. * List of inspectable custom properties (used by the Inspector)
  92907. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  92908. */
  92909. inspectableCustomProperties: IInspectable[];
  92910. /**
  92911. * An observable triggered before computing the skeleton's matrices
  92912. */
  92913. onBeforeComputeObservable: Observable<Skeleton>;
  92914. /**
  92915. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  92916. */
  92917. get isUsingTextureForMatrices(): boolean;
  92918. /**
  92919. * Gets the unique ID of this skeleton
  92920. */
  92921. get uniqueId(): number;
  92922. /**
  92923. * Creates a new skeleton
  92924. * @param name defines the skeleton name
  92925. * @param id defines the skeleton Id
  92926. * @param scene defines the hosting scene
  92927. */
  92928. constructor(
  92929. /** defines the skeleton name */
  92930. name: string,
  92931. /** defines the skeleton Id */
  92932. id: string, scene: Scene);
  92933. /**
  92934. * Gets the current object class name.
  92935. * @return the class name
  92936. */
  92937. getClassName(): string;
  92938. /**
  92939. * Returns an array containing the root bones
  92940. * @returns an array containing the root bones
  92941. */
  92942. getChildren(): Array<Bone>;
  92943. /**
  92944. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  92945. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  92946. * @returns a Float32Array containing matrices data
  92947. */
  92948. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  92949. /**
  92950. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  92951. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  92952. * @returns a raw texture containing the data
  92953. */
  92954. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  92955. /**
  92956. * Gets the current hosting scene
  92957. * @returns a scene object
  92958. */
  92959. getScene(): Scene;
  92960. /**
  92961. * Gets a string representing the current skeleton data
  92962. * @param fullDetails defines a boolean indicating if we want a verbose version
  92963. * @returns a string representing the current skeleton data
  92964. */
  92965. toString(fullDetails?: boolean): string;
  92966. /**
  92967. * Get bone's index searching by name
  92968. * @param name defines bone's name to search for
  92969. * @return the indice of the bone. Returns -1 if not found
  92970. */
  92971. getBoneIndexByName(name: string): number;
  92972. /**
  92973. * Creater a new animation range
  92974. * @param name defines the name of the range
  92975. * @param from defines the start key
  92976. * @param to defines the end key
  92977. */
  92978. createAnimationRange(name: string, from: number, to: number): void;
  92979. /**
  92980. * Delete a specific animation range
  92981. * @param name defines the name of the range
  92982. * @param deleteFrames defines if frames must be removed as well
  92983. */
  92984. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  92985. /**
  92986. * Gets a specific animation range
  92987. * @param name defines the name of the range to look for
  92988. * @returns the requested animation range or null if not found
  92989. */
  92990. getAnimationRange(name: string): Nullable<AnimationRange>;
  92991. /**
  92992. * Gets the list of all animation ranges defined on this skeleton
  92993. * @returns an array
  92994. */
  92995. getAnimationRanges(): Nullable<AnimationRange>[];
  92996. /**
  92997. * Copy animation range from a source skeleton.
  92998. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  92999. * @param source defines the source skeleton
  93000. * @param name defines the name of the range to copy
  93001. * @param rescaleAsRequired defines if rescaling must be applied if required
  93002. * @returns true if operation was successful
  93003. */
  93004. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  93005. /**
  93006. * Forces the skeleton to go to rest pose
  93007. */
  93008. returnToRest(): void;
  93009. private _getHighestAnimationFrame;
  93010. /**
  93011. * Begin a specific animation range
  93012. * @param name defines the name of the range to start
  93013. * @param loop defines if looping must be turned on (false by default)
  93014. * @param speedRatio defines the speed ratio to apply (1 by default)
  93015. * @param onAnimationEnd defines a callback which will be called when animation will end
  93016. * @returns a new animatable
  93017. */
  93018. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  93019. /**
  93020. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  93021. * @param skeleton defines the Skeleton containing the animation range to convert
  93022. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  93023. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  93024. * @returns the original skeleton
  93025. */
  93026. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  93027. /** @hidden */
  93028. _markAsDirty(): void;
  93029. /** @hidden */
  93030. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  93031. /** @hidden */
  93032. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  93033. private _computeTransformMatrices;
  93034. /**
  93035. * Build all resources required to render a skeleton
  93036. */
  93037. prepare(): void;
  93038. /**
  93039. * Gets the list of animatables currently running for this skeleton
  93040. * @returns an array of animatables
  93041. */
  93042. getAnimatables(): IAnimatable[];
  93043. /**
  93044. * Clone the current skeleton
  93045. * @param name defines the name of the new skeleton
  93046. * @param id defines the id of the new skeleton
  93047. * @returns the new skeleton
  93048. */
  93049. clone(name: string, id?: string): Skeleton;
  93050. /**
  93051. * Enable animation blending for this skeleton
  93052. * @param blendingSpeed defines the blending speed to apply
  93053. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  93054. */
  93055. enableBlending(blendingSpeed?: number): void;
  93056. /**
  93057. * Releases all resources associated with the current skeleton
  93058. */
  93059. dispose(): void;
  93060. /**
  93061. * Serialize the skeleton in a JSON object
  93062. * @returns a JSON object
  93063. */
  93064. serialize(): any;
  93065. /**
  93066. * Creates a new skeleton from serialized data
  93067. * @param parsedSkeleton defines the serialized data
  93068. * @param scene defines the hosting scene
  93069. * @returns a new skeleton
  93070. */
  93071. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  93072. /**
  93073. * Compute all node absolute transforms
  93074. * @param forceUpdate defines if computation must be done even if cache is up to date
  93075. */
  93076. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  93077. /**
  93078. * Gets the root pose matrix
  93079. * @returns a matrix
  93080. */
  93081. getPoseMatrix(): Nullable<Matrix>;
  93082. /**
  93083. * Sorts bones per internal index
  93084. */
  93085. sortBones(): void;
  93086. private _sortBones;
  93087. }
  93088. }
  93089. declare module BABYLON {
  93090. /**
  93091. * Creates an instance based on a source mesh.
  93092. */
  93093. export class InstancedMesh extends AbstractMesh {
  93094. private _sourceMesh;
  93095. private _currentLOD;
  93096. /** @hidden */
  93097. _indexInSourceMeshInstanceArray: number;
  93098. constructor(name: string, source: Mesh);
  93099. /**
  93100. * Returns the string "InstancedMesh".
  93101. */
  93102. getClassName(): string;
  93103. /** Gets the list of lights affecting that mesh */
  93104. get lightSources(): Light[];
  93105. _resyncLightSources(): void;
  93106. _resyncLightSource(light: Light): void;
  93107. _removeLightSource(light: Light, dispose: boolean): void;
  93108. /**
  93109. * If the source mesh receives shadows
  93110. */
  93111. get receiveShadows(): boolean;
  93112. /**
  93113. * The material of the source mesh
  93114. */
  93115. get material(): Nullable<Material>;
  93116. /**
  93117. * Visibility of the source mesh
  93118. */
  93119. get visibility(): number;
  93120. /**
  93121. * Skeleton of the source mesh
  93122. */
  93123. get skeleton(): Nullable<Skeleton>;
  93124. /**
  93125. * Rendering ground id of the source mesh
  93126. */
  93127. get renderingGroupId(): number;
  93128. set renderingGroupId(value: number);
  93129. /**
  93130. * Returns the total number of vertices (integer).
  93131. */
  93132. getTotalVertices(): number;
  93133. /**
  93134. * Returns a positive integer : the total number of indices in this mesh geometry.
  93135. * @returns the numner of indices or zero if the mesh has no geometry.
  93136. */
  93137. getTotalIndices(): number;
  93138. /**
  93139. * The source mesh of the instance
  93140. */
  93141. get sourceMesh(): Mesh;
  93142. /**
  93143. * Creates a new InstancedMesh object from the mesh model.
  93144. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  93145. * @param name defines the name of the new instance
  93146. * @returns a new InstancedMesh
  93147. */
  93148. createInstance(name: string): InstancedMesh;
  93149. /**
  93150. * Is this node ready to be used/rendered
  93151. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  93152. * @return {boolean} is it ready
  93153. */
  93154. isReady(completeCheck?: boolean): boolean;
  93155. /**
  93156. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  93157. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  93158. * @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.
  93159. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  93160. */
  93161. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  93162. /**
  93163. * Sets the vertex data of the mesh geometry for the requested `kind`.
  93164. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  93165. * The `data` are either a numeric array either a Float32Array.
  93166. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  93167. * 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).
  93168. * Note that a new underlying VertexBuffer object is created each call.
  93169. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  93170. *
  93171. * Possible `kind` values :
  93172. * - VertexBuffer.PositionKind
  93173. * - VertexBuffer.UVKind
  93174. * - VertexBuffer.UV2Kind
  93175. * - VertexBuffer.UV3Kind
  93176. * - VertexBuffer.UV4Kind
  93177. * - VertexBuffer.UV5Kind
  93178. * - VertexBuffer.UV6Kind
  93179. * - VertexBuffer.ColorKind
  93180. * - VertexBuffer.MatricesIndicesKind
  93181. * - VertexBuffer.MatricesIndicesExtraKind
  93182. * - VertexBuffer.MatricesWeightsKind
  93183. * - VertexBuffer.MatricesWeightsExtraKind
  93184. *
  93185. * Returns the Mesh.
  93186. */
  93187. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  93188. /**
  93189. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  93190. * If the mesh has no geometry, it is simply returned as it is.
  93191. * The `data` are either a numeric array either a Float32Array.
  93192. * No new underlying VertexBuffer object is created.
  93193. * 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.
  93194. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  93195. *
  93196. * Possible `kind` values :
  93197. * - VertexBuffer.PositionKind
  93198. * - VertexBuffer.UVKind
  93199. * - VertexBuffer.UV2Kind
  93200. * - VertexBuffer.UV3Kind
  93201. * - VertexBuffer.UV4Kind
  93202. * - VertexBuffer.UV5Kind
  93203. * - VertexBuffer.UV6Kind
  93204. * - VertexBuffer.ColorKind
  93205. * - VertexBuffer.MatricesIndicesKind
  93206. * - VertexBuffer.MatricesIndicesExtraKind
  93207. * - VertexBuffer.MatricesWeightsKind
  93208. * - VertexBuffer.MatricesWeightsExtraKind
  93209. *
  93210. * Returns the Mesh.
  93211. */
  93212. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  93213. /**
  93214. * Sets the mesh indices.
  93215. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  93216. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  93217. * This method creates a new index buffer each call.
  93218. * Returns the Mesh.
  93219. */
  93220. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  93221. /**
  93222. * Boolean : True if the mesh owns the requested kind of data.
  93223. */
  93224. isVerticesDataPresent(kind: string): boolean;
  93225. /**
  93226. * Returns an array of indices (IndicesArray).
  93227. */
  93228. getIndices(): Nullable<IndicesArray>;
  93229. get _positions(): Nullable<Vector3[]>;
  93230. /**
  93231. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  93232. * This means the mesh underlying bounding box and sphere are recomputed.
  93233. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  93234. * @returns the current mesh
  93235. */
  93236. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  93237. /** @hidden */
  93238. _preActivate(): InstancedMesh;
  93239. /** @hidden */
  93240. _activate(renderId: number, intermediateRendering: boolean): boolean;
  93241. /** @hidden */
  93242. _postActivate(): void;
  93243. getWorldMatrix(): Matrix;
  93244. get isAnInstance(): boolean;
  93245. /**
  93246. * Returns the current associated LOD AbstractMesh.
  93247. */
  93248. getLOD(camera: Camera): AbstractMesh;
  93249. /** @hidden */
  93250. _preActivateForIntermediateRendering(renderId: number): Mesh;
  93251. /** @hidden */
  93252. _syncSubMeshes(): InstancedMesh;
  93253. /** @hidden */
  93254. _generatePointsArray(): boolean;
  93255. /**
  93256. * Creates a new InstancedMesh from the current mesh.
  93257. * - name (string) : the cloned mesh name
  93258. * - newParent (optional Node) : the optional Node to parent the clone to.
  93259. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  93260. *
  93261. * Returns the clone.
  93262. */
  93263. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  93264. /**
  93265. * Disposes the InstancedMesh.
  93266. * Returns nothing.
  93267. */
  93268. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  93269. }
  93270. interface Mesh {
  93271. /**
  93272. * Register a custom buffer that will be instanced
  93273. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  93274. * @param kind defines the buffer kind
  93275. * @param stride defines the stride in floats
  93276. */
  93277. registerInstancedBuffer(kind: string, stride: number): void;
  93278. /** @hidden */
  93279. _userInstancedBuffersStorage: {
  93280. data: {
  93281. [key: string]: Float32Array;
  93282. };
  93283. sizes: {
  93284. [key: string]: number;
  93285. };
  93286. vertexBuffers: {
  93287. [key: string]: Nullable<VertexBuffer>;
  93288. };
  93289. strides: {
  93290. [key: string]: number;
  93291. };
  93292. };
  93293. }
  93294. interface AbstractMesh {
  93295. /**
  93296. * Object used to store instanced buffers defined by user
  93297. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  93298. */
  93299. instancedBuffers: {
  93300. [key: string]: any;
  93301. };
  93302. }
  93303. }
  93304. declare module BABYLON {
  93305. /**
  93306. * Defines the options associated with the creation of a shader material.
  93307. */
  93308. export interface IShaderMaterialOptions {
  93309. /**
  93310. * Does the material work in alpha blend mode
  93311. */
  93312. needAlphaBlending: boolean;
  93313. /**
  93314. * Does the material work in alpha test mode
  93315. */
  93316. needAlphaTesting: boolean;
  93317. /**
  93318. * The list of attribute names used in the shader
  93319. */
  93320. attributes: string[];
  93321. /**
  93322. * The list of unifrom names used in the shader
  93323. */
  93324. uniforms: string[];
  93325. /**
  93326. * The list of UBO names used in the shader
  93327. */
  93328. uniformBuffers: string[];
  93329. /**
  93330. * The list of sampler names used in the shader
  93331. */
  93332. samplers: string[];
  93333. /**
  93334. * The list of defines used in the shader
  93335. */
  93336. defines: string[];
  93337. }
  93338. /**
  93339. * 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.
  93340. *
  93341. * This returned material effects how the mesh will look based on the code in the shaders.
  93342. *
  93343. * @see http://doc.babylonjs.com/how_to/shader_material
  93344. */
  93345. export class ShaderMaterial extends Material {
  93346. private _shaderPath;
  93347. private _options;
  93348. private _textures;
  93349. private _textureArrays;
  93350. private _floats;
  93351. private _ints;
  93352. private _floatsArrays;
  93353. private _colors3;
  93354. private _colors3Arrays;
  93355. private _colors4;
  93356. private _colors4Arrays;
  93357. private _vectors2;
  93358. private _vectors3;
  93359. private _vectors4;
  93360. private _matrices;
  93361. private _matrixArrays;
  93362. private _matrices3x3;
  93363. private _matrices2x2;
  93364. private _vectors2Arrays;
  93365. private _vectors3Arrays;
  93366. private _vectors4Arrays;
  93367. private _cachedWorldViewMatrix;
  93368. private _cachedWorldViewProjectionMatrix;
  93369. private _renderId;
  93370. private _multiview;
  93371. private _cachedDefines;
  93372. /**
  93373. * Instantiate a new shader material.
  93374. * 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.
  93375. * This returned material effects how the mesh will look based on the code in the shaders.
  93376. * @see http://doc.babylonjs.com/how_to/shader_material
  93377. * @param name Define the name of the material in the scene
  93378. * @param scene Define the scene the material belongs to
  93379. * @param shaderPath Defines the route to the shader code in one of three ways:
  93380. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  93381. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  93382. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  93383. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  93384. * @param options Define the options used to create the shader
  93385. */
  93386. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  93387. /**
  93388. * Gets the shader path used to define the shader code
  93389. * It can be modified to trigger a new compilation
  93390. */
  93391. get shaderPath(): any;
  93392. /**
  93393. * Sets the shader path used to define the shader code
  93394. * It can be modified to trigger a new compilation
  93395. */
  93396. set shaderPath(shaderPath: any);
  93397. /**
  93398. * Gets the options used to compile the shader.
  93399. * They can be modified to trigger a new compilation
  93400. */
  93401. get options(): IShaderMaterialOptions;
  93402. /**
  93403. * Gets the current class name of the material e.g. "ShaderMaterial"
  93404. * Mainly use in serialization.
  93405. * @returns the class name
  93406. */
  93407. getClassName(): string;
  93408. /**
  93409. * Specifies if the material will require alpha blending
  93410. * @returns a boolean specifying if alpha blending is needed
  93411. */
  93412. needAlphaBlending(): boolean;
  93413. /**
  93414. * Specifies if this material should be rendered in alpha test mode
  93415. * @returns a boolean specifying if an alpha test is needed.
  93416. */
  93417. needAlphaTesting(): boolean;
  93418. private _checkUniform;
  93419. /**
  93420. * Set a texture in the shader.
  93421. * @param name Define the name of the uniform samplers as defined in the shader
  93422. * @param texture Define the texture to bind to this sampler
  93423. * @return the material itself allowing "fluent" like uniform updates
  93424. */
  93425. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  93426. /**
  93427. * Set a texture array in the shader.
  93428. * @param name Define the name of the uniform sampler array as defined in the shader
  93429. * @param textures Define the list of textures to bind to this sampler
  93430. * @return the material itself allowing "fluent" like uniform updates
  93431. */
  93432. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  93433. /**
  93434. * Set a float in the shader.
  93435. * @param name Define the name of the uniform as defined in the shader
  93436. * @param value Define the value to give to the uniform
  93437. * @return the material itself allowing "fluent" like uniform updates
  93438. */
  93439. setFloat(name: string, value: number): ShaderMaterial;
  93440. /**
  93441. * Set a int in the shader.
  93442. * @param name Define the name of the uniform as defined in the shader
  93443. * @param value Define the value to give to the uniform
  93444. * @return the material itself allowing "fluent" like uniform updates
  93445. */
  93446. setInt(name: string, value: number): ShaderMaterial;
  93447. /**
  93448. * Set an array of floats in the shader.
  93449. * @param name Define the name of the uniform as defined in the shader
  93450. * @param value Define the value to give to the uniform
  93451. * @return the material itself allowing "fluent" like uniform updates
  93452. */
  93453. setFloats(name: string, value: number[]): ShaderMaterial;
  93454. /**
  93455. * Set a vec3 in the shader from a Color3.
  93456. * @param name Define the name of the uniform as defined in the shader
  93457. * @param value Define the value to give to the uniform
  93458. * @return the material itself allowing "fluent" like uniform updates
  93459. */
  93460. setColor3(name: string, value: Color3): ShaderMaterial;
  93461. /**
  93462. * Set a vec3 array in the shader from a Color3 array.
  93463. * @param name Define the name of the uniform as defined in the shader
  93464. * @param value Define the value to give to the uniform
  93465. * @return the material itself allowing "fluent" like uniform updates
  93466. */
  93467. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  93468. /**
  93469. * Set a vec4 in the shader from a Color4.
  93470. * @param name Define the name of the uniform as defined in the shader
  93471. * @param value Define the value to give to the uniform
  93472. * @return the material itself allowing "fluent" like uniform updates
  93473. */
  93474. setColor4(name: string, value: Color4): ShaderMaterial;
  93475. /**
  93476. * Set a vec4 array in the shader from a Color4 array.
  93477. * @param name Define the name of the uniform as defined in the shader
  93478. * @param value Define the value to give to the uniform
  93479. * @return the material itself allowing "fluent" like uniform updates
  93480. */
  93481. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  93482. /**
  93483. * Set a vec2 in the shader from a Vector2.
  93484. * @param name Define the name of the uniform as defined in the shader
  93485. * @param value Define the value to give to the uniform
  93486. * @return the material itself allowing "fluent" like uniform updates
  93487. */
  93488. setVector2(name: string, value: Vector2): ShaderMaterial;
  93489. /**
  93490. * Set a vec3 in the shader from a Vector3.
  93491. * @param name Define the name of the uniform as defined in the shader
  93492. * @param value Define the value to give to the uniform
  93493. * @return the material itself allowing "fluent" like uniform updates
  93494. */
  93495. setVector3(name: string, value: Vector3): ShaderMaterial;
  93496. /**
  93497. * Set a vec4 in the shader from a Vector4.
  93498. * @param name Define the name of the uniform as defined in the shader
  93499. * @param value Define the value to give to the uniform
  93500. * @return the material itself allowing "fluent" like uniform updates
  93501. */
  93502. setVector4(name: string, value: Vector4): ShaderMaterial;
  93503. /**
  93504. * Set a mat4 in the shader from a Matrix.
  93505. * @param name Define the name of the uniform as defined in the shader
  93506. * @param value Define the value to give to the uniform
  93507. * @return the material itself allowing "fluent" like uniform updates
  93508. */
  93509. setMatrix(name: string, value: Matrix): ShaderMaterial;
  93510. /**
  93511. * Set a float32Array in the shader from a matrix array.
  93512. * @param name Define the name of the uniform as defined in the shader
  93513. * @param value Define the value to give to the uniform
  93514. * @return the material itself allowing "fluent" like uniform updates
  93515. */
  93516. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  93517. /**
  93518. * Set a mat3 in the shader from a Float32Array.
  93519. * @param name Define the name of the uniform as defined in the shader
  93520. * @param value Define the value to give to the uniform
  93521. * @return the material itself allowing "fluent" like uniform updates
  93522. */
  93523. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  93524. /**
  93525. * Set a mat2 in the shader from a Float32Array.
  93526. * @param name Define the name of the uniform as defined in the shader
  93527. * @param value Define the value to give to the uniform
  93528. * @return the material itself allowing "fluent" like uniform updates
  93529. */
  93530. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  93531. /**
  93532. * Set a vec2 array in the shader from a number array.
  93533. * @param name Define the name of the uniform as defined in the shader
  93534. * @param value Define the value to give to the uniform
  93535. * @return the material itself allowing "fluent" like uniform updates
  93536. */
  93537. setArray2(name: string, value: number[]): ShaderMaterial;
  93538. /**
  93539. * Set a vec3 array in the shader from a number array.
  93540. * @param name Define the name of the uniform as defined in the shader
  93541. * @param value Define the value to give to the uniform
  93542. * @return the material itself allowing "fluent" like uniform updates
  93543. */
  93544. setArray3(name: string, value: number[]): ShaderMaterial;
  93545. /**
  93546. * Set a vec4 array in the shader from a number array.
  93547. * @param name Define the name of the uniform as defined in the shader
  93548. * @param value Define the value to give to the uniform
  93549. * @return the material itself allowing "fluent" like uniform updates
  93550. */
  93551. setArray4(name: string, value: number[]): ShaderMaterial;
  93552. private _checkCache;
  93553. /**
  93554. * Specifies that the submesh is ready to be used
  93555. * @param mesh defines the mesh to check
  93556. * @param subMesh defines which submesh to check
  93557. * @param useInstances specifies that instances should be used
  93558. * @returns a boolean indicating that the submesh is ready or not
  93559. */
  93560. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  93561. /**
  93562. * Checks if the material is ready to render the requested mesh
  93563. * @param mesh Define the mesh to render
  93564. * @param useInstances Define whether or not the material is used with instances
  93565. * @returns true if ready, otherwise false
  93566. */
  93567. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  93568. /**
  93569. * Binds the world matrix to the material
  93570. * @param world defines the world transformation matrix
  93571. * @param effectOverride - If provided, use this effect instead of internal effect
  93572. */
  93573. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  93574. /**
  93575. * Binds the submesh to this material by preparing the effect and shader to draw
  93576. * @param world defines the world transformation matrix
  93577. * @param mesh defines the mesh containing the submesh
  93578. * @param subMesh defines the submesh to bind the material to
  93579. */
  93580. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  93581. /**
  93582. * Binds the material to the mesh
  93583. * @param world defines the world transformation matrix
  93584. * @param mesh defines the mesh to bind the material to
  93585. * @param effectOverride - If provided, use this effect instead of internal effect
  93586. */
  93587. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  93588. protected _afterBind(mesh?: Mesh): void;
  93589. /**
  93590. * Gets the active textures from the material
  93591. * @returns an array of textures
  93592. */
  93593. getActiveTextures(): BaseTexture[];
  93594. /**
  93595. * Specifies if the material uses a texture
  93596. * @param texture defines the texture to check against the material
  93597. * @returns a boolean specifying if the material uses the texture
  93598. */
  93599. hasTexture(texture: BaseTexture): boolean;
  93600. /**
  93601. * Makes a duplicate of the material, and gives it a new name
  93602. * @param name defines the new name for the duplicated material
  93603. * @returns the cloned material
  93604. */
  93605. clone(name: string): ShaderMaterial;
  93606. /**
  93607. * Disposes the material
  93608. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  93609. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  93610. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  93611. */
  93612. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  93613. /**
  93614. * Serializes this material in a JSON representation
  93615. * @returns the serialized material object
  93616. */
  93617. serialize(): any;
  93618. /**
  93619. * Creates a shader material from parsed shader material data
  93620. * @param source defines the JSON represnetation of the material
  93621. * @param scene defines the hosting scene
  93622. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  93623. * @returns a new material
  93624. */
  93625. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  93626. }
  93627. }
  93628. declare module BABYLON {
  93629. /** @hidden */
  93630. export var colorPixelShader: {
  93631. name: string;
  93632. shader: string;
  93633. };
  93634. }
  93635. declare module BABYLON {
  93636. /** @hidden */
  93637. export var colorVertexShader: {
  93638. name: string;
  93639. shader: string;
  93640. };
  93641. }
  93642. declare module BABYLON {
  93643. /**
  93644. * Line mesh
  93645. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  93646. */
  93647. export class LinesMesh extends Mesh {
  93648. /**
  93649. * If vertex color should be applied to the mesh
  93650. */
  93651. readonly useVertexColor?: boolean | undefined;
  93652. /**
  93653. * If vertex alpha should be applied to the mesh
  93654. */
  93655. readonly useVertexAlpha?: boolean | undefined;
  93656. /**
  93657. * Color of the line (Default: White)
  93658. */
  93659. color: Color3;
  93660. /**
  93661. * Alpha of the line (Default: 1)
  93662. */
  93663. alpha: number;
  93664. /**
  93665. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  93666. * This margin is expressed in world space coordinates, so its value may vary.
  93667. * Default value is 0.1
  93668. */
  93669. intersectionThreshold: number;
  93670. private _colorShader;
  93671. private color4;
  93672. /**
  93673. * Creates a new LinesMesh
  93674. * @param name defines the name
  93675. * @param scene defines the hosting scene
  93676. * @param parent defines the parent mesh if any
  93677. * @param source defines the optional source LinesMesh used to clone data from
  93678. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  93679. * When false, achieved by calling a clone(), also passing False.
  93680. * This will make creation of children, recursive.
  93681. * @param useVertexColor defines if this LinesMesh supports vertex color
  93682. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  93683. */
  93684. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  93685. /**
  93686. * If vertex color should be applied to the mesh
  93687. */
  93688. useVertexColor?: boolean | undefined,
  93689. /**
  93690. * If vertex alpha should be applied to the mesh
  93691. */
  93692. useVertexAlpha?: boolean | undefined);
  93693. private _addClipPlaneDefine;
  93694. private _removeClipPlaneDefine;
  93695. isReady(): boolean;
  93696. /**
  93697. * Returns the string "LineMesh"
  93698. */
  93699. getClassName(): string;
  93700. /**
  93701. * @hidden
  93702. */
  93703. get material(): Material;
  93704. /**
  93705. * @hidden
  93706. */
  93707. set material(value: Material);
  93708. /**
  93709. * @hidden
  93710. */
  93711. get checkCollisions(): boolean;
  93712. /** @hidden */
  93713. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  93714. /** @hidden */
  93715. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  93716. /**
  93717. * Disposes of the line mesh
  93718. * @param doNotRecurse If children should be disposed
  93719. */
  93720. dispose(doNotRecurse?: boolean): void;
  93721. /**
  93722. * Returns a new LineMesh object cloned from the current one.
  93723. */
  93724. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  93725. /**
  93726. * Creates a new InstancedLinesMesh object from the mesh model.
  93727. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  93728. * @param name defines the name of the new instance
  93729. * @returns a new InstancedLinesMesh
  93730. */
  93731. createInstance(name: string): InstancedLinesMesh;
  93732. }
  93733. /**
  93734. * Creates an instance based on a source LinesMesh
  93735. */
  93736. export class InstancedLinesMesh extends InstancedMesh {
  93737. /**
  93738. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  93739. * This margin is expressed in world space coordinates, so its value may vary.
  93740. * Initilized with the intersectionThreshold value of the source LinesMesh
  93741. */
  93742. intersectionThreshold: number;
  93743. constructor(name: string, source: LinesMesh);
  93744. /**
  93745. * Returns the string "InstancedLinesMesh".
  93746. */
  93747. getClassName(): string;
  93748. }
  93749. }
  93750. declare module BABYLON {
  93751. /** @hidden */
  93752. export var linePixelShader: {
  93753. name: string;
  93754. shader: string;
  93755. };
  93756. }
  93757. declare module BABYLON {
  93758. /** @hidden */
  93759. export var lineVertexShader: {
  93760. name: string;
  93761. shader: string;
  93762. };
  93763. }
  93764. declare module BABYLON {
  93765. interface AbstractMesh {
  93766. /**
  93767. * Gets the edgesRenderer associated with the mesh
  93768. */
  93769. edgesRenderer: Nullable<EdgesRenderer>;
  93770. }
  93771. interface LinesMesh {
  93772. /**
  93773. * Enables the edge rendering mode on the mesh.
  93774. * This mode makes the mesh edges visible
  93775. * @param epsilon defines the maximal distance between two angles to detect a face
  93776. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  93777. * @returns the currentAbstractMesh
  93778. * @see https://www.babylonjs-playground.com/#19O9TU#0
  93779. */
  93780. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  93781. }
  93782. interface InstancedLinesMesh {
  93783. /**
  93784. * Enables the edge rendering mode on the mesh.
  93785. * This mode makes the mesh edges visible
  93786. * @param epsilon defines the maximal distance between two angles to detect a face
  93787. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  93788. * @returns the current InstancedLinesMesh
  93789. * @see https://www.babylonjs-playground.com/#19O9TU#0
  93790. */
  93791. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  93792. }
  93793. /**
  93794. * Defines the minimum contract an Edges renderer should follow.
  93795. */
  93796. export interface IEdgesRenderer extends IDisposable {
  93797. /**
  93798. * Gets or sets a boolean indicating if the edgesRenderer is active
  93799. */
  93800. isEnabled: boolean;
  93801. /**
  93802. * Renders the edges of the attached mesh,
  93803. */
  93804. render(): void;
  93805. /**
  93806. * Checks wether or not the edges renderer is ready to render.
  93807. * @return true if ready, otherwise false.
  93808. */
  93809. isReady(): boolean;
  93810. }
  93811. /**
  93812. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  93813. */
  93814. export class EdgesRenderer implements IEdgesRenderer {
  93815. /**
  93816. * Define the size of the edges with an orthographic camera
  93817. */
  93818. edgesWidthScalerForOrthographic: number;
  93819. /**
  93820. * Define the size of the edges with a perspective camera
  93821. */
  93822. edgesWidthScalerForPerspective: number;
  93823. protected _source: AbstractMesh;
  93824. protected _linesPositions: number[];
  93825. protected _linesNormals: number[];
  93826. protected _linesIndices: number[];
  93827. protected _epsilon: number;
  93828. protected _indicesCount: number;
  93829. protected _lineShader: ShaderMaterial;
  93830. protected _ib: DataBuffer;
  93831. protected _buffers: {
  93832. [key: string]: Nullable<VertexBuffer>;
  93833. };
  93834. protected _checkVerticesInsteadOfIndices: boolean;
  93835. private _meshRebuildObserver;
  93836. private _meshDisposeObserver;
  93837. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  93838. isEnabled: boolean;
  93839. /**
  93840. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  93841. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  93842. * @param source Mesh used to create edges
  93843. * @param epsilon sum of angles in adjacency to check for edge
  93844. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  93845. * @param generateEdgesLines - should generate Lines or only prepare resources.
  93846. */
  93847. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  93848. protected _prepareRessources(): void;
  93849. /** @hidden */
  93850. _rebuild(): void;
  93851. /**
  93852. * Releases the required resources for the edges renderer
  93853. */
  93854. dispose(): void;
  93855. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  93856. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  93857. /**
  93858. * Checks if the pair of p0 and p1 is en edge
  93859. * @param faceIndex
  93860. * @param edge
  93861. * @param faceNormals
  93862. * @param p0
  93863. * @param p1
  93864. * @private
  93865. */
  93866. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  93867. /**
  93868. * push line into the position, normal and index buffer
  93869. * @protected
  93870. */
  93871. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  93872. /**
  93873. * Generates lines edges from adjacencjes
  93874. * @private
  93875. */
  93876. _generateEdgesLines(): void;
  93877. /**
  93878. * Checks wether or not the edges renderer is ready to render.
  93879. * @return true if ready, otherwise false.
  93880. */
  93881. isReady(): boolean;
  93882. /**
  93883. * Renders the edges of the attached mesh,
  93884. */
  93885. render(): void;
  93886. }
  93887. /**
  93888. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  93889. */
  93890. export class LineEdgesRenderer extends EdgesRenderer {
  93891. /**
  93892. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  93893. * @param source LineMesh used to generate edges
  93894. * @param epsilon not important (specified angle for edge detection)
  93895. * @param checkVerticesInsteadOfIndices not important for LineMesh
  93896. */
  93897. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  93898. /**
  93899. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  93900. */
  93901. _generateEdgesLines(): void;
  93902. }
  93903. }
  93904. declare module BABYLON {
  93905. /**
  93906. * This represents the object necessary to create a rendering group.
  93907. * This is exclusively used and created by the rendering manager.
  93908. * To modify the behavior, you use the available helpers in your scene or meshes.
  93909. * @hidden
  93910. */
  93911. export class RenderingGroup {
  93912. index: number;
  93913. private static _zeroVector;
  93914. private _scene;
  93915. private _opaqueSubMeshes;
  93916. private _transparentSubMeshes;
  93917. private _alphaTestSubMeshes;
  93918. private _depthOnlySubMeshes;
  93919. private _particleSystems;
  93920. private _spriteManagers;
  93921. private _opaqueSortCompareFn;
  93922. private _alphaTestSortCompareFn;
  93923. private _transparentSortCompareFn;
  93924. private _renderOpaque;
  93925. private _renderAlphaTest;
  93926. private _renderTransparent;
  93927. /** @hidden */
  93928. _edgesRenderers: SmartArray<IEdgesRenderer>;
  93929. onBeforeTransparentRendering: () => void;
  93930. /**
  93931. * Set the opaque sort comparison function.
  93932. * If null the sub meshes will be render in the order they were created
  93933. */
  93934. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  93935. /**
  93936. * Set the alpha test sort comparison function.
  93937. * If null the sub meshes will be render in the order they were created
  93938. */
  93939. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  93940. /**
  93941. * Set the transparent sort comparison function.
  93942. * If null the sub meshes will be render in the order they were created
  93943. */
  93944. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  93945. /**
  93946. * Creates a new rendering group.
  93947. * @param index The rendering group index
  93948. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  93949. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  93950. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  93951. */
  93952. 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>);
  93953. /**
  93954. * Render all the sub meshes contained in the group.
  93955. * @param customRenderFunction Used to override the default render behaviour of the group.
  93956. * @returns true if rendered some submeshes.
  93957. */
  93958. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  93959. /**
  93960. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  93961. * @param subMeshes The submeshes to render
  93962. */
  93963. private renderOpaqueSorted;
  93964. /**
  93965. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  93966. * @param subMeshes The submeshes to render
  93967. */
  93968. private renderAlphaTestSorted;
  93969. /**
  93970. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  93971. * @param subMeshes The submeshes to render
  93972. */
  93973. private renderTransparentSorted;
  93974. /**
  93975. * Renders the submeshes in a specified order.
  93976. * @param subMeshes The submeshes to sort before render
  93977. * @param sortCompareFn The comparison function use to sort
  93978. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  93979. * @param transparent Specifies to activate blending if true
  93980. */
  93981. private static renderSorted;
  93982. /**
  93983. * Renders the submeshes in the order they were dispatched (no sort applied).
  93984. * @param subMeshes The submeshes to render
  93985. */
  93986. private static renderUnsorted;
  93987. /**
  93988. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  93989. * are rendered back to front if in the same alpha index.
  93990. *
  93991. * @param a The first submesh
  93992. * @param b The second submesh
  93993. * @returns The result of the comparison
  93994. */
  93995. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  93996. /**
  93997. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  93998. * are rendered back to front.
  93999. *
  94000. * @param a The first submesh
  94001. * @param b The second submesh
  94002. * @returns The result of the comparison
  94003. */
  94004. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  94005. /**
  94006. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  94007. * are rendered front to back (prevent overdraw).
  94008. *
  94009. * @param a The first submesh
  94010. * @param b The second submesh
  94011. * @returns The result of the comparison
  94012. */
  94013. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  94014. /**
  94015. * Resets the different lists of submeshes to prepare a new frame.
  94016. */
  94017. prepare(): void;
  94018. dispose(): void;
  94019. /**
  94020. * Inserts the submesh in its correct queue depending on its material.
  94021. * @param subMesh The submesh to dispatch
  94022. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  94023. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  94024. */
  94025. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  94026. dispatchSprites(spriteManager: ISpriteManager): void;
  94027. dispatchParticles(particleSystem: IParticleSystem): void;
  94028. private _renderParticles;
  94029. private _renderSprites;
  94030. }
  94031. }
  94032. declare module BABYLON {
  94033. /**
  94034. * Interface describing the different options available in the rendering manager
  94035. * regarding Auto Clear between groups.
  94036. */
  94037. export interface IRenderingManagerAutoClearSetup {
  94038. /**
  94039. * Defines whether or not autoclear is enable.
  94040. */
  94041. autoClear: boolean;
  94042. /**
  94043. * Defines whether or not to autoclear the depth buffer.
  94044. */
  94045. depth: boolean;
  94046. /**
  94047. * Defines whether or not to autoclear the stencil buffer.
  94048. */
  94049. stencil: boolean;
  94050. }
  94051. /**
  94052. * This class is used by the onRenderingGroupObservable
  94053. */
  94054. export class RenderingGroupInfo {
  94055. /**
  94056. * The Scene that being rendered
  94057. */
  94058. scene: Scene;
  94059. /**
  94060. * The camera currently used for the rendering pass
  94061. */
  94062. camera: Nullable<Camera>;
  94063. /**
  94064. * The ID of the renderingGroup being processed
  94065. */
  94066. renderingGroupId: number;
  94067. }
  94068. /**
  94069. * This is the manager responsible of all the rendering for meshes sprites and particles.
  94070. * It is enable to manage the different groups as well as the different necessary sort functions.
  94071. * This should not be used directly aside of the few static configurations
  94072. */
  94073. export class RenderingManager {
  94074. /**
  94075. * The max id used for rendering groups (not included)
  94076. */
  94077. static MAX_RENDERINGGROUPS: number;
  94078. /**
  94079. * The min id used for rendering groups (included)
  94080. */
  94081. static MIN_RENDERINGGROUPS: number;
  94082. /**
  94083. * Used to globally prevent autoclearing scenes.
  94084. */
  94085. static AUTOCLEAR: boolean;
  94086. /**
  94087. * @hidden
  94088. */
  94089. _useSceneAutoClearSetup: boolean;
  94090. private _scene;
  94091. private _renderingGroups;
  94092. private _depthStencilBufferAlreadyCleaned;
  94093. private _autoClearDepthStencil;
  94094. private _customOpaqueSortCompareFn;
  94095. private _customAlphaTestSortCompareFn;
  94096. private _customTransparentSortCompareFn;
  94097. private _renderingGroupInfo;
  94098. /**
  94099. * Instantiates a new rendering group for a particular scene
  94100. * @param scene Defines the scene the groups belongs to
  94101. */
  94102. constructor(scene: Scene);
  94103. private _clearDepthStencilBuffer;
  94104. /**
  94105. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  94106. * @hidden
  94107. */
  94108. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  94109. /**
  94110. * Resets the different information of the group to prepare a new frame
  94111. * @hidden
  94112. */
  94113. reset(): void;
  94114. /**
  94115. * Dispose and release the group and its associated resources.
  94116. * @hidden
  94117. */
  94118. dispose(): void;
  94119. /**
  94120. * Clear the info related to rendering groups preventing retention points during dispose.
  94121. */
  94122. freeRenderingGroups(): void;
  94123. private _prepareRenderingGroup;
  94124. /**
  94125. * Add a sprite manager to the rendering manager in order to render it this frame.
  94126. * @param spriteManager Define the sprite manager to render
  94127. */
  94128. dispatchSprites(spriteManager: ISpriteManager): void;
  94129. /**
  94130. * Add a particle system to the rendering manager in order to render it this frame.
  94131. * @param particleSystem Define the particle system to render
  94132. */
  94133. dispatchParticles(particleSystem: IParticleSystem): void;
  94134. /**
  94135. * Add a submesh to the manager in order to render it this frame
  94136. * @param subMesh The submesh to dispatch
  94137. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  94138. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  94139. */
  94140. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  94141. /**
  94142. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  94143. * This allowed control for front to back rendering or reversly depending of the special needs.
  94144. *
  94145. * @param renderingGroupId The rendering group id corresponding to its index
  94146. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  94147. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  94148. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  94149. */
  94150. 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;
  94151. /**
  94152. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  94153. *
  94154. * @param renderingGroupId The rendering group id corresponding to its index
  94155. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  94156. * @param depth Automatically clears depth between groups if true and autoClear is true.
  94157. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  94158. */
  94159. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  94160. /**
  94161. * Gets the current auto clear configuration for one rendering group of the rendering
  94162. * manager.
  94163. * @param index the rendering group index to get the information for
  94164. * @returns The auto clear setup for the requested rendering group
  94165. */
  94166. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  94167. }
  94168. }
  94169. declare module BABYLON {
  94170. /**
  94171. * Defines the options associated with the creation of a custom shader for a shadow generator.
  94172. */
  94173. export interface ICustomShaderOptions {
  94174. /**
  94175. * Gets or sets the custom shader name to use
  94176. */
  94177. shaderName: string;
  94178. /**
  94179. * The list of attribute names used in the shader
  94180. */
  94181. attributes?: string[];
  94182. /**
  94183. * The list of unifrom names used in the shader
  94184. */
  94185. uniforms?: string[];
  94186. /**
  94187. * The list of sampler names used in the shader
  94188. */
  94189. samplers?: string[];
  94190. /**
  94191. * The list of defines used in the shader
  94192. */
  94193. defines?: string[];
  94194. }
  94195. /**
  94196. * Interface to implement to create a shadow generator compatible with BJS.
  94197. */
  94198. export interface IShadowGenerator {
  94199. /**
  94200. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  94201. * @returns The render target texture if present otherwise, null
  94202. */
  94203. getShadowMap(): Nullable<RenderTargetTexture>;
  94204. /**
  94205. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  94206. * @param subMesh The submesh we want to render in the shadow map
  94207. * @param useInstances Defines wether will draw in the map using instances
  94208. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  94209. * @returns true if ready otherwise, false
  94210. */
  94211. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  94212. /**
  94213. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  94214. * @param defines Defines of the material we want to update
  94215. * @param lightIndex Index of the light in the enabled light list of the material
  94216. */
  94217. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  94218. /**
  94219. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  94220. * defined in the generator but impacting the effect).
  94221. * It implies the unifroms available on the materials are the standard BJS ones.
  94222. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  94223. * @param effect The effect we are binfing the information for
  94224. */
  94225. bindShadowLight(lightIndex: string, effect: Effect): void;
  94226. /**
  94227. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  94228. * (eq to shadow prjection matrix * light transform matrix)
  94229. * @returns The transform matrix used to create the shadow map
  94230. */
  94231. getTransformMatrix(): Matrix;
  94232. /**
  94233. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  94234. * Cube and 2D textures for instance.
  94235. */
  94236. recreateShadowMap(): void;
  94237. /**
  94238. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  94239. * @param onCompiled Callback triggered at the and of the effects compilation
  94240. * @param options Sets of optional options forcing the compilation with different modes
  94241. */
  94242. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  94243. useInstances: boolean;
  94244. }>): void;
  94245. /**
  94246. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  94247. * @param options Sets of optional options forcing the compilation with different modes
  94248. * @returns A promise that resolves when the compilation completes
  94249. */
  94250. forceCompilationAsync(options?: Partial<{
  94251. useInstances: boolean;
  94252. }>): Promise<void>;
  94253. /**
  94254. * Serializes the shadow generator setup to a json object.
  94255. * @returns The serialized JSON object
  94256. */
  94257. serialize(): any;
  94258. /**
  94259. * Disposes the Shadow map and related Textures and effects.
  94260. */
  94261. dispose(): void;
  94262. }
  94263. /**
  94264. * Default implementation IShadowGenerator.
  94265. * This is the main object responsible of generating shadows in the framework.
  94266. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  94267. */
  94268. export class ShadowGenerator implements IShadowGenerator {
  94269. /**
  94270. * Name of the shadow generator class
  94271. */
  94272. static CLASSNAME: string;
  94273. /**
  94274. * Shadow generator mode None: no filtering applied.
  94275. */
  94276. static readonly FILTER_NONE: number;
  94277. /**
  94278. * Shadow generator mode ESM: Exponential Shadow Mapping.
  94279. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  94280. */
  94281. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  94282. /**
  94283. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  94284. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  94285. */
  94286. static readonly FILTER_POISSONSAMPLING: number;
  94287. /**
  94288. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  94289. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  94290. */
  94291. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  94292. /**
  94293. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  94294. * edge artifacts on steep falloff.
  94295. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  94296. */
  94297. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  94298. /**
  94299. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  94300. * edge artifacts on steep falloff.
  94301. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  94302. */
  94303. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  94304. /**
  94305. * Shadow generator mode PCF: Percentage Closer Filtering
  94306. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  94307. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  94308. */
  94309. static readonly FILTER_PCF: number;
  94310. /**
  94311. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  94312. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  94313. * Contact Hardening
  94314. */
  94315. static readonly FILTER_PCSS: number;
  94316. /**
  94317. * Reserved for PCF and PCSS
  94318. * Highest Quality.
  94319. *
  94320. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  94321. *
  94322. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  94323. */
  94324. static readonly QUALITY_HIGH: number;
  94325. /**
  94326. * Reserved for PCF and PCSS
  94327. * Good tradeoff for quality/perf cross devices
  94328. *
  94329. * Execute PCF on a 3*3 kernel.
  94330. *
  94331. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  94332. */
  94333. static readonly QUALITY_MEDIUM: number;
  94334. /**
  94335. * Reserved for PCF and PCSS
  94336. * The lowest quality but the fastest.
  94337. *
  94338. * Execute PCF on a 1*1 kernel.
  94339. *
  94340. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  94341. */
  94342. static readonly QUALITY_LOW: number;
  94343. /** Gets or sets the custom shader name to use */
  94344. customShaderOptions: ICustomShaderOptions;
  94345. /**
  94346. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  94347. */
  94348. onBeforeShadowMapRenderObservable: Observable<Effect>;
  94349. /**
  94350. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  94351. */
  94352. onAfterShadowMapRenderObservable: Observable<Effect>;
  94353. /**
  94354. * Observable triggered before a mesh is rendered in the shadow map.
  94355. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  94356. */
  94357. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  94358. /**
  94359. * Observable triggered after a mesh is rendered in the shadow map.
  94360. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  94361. */
  94362. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  94363. protected _bias: number;
  94364. /**
  94365. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  94366. */
  94367. get bias(): number;
  94368. /**
  94369. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  94370. */
  94371. set bias(bias: number);
  94372. protected _normalBias: number;
  94373. /**
  94374. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  94375. */
  94376. get normalBias(): number;
  94377. /**
  94378. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  94379. */
  94380. set normalBias(normalBias: number);
  94381. protected _blurBoxOffset: number;
  94382. /**
  94383. * Gets the blur box offset: offset applied during the blur pass.
  94384. * Only useful if useKernelBlur = false
  94385. */
  94386. get blurBoxOffset(): number;
  94387. /**
  94388. * Sets the blur box offset: offset applied during the blur pass.
  94389. * Only useful if useKernelBlur = false
  94390. */
  94391. set blurBoxOffset(value: number);
  94392. protected _blurScale: number;
  94393. /**
  94394. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  94395. * 2 means half of the size.
  94396. */
  94397. get blurScale(): number;
  94398. /**
  94399. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  94400. * 2 means half of the size.
  94401. */
  94402. set blurScale(value: number);
  94403. protected _blurKernel: number;
  94404. /**
  94405. * Gets the blur kernel: kernel size of the blur pass.
  94406. * Only useful if useKernelBlur = true
  94407. */
  94408. get blurKernel(): number;
  94409. /**
  94410. * Sets the blur kernel: kernel size of the blur pass.
  94411. * Only useful if useKernelBlur = true
  94412. */
  94413. set blurKernel(value: number);
  94414. protected _useKernelBlur: boolean;
  94415. /**
  94416. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  94417. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  94418. */
  94419. get useKernelBlur(): boolean;
  94420. /**
  94421. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  94422. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  94423. */
  94424. set useKernelBlur(value: boolean);
  94425. protected _depthScale: number;
  94426. /**
  94427. * Gets the depth scale used in ESM mode.
  94428. */
  94429. get depthScale(): number;
  94430. /**
  94431. * Sets the depth scale used in ESM mode.
  94432. * This can override the scale stored on the light.
  94433. */
  94434. set depthScale(value: number);
  94435. protected _validateFilter(filter: number): number;
  94436. protected _filter: number;
  94437. /**
  94438. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  94439. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  94440. */
  94441. get filter(): number;
  94442. /**
  94443. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  94444. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  94445. */
  94446. set filter(value: number);
  94447. /**
  94448. * Gets if the current filter is set to Poisson Sampling.
  94449. */
  94450. get usePoissonSampling(): boolean;
  94451. /**
  94452. * Sets the current filter to Poisson Sampling.
  94453. */
  94454. set usePoissonSampling(value: boolean);
  94455. /**
  94456. * Gets if the current filter is set to ESM.
  94457. */
  94458. get useExponentialShadowMap(): boolean;
  94459. /**
  94460. * Sets the current filter is to ESM.
  94461. */
  94462. set useExponentialShadowMap(value: boolean);
  94463. /**
  94464. * Gets if the current filter is set to filtered ESM.
  94465. */
  94466. get useBlurExponentialShadowMap(): boolean;
  94467. /**
  94468. * Gets if the current filter is set to filtered ESM.
  94469. */
  94470. set useBlurExponentialShadowMap(value: boolean);
  94471. /**
  94472. * Gets if the current filter is set to "close ESM" (using the inverse of the
  94473. * exponential to prevent steep falloff artifacts).
  94474. */
  94475. get useCloseExponentialShadowMap(): boolean;
  94476. /**
  94477. * Sets the current filter to "close ESM" (using the inverse of the
  94478. * exponential to prevent steep falloff artifacts).
  94479. */
  94480. set useCloseExponentialShadowMap(value: boolean);
  94481. /**
  94482. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  94483. * exponential to prevent steep falloff artifacts).
  94484. */
  94485. get useBlurCloseExponentialShadowMap(): boolean;
  94486. /**
  94487. * Sets the current filter to filtered "close ESM" (using the inverse of the
  94488. * exponential to prevent steep falloff artifacts).
  94489. */
  94490. set useBlurCloseExponentialShadowMap(value: boolean);
  94491. /**
  94492. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  94493. */
  94494. get usePercentageCloserFiltering(): boolean;
  94495. /**
  94496. * Sets the current filter to "PCF" (percentage closer filtering).
  94497. */
  94498. set usePercentageCloserFiltering(value: boolean);
  94499. protected _filteringQuality: number;
  94500. /**
  94501. * Gets the PCF or PCSS Quality.
  94502. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  94503. */
  94504. get filteringQuality(): number;
  94505. /**
  94506. * Sets the PCF or PCSS Quality.
  94507. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  94508. */
  94509. set filteringQuality(filteringQuality: number);
  94510. /**
  94511. * Gets if the current filter is set to "PCSS" (contact hardening).
  94512. */
  94513. get useContactHardeningShadow(): boolean;
  94514. /**
  94515. * Sets the current filter to "PCSS" (contact hardening).
  94516. */
  94517. set useContactHardeningShadow(value: boolean);
  94518. protected _contactHardeningLightSizeUVRatio: number;
  94519. /**
  94520. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  94521. * Using a ratio helps keeping shape stability independently of the map size.
  94522. *
  94523. * It does not account for the light projection as it was having too much
  94524. * instability during the light setup or during light position changes.
  94525. *
  94526. * Only valid if useContactHardeningShadow is true.
  94527. */
  94528. get contactHardeningLightSizeUVRatio(): number;
  94529. /**
  94530. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  94531. * Using a ratio helps keeping shape stability independently of the map size.
  94532. *
  94533. * It does not account for the light projection as it was having too much
  94534. * instability during the light setup or during light position changes.
  94535. *
  94536. * Only valid if useContactHardeningShadow is true.
  94537. */
  94538. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  94539. protected _darkness: number;
  94540. /** Gets or sets the actual darkness of a shadow */
  94541. get darkness(): number;
  94542. set darkness(value: number);
  94543. /**
  94544. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  94545. * 0 means strongest and 1 would means no shadow.
  94546. * @returns the darkness.
  94547. */
  94548. getDarkness(): number;
  94549. /**
  94550. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  94551. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  94552. * @returns the shadow generator allowing fluent coding.
  94553. */
  94554. setDarkness(darkness: number): ShadowGenerator;
  94555. protected _transparencyShadow: boolean;
  94556. /** Gets or sets the ability to have transparent shadow */
  94557. get transparencyShadow(): boolean;
  94558. set transparencyShadow(value: boolean);
  94559. /**
  94560. * Sets the ability to have transparent shadow (boolean).
  94561. * @param transparent True if transparent else False
  94562. * @returns the shadow generator allowing fluent coding
  94563. */
  94564. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  94565. /**
  94566. * Enables or disables shadows with varying strength based on the transparency
  94567. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  94568. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  94569. * mesh.visibility * alphaTexture.a
  94570. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  94571. */
  94572. enableSoftTransparentShadow: boolean;
  94573. protected _shadowMap: Nullable<RenderTargetTexture>;
  94574. protected _shadowMap2: Nullable<RenderTargetTexture>;
  94575. /**
  94576. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  94577. * @returns The render target texture if present otherwise, null
  94578. */
  94579. getShadowMap(): Nullable<RenderTargetTexture>;
  94580. /**
  94581. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  94582. * @returns The render target texture if the shadow map is present otherwise, null
  94583. */
  94584. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  94585. /**
  94586. * Gets the class name of that object
  94587. * @returns "ShadowGenerator"
  94588. */
  94589. getClassName(): string;
  94590. /**
  94591. * Helper function to add a mesh and its descendants to the list of shadow casters.
  94592. * @param mesh Mesh to add
  94593. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  94594. * @returns the Shadow Generator itself
  94595. */
  94596. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  94597. /**
  94598. * Helper function to remove a mesh and its descendants from the list of shadow casters
  94599. * @param mesh Mesh to remove
  94600. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  94601. * @returns the Shadow Generator itself
  94602. */
  94603. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  94604. /**
  94605. * Controls the extent to which the shadows fade out at the edge of the frustum
  94606. */
  94607. frustumEdgeFalloff: number;
  94608. protected _light: IShadowLight;
  94609. /**
  94610. * Returns the associated light object.
  94611. * @returns the light generating the shadow
  94612. */
  94613. getLight(): IShadowLight;
  94614. /**
  94615. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  94616. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  94617. * It might on the other hand introduce peter panning.
  94618. */
  94619. forceBackFacesOnly: boolean;
  94620. protected _scene: Scene;
  94621. protected _lightDirection: Vector3;
  94622. protected _effect: Effect;
  94623. protected _viewMatrix: Matrix;
  94624. protected _projectionMatrix: Matrix;
  94625. protected _transformMatrix: Matrix;
  94626. protected _cachedPosition: Vector3;
  94627. protected _cachedDirection: Vector3;
  94628. protected _cachedDefines: string;
  94629. protected _currentRenderID: number;
  94630. protected _boxBlurPostprocess: Nullable<PostProcess>;
  94631. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  94632. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  94633. protected _blurPostProcesses: PostProcess[];
  94634. protected _mapSize: number;
  94635. protected _currentFaceIndex: number;
  94636. protected _currentFaceIndexCache: number;
  94637. protected _textureType: number;
  94638. protected _defaultTextureMatrix: Matrix;
  94639. protected _storedUniqueId: Nullable<number>;
  94640. /** @hidden */
  94641. static _SceneComponentInitialization: (scene: Scene) => void;
  94642. /**
  94643. * Creates a ShadowGenerator object.
  94644. * A ShadowGenerator is the required tool to use the shadows.
  94645. * Each light casting shadows needs to use its own ShadowGenerator.
  94646. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  94647. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  94648. * @param light The light object generating the shadows.
  94649. * @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.
  94650. */
  94651. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  94652. protected _initializeGenerator(): void;
  94653. protected _createTargetRenderTexture(): void;
  94654. protected _initializeShadowMap(): void;
  94655. protected _initializeBlurRTTAndPostProcesses(): void;
  94656. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  94657. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  94658. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  94659. protected _applyFilterValues(): void;
  94660. /**
  94661. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  94662. * @param onCompiled Callback triggered at the and of the effects compilation
  94663. * @param options Sets of optional options forcing the compilation with different modes
  94664. */
  94665. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  94666. useInstances: boolean;
  94667. }>): void;
  94668. /**
  94669. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  94670. * @param options Sets of optional options forcing the compilation with different modes
  94671. * @returns A promise that resolves when the compilation completes
  94672. */
  94673. forceCompilationAsync(options?: Partial<{
  94674. useInstances: boolean;
  94675. }>): Promise<void>;
  94676. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  94677. private _prepareShadowDefines;
  94678. /**
  94679. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  94680. * @param subMesh The submesh we want to render in the shadow map
  94681. * @param useInstances Defines wether will draw in the map using instances
  94682. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  94683. * @returns true if ready otherwise, false
  94684. */
  94685. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  94686. /**
  94687. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  94688. * @param defines Defines of the material we want to update
  94689. * @param lightIndex Index of the light in the enabled light list of the material
  94690. */
  94691. prepareDefines(defines: any, lightIndex: number): void;
  94692. /**
  94693. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  94694. * defined in the generator but impacting the effect).
  94695. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  94696. * @param effect The effect we are binfing the information for
  94697. */
  94698. bindShadowLight(lightIndex: string, effect: Effect): void;
  94699. /**
  94700. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  94701. * (eq to shadow prjection matrix * light transform matrix)
  94702. * @returns The transform matrix used to create the shadow map
  94703. */
  94704. getTransformMatrix(): Matrix;
  94705. /**
  94706. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  94707. * Cube and 2D textures for instance.
  94708. */
  94709. recreateShadowMap(): void;
  94710. protected _disposeBlurPostProcesses(): void;
  94711. protected _disposeRTTandPostProcesses(): void;
  94712. /**
  94713. * Disposes the ShadowGenerator.
  94714. * Returns nothing.
  94715. */
  94716. dispose(): void;
  94717. /**
  94718. * Serializes the shadow generator setup to a json object.
  94719. * @returns The serialized JSON object
  94720. */
  94721. serialize(): any;
  94722. /**
  94723. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  94724. * @param parsedShadowGenerator The JSON object to parse
  94725. * @param scene The scene to create the shadow map for
  94726. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  94727. * @returns The parsed shadow generator
  94728. */
  94729. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  94730. }
  94731. }
  94732. declare module BABYLON {
  94733. /**
  94734. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  94735. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  94736. * 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.
  94737. */
  94738. export abstract class Light extends Node {
  94739. /**
  94740. * Falloff Default: light is falling off following the material specification:
  94741. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  94742. */
  94743. static readonly FALLOFF_DEFAULT: number;
  94744. /**
  94745. * Falloff Physical: light is falling off following the inverse squared distance law.
  94746. */
  94747. static readonly FALLOFF_PHYSICAL: number;
  94748. /**
  94749. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  94750. * to enhance interoperability with other engines.
  94751. */
  94752. static readonly FALLOFF_GLTF: number;
  94753. /**
  94754. * Falloff Standard: light is falling off like in the standard material
  94755. * to enhance interoperability with other materials.
  94756. */
  94757. static readonly FALLOFF_STANDARD: number;
  94758. /**
  94759. * If every light affecting the material is in this lightmapMode,
  94760. * material.lightmapTexture adds or multiplies
  94761. * (depends on material.useLightmapAsShadowmap)
  94762. * after every other light calculations.
  94763. */
  94764. static readonly LIGHTMAP_DEFAULT: number;
  94765. /**
  94766. * material.lightmapTexture as only diffuse lighting from this light
  94767. * adds only specular lighting from this light
  94768. * adds dynamic shadows
  94769. */
  94770. static readonly LIGHTMAP_SPECULAR: number;
  94771. /**
  94772. * material.lightmapTexture as only lighting
  94773. * no light calculation from this light
  94774. * only adds dynamic shadows from this light
  94775. */
  94776. static readonly LIGHTMAP_SHADOWSONLY: number;
  94777. /**
  94778. * Each light type uses the default quantity according to its type:
  94779. * point/spot lights use luminous intensity
  94780. * directional lights use illuminance
  94781. */
  94782. static readonly INTENSITYMODE_AUTOMATIC: number;
  94783. /**
  94784. * lumen (lm)
  94785. */
  94786. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  94787. /**
  94788. * candela (lm/sr)
  94789. */
  94790. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  94791. /**
  94792. * lux (lm/m^2)
  94793. */
  94794. static readonly INTENSITYMODE_ILLUMINANCE: number;
  94795. /**
  94796. * nit (cd/m^2)
  94797. */
  94798. static readonly INTENSITYMODE_LUMINANCE: number;
  94799. /**
  94800. * Light type const id of the point light.
  94801. */
  94802. static readonly LIGHTTYPEID_POINTLIGHT: number;
  94803. /**
  94804. * Light type const id of the directional light.
  94805. */
  94806. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  94807. /**
  94808. * Light type const id of the spot light.
  94809. */
  94810. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  94811. /**
  94812. * Light type const id of the hemispheric light.
  94813. */
  94814. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  94815. /**
  94816. * Diffuse gives the basic color to an object.
  94817. */
  94818. diffuse: Color3;
  94819. /**
  94820. * Specular produces a highlight color on an object.
  94821. * Note: This is note affecting PBR materials.
  94822. */
  94823. specular: Color3;
  94824. /**
  94825. * Defines the falloff type for this light. This lets overrriding how punctual light are
  94826. * falling off base on range or angle.
  94827. * This can be set to any values in Light.FALLOFF_x.
  94828. *
  94829. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  94830. * other types of materials.
  94831. */
  94832. falloffType: number;
  94833. /**
  94834. * Strength of the light.
  94835. * Note: By default it is define in the framework own unit.
  94836. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  94837. */
  94838. intensity: number;
  94839. private _range;
  94840. protected _inverseSquaredRange: number;
  94841. /**
  94842. * Defines how far from the source the light is impacting in scene units.
  94843. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  94844. */
  94845. get range(): number;
  94846. /**
  94847. * Defines how far from the source the light is impacting in scene units.
  94848. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  94849. */
  94850. set range(value: number);
  94851. /**
  94852. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  94853. * of light.
  94854. */
  94855. private _photometricScale;
  94856. private _intensityMode;
  94857. /**
  94858. * Gets the photometric scale used to interpret the intensity.
  94859. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  94860. */
  94861. get intensityMode(): number;
  94862. /**
  94863. * Sets the photometric scale used to interpret the intensity.
  94864. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  94865. */
  94866. set intensityMode(value: number);
  94867. private _radius;
  94868. /**
  94869. * Gets the light radius used by PBR Materials to simulate soft area lights.
  94870. */
  94871. get radius(): number;
  94872. /**
  94873. * sets the light radius used by PBR Materials to simulate soft area lights.
  94874. */
  94875. set radius(value: number);
  94876. private _renderPriority;
  94877. /**
  94878. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  94879. * exceeding the number allowed of the materials.
  94880. */
  94881. renderPriority: number;
  94882. private _shadowEnabled;
  94883. /**
  94884. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  94885. * the current shadow generator.
  94886. */
  94887. get shadowEnabled(): boolean;
  94888. /**
  94889. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  94890. * the current shadow generator.
  94891. */
  94892. set shadowEnabled(value: boolean);
  94893. private _includedOnlyMeshes;
  94894. /**
  94895. * Gets the only meshes impacted by this light.
  94896. */
  94897. get includedOnlyMeshes(): AbstractMesh[];
  94898. /**
  94899. * Sets the only meshes impacted by this light.
  94900. */
  94901. set includedOnlyMeshes(value: AbstractMesh[]);
  94902. private _excludedMeshes;
  94903. /**
  94904. * Gets the meshes not impacted by this light.
  94905. */
  94906. get excludedMeshes(): AbstractMesh[];
  94907. /**
  94908. * Sets the meshes not impacted by this light.
  94909. */
  94910. set excludedMeshes(value: AbstractMesh[]);
  94911. private _excludeWithLayerMask;
  94912. /**
  94913. * Gets the layer id use to find what meshes are not impacted by the light.
  94914. * Inactive if 0
  94915. */
  94916. get excludeWithLayerMask(): number;
  94917. /**
  94918. * Sets the layer id use to find what meshes are not impacted by the light.
  94919. * Inactive if 0
  94920. */
  94921. set excludeWithLayerMask(value: number);
  94922. private _includeOnlyWithLayerMask;
  94923. /**
  94924. * Gets the layer id use to find what meshes are impacted by the light.
  94925. * Inactive if 0
  94926. */
  94927. get includeOnlyWithLayerMask(): number;
  94928. /**
  94929. * Sets the layer id use to find what meshes are impacted by the light.
  94930. * Inactive if 0
  94931. */
  94932. set includeOnlyWithLayerMask(value: number);
  94933. private _lightmapMode;
  94934. /**
  94935. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  94936. */
  94937. get lightmapMode(): number;
  94938. /**
  94939. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  94940. */
  94941. set lightmapMode(value: number);
  94942. /**
  94943. * Shadow generator associted to the light.
  94944. * @hidden Internal use only.
  94945. */
  94946. _shadowGenerator: Nullable<IShadowGenerator>;
  94947. /**
  94948. * @hidden Internal use only.
  94949. */
  94950. _excludedMeshesIds: string[];
  94951. /**
  94952. * @hidden Internal use only.
  94953. */
  94954. _includedOnlyMeshesIds: string[];
  94955. /**
  94956. * The current light unifom buffer.
  94957. * @hidden Internal use only.
  94958. */
  94959. _uniformBuffer: UniformBuffer;
  94960. /** @hidden */
  94961. _renderId: number;
  94962. /**
  94963. * Creates a Light object in the scene.
  94964. * Documentation : https://doc.babylonjs.com/babylon101/lights
  94965. * @param name The firendly name of the light
  94966. * @param scene The scene the light belongs too
  94967. */
  94968. constructor(name: string, scene: Scene);
  94969. protected abstract _buildUniformLayout(): void;
  94970. /**
  94971. * Sets the passed Effect "effect" with the Light information.
  94972. * @param effect The effect to update
  94973. * @param lightIndex The index of the light in the effect to update
  94974. * @returns The light
  94975. */
  94976. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  94977. /**
  94978. * Sets the passed Effect "effect" with the Light textures.
  94979. * @param effect The effect to update
  94980. * @param lightIndex The index of the light in the effect to update
  94981. * @returns The light
  94982. */
  94983. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  94984. /**
  94985. * Binds the lights information from the scene to the effect for the given mesh.
  94986. * @param lightIndex Light index
  94987. * @param scene The scene where the light belongs to
  94988. * @param effect The effect we are binding the data to
  94989. * @param useSpecular Defines if specular is supported
  94990. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  94991. */
  94992. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  94993. /**
  94994. * Sets the passed Effect "effect" with the Light information.
  94995. * @param effect The effect to update
  94996. * @param lightDataUniformName The uniform used to store light data (position or direction)
  94997. * @returns The light
  94998. */
  94999. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  95000. /**
  95001. * Returns the string "Light".
  95002. * @returns the class name
  95003. */
  95004. getClassName(): string;
  95005. /** @hidden */
  95006. readonly _isLight: boolean;
  95007. /**
  95008. * Converts the light information to a readable string for debug purpose.
  95009. * @param fullDetails Supports for multiple levels of logging within scene loading
  95010. * @returns the human readable light info
  95011. */
  95012. toString(fullDetails?: boolean): string;
  95013. /** @hidden */
  95014. protected _syncParentEnabledState(): void;
  95015. /**
  95016. * Set the enabled state of this node.
  95017. * @param value - the new enabled state
  95018. */
  95019. setEnabled(value: boolean): void;
  95020. /**
  95021. * Returns the Light associated shadow generator if any.
  95022. * @return the associated shadow generator.
  95023. */
  95024. getShadowGenerator(): Nullable<IShadowGenerator>;
  95025. /**
  95026. * Returns a Vector3, the absolute light position in the World.
  95027. * @returns the world space position of the light
  95028. */
  95029. getAbsolutePosition(): Vector3;
  95030. /**
  95031. * Specifies if the light will affect the passed mesh.
  95032. * @param mesh The mesh to test against the light
  95033. * @return true the mesh is affected otherwise, false.
  95034. */
  95035. canAffectMesh(mesh: AbstractMesh): boolean;
  95036. /**
  95037. * Sort function to order lights for rendering.
  95038. * @param a First Light object to compare to second.
  95039. * @param b Second Light object to compare first.
  95040. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  95041. */
  95042. static CompareLightsPriority(a: Light, b: Light): number;
  95043. /**
  95044. * Releases resources associated with this node.
  95045. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  95046. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  95047. */
  95048. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  95049. /**
  95050. * Returns the light type ID (integer).
  95051. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  95052. */
  95053. getTypeID(): number;
  95054. /**
  95055. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  95056. * @returns the scaled intensity in intensity mode unit
  95057. */
  95058. getScaledIntensity(): number;
  95059. /**
  95060. * Returns a new Light object, named "name", from the current one.
  95061. * @param name The name of the cloned light
  95062. * @param newParent The parent of this light, if it has one
  95063. * @returns the new created light
  95064. */
  95065. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  95066. /**
  95067. * Serializes the current light into a Serialization object.
  95068. * @returns the serialized object.
  95069. */
  95070. serialize(): any;
  95071. /**
  95072. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  95073. * This new light is named "name" and added to the passed scene.
  95074. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  95075. * @param name The friendly name of the light
  95076. * @param scene The scene the new light will belong to
  95077. * @returns the constructor function
  95078. */
  95079. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  95080. /**
  95081. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  95082. * @param parsedLight The JSON representation of the light
  95083. * @param scene The scene to create the parsed light in
  95084. * @returns the created light after parsing
  95085. */
  95086. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  95087. private _hookArrayForExcluded;
  95088. private _hookArrayForIncludedOnly;
  95089. private _resyncMeshes;
  95090. /**
  95091. * Forces the meshes to update their light related information in their rendering used effects
  95092. * @hidden Internal Use Only
  95093. */
  95094. _markMeshesAsLightDirty(): void;
  95095. /**
  95096. * Recomputes the cached photometric scale if needed.
  95097. */
  95098. private _computePhotometricScale;
  95099. /**
  95100. * Returns the Photometric Scale according to the light type and intensity mode.
  95101. */
  95102. private _getPhotometricScale;
  95103. /**
  95104. * Reorder the light in the scene according to their defined priority.
  95105. * @hidden Internal Use Only
  95106. */
  95107. _reorderLightsInScene(): void;
  95108. /**
  95109. * Prepares the list of defines specific to the light type.
  95110. * @param defines the list of defines
  95111. * @param lightIndex defines the index of the light for the effect
  95112. */
  95113. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  95114. }
  95115. }
  95116. declare module BABYLON {
  95117. /**
  95118. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  95119. * This is the base of the follow, arc rotate cameras and Free camera
  95120. * @see http://doc.babylonjs.com/features/cameras
  95121. */
  95122. export class TargetCamera extends Camera {
  95123. private static _RigCamTransformMatrix;
  95124. private static _TargetTransformMatrix;
  95125. private static _TargetFocalPoint;
  95126. /**
  95127. * Define the current direction the camera is moving to
  95128. */
  95129. cameraDirection: Vector3;
  95130. /**
  95131. * Define the current rotation the camera is rotating to
  95132. */
  95133. cameraRotation: Vector2;
  95134. /**
  95135. * When set, the up vector of the camera will be updated by the rotation of the camera
  95136. */
  95137. updateUpVectorFromRotation: boolean;
  95138. private _tmpQuaternion;
  95139. /**
  95140. * Define the current rotation of the camera
  95141. */
  95142. rotation: Vector3;
  95143. /**
  95144. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  95145. */
  95146. rotationQuaternion: Quaternion;
  95147. /**
  95148. * Define the current speed of the camera
  95149. */
  95150. speed: number;
  95151. /**
  95152. * Add constraint to the camera to prevent it to move freely in all directions and
  95153. * around all axis.
  95154. */
  95155. noRotationConstraint: boolean;
  95156. /**
  95157. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  95158. * panning
  95159. */
  95160. invertRotation: boolean;
  95161. /**
  95162. * Speed multiplier for inverse camera panning
  95163. */
  95164. inverseRotationSpeed: number;
  95165. /**
  95166. * Define the current target of the camera as an object or a position.
  95167. */
  95168. lockedTarget: any;
  95169. /** @hidden */
  95170. _currentTarget: Vector3;
  95171. /** @hidden */
  95172. _initialFocalDistance: number;
  95173. /** @hidden */
  95174. _viewMatrix: Matrix;
  95175. /** @hidden */
  95176. _camMatrix: Matrix;
  95177. /** @hidden */
  95178. _cameraTransformMatrix: Matrix;
  95179. /** @hidden */
  95180. _cameraRotationMatrix: Matrix;
  95181. /** @hidden */
  95182. _referencePoint: Vector3;
  95183. /** @hidden */
  95184. _transformedReferencePoint: Vector3;
  95185. protected _globalCurrentTarget: Vector3;
  95186. protected _globalCurrentUpVector: Vector3;
  95187. /** @hidden */
  95188. _reset: () => void;
  95189. private _defaultUp;
  95190. /**
  95191. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  95192. * This is the base of the follow, arc rotate cameras and Free camera
  95193. * @see http://doc.babylonjs.com/features/cameras
  95194. * @param name Defines the name of the camera in the scene
  95195. * @param position Defines the start position of the camera in the scene
  95196. * @param scene Defines the scene the camera belongs to
  95197. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  95198. */
  95199. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  95200. /**
  95201. * Gets the position in front of the camera at a given distance.
  95202. * @param distance The distance from the camera we want the position to be
  95203. * @returns the position
  95204. */
  95205. getFrontPosition(distance: number): Vector3;
  95206. /** @hidden */
  95207. _getLockedTargetPosition(): Nullable<Vector3>;
  95208. private _storedPosition;
  95209. private _storedRotation;
  95210. private _storedRotationQuaternion;
  95211. /**
  95212. * Store current camera state of the camera (fov, position, rotation, etc..)
  95213. * @returns the camera
  95214. */
  95215. storeState(): Camera;
  95216. /**
  95217. * Restored camera state. You must call storeState() first
  95218. * @returns whether it was successful or not
  95219. * @hidden
  95220. */
  95221. _restoreStateValues(): boolean;
  95222. /** @hidden */
  95223. _initCache(): void;
  95224. /** @hidden */
  95225. _updateCache(ignoreParentClass?: boolean): void;
  95226. /** @hidden */
  95227. _isSynchronizedViewMatrix(): boolean;
  95228. /** @hidden */
  95229. _computeLocalCameraSpeed(): number;
  95230. /**
  95231. * Defines the target the camera should look at.
  95232. * @param target Defines the new target as a Vector or a mesh
  95233. */
  95234. setTarget(target: Vector3): void;
  95235. /**
  95236. * Return the current target position of the camera. This value is expressed in local space.
  95237. * @returns the target position
  95238. */
  95239. getTarget(): Vector3;
  95240. /** @hidden */
  95241. _decideIfNeedsToMove(): boolean;
  95242. /** @hidden */
  95243. _updatePosition(): void;
  95244. /** @hidden */
  95245. _checkInputs(): void;
  95246. protected _updateCameraRotationMatrix(): void;
  95247. /**
  95248. * 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)
  95249. * @returns the current camera
  95250. */
  95251. private _rotateUpVectorWithCameraRotationMatrix;
  95252. private _cachedRotationZ;
  95253. private _cachedQuaternionRotationZ;
  95254. /** @hidden */
  95255. _getViewMatrix(): Matrix;
  95256. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  95257. /**
  95258. * @hidden
  95259. */
  95260. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  95261. /**
  95262. * @hidden
  95263. */
  95264. _updateRigCameras(): void;
  95265. private _getRigCamPositionAndTarget;
  95266. /**
  95267. * Gets the current object class name.
  95268. * @return the class name
  95269. */
  95270. getClassName(): string;
  95271. }
  95272. }
  95273. declare module BABYLON {
  95274. /**
  95275. * Gather the list of keyboard event types as constants.
  95276. */
  95277. export class KeyboardEventTypes {
  95278. /**
  95279. * The keydown event is fired when a key becomes active (pressed).
  95280. */
  95281. static readonly KEYDOWN: number;
  95282. /**
  95283. * The keyup event is fired when a key has been released.
  95284. */
  95285. static readonly KEYUP: number;
  95286. }
  95287. /**
  95288. * This class is used to store keyboard related info for the onKeyboardObservable event.
  95289. */
  95290. export class KeyboardInfo {
  95291. /**
  95292. * Defines the type of event (KeyboardEventTypes)
  95293. */
  95294. type: number;
  95295. /**
  95296. * Defines the related dom event
  95297. */
  95298. event: KeyboardEvent;
  95299. /**
  95300. * Instantiates a new keyboard info.
  95301. * This class is used to store keyboard related info for the onKeyboardObservable event.
  95302. * @param type Defines the type of event (KeyboardEventTypes)
  95303. * @param event Defines the related dom event
  95304. */
  95305. constructor(
  95306. /**
  95307. * Defines the type of event (KeyboardEventTypes)
  95308. */
  95309. type: number,
  95310. /**
  95311. * Defines the related dom event
  95312. */
  95313. event: KeyboardEvent);
  95314. }
  95315. /**
  95316. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  95317. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  95318. */
  95319. export class KeyboardInfoPre extends KeyboardInfo {
  95320. /**
  95321. * Defines the type of event (KeyboardEventTypes)
  95322. */
  95323. type: number;
  95324. /**
  95325. * Defines the related dom event
  95326. */
  95327. event: KeyboardEvent;
  95328. /**
  95329. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  95330. */
  95331. skipOnPointerObservable: boolean;
  95332. /**
  95333. * Instantiates a new keyboard pre info.
  95334. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  95335. * @param type Defines the type of event (KeyboardEventTypes)
  95336. * @param event Defines the related dom event
  95337. */
  95338. constructor(
  95339. /**
  95340. * Defines the type of event (KeyboardEventTypes)
  95341. */
  95342. type: number,
  95343. /**
  95344. * Defines the related dom event
  95345. */
  95346. event: KeyboardEvent);
  95347. }
  95348. }
  95349. declare module BABYLON {
  95350. /**
  95351. * Manage the keyboard inputs to control the movement of a free camera.
  95352. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95353. */
  95354. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  95355. /**
  95356. * Defines the camera the input is attached to.
  95357. */
  95358. camera: FreeCamera;
  95359. /**
  95360. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  95361. */
  95362. keysUp: number[];
  95363. /**
  95364. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  95365. */
  95366. keysUpward: number[];
  95367. /**
  95368. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  95369. */
  95370. keysDown: number[];
  95371. /**
  95372. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  95373. */
  95374. keysDownward: number[];
  95375. /**
  95376. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  95377. */
  95378. keysLeft: number[];
  95379. /**
  95380. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  95381. */
  95382. keysRight: number[];
  95383. private _keys;
  95384. private _onCanvasBlurObserver;
  95385. private _onKeyboardObserver;
  95386. private _engine;
  95387. private _scene;
  95388. /**
  95389. * Attach the input controls to a specific dom element to get the input from.
  95390. * @param element Defines the element the controls should be listened from
  95391. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  95392. */
  95393. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95394. /**
  95395. * Detach the current controls from the specified dom element.
  95396. * @param element Defines the element to stop listening the inputs from
  95397. */
  95398. detachControl(element: Nullable<HTMLElement>): void;
  95399. /**
  95400. * Update the current camera state depending on the inputs that have been used this frame.
  95401. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  95402. */
  95403. checkInputs(): void;
  95404. /**
  95405. * Gets the class name of the current intput.
  95406. * @returns the class name
  95407. */
  95408. getClassName(): string;
  95409. /** @hidden */
  95410. _onLostFocus(): void;
  95411. /**
  95412. * Get the friendly name associated with the input class.
  95413. * @returns the input friendly name
  95414. */
  95415. getSimpleName(): string;
  95416. }
  95417. }
  95418. declare module BABYLON {
  95419. /**
  95420. * Gather the list of pointer event types as constants.
  95421. */
  95422. export class PointerEventTypes {
  95423. /**
  95424. * 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.
  95425. */
  95426. static readonly POINTERDOWN: number;
  95427. /**
  95428. * The pointerup event is fired when a pointer is no longer active.
  95429. */
  95430. static readonly POINTERUP: number;
  95431. /**
  95432. * The pointermove event is fired when a pointer changes coordinates.
  95433. */
  95434. static readonly POINTERMOVE: number;
  95435. /**
  95436. * The pointerwheel event is fired when a mouse wheel has been rotated.
  95437. */
  95438. static readonly POINTERWHEEL: number;
  95439. /**
  95440. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  95441. */
  95442. static readonly POINTERPICK: number;
  95443. /**
  95444. * The pointertap event is fired when a the object has been touched and released without drag.
  95445. */
  95446. static readonly POINTERTAP: number;
  95447. /**
  95448. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  95449. */
  95450. static readonly POINTERDOUBLETAP: number;
  95451. }
  95452. /**
  95453. * Base class of pointer info types.
  95454. */
  95455. export class PointerInfoBase {
  95456. /**
  95457. * Defines the type of event (PointerEventTypes)
  95458. */
  95459. type: number;
  95460. /**
  95461. * Defines the related dom event
  95462. */
  95463. event: PointerEvent | MouseWheelEvent;
  95464. /**
  95465. * Instantiates the base class of pointers info.
  95466. * @param type Defines the type of event (PointerEventTypes)
  95467. * @param event Defines the related dom event
  95468. */
  95469. constructor(
  95470. /**
  95471. * Defines the type of event (PointerEventTypes)
  95472. */
  95473. type: number,
  95474. /**
  95475. * Defines the related dom event
  95476. */
  95477. event: PointerEvent | MouseWheelEvent);
  95478. }
  95479. /**
  95480. * This class is used to store pointer related info for the onPrePointerObservable event.
  95481. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  95482. */
  95483. export class PointerInfoPre extends PointerInfoBase {
  95484. /**
  95485. * Ray from a pointer if availible (eg. 6dof controller)
  95486. */
  95487. ray: Nullable<Ray>;
  95488. /**
  95489. * Defines the local position of the pointer on the canvas.
  95490. */
  95491. localPosition: Vector2;
  95492. /**
  95493. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  95494. */
  95495. skipOnPointerObservable: boolean;
  95496. /**
  95497. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  95498. * @param type Defines the type of event (PointerEventTypes)
  95499. * @param event Defines the related dom event
  95500. * @param localX Defines the local x coordinates of the pointer when the event occured
  95501. * @param localY Defines the local y coordinates of the pointer when the event occured
  95502. */
  95503. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  95504. }
  95505. /**
  95506. * This type contains all the data related to a pointer event in Babylon.js.
  95507. * 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.
  95508. */
  95509. export class PointerInfo extends PointerInfoBase {
  95510. /**
  95511. * Defines the picking info associated to the info (if any)\
  95512. */
  95513. pickInfo: Nullable<PickingInfo>;
  95514. /**
  95515. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  95516. * @param type Defines the type of event (PointerEventTypes)
  95517. * @param event Defines the related dom event
  95518. * @param pickInfo Defines the picking info associated to the info (if any)\
  95519. */
  95520. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  95521. /**
  95522. * Defines the picking info associated to the info (if any)\
  95523. */
  95524. pickInfo: Nullable<PickingInfo>);
  95525. }
  95526. /**
  95527. * Data relating to a touch event on the screen.
  95528. */
  95529. export interface PointerTouch {
  95530. /**
  95531. * X coordinate of touch.
  95532. */
  95533. x: number;
  95534. /**
  95535. * Y coordinate of touch.
  95536. */
  95537. y: number;
  95538. /**
  95539. * Id of touch. Unique for each finger.
  95540. */
  95541. pointerId: number;
  95542. /**
  95543. * Event type passed from DOM.
  95544. */
  95545. type: any;
  95546. }
  95547. }
  95548. declare module BABYLON {
  95549. /**
  95550. * Manage the mouse inputs to control the movement of a free camera.
  95551. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95552. */
  95553. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  95554. /**
  95555. * Define if touch is enabled in the mouse input
  95556. */
  95557. touchEnabled: boolean;
  95558. /**
  95559. * Defines the camera the input is attached to.
  95560. */
  95561. camera: FreeCamera;
  95562. /**
  95563. * Defines the buttons associated with the input to handle camera move.
  95564. */
  95565. buttons: number[];
  95566. /**
  95567. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  95568. */
  95569. angularSensibility: number;
  95570. private _pointerInput;
  95571. private _onMouseMove;
  95572. private _observer;
  95573. private previousPosition;
  95574. /**
  95575. * Observable for when a pointer move event occurs containing the move offset
  95576. */
  95577. onPointerMovedObservable: Observable<{
  95578. offsetX: number;
  95579. offsetY: number;
  95580. }>;
  95581. /**
  95582. * @hidden
  95583. * If the camera should be rotated automatically based on pointer movement
  95584. */
  95585. _allowCameraRotation: boolean;
  95586. /**
  95587. * Manage the mouse inputs to control the movement of a free camera.
  95588. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95589. * @param touchEnabled Defines if touch is enabled or not
  95590. */
  95591. constructor(
  95592. /**
  95593. * Define if touch is enabled in the mouse input
  95594. */
  95595. touchEnabled?: boolean);
  95596. /**
  95597. * Attach the input controls to a specific dom element to get the input from.
  95598. * @param element Defines the element the controls should be listened from
  95599. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  95600. */
  95601. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95602. /**
  95603. * Called on JS contextmenu event.
  95604. * Override this method to provide functionality.
  95605. */
  95606. protected onContextMenu(evt: PointerEvent): void;
  95607. /**
  95608. * Detach the current controls from the specified dom element.
  95609. * @param element Defines the element to stop listening the inputs from
  95610. */
  95611. detachControl(element: Nullable<HTMLElement>): void;
  95612. /**
  95613. * Gets the class name of the current intput.
  95614. * @returns the class name
  95615. */
  95616. getClassName(): string;
  95617. /**
  95618. * Get the friendly name associated with the input class.
  95619. * @returns the input friendly name
  95620. */
  95621. getSimpleName(): string;
  95622. }
  95623. }
  95624. declare module BABYLON {
  95625. /**
  95626. * Manage the touch inputs to control the movement of a free camera.
  95627. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95628. */
  95629. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  95630. /**
  95631. * Defines the camera the input is attached to.
  95632. */
  95633. camera: FreeCamera;
  95634. /**
  95635. * Defines the touch sensibility for rotation.
  95636. * The higher the faster.
  95637. */
  95638. touchAngularSensibility: number;
  95639. /**
  95640. * Defines the touch sensibility for move.
  95641. * The higher the faster.
  95642. */
  95643. touchMoveSensibility: number;
  95644. private _offsetX;
  95645. private _offsetY;
  95646. private _pointerPressed;
  95647. private _pointerInput;
  95648. private _observer;
  95649. private _onLostFocus;
  95650. /**
  95651. * Attach the input controls to a specific dom element to get the input from.
  95652. * @param element Defines the element the controls should be listened from
  95653. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  95654. */
  95655. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95656. /**
  95657. * Detach the current controls from the specified dom element.
  95658. * @param element Defines the element to stop listening the inputs from
  95659. */
  95660. detachControl(element: Nullable<HTMLElement>): void;
  95661. /**
  95662. * Update the current camera state depending on the inputs that have been used this frame.
  95663. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  95664. */
  95665. checkInputs(): void;
  95666. /**
  95667. * Gets the class name of the current intput.
  95668. * @returns the class name
  95669. */
  95670. getClassName(): string;
  95671. /**
  95672. * Get the friendly name associated with the input class.
  95673. * @returns the input friendly name
  95674. */
  95675. getSimpleName(): string;
  95676. }
  95677. }
  95678. declare module BABYLON {
  95679. /**
  95680. * Default Inputs manager for the FreeCamera.
  95681. * It groups all the default supported inputs for ease of use.
  95682. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95683. */
  95684. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  95685. /**
  95686. * @hidden
  95687. */
  95688. _mouseInput: Nullable<FreeCameraMouseInput>;
  95689. /**
  95690. * Instantiates a new FreeCameraInputsManager.
  95691. * @param camera Defines the camera the inputs belong to
  95692. */
  95693. constructor(camera: FreeCamera);
  95694. /**
  95695. * Add keyboard input support to the input manager.
  95696. * @returns the current input manager
  95697. */
  95698. addKeyboard(): FreeCameraInputsManager;
  95699. /**
  95700. * Add mouse input support to the input manager.
  95701. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  95702. * @returns the current input manager
  95703. */
  95704. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  95705. /**
  95706. * Removes the mouse input support from the manager
  95707. * @returns the current input manager
  95708. */
  95709. removeMouse(): FreeCameraInputsManager;
  95710. /**
  95711. * Add touch input support to the input manager.
  95712. * @returns the current input manager
  95713. */
  95714. addTouch(): FreeCameraInputsManager;
  95715. /**
  95716. * Remove all attached input methods from a camera
  95717. */
  95718. clear(): void;
  95719. }
  95720. }
  95721. declare module BABYLON {
  95722. /**
  95723. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  95724. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  95725. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  95726. */
  95727. export class FreeCamera extends TargetCamera {
  95728. /**
  95729. * Define the collision ellipsoid of the camera.
  95730. * This is helpful to simulate a camera body like the player body around the camera
  95731. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  95732. */
  95733. ellipsoid: Vector3;
  95734. /**
  95735. * Define an offset for the position of the ellipsoid around the camera.
  95736. * This can be helpful to determine the center of the body near the gravity center of the body
  95737. * instead of its head.
  95738. */
  95739. ellipsoidOffset: Vector3;
  95740. /**
  95741. * Enable or disable collisions of the camera with the rest of the scene objects.
  95742. */
  95743. checkCollisions: boolean;
  95744. /**
  95745. * Enable or disable gravity on the camera.
  95746. */
  95747. applyGravity: boolean;
  95748. /**
  95749. * Define the input manager associated to the camera.
  95750. */
  95751. inputs: FreeCameraInputsManager;
  95752. /**
  95753. * Gets the input sensibility for a mouse input. (default is 2000.0)
  95754. * Higher values reduce sensitivity.
  95755. */
  95756. get angularSensibility(): number;
  95757. /**
  95758. * Sets the input sensibility for a mouse input. (default is 2000.0)
  95759. * Higher values reduce sensitivity.
  95760. */
  95761. set angularSensibility(value: number);
  95762. /**
  95763. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  95764. */
  95765. get keysUp(): number[];
  95766. set keysUp(value: number[]);
  95767. /**
  95768. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  95769. */
  95770. get keysUpward(): number[];
  95771. set keysUpward(value: number[]);
  95772. /**
  95773. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  95774. */
  95775. get keysDown(): number[];
  95776. set keysDown(value: number[]);
  95777. /**
  95778. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  95779. */
  95780. get keysDownward(): number[];
  95781. set keysDownward(value: number[]);
  95782. /**
  95783. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  95784. */
  95785. get keysLeft(): number[];
  95786. set keysLeft(value: number[]);
  95787. /**
  95788. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  95789. */
  95790. get keysRight(): number[];
  95791. set keysRight(value: number[]);
  95792. /**
  95793. * Event raised when the camera collide with a mesh in the scene.
  95794. */
  95795. onCollide: (collidedMesh: AbstractMesh) => void;
  95796. private _collider;
  95797. private _needMoveForGravity;
  95798. private _oldPosition;
  95799. private _diffPosition;
  95800. private _newPosition;
  95801. /** @hidden */
  95802. _localDirection: Vector3;
  95803. /** @hidden */
  95804. _transformedDirection: Vector3;
  95805. /**
  95806. * Instantiates a Free Camera.
  95807. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  95808. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  95809. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  95810. * @param name Define the name of the camera in the scene
  95811. * @param position Define the start position of the camera in the scene
  95812. * @param scene Define the scene the camera belongs to
  95813. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  95814. */
  95815. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  95816. /**
  95817. * Attached controls to the current camera.
  95818. * @param element Defines the element the controls should be listened from
  95819. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  95820. */
  95821. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95822. /**
  95823. * Detach the current controls from the camera.
  95824. * The camera will stop reacting to inputs.
  95825. * @param element Defines the element to stop listening the inputs from
  95826. */
  95827. detachControl(element: HTMLElement): void;
  95828. private _collisionMask;
  95829. /**
  95830. * Define a collision mask to limit the list of object the camera can collide with
  95831. */
  95832. get collisionMask(): number;
  95833. set collisionMask(mask: number);
  95834. /** @hidden */
  95835. _collideWithWorld(displacement: Vector3): void;
  95836. private _onCollisionPositionChange;
  95837. /** @hidden */
  95838. _checkInputs(): void;
  95839. /** @hidden */
  95840. _decideIfNeedsToMove(): boolean;
  95841. /** @hidden */
  95842. _updatePosition(): void;
  95843. /**
  95844. * Destroy the camera and release the current resources hold by it.
  95845. */
  95846. dispose(): void;
  95847. /**
  95848. * Gets the current object class name.
  95849. * @return the class name
  95850. */
  95851. getClassName(): string;
  95852. }
  95853. }
  95854. declare module BABYLON {
  95855. /**
  95856. * Represents a gamepad control stick position
  95857. */
  95858. export class StickValues {
  95859. /**
  95860. * The x component of the control stick
  95861. */
  95862. x: number;
  95863. /**
  95864. * The y component of the control stick
  95865. */
  95866. y: number;
  95867. /**
  95868. * Initializes the gamepad x and y control stick values
  95869. * @param x The x component of the gamepad control stick value
  95870. * @param y The y component of the gamepad control stick value
  95871. */
  95872. constructor(
  95873. /**
  95874. * The x component of the control stick
  95875. */
  95876. x: number,
  95877. /**
  95878. * The y component of the control stick
  95879. */
  95880. y: number);
  95881. }
  95882. /**
  95883. * An interface which manages callbacks for gamepad button changes
  95884. */
  95885. export interface GamepadButtonChanges {
  95886. /**
  95887. * Called when a gamepad has been changed
  95888. */
  95889. changed: boolean;
  95890. /**
  95891. * Called when a gamepad press event has been triggered
  95892. */
  95893. pressChanged: boolean;
  95894. /**
  95895. * Called when a touch event has been triggered
  95896. */
  95897. touchChanged: boolean;
  95898. /**
  95899. * Called when a value has changed
  95900. */
  95901. valueChanged: boolean;
  95902. }
  95903. /**
  95904. * Represents a gamepad
  95905. */
  95906. export class Gamepad {
  95907. /**
  95908. * The id of the gamepad
  95909. */
  95910. id: string;
  95911. /**
  95912. * The index of the gamepad
  95913. */
  95914. index: number;
  95915. /**
  95916. * The browser gamepad
  95917. */
  95918. browserGamepad: any;
  95919. /**
  95920. * Specifies what type of gamepad this represents
  95921. */
  95922. type: number;
  95923. private _leftStick;
  95924. private _rightStick;
  95925. /** @hidden */
  95926. _isConnected: boolean;
  95927. private _leftStickAxisX;
  95928. private _leftStickAxisY;
  95929. private _rightStickAxisX;
  95930. private _rightStickAxisY;
  95931. /**
  95932. * Triggered when the left control stick has been changed
  95933. */
  95934. private _onleftstickchanged;
  95935. /**
  95936. * Triggered when the right control stick has been changed
  95937. */
  95938. private _onrightstickchanged;
  95939. /**
  95940. * Represents a gamepad controller
  95941. */
  95942. static GAMEPAD: number;
  95943. /**
  95944. * Represents a generic controller
  95945. */
  95946. static GENERIC: number;
  95947. /**
  95948. * Represents an XBox controller
  95949. */
  95950. static XBOX: number;
  95951. /**
  95952. * Represents a pose-enabled controller
  95953. */
  95954. static POSE_ENABLED: number;
  95955. /**
  95956. * Represents an Dual Shock controller
  95957. */
  95958. static DUALSHOCK: number;
  95959. /**
  95960. * Specifies whether the left control stick should be Y-inverted
  95961. */
  95962. protected _invertLeftStickY: boolean;
  95963. /**
  95964. * Specifies if the gamepad has been connected
  95965. */
  95966. get isConnected(): boolean;
  95967. /**
  95968. * Initializes the gamepad
  95969. * @param id The id of the gamepad
  95970. * @param index The index of the gamepad
  95971. * @param browserGamepad The browser gamepad
  95972. * @param leftStickX The x component of the left joystick
  95973. * @param leftStickY The y component of the left joystick
  95974. * @param rightStickX The x component of the right joystick
  95975. * @param rightStickY The y component of the right joystick
  95976. */
  95977. constructor(
  95978. /**
  95979. * The id of the gamepad
  95980. */
  95981. id: string,
  95982. /**
  95983. * The index of the gamepad
  95984. */
  95985. index: number,
  95986. /**
  95987. * The browser gamepad
  95988. */
  95989. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  95990. /**
  95991. * Callback triggered when the left joystick has changed
  95992. * @param callback
  95993. */
  95994. onleftstickchanged(callback: (values: StickValues) => void): void;
  95995. /**
  95996. * Callback triggered when the right joystick has changed
  95997. * @param callback
  95998. */
  95999. onrightstickchanged(callback: (values: StickValues) => void): void;
  96000. /**
  96001. * Gets the left joystick
  96002. */
  96003. get leftStick(): StickValues;
  96004. /**
  96005. * Sets the left joystick values
  96006. */
  96007. set leftStick(newValues: StickValues);
  96008. /**
  96009. * Gets the right joystick
  96010. */
  96011. get rightStick(): StickValues;
  96012. /**
  96013. * Sets the right joystick value
  96014. */
  96015. set rightStick(newValues: StickValues);
  96016. /**
  96017. * Updates the gamepad joystick positions
  96018. */
  96019. update(): void;
  96020. /**
  96021. * Disposes the gamepad
  96022. */
  96023. dispose(): void;
  96024. }
  96025. /**
  96026. * Represents a generic gamepad
  96027. */
  96028. export class GenericPad extends Gamepad {
  96029. private _buttons;
  96030. private _onbuttondown;
  96031. private _onbuttonup;
  96032. /**
  96033. * Observable triggered when a button has been pressed
  96034. */
  96035. onButtonDownObservable: Observable<number>;
  96036. /**
  96037. * Observable triggered when a button has been released
  96038. */
  96039. onButtonUpObservable: Observable<number>;
  96040. /**
  96041. * Callback triggered when a button has been pressed
  96042. * @param callback Called when a button has been pressed
  96043. */
  96044. onbuttondown(callback: (buttonPressed: number) => void): void;
  96045. /**
  96046. * Callback triggered when a button has been released
  96047. * @param callback Called when a button has been released
  96048. */
  96049. onbuttonup(callback: (buttonReleased: number) => void): void;
  96050. /**
  96051. * Initializes the generic gamepad
  96052. * @param id The id of the generic gamepad
  96053. * @param index The index of the generic gamepad
  96054. * @param browserGamepad The browser gamepad
  96055. */
  96056. constructor(id: string, index: number, browserGamepad: any);
  96057. private _setButtonValue;
  96058. /**
  96059. * Updates the generic gamepad
  96060. */
  96061. update(): void;
  96062. /**
  96063. * Disposes the generic gamepad
  96064. */
  96065. dispose(): void;
  96066. }
  96067. }
  96068. declare module BABYLON {
  96069. /**
  96070. * Defines the types of pose enabled controllers that are supported
  96071. */
  96072. export enum PoseEnabledControllerType {
  96073. /**
  96074. * HTC Vive
  96075. */
  96076. VIVE = 0,
  96077. /**
  96078. * Oculus Rift
  96079. */
  96080. OCULUS = 1,
  96081. /**
  96082. * Windows mixed reality
  96083. */
  96084. WINDOWS = 2,
  96085. /**
  96086. * Samsung gear VR
  96087. */
  96088. GEAR_VR = 3,
  96089. /**
  96090. * Google Daydream
  96091. */
  96092. DAYDREAM = 4,
  96093. /**
  96094. * Generic
  96095. */
  96096. GENERIC = 5
  96097. }
  96098. /**
  96099. * Defines the MutableGamepadButton interface for the state of a gamepad button
  96100. */
  96101. export interface MutableGamepadButton {
  96102. /**
  96103. * Value of the button/trigger
  96104. */
  96105. value: number;
  96106. /**
  96107. * If the button/trigger is currently touched
  96108. */
  96109. touched: boolean;
  96110. /**
  96111. * If the button/trigger is currently pressed
  96112. */
  96113. pressed: boolean;
  96114. }
  96115. /**
  96116. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  96117. * @hidden
  96118. */
  96119. export interface ExtendedGamepadButton extends GamepadButton {
  96120. /**
  96121. * If the button/trigger is currently pressed
  96122. */
  96123. readonly pressed: boolean;
  96124. /**
  96125. * If the button/trigger is currently touched
  96126. */
  96127. readonly touched: boolean;
  96128. /**
  96129. * Value of the button/trigger
  96130. */
  96131. readonly value: number;
  96132. }
  96133. /** @hidden */
  96134. export interface _GamePadFactory {
  96135. /**
  96136. * Returns whether or not the current gamepad can be created for this type of controller.
  96137. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  96138. * @returns true if it can be created, otherwise false
  96139. */
  96140. canCreate(gamepadInfo: any): boolean;
  96141. /**
  96142. * Creates a new instance of the Gamepad.
  96143. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  96144. * @returns the new gamepad instance
  96145. */
  96146. create(gamepadInfo: any): Gamepad;
  96147. }
  96148. /**
  96149. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  96150. */
  96151. export class PoseEnabledControllerHelper {
  96152. /** @hidden */
  96153. static _ControllerFactories: _GamePadFactory[];
  96154. /** @hidden */
  96155. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  96156. /**
  96157. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  96158. * @param vrGamepad the gamepad to initialized
  96159. * @returns a vr controller of the type the gamepad identified as
  96160. */
  96161. static InitiateController(vrGamepad: any): Gamepad;
  96162. }
  96163. /**
  96164. * Defines the PoseEnabledController object that contains state of a vr capable controller
  96165. */
  96166. export class PoseEnabledController extends Gamepad implements PoseControlled {
  96167. /**
  96168. * If the controller is used in a webXR session
  96169. */
  96170. isXR: boolean;
  96171. private _deviceRoomPosition;
  96172. private _deviceRoomRotationQuaternion;
  96173. /**
  96174. * The device position in babylon space
  96175. */
  96176. devicePosition: Vector3;
  96177. /**
  96178. * The device rotation in babylon space
  96179. */
  96180. deviceRotationQuaternion: Quaternion;
  96181. /**
  96182. * The scale factor of the device in babylon space
  96183. */
  96184. deviceScaleFactor: number;
  96185. /**
  96186. * (Likely devicePosition should be used instead) The device position in its room space
  96187. */
  96188. position: Vector3;
  96189. /**
  96190. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  96191. */
  96192. rotationQuaternion: Quaternion;
  96193. /**
  96194. * The type of controller (Eg. Windows mixed reality)
  96195. */
  96196. controllerType: PoseEnabledControllerType;
  96197. protected _calculatedPosition: Vector3;
  96198. private _calculatedRotation;
  96199. /**
  96200. * The raw pose from the device
  96201. */
  96202. rawPose: DevicePose;
  96203. private _trackPosition;
  96204. private _maxRotationDistFromHeadset;
  96205. private _draggedRoomRotation;
  96206. /**
  96207. * @hidden
  96208. */
  96209. _disableTrackPosition(fixedPosition: Vector3): void;
  96210. /**
  96211. * Internal, the mesh attached to the controller
  96212. * @hidden
  96213. */
  96214. _mesh: Nullable<AbstractMesh>;
  96215. private _poseControlledCamera;
  96216. private _leftHandSystemQuaternion;
  96217. /**
  96218. * Internal, matrix used to convert room space to babylon space
  96219. * @hidden
  96220. */
  96221. _deviceToWorld: Matrix;
  96222. /**
  96223. * Node to be used when casting a ray from the controller
  96224. * @hidden
  96225. */
  96226. _pointingPoseNode: Nullable<TransformNode>;
  96227. /**
  96228. * Name of the child mesh that can be used to cast a ray from the controller
  96229. */
  96230. static readonly POINTING_POSE: string;
  96231. /**
  96232. * Creates a new PoseEnabledController from a gamepad
  96233. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  96234. */
  96235. constructor(browserGamepad: any);
  96236. private _workingMatrix;
  96237. /**
  96238. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  96239. */
  96240. update(): void;
  96241. /**
  96242. * Updates only the pose device and mesh without doing any button event checking
  96243. */
  96244. protected _updatePoseAndMesh(): void;
  96245. /**
  96246. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  96247. * @param poseData raw pose fromthe device
  96248. */
  96249. updateFromDevice(poseData: DevicePose): void;
  96250. /**
  96251. * @hidden
  96252. */
  96253. _meshAttachedObservable: Observable<AbstractMesh>;
  96254. /**
  96255. * Attaches a mesh to the controller
  96256. * @param mesh the mesh to be attached
  96257. */
  96258. attachToMesh(mesh: AbstractMesh): void;
  96259. /**
  96260. * Attaches the controllers mesh to a camera
  96261. * @param camera the camera the mesh should be attached to
  96262. */
  96263. attachToPoseControlledCamera(camera: TargetCamera): void;
  96264. /**
  96265. * Disposes of the controller
  96266. */
  96267. dispose(): void;
  96268. /**
  96269. * The mesh that is attached to the controller
  96270. */
  96271. get mesh(): Nullable<AbstractMesh>;
  96272. /**
  96273. * Gets the ray of the controller in the direction the controller is pointing
  96274. * @param length the length the resulting ray should be
  96275. * @returns a ray in the direction the controller is pointing
  96276. */
  96277. getForwardRay(length?: number): Ray;
  96278. }
  96279. }
  96280. declare module BABYLON {
  96281. /**
  96282. * Defines the WebVRController object that represents controllers tracked in 3D space
  96283. */
  96284. export abstract class WebVRController extends PoseEnabledController {
  96285. /**
  96286. * Internal, the default controller model for the controller
  96287. */
  96288. protected _defaultModel: Nullable<AbstractMesh>;
  96289. /**
  96290. * Fired when the trigger state has changed
  96291. */
  96292. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  96293. /**
  96294. * Fired when the main button state has changed
  96295. */
  96296. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  96297. /**
  96298. * Fired when the secondary button state has changed
  96299. */
  96300. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  96301. /**
  96302. * Fired when the pad state has changed
  96303. */
  96304. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  96305. /**
  96306. * Fired when controllers stick values have changed
  96307. */
  96308. onPadValuesChangedObservable: Observable<StickValues>;
  96309. /**
  96310. * Array of button availible on the controller
  96311. */
  96312. protected _buttons: Array<MutableGamepadButton>;
  96313. private _onButtonStateChange;
  96314. /**
  96315. * Fired when a controller button's state has changed
  96316. * @param callback the callback containing the button that was modified
  96317. */
  96318. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  96319. /**
  96320. * X and Y axis corresponding to the controllers joystick
  96321. */
  96322. pad: StickValues;
  96323. /**
  96324. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  96325. */
  96326. hand: string;
  96327. /**
  96328. * The default controller model for the controller
  96329. */
  96330. get defaultModel(): Nullable<AbstractMesh>;
  96331. /**
  96332. * Creates a new WebVRController from a gamepad
  96333. * @param vrGamepad the gamepad that the WebVRController should be created from
  96334. */
  96335. constructor(vrGamepad: any);
  96336. /**
  96337. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  96338. */
  96339. update(): void;
  96340. /**
  96341. * Function to be called when a button is modified
  96342. */
  96343. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  96344. /**
  96345. * Loads a mesh and attaches it to the controller
  96346. * @param scene the scene the mesh should be added to
  96347. * @param meshLoaded callback for when the mesh has been loaded
  96348. */
  96349. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  96350. private _setButtonValue;
  96351. private _changes;
  96352. private _checkChanges;
  96353. /**
  96354. * Disposes of th webVRCOntroller
  96355. */
  96356. dispose(): void;
  96357. }
  96358. }
  96359. declare module BABYLON {
  96360. /**
  96361. * The HemisphericLight simulates the ambient environment light,
  96362. * so the passed direction is the light reflection direction, not the incoming direction.
  96363. */
  96364. export class HemisphericLight extends Light {
  96365. /**
  96366. * The groundColor is the light in the opposite direction to the one specified during creation.
  96367. * 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.
  96368. */
  96369. groundColor: Color3;
  96370. /**
  96371. * The light reflection direction, not the incoming direction.
  96372. */
  96373. direction: Vector3;
  96374. /**
  96375. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  96376. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  96377. * The HemisphericLight can't cast shadows.
  96378. * Documentation : https://doc.babylonjs.com/babylon101/lights
  96379. * @param name The friendly name of the light
  96380. * @param direction The direction of the light reflection
  96381. * @param scene The scene the light belongs to
  96382. */
  96383. constructor(name: string, direction: Vector3, scene: Scene);
  96384. protected _buildUniformLayout(): void;
  96385. /**
  96386. * Returns the string "HemisphericLight".
  96387. * @return The class name
  96388. */
  96389. getClassName(): string;
  96390. /**
  96391. * Sets the HemisphericLight direction towards the passed target (Vector3).
  96392. * Returns the updated direction.
  96393. * @param target The target the direction should point to
  96394. * @return The computed direction
  96395. */
  96396. setDirectionToTarget(target: Vector3): Vector3;
  96397. /**
  96398. * Returns the shadow generator associated to the light.
  96399. * @returns Always null for hemispheric lights because it does not support shadows.
  96400. */
  96401. getShadowGenerator(): Nullable<IShadowGenerator>;
  96402. /**
  96403. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  96404. * @param effect The effect to update
  96405. * @param lightIndex The index of the light in the effect to update
  96406. * @returns The hemispheric light
  96407. */
  96408. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  96409. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  96410. /**
  96411. * Computes the world matrix of the node
  96412. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  96413. * @param useWasUpdatedFlag defines a reserved property
  96414. * @returns the world matrix
  96415. */
  96416. computeWorldMatrix(): Matrix;
  96417. /**
  96418. * Returns the integer 3.
  96419. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  96420. */
  96421. getTypeID(): number;
  96422. /**
  96423. * Prepares the list of defines specific to the light type.
  96424. * @param defines the list of defines
  96425. * @param lightIndex defines the index of the light for the effect
  96426. */
  96427. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  96428. }
  96429. }
  96430. declare module BABYLON {
  96431. /** @hidden */
  96432. export var vrMultiviewToSingleviewPixelShader: {
  96433. name: string;
  96434. shader: string;
  96435. };
  96436. }
  96437. declare module BABYLON {
  96438. /**
  96439. * Renders to multiple views with a single draw call
  96440. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  96441. */
  96442. export class MultiviewRenderTarget extends RenderTargetTexture {
  96443. /**
  96444. * Creates a multiview render target
  96445. * @param scene scene used with the render target
  96446. * @param size the size of the render target (used for each view)
  96447. */
  96448. constructor(scene: Scene, size?: number | {
  96449. width: number;
  96450. height: number;
  96451. } | {
  96452. ratio: number;
  96453. });
  96454. /**
  96455. * @hidden
  96456. * @param faceIndex the face index, if its a cube texture
  96457. */
  96458. _bindFrameBuffer(faceIndex?: number): void;
  96459. /**
  96460. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  96461. * @returns the view count
  96462. */
  96463. getViewCount(): number;
  96464. }
  96465. }
  96466. declare module BABYLON {
  96467. interface Engine {
  96468. /**
  96469. * Creates a new multiview render target
  96470. * @param width defines the width of the texture
  96471. * @param height defines the height of the texture
  96472. * @returns the created multiview texture
  96473. */
  96474. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  96475. /**
  96476. * Binds a multiview framebuffer to be drawn to
  96477. * @param multiviewTexture texture to bind
  96478. */
  96479. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  96480. }
  96481. interface Camera {
  96482. /**
  96483. * @hidden
  96484. * 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)
  96485. */
  96486. _useMultiviewToSingleView: boolean;
  96487. /**
  96488. * @hidden
  96489. * 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)
  96490. */
  96491. _multiviewTexture: Nullable<RenderTargetTexture>;
  96492. /**
  96493. * @hidden
  96494. * ensures the multiview texture of the camera exists and has the specified width/height
  96495. * @param width height to set on the multiview texture
  96496. * @param height width to set on the multiview texture
  96497. */
  96498. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  96499. }
  96500. interface Scene {
  96501. /** @hidden */
  96502. _transformMatrixR: Matrix;
  96503. /** @hidden */
  96504. _multiviewSceneUbo: Nullable<UniformBuffer>;
  96505. /** @hidden */
  96506. _createMultiviewUbo(): void;
  96507. /** @hidden */
  96508. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  96509. /** @hidden */
  96510. _renderMultiviewToSingleView(camera: Camera): void;
  96511. }
  96512. }
  96513. declare module BABYLON {
  96514. /**
  96515. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  96516. * This will not be used for webXR as it supports displaying texture arrays directly
  96517. */
  96518. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  96519. /**
  96520. * Initializes a VRMultiviewToSingleview
  96521. * @param name name of the post process
  96522. * @param camera camera to be applied to
  96523. * @param scaleFactor scaling factor to the size of the output texture
  96524. */
  96525. constructor(name: string, camera: Camera, scaleFactor: number);
  96526. }
  96527. }
  96528. declare module BABYLON {
  96529. /**
  96530. * Interface used to define additional presentation attributes
  96531. */
  96532. export interface IVRPresentationAttributes {
  96533. /**
  96534. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  96535. */
  96536. highRefreshRate: boolean;
  96537. /**
  96538. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  96539. */
  96540. foveationLevel: number;
  96541. }
  96542. interface Engine {
  96543. /** @hidden */
  96544. _vrDisplay: any;
  96545. /** @hidden */
  96546. _vrSupported: boolean;
  96547. /** @hidden */
  96548. _oldSize: Size;
  96549. /** @hidden */
  96550. _oldHardwareScaleFactor: number;
  96551. /** @hidden */
  96552. _vrExclusivePointerMode: boolean;
  96553. /** @hidden */
  96554. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  96555. /** @hidden */
  96556. _onVRDisplayPointerRestricted: () => void;
  96557. /** @hidden */
  96558. _onVRDisplayPointerUnrestricted: () => void;
  96559. /** @hidden */
  96560. _onVrDisplayConnect: Nullable<(display: any) => void>;
  96561. /** @hidden */
  96562. _onVrDisplayDisconnect: Nullable<() => void>;
  96563. /** @hidden */
  96564. _onVrDisplayPresentChange: Nullable<() => void>;
  96565. /**
  96566. * Observable signaled when VR display mode changes
  96567. */
  96568. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  96569. /**
  96570. * Observable signaled when VR request present is complete
  96571. */
  96572. onVRRequestPresentComplete: Observable<boolean>;
  96573. /**
  96574. * Observable signaled when VR request present starts
  96575. */
  96576. onVRRequestPresentStart: Observable<Engine>;
  96577. /**
  96578. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  96579. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  96580. */
  96581. isInVRExclusivePointerMode: boolean;
  96582. /**
  96583. * Gets a boolean indicating if a webVR device was detected
  96584. * @returns true if a webVR device was detected
  96585. */
  96586. isVRDevicePresent(): boolean;
  96587. /**
  96588. * Gets the current webVR device
  96589. * @returns the current webVR device (or null)
  96590. */
  96591. getVRDevice(): any;
  96592. /**
  96593. * Initializes a webVR display and starts listening to display change events
  96594. * The onVRDisplayChangedObservable will be notified upon these changes
  96595. * @returns A promise containing a VRDisplay and if vr is supported
  96596. */
  96597. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  96598. /** @hidden */
  96599. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  96600. /**
  96601. * Gets or sets the presentation attributes used to configure VR rendering
  96602. */
  96603. vrPresentationAttributes?: IVRPresentationAttributes;
  96604. /**
  96605. * Call this function to switch to webVR mode
  96606. * Will do nothing if webVR is not supported or if there is no webVR device
  96607. * @param options the webvr options provided to the camera. mainly used for multiview
  96608. * @see http://doc.babylonjs.com/how_to/webvr_camera
  96609. */
  96610. enableVR(options: WebVROptions): void;
  96611. /** @hidden */
  96612. _onVRFullScreenTriggered(): void;
  96613. }
  96614. }
  96615. declare module BABYLON {
  96616. /**
  96617. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  96618. * IMPORTANT!! The data is right-hand data.
  96619. * @export
  96620. * @interface DevicePose
  96621. */
  96622. export interface DevicePose {
  96623. /**
  96624. * The position of the device, values in array are [x,y,z].
  96625. */
  96626. readonly position: Nullable<Float32Array>;
  96627. /**
  96628. * The linearVelocity of the device, values in array are [x,y,z].
  96629. */
  96630. readonly linearVelocity: Nullable<Float32Array>;
  96631. /**
  96632. * The linearAcceleration of the device, values in array are [x,y,z].
  96633. */
  96634. readonly linearAcceleration: Nullable<Float32Array>;
  96635. /**
  96636. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  96637. */
  96638. readonly orientation: Nullable<Float32Array>;
  96639. /**
  96640. * The angularVelocity of the device, values in array are [x,y,z].
  96641. */
  96642. readonly angularVelocity: Nullable<Float32Array>;
  96643. /**
  96644. * The angularAcceleration of the device, values in array are [x,y,z].
  96645. */
  96646. readonly angularAcceleration: Nullable<Float32Array>;
  96647. }
  96648. /**
  96649. * Interface representing a pose controlled object in Babylon.
  96650. * A pose controlled object has both regular pose values as well as pose values
  96651. * from an external device such as a VR head mounted display
  96652. */
  96653. export interface PoseControlled {
  96654. /**
  96655. * The position of the object in babylon space.
  96656. */
  96657. position: Vector3;
  96658. /**
  96659. * The rotation quaternion of the object in babylon space.
  96660. */
  96661. rotationQuaternion: Quaternion;
  96662. /**
  96663. * The position of the device in babylon space.
  96664. */
  96665. devicePosition?: Vector3;
  96666. /**
  96667. * The rotation quaternion of the device in babylon space.
  96668. */
  96669. deviceRotationQuaternion: Quaternion;
  96670. /**
  96671. * The raw pose coming from the device.
  96672. */
  96673. rawPose: Nullable<DevicePose>;
  96674. /**
  96675. * The scale of the device to be used when translating from device space to babylon space.
  96676. */
  96677. deviceScaleFactor: number;
  96678. /**
  96679. * Updates the poseControlled values based on the input device pose.
  96680. * @param poseData the pose data to update the object with
  96681. */
  96682. updateFromDevice(poseData: DevicePose): void;
  96683. }
  96684. /**
  96685. * Set of options to customize the webVRCamera
  96686. */
  96687. export interface WebVROptions {
  96688. /**
  96689. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  96690. */
  96691. trackPosition?: boolean;
  96692. /**
  96693. * Sets the scale of the vrDevice in babylon space. (default: 1)
  96694. */
  96695. positionScale?: number;
  96696. /**
  96697. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  96698. */
  96699. displayName?: string;
  96700. /**
  96701. * Should the native controller meshes be initialized. (default: true)
  96702. */
  96703. controllerMeshes?: boolean;
  96704. /**
  96705. * Creating a default HemiLight only on controllers. (default: true)
  96706. */
  96707. defaultLightingOnControllers?: boolean;
  96708. /**
  96709. * If you don't want to use the default VR button of the helper. (default: false)
  96710. */
  96711. useCustomVRButton?: boolean;
  96712. /**
  96713. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  96714. */
  96715. customVRButton?: HTMLButtonElement;
  96716. /**
  96717. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  96718. */
  96719. rayLength?: number;
  96720. /**
  96721. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  96722. */
  96723. defaultHeight?: number;
  96724. /**
  96725. * If multiview should be used if availible (default: false)
  96726. */
  96727. useMultiview?: boolean;
  96728. }
  96729. /**
  96730. * This represents a WebVR camera.
  96731. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  96732. * @example http://doc.babylonjs.com/how_to/webvr_camera
  96733. */
  96734. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  96735. private webVROptions;
  96736. /**
  96737. * @hidden
  96738. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  96739. */
  96740. _vrDevice: any;
  96741. /**
  96742. * The rawPose of the vrDevice.
  96743. */
  96744. rawPose: Nullable<DevicePose>;
  96745. private _onVREnabled;
  96746. private _specsVersion;
  96747. private _attached;
  96748. private _frameData;
  96749. protected _descendants: Array<Node>;
  96750. private _deviceRoomPosition;
  96751. /** @hidden */
  96752. _deviceRoomRotationQuaternion: Quaternion;
  96753. private _standingMatrix;
  96754. /**
  96755. * Represents device position in babylon space.
  96756. */
  96757. devicePosition: Vector3;
  96758. /**
  96759. * Represents device rotation in babylon space.
  96760. */
  96761. deviceRotationQuaternion: Quaternion;
  96762. /**
  96763. * The scale of the device to be used when translating from device space to babylon space.
  96764. */
  96765. deviceScaleFactor: number;
  96766. private _deviceToWorld;
  96767. private _worldToDevice;
  96768. /**
  96769. * References to the webVR controllers for the vrDevice.
  96770. */
  96771. controllers: Array<WebVRController>;
  96772. /**
  96773. * Emits an event when a controller is attached.
  96774. */
  96775. onControllersAttachedObservable: Observable<WebVRController[]>;
  96776. /**
  96777. * Emits an event when a controller's mesh has been loaded;
  96778. */
  96779. onControllerMeshLoadedObservable: Observable<WebVRController>;
  96780. /**
  96781. * Emits an event when the HMD's pose has been updated.
  96782. */
  96783. onPoseUpdatedFromDeviceObservable: Observable<any>;
  96784. private _poseSet;
  96785. /**
  96786. * If the rig cameras be used as parent instead of this camera.
  96787. */
  96788. rigParenting: boolean;
  96789. private _lightOnControllers;
  96790. private _defaultHeight?;
  96791. /**
  96792. * Instantiates a WebVRFreeCamera.
  96793. * @param name The name of the WebVRFreeCamera
  96794. * @param position The starting anchor position for the camera
  96795. * @param scene The scene the camera belongs to
  96796. * @param webVROptions a set of customizable options for the webVRCamera
  96797. */
  96798. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  96799. /**
  96800. * Gets the device distance from the ground in meters.
  96801. * @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.
  96802. */
  96803. deviceDistanceToRoomGround(): number;
  96804. /**
  96805. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  96806. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  96807. */
  96808. useStandingMatrix(callback?: (bool: boolean) => void): void;
  96809. /**
  96810. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  96811. * @returns A promise with a boolean set to if the standing matrix is supported.
  96812. */
  96813. useStandingMatrixAsync(): Promise<boolean>;
  96814. /**
  96815. * Disposes the camera
  96816. */
  96817. dispose(): void;
  96818. /**
  96819. * Gets a vrController by name.
  96820. * @param name The name of the controller to retreive
  96821. * @returns the controller matching the name specified or null if not found
  96822. */
  96823. getControllerByName(name: string): Nullable<WebVRController>;
  96824. private _leftController;
  96825. /**
  96826. * The controller corresponding to the users left hand.
  96827. */
  96828. get leftController(): Nullable<WebVRController>;
  96829. private _rightController;
  96830. /**
  96831. * The controller corresponding to the users right hand.
  96832. */
  96833. get rightController(): Nullable<WebVRController>;
  96834. /**
  96835. * Casts a ray forward from the vrCamera's gaze.
  96836. * @param length Length of the ray (default: 100)
  96837. * @returns the ray corresponding to the gaze
  96838. */
  96839. getForwardRay(length?: number): Ray;
  96840. /**
  96841. * @hidden
  96842. * Updates the camera based on device's frame data
  96843. */
  96844. _checkInputs(): void;
  96845. /**
  96846. * Updates the poseControlled values based on the input device pose.
  96847. * @param poseData Pose coming from the device
  96848. */
  96849. updateFromDevice(poseData: DevicePose): void;
  96850. private _htmlElementAttached;
  96851. private _detachIfAttached;
  96852. /**
  96853. * WebVR's attach control will start broadcasting frames to the device.
  96854. * Note that in certain browsers (chrome for example) this function must be called
  96855. * within a user-interaction callback. Example:
  96856. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  96857. *
  96858. * @param element html element to attach the vrDevice to
  96859. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  96860. */
  96861. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96862. /**
  96863. * Detaches the camera from the html element and disables VR
  96864. *
  96865. * @param element html element to detach from
  96866. */
  96867. detachControl(element: HTMLElement): void;
  96868. /**
  96869. * @returns the name of this class
  96870. */
  96871. getClassName(): string;
  96872. /**
  96873. * Calls resetPose on the vrDisplay
  96874. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  96875. */
  96876. resetToCurrentRotation(): void;
  96877. /**
  96878. * @hidden
  96879. * Updates the rig cameras (left and right eye)
  96880. */
  96881. _updateRigCameras(): void;
  96882. private _workingVector;
  96883. private _oneVector;
  96884. private _workingMatrix;
  96885. private updateCacheCalled;
  96886. private _correctPositionIfNotTrackPosition;
  96887. /**
  96888. * @hidden
  96889. * Updates the cached values of the camera
  96890. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  96891. */
  96892. _updateCache(ignoreParentClass?: boolean): void;
  96893. /**
  96894. * @hidden
  96895. * Get current device position in babylon world
  96896. */
  96897. _computeDevicePosition(): void;
  96898. /**
  96899. * Updates the current device position and rotation in the babylon world
  96900. */
  96901. update(): void;
  96902. /**
  96903. * @hidden
  96904. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  96905. * @returns an identity matrix
  96906. */
  96907. _getViewMatrix(): Matrix;
  96908. private _tmpMatrix;
  96909. /**
  96910. * This function is called by the two RIG cameras.
  96911. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  96912. * @hidden
  96913. */
  96914. _getWebVRViewMatrix(): Matrix;
  96915. /** @hidden */
  96916. _getWebVRProjectionMatrix(): Matrix;
  96917. private _onGamepadConnectedObserver;
  96918. private _onGamepadDisconnectedObserver;
  96919. private _updateCacheWhenTrackingDisabledObserver;
  96920. /**
  96921. * Initializes the controllers and their meshes
  96922. */
  96923. initControllers(): void;
  96924. }
  96925. }
  96926. declare module BABYLON {
  96927. /**
  96928. * "Static Class" containing the most commonly used helper while dealing with material for
  96929. * rendering purpose.
  96930. *
  96931. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  96932. *
  96933. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  96934. */
  96935. export class MaterialHelper {
  96936. /**
  96937. * Bind the current view position to an effect.
  96938. * @param effect The effect to be bound
  96939. * @param scene The scene the eyes position is used from
  96940. * @param variableName name of the shader variable that will hold the eye position
  96941. */
  96942. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  96943. /**
  96944. * Helps preparing the defines values about the UVs in used in the effect.
  96945. * UVs are shared as much as we can accross channels in the shaders.
  96946. * @param texture The texture we are preparing the UVs for
  96947. * @param defines The defines to update
  96948. * @param key The channel key "diffuse", "specular"... used in the shader
  96949. */
  96950. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  96951. /**
  96952. * Binds a texture matrix value to its corrsponding uniform
  96953. * @param texture The texture to bind the matrix for
  96954. * @param uniformBuffer The uniform buffer receivin the data
  96955. * @param key The channel key "diffuse", "specular"... used in the shader
  96956. */
  96957. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  96958. /**
  96959. * Gets the current status of the fog (should it be enabled?)
  96960. * @param mesh defines the mesh to evaluate for fog support
  96961. * @param scene defines the hosting scene
  96962. * @returns true if fog must be enabled
  96963. */
  96964. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  96965. /**
  96966. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  96967. * @param mesh defines the current mesh
  96968. * @param scene defines the current scene
  96969. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  96970. * @param pointsCloud defines if point cloud rendering has to be turned on
  96971. * @param fogEnabled defines if fog has to be turned on
  96972. * @param alphaTest defines if alpha testing has to be turned on
  96973. * @param defines defines the current list of defines
  96974. */
  96975. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  96976. /**
  96977. * Helper used to prepare the list of defines associated with frame values for shader compilation
  96978. * @param scene defines the current scene
  96979. * @param engine defines the current engine
  96980. * @param defines specifies the list of active defines
  96981. * @param useInstances defines if instances have to be turned on
  96982. * @param useClipPlane defines if clip plane have to be turned on
  96983. */
  96984. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  96985. /**
  96986. * Prepares the defines for bones
  96987. * @param mesh The mesh containing the geometry data we will draw
  96988. * @param defines The defines to update
  96989. */
  96990. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  96991. /**
  96992. * Prepares the defines for morph targets
  96993. * @param mesh The mesh containing the geometry data we will draw
  96994. * @param defines The defines to update
  96995. */
  96996. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  96997. /**
  96998. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  96999. * @param mesh The mesh containing the geometry data we will draw
  97000. * @param defines The defines to update
  97001. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  97002. * @param useBones Precise whether bones should be used or not (override mesh info)
  97003. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  97004. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  97005. * @returns false if defines are considered not dirty and have not been checked
  97006. */
  97007. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  97008. /**
  97009. * Prepares the defines related to multiview
  97010. * @param scene The scene we are intending to draw
  97011. * @param defines The defines to update
  97012. */
  97013. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  97014. /**
  97015. * Prepares the defines related to the light information passed in parameter
  97016. * @param scene The scene we are intending to draw
  97017. * @param mesh The mesh the effect is compiling for
  97018. * @param light The light the effect is compiling for
  97019. * @param lightIndex The index of the light
  97020. * @param defines The defines to update
  97021. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  97022. * @param state Defines the current state regarding what is needed (normals, etc...)
  97023. */
  97024. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  97025. needNormals: boolean;
  97026. needRebuild: boolean;
  97027. shadowEnabled: boolean;
  97028. specularEnabled: boolean;
  97029. lightmapMode: boolean;
  97030. }): void;
  97031. /**
  97032. * Prepares the defines related to the light information passed in parameter
  97033. * @param scene The scene we are intending to draw
  97034. * @param mesh The mesh the effect is compiling for
  97035. * @param defines The defines to update
  97036. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  97037. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  97038. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  97039. * @returns true if normals will be required for the rest of the effect
  97040. */
  97041. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  97042. /**
  97043. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  97044. * @param lightIndex defines the light index
  97045. * @param uniformsList The uniform list
  97046. * @param samplersList The sampler list
  97047. * @param projectedLightTexture defines if projected texture must be used
  97048. * @param uniformBuffersList defines an optional list of uniform buffers
  97049. */
  97050. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  97051. /**
  97052. * Prepares the uniforms and samplers list to be used in the effect
  97053. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  97054. * @param samplersList The sampler list
  97055. * @param defines The defines helping in the list generation
  97056. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  97057. */
  97058. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  97059. /**
  97060. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  97061. * @param defines The defines to update while falling back
  97062. * @param fallbacks The authorized effect fallbacks
  97063. * @param maxSimultaneousLights The maximum number of lights allowed
  97064. * @param rank the current rank of the Effect
  97065. * @returns The newly affected rank
  97066. */
  97067. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  97068. private static _TmpMorphInfluencers;
  97069. /**
  97070. * Prepares the list of attributes required for morph targets according to the effect defines.
  97071. * @param attribs The current list of supported attribs
  97072. * @param mesh The mesh to prepare the morph targets attributes for
  97073. * @param influencers The number of influencers
  97074. */
  97075. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  97076. /**
  97077. * Prepares the list of attributes required for morph targets according to the effect defines.
  97078. * @param attribs The current list of supported attribs
  97079. * @param mesh The mesh to prepare the morph targets attributes for
  97080. * @param defines The current Defines of the effect
  97081. */
  97082. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  97083. /**
  97084. * Prepares the list of attributes required for bones according to the effect defines.
  97085. * @param attribs The current list of supported attribs
  97086. * @param mesh The mesh to prepare the bones attributes for
  97087. * @param defines The current Defines of the effect
  97088. * @param fallbacks The current efffect fallback strategy
  97089. */
  97090. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  97091. /**
  97092. * Check and prepare the list of attributes required for instances according to the effect defines.
  97093. * @param attribs The current list of supported attribs
  97094. * @param defines The current MaterialDefines of the effect
  97095. */
  97096. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  97097. /**
  97098. * Add the list of attributes required for instances to the attribs array.
  97099. * @param attribs The current list of supported attribs
  97100. */
  97101. static PushAttributesForInstances(attribs: string[]): void;
  97102. /**
  97103. * Binds the light information to the effect.
  97104. * @param light The light containing the generator
  97105. * @param effect The effect we are binding the data to
  97106. * @param lightIndex The light index in the effect used to render
  97107. */
  97108. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  97109. /**
  97110. * Binds the lights information from the scene to the effect for the given mesh.
  97111. * @param light Light to bind
  97112. * @param lightIndex Light index
  97113. * @param scene The scene where the light belongs to
  97114. * @param effect The effect we are binding the data to
  97115. * @param useSpecular Defines if specular is supported
  97116. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  97117. */
  97118. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  97119. /**
  97120. * Binds the lights information from the scene to the effect for the given mesh.
  97121. * @param scene The scene the lights belongs to
  97122. * @param mesh The mesh we are binding the information to render
  97123. * @param effect The effect we are binding the data to
  97124. * @param defines The generated defines for the effect
  97125. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  97126. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  97127. */
  97128. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  97129. private static _tempFogColor;
  97130. /**
  97131. * Binds the fog information from the scene to the effect for the given mesh.
  97132. * @param scene The scene the lights belongs to
  97133. * @param mesh The mesh we are binding the information to render
  97134. * @param effect The effect we are binding the data to
  97135. * @param linearSpace Defines if the fog effect is applied in linear space
  97136. */
  97137. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  97138. /**
  97139. * Binds the bones information from the mesh to the effect.
  97140. * @param mesh The mesh we are binding the information to render
  97141. * @param effect The effect we are binding the data to
  97142. */
  97143. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  97144. /**
  97145. * Binds the morph targets information from the mesh to the effect.
  97146. * @param abstractMesh The mesh we are binding the information to render
  97147. * @param effect The effect we are binding the data to
  97148. */
  97149. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  97150. /**
  97151. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  97152. * @param defines The generated defines used in the effect
  97153. * @param effect The effect we are binding the data to
  97154. * @param scene The scene we are willing to render with logarithmic scale for
  97155. */
  97156. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  97157. /**
  97158. * Binds the clip plane information from the scene to the effect.
  97159. * @param scene The scene the clip plane information are extracted from
  97160. * @param effect The effect we are binding the data to
  97161. */
  97162. static BindClipPlane(effect: Effect, scene: Scene): void;
  97163. }
  97164. }
  97165. declare module BABYLON {
  97166. /**
  97167. * Block used to expose an input value
  97168. */
  97169. export class InputBlock extends NodeMaterialBlock {
  97170. private _mode;
  97171. private _associatedVariableName;
  97172. private _storedValue;
  97173. private _valueCallback;
  97174. private _type;
  97175. private _animationType;
  97176. /** Gets or set a value used to limit the range of float values */
  97177. min: number;
  97178. /** Gets or set a value used to limit the range of float values */
  97179. max: number;
  97180. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  97181. isBoolean: boolean;
  97182. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  97183. matrixMode: number;
  97184. /** @hidden */
  97185. _systemValue: Nullable<NodeMaterialSystemValues>;
  97186. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  97187. visibleInInspector: boolean;
  97188. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  97189. isConstant: boolean;
  97190. /** Gets or sets the group to use to display this block in the Inspector */
  97191. groupInInspector: string;
  97192. /** Gets an observable raised when the value is changed */
  97193. onValueChangedObservable: Observable<InputBlock>;
  97194. /**
  97195. * Gets or sets the connection point type (default is float)
  97196. */
  97197. get type(): NodeMaterialBlockConnectionPointTypes;
  97198. /**
  97199. * Creates a new InputBlock
  97200. * @param name defines the block name
  97201. * @param target defines the target of that block (Vertex by default)
  97202. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  97203. */
  97204. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  97205. /**
  97206. * Gets the output component
  97207. */
  97208. get output(): NodeMaterialConnectionPoint;
  97209. /**
  97210. * Set the source of this connection point to a vertex attribute
  97211. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  97212. * @returns the current connection point
  97213. */
  97214. setAsAttribute(attributeName?: string): InputBlock;
  97215. /**
  97216. * Set the source of this connection point to a system value
  97217. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  97218. * @returns the current connection point
  97219. */
  97220. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  97221. /**
  97222. * Gets or sets the value of that point.
  97223. * Please note that this value will be ignored if valueCallback is defined
  97224. */
  97225. get value(): any;
  97226. set value(value: any);
  97227. /**
  97228. * Gets or sets a callback used to get the value of that point.
  97229. * Please note that setting this value will force the connection point to ignore the value property
  97230. */
  97231. get valueCallback(): () => any;
  97232. set valueCallback(value: () => any);
  97233. /**
  97234. * Gets or sets the associated variable name in the shader
  97235. */
  97236. get associatedVariableName(): string;
  97237. set associatedVariableName(value: string);
  97238. /** Gets or sets the type of animation applied to the input */
  97239. get animationType(): AnimatedInputBlockTypes;
  97240. set animationType(value: AnimatedInputBlockTypes);
  97241. /**
  97242. * Gets a boolean indicating that this connection point not defined yet
  97243. */
  97244. get isUndefined(): boolean;
  97245. /**
  97246. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  97247. * In this case the connection point name must be the name of the uniform to use.
  97248. * Can only be set on inputs
  97249. */
  97250. get isUniform(): boolean;
  97251. set isUniform(value: boolean);
  97252. /**
  97253. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  97254. * In this case the connection point name must be the name of the attribute to use
  97255. * Can only be set on inputs
  97256. */
  97257. get isAttribute(): boolean;
  97258. set isAttribute(value: boolean);
  97259. /**
  97260. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  97261. * Can only be set on exit points
  97262. */
  97263. get isVarying(): boolean;
  97264. set isVarying(value: boolean);
  97265. /**
  97266. * Gets a boolean indicating that the current connection point is a system value
  97267. */
  97268. get isSystemValue(): boolean;
  97269. /**
  97270. * Gets or sets the current well known value or null if not defined as a system value
  97271. */
  97272. get systemValue(): Nullable<NodeMaterialSystemValues>;
  97273. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  97274. /**
  97275. * Gets the current class name
  97276. * @returns the class name
  97277. */
  97278. getClassName(): string;
  97279. /**
  97280. * Animate the input if animationType !== None
  97281. * @param scene defines the rendering scene
  97282. */
  97283. animate(scene: Scene): void;
  97284. private _emitDefine;
  97285. initialize(state: NodeMaterialBuildState): void;
  97286. /**
  97287. * Set the input block to its default value (based on its type)
  97288. */
  97289. setDefaultValue(): void;
  97290. private _emitConstant;
  97291. /** @hidden */
  97292. get _noContextSwitch(): boolean;
  97293. private _emit;
  97294. /** @hidden */
  97295. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  97296. /** @hidden */
  97297. _transmit(effect: Effect, scene: Scene): void;
  97298. protected _buildBlock(state: NodeMaterialBuildState): void;
  97299. protected _dumpPropertiesCode(): string;
  97300. dispose(): void;
  97301. serialize(): any;
  97302. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  97303. }
  97304. }
  97305. declare module BABYLON {
  97306. /**
  97307. * Enum used to define the compatibility state between two connection points
  97308. */
  97309. export enum NodeMaterialConnectionPointCompatibilityStates {
  97310. /** Points are compatibles */
  97311. Compatible = 0,
  97312. /** Points are incompatible because of their types */
  97313. TypeIncompatible = 1,
  97314. /** Points are incompatible because of their targets (vertex vs fragment) */
  97315. TargetIncompatible = 2
  97316. }
  97317. /**
  97318. * Defines the direction of a connection point
  97319. */
  97320. export enum NodeMaterialConnectionPointDirection {
  97321. /** Input */
  97322. Input = 0,
  97323. /** Output */
  97324. Output = 1
  97325. }
  97326. /**
  97327. * Defines a connection point for a block
  97328. */
  97329. export class NodeMaterialConnectionPoint {
  97330. /** @hidden */
  97331. _ownerBlock: NodeMaterialBlock;
  97332. /** @hidden */
  97333. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  97334. private _endpoints;
  97335. private _associatedVariableName;
  97336. private _direction;
  97337. /** @hidden */
  97338. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  97339. /** @hidden */
  97340. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  97341. private _type;
  97342. /** @hidden */
  97343. _enforceAssociatedVariableName: boolean;
  97344. /** Gets the direction of the point */
  97345. get direction(): NodeMaterialConnectionPointDirection;
  97346. /** Indicates that this connection point needs dual validation before being connected to another point */
  97347. needDualDirectionValidation: boolean;
  97348. /**
  97349. * Gets or sets the additional types supported by this connection point
  97350. */
  97351. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  97352. /**
  97353. * Gets or sets the additional types excluded by this connection point
  97354. */
  97355. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  97356. /**
  97357. * Observable triggered when this point is connected
  97358. */
  97359. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  97360. /**
  97361. * Gets or sets the associated variable name in the shader
  97362. */
  97363. get associatedVariableName(): string;
  97364. set associatedVariableName(value: string);
  97365. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  97366. get innerType(): NodeMaterialBlockConnectionPointTypes;
  97367. /**
  97368. * Gets or sets the connection point type (default is float)
  97369. */
  97370. get type(): NodeMaterialBlockConnectionPointTypes;
  97371. set type(value: NodeMaterialBlockConnectionPointTypes);
  97372. /**
  97373. * Gets or sets the connection point name
  97374. */
  97375. name: string;
  97376. /**
  97377. * Gets or sets the connection point name
  97378. */
  97379. displayName: string;
  97380. /**
  97381. * Gets or sets a boolean indicating that this connection point can be omitted
  97382. */
  97383. isOptional: boolean;
  97384. /**
  97385. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  97386. */
  97387. define: string;
  97388. /** @hidden */
  97389. _prioritizeVertex: boolean;
  97390. private _target;
  97391. /** Gets or sets the target of that connection point */
  97392. get target(): NodeMaterialBlockTargets;
  97393. set target(value: NodeMaterialBlockTargets);
  97394. /**
  97395. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  97396. */
  97397. get isConnected(): boolean;
  97398. /**
  97399. * Gets a boolean indicating that the current point is connected to an input block
  97400. */
  97401. get isConnectedToInputBlock(): boolean;
  97402. /**
  97403. * Gets a the connected input block (if any)
  97404. */
  97405. get connectInputBlock(): Nullable<InputBlock>;
  97406. /** Get the other side of the connection (if any) */
  97407. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  97408. /** Get the block that owns this connection point */
  97409. get ownerBlock(): NodeMaterialBlock;
  97410. /** Get the block connected on the other side of this connection (if any) */
  97411. get sourceBlock(): Nullable<NodeMaterialBlock>;
  97412. /** Get the block connected on the endpoints of this connection (if any) */
  97413. get connectedBlocks(): Array<NodeMaterialBlock>;
  97414. /** Gets the list of connected endpoints */
  97415. get endpoints(): NodeMaterialConnectionPoint[];
  97416. /** Gets a boolean indicating if that output point is connected to at least one input */
  97417. get hasEndpoints(): boolean;
  97418. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  97419. get isConnectedInVertexShader(): boolean;
  97420. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  97421. get isConnectedInFragmentShader(): boolean;
  97422. /**
  97423. * Creates a block suitable to be used as an input for this input point.
  97424. * If null is returned, a block based on the point type will be created.
  97425. * @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
  97426. */
  97427. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  97428. /**
  97429. * Creates a new connection point
  97430. * @param name defines the connection point name
  97431. * @param ownerBlock defines the block hosting this connection point
  97432. * @param direction defines the direction of the connection point
  97433. */
  97434. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  97435. /**
  97436. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  97437. * @returns the class name
  97438. */
  97439. getClassName(): string;
  97440. /**
  97441. * Gets a boolean indicating if the current point can be connected to another point
  97442. * @param connectionPoint defines the other connection point
  97443. * @returns a boolean
  97444. */
  97445. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  97446. /**
  97447. * Gets a number indicating if the current point can be connected to another point
  97448. * @param connectionPoint defines the other connection point
  97449. * @returns a number defining the compatibility state
  97450. */
  97451. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  97452. /**
  97453. * Connect this point to another connection point
  97454. * @param connectionPoint defines the other connection point
  97455. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  97456. * @returns the current connection point
  97457. */
  97458. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  97459. /**
  97460. * Disconnect this point from one of his endpoint
  97461. * @param endpoint defines the other connection point
  97462. * @returns the current connection point
  97463. */
  97464. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  97465. /**
  97466. * Serializes this point in a JSON representation
  97467. * @param isInput defines if the connection point is an input (default is true)
  97468. * @returns the serialized point object
  97469. */
  97470. serialize(isInput?: boolean): any;
  97471. /**
  97472. * Release resources
  97473. */
  97474. dispose(): void;
  97475. }
  97476. }
  97477. declare module BABYLON {
  97478. /**
  97479. * Enum used to define the material modes
  97480. */
  97481. export enum NodeMaterialModes {
  97482. /** Regular material */
  97483. Material = 0,
  97484. /** For post process */
  97485. PostProcess = 1,
  97486. /** For particle system */
  97487. Particle = 2
  97488. }
  97489. }
  97490. declare module BABYLON {
  97491. /**
  97492. * Block used to read a texture from a sampler
  97493. */
  97494. export class TextureBlock extends NodeMaterialBlock {
  97495. private _defineName;
  97496. private _linearDefineName;
  97497. private _gammaDefineName;
  97498. private _tempTextureRead;
  97499. private _samplerName;
  97500. private _transformedUVName;
  97501. private _textureTransformName;
  97502. private _textureInfoName;
  97503. private _mainUVName;
  97504. private _mainUVDefineName;
  97505. private _fragmentOnly;
  97506. /**
  97507. * Gets or sets the texture associated with the node
  97508. */
  97509. texture: Nullable<Texture>;
  97510. /**
  97511. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  97512. */
  97513. convertToGammaSpace: boolean;
  97514. /**
  97515. * Gets or sets a boolean indicating if content needs to be converted to linear space
  97516. */
  97517. convertToLinearSpace: boolean;
  97518. /**
  97519. * Create a new TextureBlock
  97520. * @param name defines the block name
  97521. */
  97522. constructor(name: string, fragmentOnly?: boolean);
  97523. /**
  97524. * Gets the current class name
  97525. * @returns the class name
  97526. */
  97527. getClassName(): string;
  97528. /**
  97529. * Gets the uv input component
  97530. */
  97531. get uv(): NodeMaterialConnectionPoint;
  97532. /**
  97533. * Gets the rgba output component
  97534. */
  97535. get rgba(): NodeMaterialConnectionPoint;
  97536. /**
  97537. * Gets the rgb output component
  97538. */
  97539. get rgb(): NodeMaterialConnectionPoint;
  97540. /**
  97541. * Gets the r output component
  97542. */
  97543. get r(): NodeMaterialConnectionPoint;
  97544. /**
  97545. * Gets the g output component
  97546. */
  97547. get g(): NodeMaterialConnectionPoint;
  97548. /**
  97549. * Gets the b output component
  97550. */
  97551. get b(): NodeMaterialConnectionPoint;
  97552. /**
  97553. * Gets the a output component
  97554. */
  97555. get a(): NodeMaterialConnectionPoint;
  97556. get target(): NodeMaterialBlockTargets;
  97557. autoConfigure(material: NodeMaterial): void;
  97558. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  97559. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  97560. isReady(): boolean;
  97561. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  97562. private get _isMixed();
  97563. private _injectVertexCode;
  97564. private _writeTextureRead;
  97565. private _writeOutput;
  97566. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  97567. protected _dumpPropertiesCode(): string;
  97568. serialize(): any;
  97569. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  97570. }
  97571. }
  97572. declare module BABYLON {
  97573. /** @hidden */
  97574. export var reflectionFunction: {
  97575. name: string;
  97576. shader: string;
  97577. };
  97578. }
  97579. declare module BABYLON {
  97580. /**
  97581. * Base block used to read a reflection texture from a sampler
  97582. */
  97583. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  97584. /** @hidden */
  97585. _define3DName: string;
  97586. /** @hidden */
  97587. _defineCubicName: string;
  97588. /** @hidden */
  97589. _defineExplicitName: string;
  97590. /** @hidden */
  97591. _defineProjectionName: string;
  97592. /** @hidden */
  97593. _defineLocalCubicName: string;
  97594. /** @hidden */
  97595. _defineSphericalName: string;
  97596. /** @hidden */
  97597. _definePlanarName: string;
  97598. /** @hidden */
  97599. _defineEquirectangularName: string;
  97600. /** @hidden */
  97601. _defineMirroredEquirectangularFixedName: string;
  97602. /** @hidden */
  97603. _defineEquirectangularFixedName: string;
  97604. /** @hidden */
  97605. _defineSkyboxName: string;
  97606. /** @hidden */
  97607. _defineOppositeZ: string;
  97608. /** @hidden */
  97609. _cubeSamplerName: string;
  97610. /** @hidden */
  97611. _2DSamplerName: string;
  97612. protected _positionUVWName: string;
  97613. protected _directionWName: string;
  97614. protected _reflectionVectorName: string;
  97615. /** @hidden */
  97616. _reflectionCoordsName: string;
  97617. /** @hidden */
  97618. _reflectionMatrixName: string;
  97619. protected _reflectionColorName: string;
  97620. /**
  97621. * Gets or sets the texture associated with the node
  97622. */
  97623. texture: Nullable<BaseTexture>;
  97624. /**
  97625. * Create a new ReflectionTextureBaseBlock
  97626. * @param name defines the block name
  97627. */
  97628. constructor(name: string);
  97629. /**
  97630. * Gets the current class name
  97631. * @returns the class name
  97632. */
  97633. getClassName(): string;
  97634. /**
  97635. * Gets the world position input component
  97636. */
  97637. abstract get position(): NodeMaterialConnectionPoint;
  97638. /**
  97639. * Gets the world position input component
  97640. */
  97641. abstract get worldPosition(): NodeMaterialConnectionPoint;
  97642. /**
  97643. * Gets the world normal input component
  97644. */
  97645. abstract get worldNormal(): NodeMaterialConnectionPoint;
  97646. /**
  97647. * Gets the world input component
  97648. */
  97649. abstract get world(): NodeMaterialConnectionPoint;
  97650. /**
  97651. * Gets the camera (or eye) position component
  97652. */
  97653. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  97654. /**
  97655. * Gets the view input component
  97656. */
  97657. abstract get view(): NodeMaterialConnectionPoint;
  97658. protected _getTexture(): Nullable<BaseTexture>;
  97659. autoConfigure(material: NodeMaterial): void;
  97660. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  97661. isReady(): boolean;
  97662. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  97663. /**
  97664. * Gets the code to inject in the vertex shader
  97665. * @param state current state of the node material building
  97666. * @returns the shader code
  97667. */
  97668. handleVertexSide(state: NodeMaterialBuildState): string;
  97669. /**
  97670. * Handles the inits for the fragment code path
  97671. * @param state node material build state
  97672. */
  97673. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  97674. /**
  97675. * Generates the reflection coords code for the fragment code path
  97676. * @param worldNormalVarName name of the world normal variable
  97677. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  97678. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  97679. * @returns the shader code
  97680. */
  97681. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  97682. /**
  97683. * Generates the reflection color code for the fragment code path
  97684. * @param lodVarName name of the lod variable
  97685. * @param swizzleLookupTexture swizzle to use for the final color variable
  97686. * @returns the shader code
  97687. */
  97688. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  97689. /**
  97690. * Generates the code corresponding to the connected output points
  97691. * @param state node material build state
  97692. * @param varName name of the variable to output
  97693. * @returns the shader code
  97694. */
  97695. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  97696. protected _buildBlock(state: NodeMaterialBuildState): this;
  97697. protected _dumpPropertiesCode(): string;
  97698. serialize(): any;
  97699. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  97700. }
  97701. }
  97702. declare module BABYLON {
  97703. /**
  97704. * Defines a connection point to be used for points with a custom object type
  97705. */
  97706. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  97707. private _blockType;
  97708. private _blockName;
  97709. private _nameForCheking?;
  97710. /**
  97711. * Creates a new connection point
  97712. * @param name defines the connection point name
  97713. * @param ownerBlock defines the block hosting this connection point
  97714. * @param direction defines the direction of the connection point
  97715. */
  97716. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  97717. /**
  97718. * Gets a number indicating if the current point can be connected to another point
  97719. * @param connectionPoint defines the other connection point
  97720. * @returns a number defining the compatibility state
  97721. */
  97722. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  97723. /**
  97724. * Creates a block suitable to be used as an input for this input point.
  97725. * If null is returned, a block based on the point type will be created.
  97726. * @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
  97727. */
  97728. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  97729. }
  97730. }
  97731. declare module BABYLON {
  97732. /**
  97733. * Enum defining the type of properties that can be edited in the property pages in the NME
  97734. */
  97735. export enum PropertyTypeForEdition {
  97736. /** property is a boolean */
  97737. Boolean = 0,
  97738. /** property is a float */
  97739. Float = 1,
  97740. /** property is a Vector2 */
  97741. Vector2 = 2,
  97742. /** property is a list of values */
  97743. List = 3
  97744. }
  97745. /**
  97746. * Interface that defines an option in a variable of type list
  97747. */
  97748. export interface IEditablePropertyListOption {
  97749. /** label of the option */
  97750. "label": string;
  97751. /** value of the option */
  97752. "value": number;
  97753. }
  97754. /**
  97755. * Interface that defines the options available for an editable property
  97756. */
  97757. export interface IEditablePropertyOption {
  97758. /** min value */
  97759. "min"?: number;
  97760. /** max value */
  97761. "max"?: number;
  97762. /** notifiers: indicates which actions to take when the property is changed */
  97763. "notifiers"?: {
  97764. /** the material should be rebuilt */
  97765. "rebuild"?: boolean;
  97766. /** the preview should be updated */
  97767. "update"?: boolean;
  97768. };
  97769. /** list of the options for a variable of type list */
  97770. "options"?: IEditablePropertyListOption[];
  97771. }
  97772. /**
  97773. * Interface that describes an editable property
  97774. */
  97775. export interface IPropertyDescriptionForEdition {
  97776. /** name of the property */
  97777. "propertyName": string;
  97778. /** display name of the property */
  97779. "displayName": string;
  97780. /** type of the property */
  97781. "type": PropertyTypeForEdition;
  97782. /** group of the property - all properties with the same group value will be displayed in a specific section */
  97783. "groupName": string;
  97784. /** options for the property */
  97785. "options": IEditablePropertyOption;
  97786. }
  97787. /**
  97788. * Decorator that flags a property in a node material block as being editable
  97789. */
  97790. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  97791. }
  97792. declare module BABYLON {
  97793. /**
  97794. * Block used to implement the refraction part of the sub surface module of the PBR material
  97795. */
  97796. export class RefractionBlock extends NodeMaterialBlock {
  97797. /** @hidden */
  97798. _define3DName: string;
  97799. /** @hidden */
  97800. _refractionMatrixName: string;
  97801. /** @hidden */
  97802. _defineLODRefractionAlpha: string;
  97803. /** @hidden */
  97804. _defineLinearSpecularRefraction: string;
  97805. /** @hidden */
  97806. _defineOppositeZ: string;
  97807. /** @hidden */
  97808. _cubeSamplerName: string;
  97809. /** @hidden */
  97810. _2DSamplerName: string;
  97811. /** @hidden */
  97812. _vRefractionMicrosurfaceInfosName: string;
  97813. /** @hidden */
  97814. _vRefractionInfosName: string;
  97815. private _scene;
  97816. /**
  97817. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  97818. * Materials half opaque for instance using refraction could benefit from this control.
  97819. */
  97820. linkRefractionWithTransparency: boolean;
  97821. /**
  97822. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  97823. */
  97824. invertRefractionY: boolean;
  97825. /**
  97826. * Gets or sets the texture associated with the node
  97827. */
  97828. texture: Nullable<BaseTexture>;
  97829. /**
  97830. * Create a new RefractionBlock
  97831. * @param name defines the block name
  97832. */
  97833. constructor(name: string);
  97834. /**
  97835. * Gets the current class name
  97836. * @returns the class name
  97837. */
  97838. getClassName(): string;
  97839. /**
  97840. * Gets the intensity input component
  97841. */
  97842. get intensity(): NodeMaterialConnectionPoint;
  97843. /**
  97844. * Gets the index of refraction input component
  97845. */
  97846. get indexOfRefraction(): NodeMaterialConnectionPoint;
  97847. /**
  97848. * Gets the tint at distance input component
  97849. */
  97850. get tintAtDistance(): NodeMaterialConnectionPoint;
  97851. /**
  97852. * Gets the view input component
  97853. */
  97854. get view(): NodeMaterialConnectionPoint;
  97855. /**
  97856. * Gets the refraction object output component
  97857. */
  97858. get refraction(): NodeMaterialConnectionPoint;
  97859. /**
  97860. * Returns true if the block has a texture
  97861. */
  97862. get hasTexture(): boolean;
  97863. protected _getTexture(): Nullable<BaseTexture>;
  97864. autoConfigure(material: NodeMaterial): void;
  97865. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  97866. isReady(): boolean;
  97867. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  97868. /**
  97869. * Gets the main code of the block (fragment side)
  97870. * @param state current state of the node material building
  97871. * @returns the shader code
  97872. */
  97873. getCode(state: NodeMaterialBuildState): string;
  97874. protected _buildBlock(state: NodeMaterialBuildState): this;
  97875. protected _dumpPropertiesCode(): string;
  97876. serialize(): any;
  97877. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  97878. }
  97879. }
  97880. declare module BABYLON {
  97881. /**
  97882. * Base block used as input for post process
  97883. */
  97884. export class CurrentScreenBlock extends NodeMaterialBlock {
  97885. private _samplerName;
  97886. private _linearDefineName;
  97887. private _gammaDefineName;
  97888. private _mainUVName;
  97889. private _tempTextureRead;
  97890. /**
  97891. * Gets or sets the texture associated with the node
  97892. */
  97893. texture: Nullable<BaseTexture>;
  97894. /**
  97895. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  97896. */
  97897. convertToGammaSpace: boolean;
  97898. /**
  97899. * Gets or sets a boolean indicating if content needs to be converted to linear space
  97900. */
  97901. convertToLinearSpace: boolean;
  97902. /**
  97903. * Create a new CurrentScreenBlock
  97904. * @param name defines the block name
  97905. */
  97906. constructor(name: string);
  97907. /**
  97908. * Gets the current class name
  97909. * @returns the class name
  97910. */
  97911. getClassName(): string;
  97912. /**
  97913. * Gets the uv input component
  97914. */
  97915. get uv(): NodeMaterialConnectionPoint;
  97916. /**
  97917. * Gets the rgba output component
  97918. */
  97919. get rgba(): NodeMaterialConnectionPoint;
  97920. /**
  97921. * Gets the rgb output component
  97922. */
  97923. get rgb(): NodeMaterialConnectionPoint;
  97924. /**
  97925. * Gets the r output component
  97926. */
  97927. get r(): NodeMaterialConnectionPoint;
  97928. /**
  97929. * Gets the g output component
  97930. */
  97931. get g(): NodeMaterialConnectionPoint;
  97932. /**
  97933. * Gets the b output component
  97934. */
  97935. get b(): NodeMaterialConnectionPoint;
  97936. /**
  97937. * Gets the a output component
  97938. */
  97939. get a(): NodeMaterialConnectionPoint;
  97940. /**
  97941. * Initialize the block and prepare the context for build
  97942. * @param state defines the state that will be used for the build
  97943. */
  97944. initialize(state: NodeMaterialBuildState): void;
  97945. get target(): NodeMaterialBlockTargets;
  97946. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  97947. isReady(): boolean;
  97948. private _injectVertexCode;
  97949. private _writeTextureRead;
  97950. private _writeOutput;
  97951. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  97952. serialize(): any;
  97953. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  97954. }
  97955. }
  97956. declare module BABYLON {
  97957. /**
  97958. * Base block used for the particle texture
  97959. */
  97960. export class ParticleTextureBlock extends NodeMaterialBlock {
  97961. private _samplerName;
  97962. private _linearDefineName;
  97963. private _gammaDefineName;
  97964. private _tempTextureRead;
  97965. /**
  97966. * Gets or sets the texture associated with the node
  97967. */
  97968. texture: Nullable<BaseTexture>;
  97969. /**
  97970. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  97971. */
  97972. convertToGammaSpace: boolean;
  97973. /**
  97974. * Gets or sets a boolean indicating if content needs to be converted to linear space
  97975. */
  97976. convertToLinearSpace: boolean;
  97977. /**
  97978. * Create a new ParticleTextureBlock
  97979. * @param name defines the block name
  97980. */
  97981. constructor(name: string);
  97982. /**
  97983. * Gets the current class name
  97984. * @returns the class name
  97985. */
  97986. getClassName(): string;
  97987. /**
  97988. * Gets the uv input component
  97989. */
  97990. get uv(): NodeMaterialConnectionPoint;
  97991. /**
  97992. * Gets the rgba output component
  97993. */
  97994. get rgba(): NodeMaterialConnectionPoint;
  97995. /**
  97996. * Gets the rgb output component
  97997. */
  97998. get rgb(): NodeMaterialConnectionPoint;
  97999. /**
  98000. * Gets the r output component
  98001. */
  98002. get r(): NodeMaterialConnectionPoint;
  98003. /**
  98004. * Gets the g output component
  98005. */
  98006. get g(): NodeMaterialConnectionPoint;
  98007. /**
  98008. * Gets the b output component
  98009. */
  98010. get b(): NodeMaterialConnectionPoint;
  98011. /**
  98012. * Gets the a output component
  98013. */
  98014. get a(): NodeMaterialConnectionPoint;
  98015. /**
  98016. * Initialize the block and prepare the context for build
  98017. * @param state defines the state that will be used for the build
  98018. */
  98019. initialize(state: NodeMaterialBuildState): void;
  98020. autoConfigure(material: NodeMaterial): void;
  98021. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  98022. isReady(): boolean;
  98023. private _writeOutput;
  98024. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  98025. serialize(): any;
  98026. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  98027. }
  98028. }
  98029. declare module BABYLON {
  98030. /**
  98031. * Class used to store shared data between 2 NodeMaterialBuildState
  98032. */
  98033. export class NodeMaterialBuildStateSharedData {
  98034. /**
  98035. * Gets the list of emitted varyings
  98036. */
  98037. temps: string[];
  98038. /**
  98039. * Gets the list of emitted varyings
  98040. */
  98041. varyings: string[];
  98042. /**
  98043. * Gets the varying declaration string
  98044. */
  98045. varyingDeclaration: string;
  98046. /**
  98047. * Input blocks
  98048. */
  98049. inputBlocks: InputBlock[];
  98050. /**
  98051. * Input blocks
  98052. */
  98053. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  98054. /**
  98055. * Bindable blocks (Blocks that need to set data to the effect)
  98056. */
  98057. bindableBlocks: NodeMaterialBlock[];
  98058. /**
  98059. * List of blocks that can provide a compilation fallback
  98060. */
  98061. blocksWithFallbacks: NodeMaterialBlock[];
  98062. /**
  98063. * List of blocks that can provide a define update
  98064. */
  98065. blocksWithDefines: NodeMaterialBlock[];
  98066. /**
  98067. * List of blocks that can provide a repeatable content
  98068. */
  98069. repeatableContentBlocks: NodeMaterialBlock[];
  98070. /**
  98071. * List of blocks that can provide a dynamic list of uniforms
  98072. */
  98073. dynamicUniformBlocks: NodeMaterialBlock[];
  98074. /**
  98075. * List of blocks that can block the isReady function for the material
  98076. */
  98077. blockingBlocks: NodeMaterialBlock[];
  98078. /**
  98079. * Gets the list of animated inputs
  98080. */
  98081. animatedInputs: InputBlock[];
  98082. /**
  98083. * Build Id used to avoid multiple recompilations
  98084. */
  98085. buildId: number;
  98086. /** List of emitted variables */
  98087. variableNames: {
  98088. [key: string]: number;
  98089. };
  98090. /** List of emitted defines */
  98091. defineNames: {
  98092. [key: string]: number;
  98093. };
  98094. /** Should emit comments? */
  98095. emitComments: boolean;
  98096. /** Emit build activity */
  98097. verbose: boolean;
  98098. /** Gets or sets the hosting scene */
  98099. scene: Scene;
  98100. /**
  98101. * Gets the compilation hints emitted at compilation time
  98102. */
  98103. hints: {
  98104. needWorldViewMatrix: boolean;
  98105. needWorldViewProjectionMatrix: boolean;
  98106. needAlphaBlending: boolean;
  98107. needAlphaTesting: boolean;
  98108. };
  98109. /**
  98110. * List of compilation checks
  98111. */
  98112. checks: {
  98113. emitVertex: boolean;
  98114. emitFragment: boolean;
  98115. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  98116. };
  98117. /**
  98118. * Is vertex program allowed to be empty?
  98119. */
  98120. allowEmptyVertexProgram: boolean;
  98121. /** Creates a new shared data */
  98122. constructor();
  98123. /**
  98124. * Emits console errors and exceptions if there is a failing check
  98125. */
  98126. emitErrors(): void;
  98127. }
  98128. }
  98129. declare module BABYLON {
  98130. /**
  98131. * Class used to store node based material build state
  98132. */
  98133. export class NodeMaterialBuildState {
  98134. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  98135. supportUniformBuffers: boolean;
  98136. /**
  98137. * Gets the list of emitted attributes
  98138. */
  98139. attributes: string[];
  98140. /**
  98141. * Gets the list of emitted uniforms
  98142. */
  98143. uniforms: string[];
  98144. /**
  98145. * Gets the list of emitted constants
  98146. */
  98147. constants: string[];
  98148. /**
  98149. * Gets the list of emitted samplers
  98150. */
  98151. samplers: string[];
  98152. /**
  98153. * Gets the list of emitted functions
  98154. */
  98155. functions: {
  98156. [key: string]: string;
  98157. };
  98158. /**
  98159. * Gets the list of emitted extensions
  98160. */
  98161. extensions: {
  98162. [key: string]: string;
  98163. };
  98164. /**
  98165. * Gets the target of the compilation state
  98166. */
  98167. target: NodeMaterialBlockTargets;
  98168. /**
  98169. * Gets the list of emitted counters
  98170. */
  98171. counters: {
  98172. [key: string]: number;
  98173. };
  98174. /**
  98175. * Shared data between multiple NodeMaterialBuildState instances
  98176. */
  98177. sharedData: NodeMaterialBuildStateSharedData;
  98178. /** @hidden */
  98179. _vertexState: NodeMaterialBuildState;
  98180. /** @hidden */
  98181. _attributeDeclaration: string;
  98182. /** @hidden */
  98183. _uniformDeclaration: string;
  98184. /** @hidden */
  98185. _constantDeclaration: string;
  98186. /** @hidden */
  98187. _samplerDeclaration: string;
  98188. /** @hidden */
  98189. _varyingTransfer: string;
  98190. /** @hidden */
  98191. _injectAtEnd: string;
  98192. private _repeatableContentAnchorIndex;
  98193. /** @hidden */
  98194. _builtCompilationString: string;
  98195. /**
  98196. * Gets the emitted compilation strings
  98197. */
  98198. compilationString: string;
  98199. /**
  98200. * Finalize the compilation strings
  98201. * @param state defines the current compilation state
  98202. */
  98203. finalize(state: NodeMaterialBuildState): void;
  98204. /** @hidden */
  98205. get _repeatableContentAnchor(): string;
  98206. /** @hidden */
  98207. _getFreeVariableName(prefix: string): string;
  98208. /** @hidden */
  98209. _getFreeDefineName(prefix: string): string;
  98210. /** @hidden */
  98211. _excludeVariableName(name: string): void;
  98212. /** @hidden */
  98213. _emit2DSampler(name: string): void;
  98214. /** @hidden */
  98215. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  98216. /** @hidden */
  98217. _emitExtension(name: string, extension: string, define?: string): void;
  98218. /** @hidden */
  98219. _emitFunction(name: string, code: string, comments: string): void;
  98220. /** @hidden */
  98221. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  98222. replaceStrings?: {
  98223. search: RegExp;
  98224. replace: string;
  98225. }[];
  98226. repeatKey?: string;
  98227. }): string;
  98228. /** @hidden */
  98229. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  98230. repeatKey?: string;
  98231. removeAttributes?: boolean;
  98232. removeUniforms?: boolean;
  98233. removeVaryings?: boolean;
  98234. removeIfDef?: boolean;
  98235. replaceStrings?: {
  98236. search: RegExp;
  98237. replace: string;
  98238. }[];
  98239. }, storeKey?: string): void;
  98240. /** @hidden */
  98241. _registerTempVariable(name: string): boolean;
  98242. /** @hidden */
  98243. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  98244. /** @hidden */
  98245. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  98246. /** @hidden */
  98247. _emitFloat(value: number): string;
  98248. }
  98249. }
  98250. declare module BABYLON {
  98251. /**
  98252. * Helper class used to generate session unique ID
  98253. */
  98254. export class UniqueIdGenerator {
  98255. private static _UniqueIdCounter;
  98256. /**
  98257. * Gets an unique (relatively to the current scene) Id
  98258. */
  98259. static get UniqueId(): number;
  98260. }
  98261. }
  98262. declare module BABYLON {
  98263. /**
  98264. * Defines a block that can be used inside a node based material
  98265. */
  98266. export class NodeMaterialBlock {
  98267. private _buildId;
  98268. private _buildTarget;
  98269. private _target;
  98270. private _isFinalMerger;
  98271. private _isInput;
  98272. protected _isUnique: boolean;
  98273. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  98274. inputsAreExclusive: boolean;
  98275. /** @hidden */
  98276. _codeVariableName: string;
  98277. /** @hidden */
  98278. _inputs: NodeMaterialConnectionPoint[];
  98279. /** @hidden */
  98280. _outputs: NodeMaterialConnectionPoint[];
  98281. /** @hidden */
  98282. _preparationId: number;
  98283. /**
  98284. * Gets or sets the name of the block
  98285. */
  98286. name: string;
  98287. /**
  98288. * Gets or sets the unique id of the node
  98289. */
  98290. uniqueId: number;
  98291. /**
  98292. * Gets or sets the comments associated with this block
  98293. */
  98294. comments: string;
  98295. /**
  98296. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  98297. */
  98298. get isUnique(): boolean;
  98299. /**
  98300. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  98301. */
  98302. get isFinalMerger(): boolean;
  98303. /**
  98304. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  98305. */
  98306. get isInput(): boolean;
  98307. /**
  98308. * Gets or sets the build Id
  98309. */
  98310. get buildId(): number;
  98311. set buildId(value: number);
  98312. /**
  98313. * Gets or sets the target of the block
  98314. */
  98315. get target(): NodeMaterialBlockTargets;
  98316. set target(value: NodeMaterialBlockTargets);
  98317. /**
  98318. * Gets the list of input points
  98319. */
  98320. get inputs(): NodeMaterialConnectionPoint[];
  98321. /** Gets the list of output points */
  98322. get outputs(): NodeMaterialConnectionPoint[];
  98323. /**
  98324. * Find an input by its name
  98325. * @param name defines the name of the input to look for
  98326. * @returns the input or null if not found
  98327. */
  98328. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  98329. /**
  98330. * Find an output by its name
  98331. * @param name defines the name of the outputto look for
  98332. * @returns the output or null if not found
  98333. */
  98334. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  98335. /**
  98336. * Creates a new NodeMaterialBlock
  98337. * @param name defines the block name
  98338. * @param target defines the target of that block (Vertex by default)
  98339. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  98340. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  98341. */
  98342. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  98343. /**
  98344. * Initialize the block and prepare the context for build
  98345. * @param state defines the state that will be used for the build
  98346. */
  98347. initialize(state: NodeMaterialBuildState): void;
  98348. /**
  98349. * Bind data to effect. Will only be called for blocks with isBindable === true
  98350. * @param effect defines the effect to bind data to
  98351. * @param nodeMaterial defines the hosting NodeMaterial
  98352. * @param mesh defines the mesh that will be rendered
  98353. * @param subMesh defines the submesh that will be rendered
  98354. */
  98355. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  98356. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  98357. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  98358. protected _writeFloat(value: number): string;
  98359. /**
  98360. * Gets the current class name e.g. "NodeMaterialBlock"
  98361. * @returns the class name
  98362. */
  98363. getClassName(): string;
  98364. /**
  98365. * Register a new input. Must be called inside a block constructor
  98366. * @param name defines the connection point name
  98367. * @param type defines the connection point type
  98368. * @param isOptional defines a boolean indicating that this input can be omitted
  98369. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  98370. * @param point an already created connection point. If not provided, create a new one
  98371. * @returns the current block
  98372. */
  98373. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  98374. /**
  98375. * Register a new output. Must be called inside a block constructor
  98376. * @param name defines the connection point name
  98377. * @param type defines the connection point type
  98378. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  98379. * @param point an already created connection point. If not provided, create a new one
  98380. * @returns the current block
  98381. */
  98382. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  98383. /**
  98384. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  98385. * @param forOutput defines an optional connection point to check compatibility with
  98386. * @returns the first available input or null
  98387. */
  98388. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  98389. /**
  98390. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  98391. * @param forBlock defines an optional block to check compatibility with
  98392. * @returns the first available input or null
  98393. */
  98394. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  98395. /**
  98396. * Gets the sibling of the given output
  98397. * @param current defines the current output
  98398. * @returns the next output in the list or null
  98399. */
  98400. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  98401. /**
  98402. * Connect current block with another block
  98403. * @param other defines the block to connect with
  98404. * @param options define the various options to help pick the right connections
  98405. * @returns the current block
  98406. */
  98407. connectTo(other: NodeMaterialBlock, options?: {
  98408. input?: string;
  98409. output?: string;
  98410. outputSwizzle?: string;
  98411. }): this | undefined;
  98412. protected _buildBlock(state: NodeMaterialBuildState): void;
  98413. /**
  98414. * Add uniforms, samplers and uniform buffers at compilation time
  98415. * @param state defines the state to update
  98416. * @param nodeMaterial defines the node material requesting the update
  98417. * @param defines defines the material defines to update
  98418. * @param uniformBuffers defines the list of uniform buffer names
  98419. */
  98420. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  98421. /**
  98422. * Add potential fallbacks if shader compilation fails
  98423. * @param mesh defines the mesh to be rendered
  98424. * @param fallbacks defines the current prioritized list of fallbacks
  98425. */
  98426. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  98427. /**
  98428. * Initialize defines for shader compilation
  98429. * @param mesh defines the mesh to be rendered
  98430. * @param nodeMaterial defines the node material requesting the update
  98431. * @param defines defines the material defines to update
  98432. * @param useInstances specifies that instances should be used
  98433. */
  98434. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  98435. /**
  98436. * Update defines for shader compilation
  98437. * @param mesh defines the mesh to be rendered
  98438. * @param nodeMaterial defines the node material requesting the update
  98439. * @param defines defines the material defines to update
  98440. * @param useInstances specifies that instances should be used
  98441. */
  98442. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  98443. /**
  98444. * Lets the block try to connect some inputs automatically
  98445. * @param material defines the hosting NodeMaterial
  98446. */
  98447. autoConfigure(material: NodeMaterial): void;
  98448. /**
  98449. * Function called when a block is declared as repeatable content generator
  98450. * @param vertexShaderState defines the current compilation state for the vertex shader
  98451. * @param fragmentShaderState defines the current compilation state for the fragment shader
  98452. * @param mesh defines the mesh to be rendered
  98453. * @param defines defines the material defines to update
  98454. */
  98455. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  98456. /**
  98457. * Checks if the block is ready
  98458. * @param mesh defines the mesh to be rendered
  98459. * @param nodeMaterial defines the node material requesting the update
  98460. * @param defines defines the material defines to update
  98461. * @param useInstances specifies that instances should be used
  98462. * @returns true if the block is ready
  98463. */
  98464. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  98465. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  98466. private _processBuild;
  98467. /**
  98468. * Compile the current node and generate the shader code
  98469. * @param state defines the current compilation state (uniforms, samplers, current string)
  98470. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  98471. * @returns true if already built
  98472. */
  98473. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  98474. protected _inputRename(name: string): string;
  98475. protected _outputRename(name: string): string;
  98476. protected _dumpPropertiesCode(): string;
  98477. /** @hidden */
  98478. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  98479. /** @hidden */
  98480. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  98481. /**
  98482. * Clone the current block to a new identical block
  98483. * @param scene defines the hosting scene
  98484. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  98485. * @returns a copy of the current block
  98486. */
  98487. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  98488. /**
  98489. * Serializes this block in a JSON representation
  98490. * @returns the serialized block object
  98491. */
  98492. serialize(): any;
  98493. /** @hidden */
  98494. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  98495. private _deserializePortDisplayNames;
  98496. /**
  98497. * Release resources
  98498. */
  98499. dispose(): void;
  98500. }
  98501. }
  98502. declare module BABYLON {
  98503. /**
  98504. * Base class of materials working in push mode in babylon JS
  98505. * @hidden
  98506. */
  98507. export class PushMaterial extends Material {
  98508. protected _activeEffect: Effect;
  98509. protected _normalMatrix: Matrix;
  98510. /**
  98511. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  98512. * This means that the material can keep using a previous shader while a new one is being compiled.
  98513. * This is mostly used when shader parallel compilation is supported (true by default)
  98514. */
  98515. allowShaderHotSwapping: boolean;
  98516. constructor(name: string, scene: Scene);
  98517. getEffect(): Effect;
  98518. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  98519. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  98520. /**
  98521. * Binds the given world matrix to the active effect
  98522. *
  98523. * @param world the matrix to bind
  98524. */
  98525. bindOnlyWorldMatrix(world: Matrix): void;
  98526. /**
  98527. * Binds the given normal matrix to the active effect
  98528. *
  98529. * @param normalMatrix the matrix to bind
  98530. */
  98531. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  98532. bind(world: Matrix, mesh?: Mesh): void;
  98533. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  98534. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  98535. }
  98536. }
  98537. declare module BABYLON {
  98538. /**
  98539. * Root class for all node material optimizers
  98540. */
  98541. export class NodeMaterialOptimizer {
  98542. /**
  98543. * Function used to optimize a NodeMaterial graph
  98544. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  98545. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  98546. */
  98547. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  98548. }
  98549. }
  98550. declare module BABYLON {
  98551. /**
  98552. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  98553. */
  98554. export class TransformBlock extends NodeMaterialBlock {
  98555. /**
  98556. * Defines the value to use to complement W value to transform it to a Vector4
  98557. */
  98558. complementW: number;
  98559. /**
  98560. * Defines the value to use to complement z value to transform it to a Vector4
  98561. */
  98562. complementZ: number;
  98563. /**
  98564. * Creates a new TransformBlock
  98565. * @param name defines the block name
  98566. */
  98567. constructor(name: string);
  98568. /**
  98569. * Gets the current class name
  98570. * @returns the class name
  98571. */
  98572. getClassName(): string;
  98573. /**
  98574. * Gets the vector input
  98575. */
  98576. get vector(): NodeMaterialConnectionPoint;
  98577. /**
  98578. * Gets the output component
  98579. */
  98580. get output(): NodeMaterialConnectionPoint;
  98581. /**
  98582. * Gets the xyz output component
  98583. */
  98584. get xyz(): NodeMaterialConnectionPoint;
  98585. /**
  98586. * Gets the matrix transform input
  98587. */
  98588. get transform(): NodeMaterialConnectionPoint;
  98589. protected _buildBlock(state: NodeMaterialBuildState): this;
  98590. serialize(): any;
  98591. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  98592. protected _dumpPropertiesCode(): string;
  98593. }
  98594. }
  98595. declare module BABYLON {
  98596. /**
  98597. * Block used to output the vertex position
  98598. */
  98599. export class VertexOutputBlock extends NodeMaterialBlock {
  98600. /**
  98601. * Creates a new VertexOutputBlock
  98602. * @param name defines the block name
  98603. */
  98604. constructor(name: string);
  98605. /**
  98606. * Gets the current class name
  98607. * @returns the class name
  98608. */
  98609. getClassName(): string;
  98610. /**
  98611. * Gets the vector input component
  98612. */
  98613. get vector(): NodeMaterialConnectionPoint;
  98614. protected _buildBlock(state: NodeMaterialBuildState): this;
  98615. }
  98616. }
  98617. declare module BABYLON {
  98618. /**
  98619. * Block used to output the final color
  98620. */
  98621. export class FragmentOutputBlock extends NodeMaterialBlock {
  98622. /**
  98623. * Create a new FragmentOutputBlock
  98624. * @param name defines the block name
  98625. */
  98626. constructor(name: string);
  98627. /**
  98628. * Gets the current class name
  98629. * @returns the class name
  98630. */
  98631. getClassName(): string;
  98632. /**
  98633. * Gets the rgba input component
  98634. */
  98635. get rgba(): NodeMaterialConnectionPoint;
  98636. /**
  98637. * Gets the rgb input component
  98638. */
  98639. get rgb(): NodeMaterialConnectionPoint;
  98640. /**
  98641. * Gets the a input component
  98642. */
  98643. get a(): NodeMaterialConnectionPoint;
  98644. protected _buildBlock(state: NodeMaterialBuildState): this;
  98645. }
  98646. }
  98647. declare module BABYLON {
  98648. /**
  98649. * Block used for the particle ramp gradient section
  98650. */
  98651. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  98652. /**
  98653. * Create a new ParticleRampGradientBlock
  98654. * @param name defines the block name
  98655. */
  98656. constructor(name: string);
  98657. /**
  98658. * Gets the current class name
  98659. * @returns the class name
  98660. */
  98661. getClassName(): string;
  98662. /**
  98663. * Gets the color input component
  98664. */
  98665. get color(): NodeMaterialConnectionPoint;
  98666. /**
  98667. * Gets the rampColor output component
  98668. */
  98669. get rampColor(): NodeMaterialConnectionPoint;
  98670. /**
  98671. * Initialize the block and prepare the context for build
  98672. * @param state defines the state that will be used for the build
  98673. */
  98674. initialize(state: NodeMaterialBuildState): void;
  98675. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  98676. }
  98677. }
  98678. declare module BABYLON {
  98679. /**
  98680. * Block used for the particle blend multiply section
  98681. */
  98682. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  98683. /**
  98684. * Create a new ParticleBlendMultiplyBlock
  98685. * @param name defines the block name
  98686. */
  98687. constructor(name: string);
  98688. /**
  98689. * Gets the current class name
  98690. * @returns the class name
  98691. */
  98692. getClassName(): string;
  98693. /**
  98694. * Gets the color input component
  98695. */
  98696. get color(): NodeMaterialConnectionPoint;
  98697. /**
  98698. * Gets the alphaTexture input component
  98699. */
  98700. get alphaTexture(): NodeMaterialConnectionPoint;
  98701. /**
  98702. * Gets the alphaColor input component
  98703. */
  98704. get alphaColor(): NodeMaterialConnectionPoint;
  98705. /**
  98706. * Gets the blendColor output component
  98707. */
  98708. get blendColor(): NodeMaterialConnectionPoint;
  98709. /**
  98710. * Initialize the block and prepare the context for build
  98711. * @param state defines the state that will be used for the build
  98712. */
  98713. initialize(state: NodeMaterialBuildState): void;
  98714. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  98715. }
  98716. }
  98717. declare module BABYLON {
  98718. /**
  98719. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  98720. */
  98721. export class VectorMergerBlock extends NodeMaterialBlock {
  98722. /**
  98723. * Create a new VectorMergerBlock
  98724. * @param name defines the block name
  98725. */
  98726. constructor(name: string);
  98727. /**
  98728. * Gets the current class name
  98729. * @returns the class name
  98730. */
  98731. getClassName(): string;
  98732. /**
  98733. * Gets the xyz component (input)
  98734. */
  98735. get xyzIn(): NodeMaterialConnectionPoint;
  98736. /**
  98737. * Gets the xy component (input)
  98738. */
  98739. get xyIn(): NodeMaterialConnectionPoint;
  98740. /**
  98741. * Gets the x component (input)
  98742. */
  98743. get x(): NodeMaterialConnectionPoint;
  98744. /**
  98745. * Gets the y component (input)
  98746. */
  98747. get y(): NodeMaterialConnectionPoint;
  98748. /**
  98749. * Gets the z component (input)
  98750. */
  98751. get z(): NodeMaterialConnectionPoint;
  98752. /**
  98753. * Gets the w component (input)
  98754. */
  98755. get w(): NodeMaterialConnectionPoint;
  98756. /**
  98757. * Gets the xyzw component (output)
  98758. */
  98759. get xyzw(): NodeMaterialConnectionPoint;
  98760. /**
  98761. * Gets the xyz component (output)
  98762. */
  98763. get xyzOut(): NodeMaterialConnectionPoint;
  98764. /**
  98765. * Gets the xy component (output)
  98766. */
  98767. get xyOut(): NodeMaterialConnectionPoint;
  98768. /**
  98769. * Gets the xy component (output)
  98770. * @deprecated Please use xyOut instead.
  98771. */
  98772. get xy(): NodeMaterialConnectionPoint;
  98773. /**
  98774. * Gets the xyz component (output)
  98775. * @deprecated Please use xyzOut instead.
  98776. */
  98777. get xyz(): NodeMaterialConnectionPoint;
  98778. protected _buildBlock(state: NodeMaterialBuildState): this;
  98779. }
  98780. }
  98781. declare module BABYLON {
  98782. /**
  98783. * Block used to remap a float from a range to a new one
  98784. */
  98785. export class RemapBlock extends NodeMaterialBlock {
  98786. /**
  98787. * Gets or sets the source range
  98788. */
  98789. sourceRange: Vector2;
  98790. /**
  98791. * Gets or sets the target range
  98792. */
  98793. targetRange: Vector2;
  98794. /**
  98795. * Creates a new RemapBlock
  98796. * @param name defines the block name
  98797. */
  98798. constructor(name: string);
  98799. /**
  98800. * Gets the current class name
  98801. * @returns the class name
  98802. */
  98803. getClassName(): string;
  98804. /**
  98805. * Gets the input component
  98806. */
  98807. get input(): NodeMaterialConnectionPoint;
  98808. /**
  98809. * Gets the source min input component
  98810. */
  98811. get sourceMin(): NodeMaterialConnectionPoint;
  98812. /**
  98813. * Gets the source max input component
  98814. */
  98815. get sourceMax(): NodeMaterialConnectionPoint;
  98816. /**
  98817. * Gets the target min input component
  98818. */
  98819. get targetMin(): NodeMaterialConnectionPoint;
  98820. /**
  98821. * Gets the target max input component
  98822. */
  98823. get targetMax(): NodeMaterialConnectionPoint;
  98824. /**
  98825. * Gets the output component
  98826. */
  98827. get output(): NodeMaterialConnectionPoint;
  98828. protected _buildBlock(state: NodeMaterialBuildState): this;
  98829. protected _dumpPropertiesCode(): string;
  98830. serialize(): any;
  98831. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  98832. }
  98833. }
  98834. declare module BABYLON {
  98835. /**
  98836. * Block used to multiply 2 values
  98837. */
  98838. export class MultiplyBlock extends NodeMaterialBlock {
  98839. /**
  98840. * Creates a new MultiplyBlock
  98841. * @param name defines the block name
  98842. */
  98843. constructor(name: string);
  98844. /**
  98845. * Gets the current class name
  98846. * @returns the class name
  98847. */
  98848. getClassName(): string;
  98849. /**
  98850. * Gets the left operand input component
  98851. */
  98852. get left(): NodeMaterialConnectionPoint;
  98853. /**
  98854. * Gets the right operand input component
  98855. */
  98856. get right(): NodeMaterialConnectionPoint;
  98857. /**
  98858. * Gets the output component
  98859. */
  98860. get output(): NodeMaterialConnectionPoint;
  98861. protected _buildBlock(state: NodeMaterialBuildState): this;
  98862. }
  98863. }
  98864. declare module BABYLON {
  98865. /**
  98866. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  98867. */
  98868. export class ColorSplitterBlock extends NodeMaterialBlock {
  98869. /**
  98870. * Create a new ColorSplitterBlock
  98871. * @param name defines the block name
  98872. */
  98873. constructor(name: string);
  98874. /**
  98875. * Gets the current class name
  98876. * @returns the class name
  98877. */
  98878. getClassName(): string;
  98879. /**
  98880. * Gets the rgba component (input)
  98881. */
  98882. get rgba(): NodeMaterialConnectionPoint;
  98883. /**
  98884. * Gets the rgb component (input)
  98885. */
  98886. get rgbIn(): NodeMaterialConnectionPoint;
  98887. /**
  98888. * Gets the rgb component (output)
  98889. */
  98890. get rgbOut(): NodeMaterialConnectionPoint;
  98891. /**
  98892. * Gets the r component (output)
  98893. */
  98894. get r(): NodeMaterialConnectionPoint;
  98895. /**
  98896. * Gets the g component (output)
  98897. */
  98898. get g(): NodeMaterialConnectionPoint;
  98899. /**
  98900. * Gets the b component (output)
  98901. */
  98902. get b(): NodeMaterialConnectionPoint;
  98903. /**
  98904. * Gets the a component (output)
  98905. */
  98906. get a(): NodeMaterialConnectionPoint;
  98907. protected _inputRename(name: string): string;
  98908. protected _outputRename(name: string): string;
  98909. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  98910. }
  98911. }
  98912. declare module BABYLON {
  98913. /**
  98914. * Interface used to configure the node material editor
  98915. */
  98916. export interface INodeMaterialEditorOptions {
  98917. /** Define the URl to load node editor script */
  98918. editorURL?: string;
  98919. }
  98920. /** @hidden */
  98921. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  98922. NORMAL: boolean;
  98923. TANGENT: boolean;
  98924. UV1: boolean;
  98925. /** BONES */
  98926. NUM_BONE_INFLUENCERS: number;
  98927. BonesPerMesh: number;
  98928. BONETEXTURE: boolean;
  98929. /** MORPH TARGETS */
  98930. MORPHTARGETS: boolean;
  98931. MORPHTARGETS_NORMAL: boolean;
  98932. MORPHTARGETS_TANGENT: boolean;
  98933. MORPHTARGETS_UV: boolean;
  98934. NUM_MORPH_INFLUENCERS: number;
  98935. /** IMAGE PROCESSING */
  98936. IMAGEPROCESSING: boolean;
  98937. VIGNETTE: boolean;
  98938. VIGNETTEBLENDMODEMULTIPLY: boolean;
  98939. VIGNETTEBLENDMODEOPAQUE: boolean;
  98940. TONEMAPPING: boolean;
  98941. TONEMAPPING_ACES: boolean;
  98942. CONTRAST: boolean;
  98943. EXPOSURE: boolean;
  98944. COLORCURVES: boolean;
  98945. COLORGRADING: boolean;
  98946. COLORGRADING3D: boolean;
  98947. SAMPLER3DGREENDEPTH: boolean;
  98948. SAMPLER3DBGRMAP: boolean;
  98949. IMAGEPROCESSINGPOSTPROCESS: boolean;
  98950. /** MISC. */
  98951. BUMPDIRECTUV: number;
  98952. constructor();
  98953. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  98954. }
  98955. /**
  98956. * Class used to configure NodeMaterial
  98957. */
  98958. export interface INodeMaterialOptions {
  98959. /**
  98960. * Defines if blocks should emit comments
  98961. */
  98962. emitComments: boolean;
  98963. }
  98964. /**
  98965. * Class used to create a node based material built by assembling shader blocks
  98966. */
  98967. export class NodeMaterial extends PushMaterial {
  98968. private static _BuildIdGenerator;
  98969. private _options;
  98970. private _vertexCompilationState;
  98971. private _fragmentCompilationState;
  98972. private _sharedData;
  98973. private _buildId;
  98974. private _buildWasSuccessful;
  98975. private _cachedWorldViewMatrix;
  98976. private _cachedWorldViewProjectionMatrix;
  98977. private _optimizers;
  98978. private _animationFrame;
  98979. /** Define the Url to load node editor script */
  98980. static EditorURL: string;
  98981. /** Define the Url to load snippets */
  98982. static SnippetUrl: string;
  98983. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  98984. static IgnoreTexturesAtLoadTime: boolean;
  98985. private BJSNODEMATERIALEDITOR;
  98986. /** Get the inspector from bundle or global */
  98987. private _getGlobalNodeMaterialEditor;
  98988. /**
  98989. * Snippet ID if the material was created from the snippet server
  98990. */
  98991. snippetId: string;
  98992. /**
  98993. * Gets or sets data used by visual editor
  98994. * @see https://nme.babylonjs.com
  98995. */
  98996. editorData: any;
  98997. /**
  98998. * 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)
  98999. */
  99000. ignoreAlpha: boolean;
  99001. /**
  99002. * Defines the maximum number of lights that can be used in the material
  99003. */
  99004. maxSimultaneousLights: number;
  99005. /**
  99006. * Observable raised when the material is built
  99007. */
  99008. onBuildObservable: Observable<NodeMaterial>;
  99009. /**
  99010. * Gets or sets the root nodes of the material vertex shader
  99011. */
  99012. _vertexOutputNodes: NodeMaterialBlock[];
  99013. /**
  99014. * Gets or sets the root nodes of the material fragment (pixel) shader
  99015. */
  99016. _fragmentOutputNodes: NodeMaterialBlock[];
  99017. /** Gets or sets options to control the node material overall behavior */
  99018. get options(): INodeMaterialOptions;
  99019. set options(options: INodeMaterialOptions);
  99020. /**
  99021. * Default configuration related to image processing available in the standard Material.
  99022. */
  99023. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  99024. /**
  99025. * Gets the image processing configuration used either in this material.
  99026. */
  99027. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  99028. /**
  99029. * Sets the Default image processing configuration used either in the this material.
  99030. *
  99031. * If sets to null, the scene one is in use.
  99032. */
  99033. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  99034. /**
  99035. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  99036. */
  99037. attachedBlocks: NodeMaterialBlock[];
  99038. /**
  99039. * Specifies the mode of the node material
  99040. * @hidden
  99041. */
  99042. _mode: NodeMaterialModes;
  99043. /**
  99044. * Gets the mode property
  99045. */
  99046. get mode(): NodeMaterialModes;
  99047. /**
  99048. * Create a new node based material
  99049. * @param name defines the material name
  99050. * @param scene defines the hosting scene
  99051. * @param options defines creation option
  99052. */
  99053. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  99054. /**
  99055. * Gets the current class name of the material e.g. "NodeMaterial"
  99056. * @returns the class name
  99057. */
  99058. getClassName(): string;
  99059. /**
  99060. * Keep track of the image processing observer to allow dispose and replace.
  99061. */
  99062. private _imageProcessingObserver;
  99063. /**
  99064. * Attaches a new image processing configuration to the Standard Material.
  99065. * @param configuration
  99066. */
  99067. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  99068. /**
  99069. * Get a block by its name
  99070. * @param name defines the name of the block to retrieve
  99071. * @returns the required block or null if not found
  99072. */
  99073. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  99074. /**
  99075. * Get a block by its name
  99076. * @param predicate defines the predicate used to find the good candidate
  99077. * @returns the required block or null if not found
  99078. */
  99079. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  99080. /**
  99081. * Get an input block by its name
  99082. * @param predicate defines the predicate used to find the good candidate
  99083. * @returns the required input block or null if not found
  99084. */
  99085. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  99086. /**
  99087. * Gets the list of input blocks attached to this material
  99088. * @returns an array of InputBlocks
  99089. */
  99090. getInputBlocks(): InputBlock[];
  99091. /**
  99092. * Adds a new optimizer to the list of optimizers
  99093. * @param optimizer defines the optimizers to add
  99094. * @returns the current material
  99095. */
  99096. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  99097. /**
  99098. * Remove an optimizer from the list of optimizers
  99099. * @param optimizer defines the optimizers to remove
  99100. * @returns the current material
  99101. */
  99102. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  99103. /**
  99104. * Add a new block to the list of output nodes
  99105. * @param node defines the node to add
  99106. * @returns the current material
  99107. */
  99108. addOutputNode(node: NodeMaterialBlock): this;
  99109. /**
  99110. * Remove a block from the list of root nodes
  99111. * @param node defines the node to remove
  99112. * @returns the current material
  99113. */
  99114. removeOutputNode(node: NodeMaterialBlock): this;
  99115. private _addVertexOutputNode;
  99116. private _removeVertexOutputNode;
  99117. private _addFragmentOutputNode;
  99118. private _removeFragmentOutputNode;
  99119. /**
  99120. * Specifies if the material will require alpha blending
  99121. * @returns a boolean specifying if alpha blending is needed
  99122. */
  99123. needAlphaBlending(): boolean;
  99124. /**
  99125. * Specifies if this material should be rendered in alpha test mode
  99126. * @returns a boolean specifying if an alpha test is needed.
  99127. */
  99128. needAlphaTesting(): boolean;
  99129. private _initializeBlock;
  99130. private _resetDualBlocks;
  99131. /**
  99132. * Remove a block from the current node material
  99133. * @param block defines the block to remove
  99134. */
  99135. removeBlock(block: NodeMaterialBlock): void;
  99136. /**
  99137. * Build the material and generates the inner effect
  99138. * @param verbose defines if the build should log activity
  99139. */
  99140. build(verbose?: boolean): void;
  99141. /**
  99142. * Runs an otpimization phase to try to improve the shader code
  99143. */
  99144. optimize(): void;
  99145. private _prepareDefinesForAttributes;
  99146. /**
  99147. * Create a post process from the material
  99148. * @param camera The camera to apply the render pass to.
  99149. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  99150. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  99151. * @param engine The engine which the post process will be applied. (default: current engine)
  99152. * @param reusable If the post process can be reused on the same frame. (default: false)
  99153. * @param textureType Type of textures used when performing the post process. (default: 0)
  99154. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  99155. * @returns the post process created
  99156. */
  99157. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): PostProcess;
  99158. /**
  99159. * Create the post process effect from the material
  99160. * @param postProcess The post process to create the effect for
  99161. */
  99162. createEffectForPostProcess(postProcess: PostProcess): void;
  99163. private _createEffectOrPostProcess;
  99164. private _createEffectForParticles;
  99165. /**
  99166. * Create the effect to be used as the custom effect for a particle system
  99167. * @param particleSystem Particle system to create the effect for
  99168. * @param onCompiled defines a function to call when the effect creation is successful
  99169. * @param onError defines a function to call when the effect creation has failed
  99170. */
  99171. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  99172. private _processDefines;
  99173. /**
  99174. * Get if the submesh is ready to be used and all its information available.
  99175. * Child classes can use it to update shaders
  99176. * @param mesh defines the mesh to check
  99177. * @param subMesh defines which submesh to check
  99178. * @param useInstances specifies that instances should be used
  99179. * @returns a boolean indicating that the submesh is ready or not
  99180. */
  99181. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  99182. /**
  99183. * Get a string representing the shaders built by the current node graph
  99184. */
  99185. get compiledShaders(): string;
  99186. /**
  99187. * Binds the world matrix to the material
  99188. * @param world defines the world transformation matrix
  99189. */
  99190. bindOnlyWorldMatrix(world: Matrix): void;
  99191. /**
  99192. * Binds the submesh to this material by preparing the effect and shader to draw
  99193. * @param world defines the world transformation matrix
  99194. * @param mesh defines the mesh containing the submesh
  99195. * @param subMesh defines the submesh to bind the material to
  99196. */
  99197. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  99198. /**
  99199. * Gets the active textures from the material
  99200. * @returns an array of textures
  99201. */
  99202. getActiveTextures(): BaseTexture[];
  99203. /**
  99204. * Gets the list of texture blocks
  99205. * @returns an array of texture blocks
  99206. */
  99207. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  99208. /**
  99209. * Specifies if the material uses a texture
  99210. * @param texture defines the texture to check against the material
  99211. * @returns a boolean specifying if the material uses the texture
  99212. */
  99213. hasTexture(texture: BaseTexture): boolean;
  99214. /**
  99215. * Disposes the material
  99216. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  99217. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  99218. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  99219. */
  99220. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  99221. /** Creates the node editor window. */
  99222. private _createNodeEditor;
  99223. /**
  99224. * Launch the node material editor
  99225. * @param config Define the configuration of the editor
  99226. * @return a promise fulfilled when the node editor is visible
  99227. */
  99228. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  99229. /**
  99230. * Clear the current material
  99231. */
  99232. clear(): void;
  99233. /**
  99234. * Clear the current material and set it to a default state
  99235. */
  99236. setToDefault(): void;
  99237. /**
  99238. * Clear the current material and set it to a default state for post process
  99239. */
  99240. setToDefaultPostProcess(): void;
  99241. /**
  99242. * Clear the current material and set it to a default state for particle
  99243. */
  99244. setToDefaultParticle(): void;
  99245. /**
  99246. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  99247. * @param url defines the url to load from
  99248. * @returns a promise that will fullfil when the material is fully loaded
  99249. */
  99250. loadAsync(url: string): Promise<void>;
  99251. private _gatherBlocks;
  99252. /**
  99253. * Generate a string containing the code declaration required to create an equivalent of this material
  99254. * @returns a string
  99255. */
  99256. generateCode(): string;
  99257. /**
  99258. * Serializes this material in a JSON representation
  99259. * @returns the serialized material object
  99260. */
  99261. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  99262. private _restoreConnections;
  99263. /**
  99264. * Clear the current graph and load a new one from a serialization object
  99265. * @param source defines the JSON representation of the material
  99266. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  99267. */
  99268. loadFromSerialization(source: any, rootUrl?: string): void;
  99269. /**
  99270. * Makes a duplicate of the current material.
  99271. * @param name - name to use for the new material.
  99272. */
  99273. clone(name: string): NodeMaterial;
  99274. /**
  99275. * Creates a node material from parsed material data
  99276. * @param source defines the JSON representation of the material
  99277. * @param scene defines the hosting scene
  99278. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  99279. * @returns a new node material
  99280. */
  99281. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  99282. /**
  99283. * Creates a node material from a snippet saved in a remote file
  99284. * @param name defines the name of the material to create
  99285. * @param url defines the url to load from
  99286. * @param scene defines the hosting scene
  99287. * @returns a promise that will resolve to the new node material
  99288. */
  99289. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  99290. /**
  99291. * Creates a node material from a snippet saved by the node material editor
  99292. * @param snippetId defines the snippet to load
  99293. * @param scene defines the hosting scene
  99294. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  99295. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  99296. * @returns a promise that will resolve to the new node material
  99297. */
  99298. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  99299. /**
  99300. * Creates a new node material set to default basic configuration
  99301. * @param name defines the name of the material
  99302. * @param scene defines the hosting scene
  99303. * @returns a new NodeMaterial
  99304. */
  99305. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  99306. }
  99307. }
  99308. declare module BABYLON {
  99309. /**
  99310. * Size options for a post process
  99311. */
  99312. export type PostProcessOptions = {
  99313. width: number;
  99314. height: number;
  99315. };
  99316. /**
  99317. * PostProcess can be used to apply a shader to a texture after it has been rendered
  99318. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  99319. */
  99320. export class PostProcess {
  99321. /** Name of the PostProcess. */
  99322. name: string;
  99323. /**
  99324. * Gets or sets the unique id of the post process
  99325. */
  99326. uniqueId: number;
  99327. /**
  99328. * Width of the texture to apply the post process on
  99329. */
  99330. width: number;
  99331. /**
  99332. * Height of the texture to apply the post process on
  99333. */
  99334. height: number;
  99335. /**
  99336. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  99337. */
  99338. nodeMaterialSource: Nullable<NodeMaterial>;
  99339. /**
  99340. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  99341. * @hidden
  99342. */
  99343. _outputTexture: Nullable<InternalTexture>;
  99344. /**
  99345. * Sampling mode used by the shader
  99346. * See https://doc.babylonjs.com/classes/3.1/texture
  99347. */
  99348. renderTargetSamplingMode: number;
  99349. /**
  99350. * Clear color to use when screen clearing
  99351. */
  99352. clearColor: Color4;
  99353. /**
  99354. * If the buffer needs to be cleared before applying the post process. (default: true)
  99355. * Should be set to false if shader will overwrite all previous pixels.
  99356. */
  99357. autoClear: boolean;
  99358. /**
  99359. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  99360. */
  99361. alphaMode: number;
  99362. /**
  99363. * Sets the setAlphaBlendConstants of the babylon engine
  99364. */
  99365. alphaConstants: Color4;
  99366. /**
  99367. * Animations to be used for the post processing
  99368. */
  99369. animations: Animation[];
  99370. /**
  99371. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  99372. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  99373. */
  99374. enablePixelPerfectMode: boolean;
  99375. /**
  99376. * Force the postprocess to be applied without taking in account viewport
  99377. */
  99378. forceFullscreenViewport: boolean;
  99379. /**
  99380. * List of inspectable custom properties (used by the Inspector)
  99381. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  99382. */
  99383. inspectableCustomProperties: IInspectable[];
  99384. /**
  99385. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  99386. *
  99387. * | Value | Type | Description |
  99388. * | ----- | ----------------------------------- | ----------- |
  99389. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  99390. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  99391. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  99392. *
  99393. */
  99394. scaleMode: number;
  99395. /**
  99396. * Force textures to be a power of two (default: false)
  99397. */
  99398. alwaysForcePOT: boolean;
  99399. private _samples;
  99400. /**
  99401. * Number of sample textures (default: 1)
  99402. */
  99403. get samples(): number;
  99404. set samples(n: number);
  99405. /**
  99406. * Modify the scale of the post process to be the same as the viewport (default: false)
  99407. */
  99408. adaptScaleToCurrentViewport: boolean;
  99409. private _camera;
  99410. private _scene;
  99411. private _engine;
  99412. private _options;
  99413. private _reusable;
  99414. private _textureType;
  99415. private _textureFormat;
  99416. /**
  99417. * Smart array of input and output textures for the post process.
  99418. * @hidden
  99419. */
  99420. _textures: SmartArray<InternalTexture>;
  99421. /**
  99422. * The index in _textures that corresponds to the output texture.
  99423. * @hidden
  99424. */
  99425. _currentRenderTextureInd: number;
  99426. private _effect;
  99427. private _samplers;
  99428. private _fragmentUrl;
  99429. private _vertexUrl;
  99430. private _parameters;
  99431. private _scaleRatio;
  99432. protected _indexParameters: any;
  99433. private _shareOutputWithPostProcess;
  99434. private _texelSize;
  99435. private _forcedOutputTexture;
  99436. /**
  99437. * Returns the fragment url or shader name used in the post process.
  99438. * @returns the fragment url or name in the shader store.
  99439. */
  99440. getEffectName(): string;
  99441. /**
  99442. * An event triggered when the postprocess is activated.
  99443. */
  99444. onActivateObservable: Observable<Camera>;
  99445. private _onActivateObserver;
  99446. /**
  99447. * A function that is added to the onActivateObservable
  99448. */
  99449. set onActivate(callback: Nullable<(camera: Camera) => void>);
  99450. /**
  99451. * An event triggered when the postprocess changes its size.
  99452. */
  99453. onSizeChangedObservable: Observable<PostProcess>;
  99454. private _onSizeChangedObserver;
  99455. /**
  99456. * A function that is added to the onSizeChangedObservable
  99457. */
  99458. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  99459. /**
  99460. * An event triggered when the postprocess applies its effect.
  99461. */
  99462. onApplyObservable: Observable<Effect>;
  99463. private _onApplyObserver;
  99464. /**
  99465. * A function that is added to the onApplyObservable
  99466. */
  99467. set onApply(callback: (effect: Effect) => void);
  99468. /**
  99469. * An event triggered before rendering the postprocess
  99470. */
  99471. onBeforeRenderObservable: Observable<Effect>;
  99472. private _onBeforeRenderObserver;
  99473. /**
  99474. * A function that is added to the onBeforeRenderObservable
  99475. */
  99476. set onBeforeRender(callback: (effect: Effect) => void);
  99477. /**
  99478. * An event triggered after rendering the postprocess
  99479. */
  99480. onAfterRenderObservable: Observable<Effect>;
  99481. private _onAfterRenderObserver;
  99482. /**
  99483. * A function that is added to the onAfterRenderObservable
  99484. */
  99485. set onAfterRender(callback: (efect: Effect) => void);
  99486. /**
  99487. * 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
  99488. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  99489. */
  99490. get inputTexture(): InternalTexture;
  99491. set inputTexture(value: InternalTexture);
  99492. /**
  99493. * Gets the camera which post process is applied to.
  99494. * @returns The camera the post process is applied to.
  99495. */
  99496. getCamera(): Camera;
  99497. /**
  99498. * Gets the texel size of the postprocess.
  99499. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  99500. */
  99501. get texelSize(): Vector2;
  99502. /**
  99503. * Creates a new instance PostProcess
  99504. * @param name The name of the PostProcess.
  99505. * @param fragmentUrl The url of the fragment shader to be used.
  99506. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  99507. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  99508. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  99509. * @param camera The camera to apply the render pass to.
  99510. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  99511. * @param engine The engine which the post process will be applied. (default: current engine)
  99512. * @param reusable If the post process can be reused on the same frame. (default: false)
  99513. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  99514. * @param textureType Type of textures used when performing the post process. (default: 0)
  99515. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  99516. * @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
  99517. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  99518. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  99519. */
  99520. constructor(
  99521. /** Name of the PostProcess. */
  99522. 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);
  99523. /**
  99524. * Gets a string idenfifying the name of the class
  99525. * @returns "PostProcess" string
  99526. */
  99527. getClassName(): string;
  99528. /**
  99529. * Gets the engine which this post process belongs to.
  99530. * @returns The engine the post process was enabled with.
  99531. */
  99532. getEngine(): Engine;
  99533. /**
  99534. * The effect that is created when initializing the post process.
  99535. * @returns The created effect corresponding the the postprocess.
  99536. */
  99537. getEffect(): Effect;
  99538. /**
  99539. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  99540. * @param postProcess The post process to share the output with.
  99541. * @returns This post process.
  99542. */
  99543. shareOutputWith(postProcess: PostProcess): PostProcess;
  99544. /**
  99545. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  99546. * This should be called if the post process that shares output with this post process is disabled/disposed.
  99547. */
  99548. useOwnOutput(): void;
  99549. /**
  99550. * Updates the effect with the current post process compile time values and recompiles the shader.
  99551. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  99552. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  99553. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  99554. * @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
  99555. * @param onCompiled Called when the shader has been compiled.
  99556. * @param onError Called if there is an error when compiling a shader.
  99557. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  99558. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  99559. */
  99560. 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;
  99561. /**
  99562. * The post process is reusable if it can be used multiple times within one frame.
  99563. * @returns If the post process is reusable
  99564. */
  99565. isReusable(): boolean;
  99566. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  99567. markTextureDirty(): void;
  99568. /**
  99569. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  99570. * 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.
  99571. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  99572. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  99573. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  99574. * @returns The target texture that was bound to be written to.
  99575. */
  99576. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  99577. /**
  99578. * If the post process is supported.
  99579. */
  99580. get isSupported(): boolean;
  99581. /**
  99582. * The aspect ratio of the output texture.
  99583. */
  99584. get aspectRatio(): number;
  99585. /**
  99586. * Get a value indicating if the post-process is ready to be used
  99587. * @returns true if the post-process is ready (shader is compiled)
  99588. */
  99589. isReady(): boolean;
  99590. /**
  99591. * Binds all textures and uniforms to the shader, this will be run on every pass.
  99592. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  99593. */
  99594. apply(): Nullable<Effect>;
  99595. private _disposeTextures;
  99596. /**
  99597. * Disposes the post process.
  99598. * @param camera The camera to dispose the post process on.
  99599. */
  99600. dispose(camera?: Camera): void;
  99601. }
  99602. }
  99603. declare module BABYLON {
  99604. /** @hidden */
  99605. export var kernelBlurVaryingDeclaration: {
  99606. name: string;
  99607. shader: string;
  99608. };
  99609. }
  99610. declare module BABYLON {
  99611. /** @hidden */
  99612. export var kernelBlurFragment: {
  99613. name: string;
  99614. shader: string;
  99615. };
  99616. }
  99617. declare module BABYLON {
  99618. /** @hidden */
  99619. export var kernelBlurFragment2: {
  99620. name: string;
  99621. shader: string;
  99622. };
  99623. }
  99624. declare module BABYLON {
  99625. /** @hidden */
  99626. export var kernelBlurPixelShader: {
  99627. name: string;
  99628. shader: string;
  99629. };
  99630. }
  99631. declare module BABYLON {
  99632. /** @hidden */
  99633. export var kernelBlurVertex: {
  99634. name: string;
  99635. shader: string;
  99636. };
  99637. }
  99638. declare module BABYLON {
  99639. /** @hidden */
  99640. export var kernelBlurVertexShader: {
  99641. name: string;
  99642. shader: string;
  99643. };
  99644. }
  99645. declare module BABYLON {
  99646. /**
  99647. * The Blur Post Process which blurs an image based on a kernel and direction.
  99648. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  99649. */
  99650. export class BlurPostProcess extends PostProcess {
  99651. /** The direction in which to blur the image. */
  99652. direction: Vector2;
  99653. private blockCompilation;
  99654. protected _kernel: number;
  99655. protected _idealKernel: number;
  99656. protected _packedFloat: boolean;
  99657. private _staticDefines;
  99658. /**
  99659. * Sets the length in pixels of the blur sample region
  99660. */
  99661. set kernel(v: number);
  99662. /**
  99663. * Gets the length in pixels of the blur sample region
  99664. */
  99665. get kernel(): number;
  99666. /**
  99667. * Sets wether or not the blur needs to unpack/repack floats
  99668. */
  99669. set packedFloat(v: boolean);
  99670. /**
  99671. * Gets wether or not the blur is unpacking/repacking floats
  99672. */
  99673. get packedFloat(): boolean;
  99674. /**
  99675. * Creates a new instance BlurPostProcess
  99676. * @param name The name of the effect.
  99677. * @param direction The direction in which to blur the image.
  99678. * @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.
  99679. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  99680. * @param camera The camera to apply the render pass to.
  99681. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  99682. * @param engine The engine which the post process will be applied. (default: current engine)
  99683. * @param reusable If the post process can be reused on the same frame. (default: false)
  99684. * @param textureType Type of textures used when performing the post process. (default: 0)
  99685. * @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)
  99686. */
  99687. constructor(name: string,
  99688. /** The direction in which to blur the image. */
  99689. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  99690. /**
  99691. * Updates the effect with the current post process compile time values and recompiles the shader.
  99692. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  99693. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  99694. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  99695. * @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
  99696. * @param onCompiled Called when the shader has been compiled.
  99697. * @param onError Called if there is an error when compiling a shader.
  99698. */
  99699. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  99700. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  99701. /**
  99702. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  99703. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  99704. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  99705. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  99706. * The gaps between physical kernels are compensated for in the weighting of the samples
  99707. * @param idealKernel Ideal blur kernel.
  99708. * @return Nearest best kernel.
  99709. */
  99710. protected _nearestBestKernel(idealKernel: number): number;
  99711. /**
  99712. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  99713. * @param x The point on the Gaussian distribution to sample.
  99714. * @return the value of the Gaussian function at x.
  99715. */
  99716. protected _gaussianWeight(x: number): number;
  99717. /**
  99718. * Generates a string that can be used as a floating point number in GLSL.
  99719. * @param x Value to print.
  99720. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  99721. * @return GLSL float string.
  99722. */
  99723. protected _glslFloat(x: number, decimalFigures?: number): string;
  99724. }
  99725. }
  99726. declare module BABYLON {
  99727. /**
  99728. * Mirror texture can be used to simulate the view from a mirror in a scene.
  99729. * It will dynamically be rendered every frame to adapt to the camera point of view.
  99730. * You can then easily use it as a reflectionTexture on a flat surface.
  99731. * In case the surface is not a plane, please consider relying on reflection probes.
  99732. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  99733. */
  99734. export class MirrorTexture extends RenderTargetTexture {
  99735. private scene;
  99736. /**
  99737. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  99738. * 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.
  99739. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  99740. */
  99741. mirrorPlane: Plane;
  99742. /**
  99743. * Define the blur ratio used to blur the reflection if needed.
  99744. */
  99745. set blurRatio(value: number);
  99746. get blurRatio(): number;
  99747. /**
  99748. * Define the adaptive blur kernel used to blur the reflection if needed.
  99749. * This will autocompute the closest best match for the `blurKernel`
  99750. */
  99751. set adaptiveBlurKernel(value: number);
  99752. /**
  99753. * Define the blur kernel used to blur the reflection if needed.
  99754. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  99755. */
  99756. set blurKernel(value: number);
  99757. /**
  99758. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  99759. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  99760. */
  99761. set blurKernelX(value: number);
  99762. get blurKernelX(): number;
  99763. /**
  99764. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  99765. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  99766. */
  99767. set blurKernelY(value: number);
  99768. get blurKernelY(): number;
  99769. private _autoComputeBlurKernel;
  99770. protected _onRatioRescale(): void;
  99771. private _updateGammaSpace;
  99772. private _imageProcessingConfigChangeObserver;
  99773. private _transformMatrix;
  99774. private _mirrorMatrix;
  99775. private _savedViewMatrix;
  99776. private _blurX;
  99777. private _blurY;
  99778. private _adaptiveBlurKernel;
  99779. private _blurKernelX;
  99780. private _blurKernelY;
  99781. private _blurRatio;
  99782. /**
  99783. * Instantiates a Mirror Texture.
  99784. * Mirror texture can be used to simulate the view from a mirror in a scene.
  99785. * It will dynamically be rendered every frame to adapt to the camera point of view.
  99786. * You can then easily use it as a reflectionTexture on a flat surface.
  99787. * In case the surface is not a plane, please consider relying on reflection probes.
  99788. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  99789. * @param name
  99790. * @param size
  99791. * @param scene
  99792. * @param generateMipMaps
  99793. * @param type
  99794. * @param samplingMode
  99795. * @param generateDepthBuffer
  99796. */
  99797. constructor(name: string, size: number | {
  99798. width: number;
  99799. height: number;
  99800. } | {
  99801. ratio: number;
  99802. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  99803. private _preparePostProcesses;
  99804. /**
  99805. * Clone the mirror texture.
  99806. * @returns the cloned texture
  99807. */
  99808. clone(): MirrorTexture;
  99809. /**
  99810. * Serialize the texture to a JSON representation you could use in Parse later on
  99811. * @returns the serialized JSON representation
  99812. */
  99813. serialize(): any;
  99814. /**
  99815. * Dispose the texture and release its associated resources.
  99816. */
  99817. dispose(): void;
  99818. }
  99819. }
  99820. declare module BABYLON {
  99821. /**
  99822. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  99823. * @see http://doc.babylonjs.com/babylon101/materials#texture
  99824. */
  99825. export class Texture extends BaseTexture {
  99826. /**
  99827. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  99828. */
  99829. static SerializeBuffers: boolean;
  99830. /** @hidden */
  99831. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  99832. /** @hidden */
  99833. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  99834. /** @hidden */
  99835. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  99836. /** nearest is mag = nearest and min = nearest and mip = linear */
  99837. static readonly NEAREST_SAMPLINGMODE: number;
  99838. /** nearest is mag = nearest and min = nearest and mip = linear */
  99839. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  99840. /** Bilinear is mag = linear and min = linear and mip = nearest */
  99841. static readonly BILINEAR_SAMPLINGMODE: number;
  99842. /** Bilinear is mag = linear and min = linear and mip = nearest */
  99843. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  99844. /** Trilinear is mag = linear and min = linear and mip = linear */
  99845. static readonly TRILINEAR_SAMPLINGMODE: number;
  99846. /** Trilinear is mag = linear and min = linear and mip = linear */
  99847. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  99848. /** mag = nearest and min = nearest and mip = nearest */
  99849. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  99850. /** mag = nearest and min = linear and mip = nearest */
  99851. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  99852. /** mag = nearest and min = linear and mip = linear */
  99853. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  99854. /** mag = nearest and min = linear and mip = none */
  99855. static readonly NEAREST_LINEAR: number;
  99856. /** mag = nearest and min = nearest and mip = none */
  99857. static readonly NEAREST_NEAREST: number;
  99858. /** mag = linear and min = nearest and mip = nearest */
  99859. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  99860. /** mag = linear and min = nearest and mip = linear */
  99861. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  99862. /** mag = linear and min = linear and mip = none */
  99863. static readonly LINEAR_LINEAR: number;
  99864. /** mag = linear and min = nearest and mip = none */
  99865. static readonly LINEAR_NEAREST: number;
  99866. /** Explicit coordinates mode */
  99867. static readonly EXPLICIT_MODE: number;
  99868. /** Spherical coordinates mode */
  99869. static readonly SPHERICAL_MODE: number;
  99870. /** Planar coordinates mode */
  99871. static readonly PLANAR_MODE: number;
  99872. /** Cubic coordinates mode */
  99873. static readonly CUBIC_MODE: number;
  99874. /** Projection coordinates mode */
  99875. static readonly PROJECTION_MODE: number;
  99876. /** Inverse Cubic coordinates mode */
  99877. static readonly SKYBOX_MODE: number;
  99878. /** Inverse Cubic coordinates mode */
  99879. static readonly INVCUBIC_MODE: number;
  99880. /** Equirectangular coordinates mode */
  99881. static readonly EQUIRECTANGULAR_MODE: number;
  99882. /** Equirectangular Fixed coordinates mode */
  99883. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  99884. /** Equirectangular Fixed Mirrored coordinates mode */
  99885. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  99886. /** Texture is not repeating outside of 0..1 UVs */
  99887. static readonly CLAMP_ADDRESSMODE: number;
  99888. /** Texture is repeating outside of 0..1 UVs */
  99889. static readonly WRAP_ADDRESSMODE: number;
  99890. /** Texture is repeating and mirrored */
  99891. static readonly MIRROR_ADDRESSMODE: number;
  99892. /**
  99893. * 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
  99894. */
  99895. static UseSerializedUrlIfAny: boolean;
  99896. /**
  99897. * Define the url of the texture.
  99898. */
  99899. url: Nullable<string>;
  99900. /**
  99901. * Define an offset on the texture to offset the u coordinates of the UVs
  99902. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  99903. */
  99904. uOffset: number;
  99905. /**
  99906. * Define an offset on the texture to offset the v coordinates of the UVs
  99907. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  99908. */
  99909. vOffset: number;
  99910. /**
  99911. * Define an offset on the texture to scale the u coordinates of the UVs
  99912. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  99913. */
  99914. uScale: number;
  99915. /**
  99916. * Define an offset on the texture to scale the v coordinates of the UVs
  99917. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  99918. */
  99919. vScale: number;
  99920. /**
  99921. * Define an offset on the texture to rotate around the u coordinates of the UVs
  99922. * @see http://doc.babylonjs.com/how_to/more_materials
  99923. */
  99924. uAng: number;
  99925. /**
  99926. * Define an offset on the texture to rotate around the v coordinates of the UVs
  99927. * @see http://doc.babylonjs.com/how_to/more_materials
  99928. */
  99929. vAng: number;
  99930. /**
  99931. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  99932. * @see http://doc.babylonjs.com/how_to/more_materials
  99933. */
  99934. wAng: number;
  99935. /**
  99936. * Defines the center of rotation (U)
  99937. */
  99938. uRotationCenter: number;
  99939. /**
  99940. * Defines the center of rotation (V)
  99941. */
  99942. vRotationCenter: number;
  99943. /**
  99944. * Defines the center of rotation (W)
  99945. */
  99946. wRotationCenter: number;
  99947. /**
  99948. * Are mip maps generated for this texture or not.
  99949. */
  99950. get noMipmap(): boolean;
  99951. /**
  99952. * List of inspectable custom properties (used by the Inspector)
  99953. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  99954. */
  99955. inspectableCustomProperties: Nullable<IInspectable[]>;
  99956. private _noMipmap;
  99957. /** @hidden */
  99958. _invertY: boolean;
  99959. private _rowGenerationMatrix;
  99960. private _cachedTextureMatrix;
  99961. private _projectionModeMatrix;
  99962. private _t0;
  99963. private _t1;
  99964. private _t2;
  99965. private _cachedUOffset;
  99966. private _cachedVOffset;
  99967. private _cachedUScale;
  99968. private _cachedVScale;
  99969. private _cachedUAng;
  99970. private _cachedVAng;
  99971. private _cachedWAng;
  99972. private _cachedProjectionMatrixId;
  99973. private _cachedCoordinatesMode;
  99974. /** @hidden */
  99975. protected _initialSamplingMode: number;
  99976. /** @hidden */
  99977. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  99978. private _deleteBuffer;
  99979. protected _format: Nullable<number>;
  99980. private _delayedOnLoad;
  99981. private _delayedOnError;
  99982. private _mimeType?;
  99983. /**
  99984. * Observable triggered once the texture has been loaded.
  99985. */
  99986. onLoadObservable: Observable<Texture>;
  99987. protected _isBlocking: boolean;
  99988. /**
  99989. * Is the texture preventing material to render while loading.
  99990. * If false, a default texture will be used instead of the loading one during the preparation step.
  99991. */
  99992. set isBlocking(value: boolean);
  99993. get isBlocking(): boolean;
  99994. /**
  99995. * Get the current sampling mode associated with the texture.
  99996. */
  99997. get samplingMode(): number;
  99998. /**
  99999. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  100000. */
  100001. get invertY(): boolean;
  100002. /**
  100003. * Instantiates a new texture.
  100004. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  100005. * @see http://doc.babylonjs.com/babylon101/materials#texture
  100006. * @param url defines the url of the picture to load as a texture
  100007. * @param sceneOrEngine defines the scene or engine the texture will belong to
  100008. * @param noMipmap defines if the texture will require mip maps or not
  100009. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  100010. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  100011. * @param onLoad defines a callback triggered when the texture has been loaded
  100012. * @param onError defines a callback triggered when an error occurred during the loading session
  100013. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  100014. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  100015. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  100016. * @param mimeType defines an optional mime type information
  100017. */
  100018. 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);
  100019. /**
  100020. * Update the url (and optional buffer) of this texture if url was null during construction.
  100021. * @param url the url of the texture
  100022. * @param buffer the buffer of the texture (defaults to null)
  100023. * @param onLoad callback called when the texture is loaded (defaults to null)
  100024. */
  100025. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  100026. /**
  100027. * Finish the loading sequence of a texture flagged as delayed load.
  100028. * @hidden
  100029. */
  100030. delayLoad(): void;
  100031. private _prepareRowForTextureGeneration;
  100032. /**
  100033. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  100034. * @returns the transform matrix of the texture.
  100035. */
  100036. getTextureMatrix(uBase?: number): Matrix;
  100037. /**
  100038. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  100039. * @returns The reflection texture transform
  100040. */
  100041. getReflectionTextureMatrix(): Matrix;
  100042. /**
  100043. * Clones the texture.
  100044. * @returns the cloned texture
  100045. */
  100046. clone(): Texture;
  100047. /**
  100048. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  100049. * @returns The JSON representation of the texture
  100050. */
  100051. serialize(): any;
  100052. /**
  100053. * Get the current class name of the texture useful for serialization or dynamic coding.
  100054. * @returns "Texture"
  100055. */
  100056. getClassName(): string;
  100057. /**
  100058. * Dispose the texture and release its associated resources.
  100059. */
  100060. dispose(): void;
  100061. /**
  100062. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  100063. * @param parsedTexture Define the JSON representation of the texture
  100064. * @param scene Define the scene the parsed texture should be instantiated in
  100065. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  100066. * @returns The parsed texture if successful
  100067. */
  100068. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  100069. /**
  100070. * Creates a texture from its base 64 representation.
  100071. * @param data Define the base64 payload without the data: prefix
  100072. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  100073. * @param scene Define the scene the texture should belong to
  100074. * @param noMipmap Forces the texture to not create mip map information if true
  100075. * @param invertY define if the texture needs to be inverted on the y axis during loading
  100076. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  100077. * @param onLoad define a callback triggered when the texture has been loaded
  100078. * @param onError define a callback triggered when an error occurred during the loading session
  100079. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  100080. * @returns the created texture
  100081. */
  100082. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  100083. /**
  100084. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  100085. * @param data Define the base64 payload without the data: prefix
  100086. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  100087. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  100088. * @param scene Define the scene the texture should belong to
  100089. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  100090. * @param noMipmap Forces the texture to not create mip map information if true
  100091. * @param invertY define if the texture needs to be inverted on the y axis during loading
  100092. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  100093. * @param onLoad define a callback triggered when the texture has been loaded
  100094. * @param onError define a callback triggered when an error occurred during the loading session
  100095. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  100096. * @returns the created texture
  100097. */
  100098. 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;
  100099. }
  100100. }
  100101. declare module BABYLON {
  100102. /**
  100103. * PostProcessManager is used to manage one or more post processes or post process pipelines
  100104. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  100105. */
  100106. export class PostProcessManager {
  100107. private _scene;
  100108. private _indexBuffer;
  100109. private _vertexBuffers;
  100110. /**
  100111. * Creates a new instance PostProcess
  100112. * @param scene The scene that the post process is associated with.
  100113. */
  100114. constructor(scene: Scene);
  100115. private _prepareBuffers;
  100116. private _buildIndexBuffer;
  100117. /**
  100118. * Rebuilds the vertex buffers of the manager.
  100119. * @hidden
  100120. */
  100121. _rebuild(): void;
  100122. /**
  100123. * Prepares a frame to be run through a post process.
  100124. * @param sourceTexture The input texture to the post procesess. (default: null)
  100125. * @param postProcesses An array of post processes to be run. (default: null)
  100126. * @returns True if the post processes were able to be run.
  100127. * @hidden
  100128. */
  100129. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  100130. /**
  100131. * Manually render a set of post processes to a texture.
  100132. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  100133. * @param postProcesses An array of post processes to be run.
  100134. * @param targetTexture The target texture to render to.
  100135. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  100136. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  100137. * @param lodLevel defines which lod of the texture to render to
  100138. */
  100139. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  100140. /**
  100141. * Finalize the result of the output of the postprocesses.
  100142. * @param doNotPresent If true the result will not be displayed to the screen.
  100143. * @param targetTexture The target texture to render to.
  100144. * @param faceIndex The index of the face to bind the target texture to.
  100145. * @param postProcesses The array of post processes to render.
  100146. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  100147. * @hidden
  100148. */
  100149. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  100150. /**
  100151. * Disposes of the post process manager.
  100152. */
  100153. dispose(): void;
  100154. }
  100155. }
  100156. declare module BABYLON {
  100157. /**
  100158. * This Helps creating a texture that will be created from a camera in your scene.
  100159. * It is basically a dynamic texture that could be used to create special effects for instance.
  100160. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  100161. */
  100162. export class RenderTargetTexture extends Texture {
  100163. isCube: boolean;
  100164. /**
  100165. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  100166. */
  100167. static readonly REFRESHRATE_RENDER_ONCE: number;
  100168. /**
  100169. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  100170. */
  100171. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  100172. /**
  100173. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  100174. * the central point of your effect and can save a lot of performances.
  100175. */
  100176. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  100177. /**
  100178. * Use this predicate to dynamically define the list of mesh you want to render.
  100179. * If set, the renderList property will be overwritten.
  100180. */
  100181. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  100182. private _renderList;
  100183. /**
  100184. * Use this list to define the list of mesh you want to render.
  100185. */
  100186. get renderList(): Nullable<Array<AbstractMesh>>;
  100187. set renderList(value: Nullable<Array<AbstractMesh>>);
  100188. /**
  100189. * Use this function to overload the renderList array at rendering time.
  100190. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  100191. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  100192. * the cube (if the RTT is a cube, else layerOrFace=0).
  100193. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  100194. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  100195. * hold dummy elements!
  100196. */
  100197. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  100198. private _hookArray;
  100199. /**
  100200. * Define if particles should be rendered in your texture.
  100201. */
  100202. renderParticles: boolean;
  100203. /**
  100204. * Define if sprites should be rendered in your texture.
  100205. */
  100206. renderSprites: boolean;
  100207. /**
  100208. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  100209. */
  100210. coordinatesMode: number;
  100211. /**
  100212. * Define the camera used to render the texture.
  100213. */
  100214. activeCamera: Nullable<Camera>;
  100215. /**
  100216. * Override the mesh isReady function with your own one.
  100217. */
  100218. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  100219. /**
  100220. * Override the render function of the texture with your own one.
  100221. */
  100222. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  100223. /**
  100224. * Define if camera post processes should be use while rendering the texture.
  100225. */
  100226. useCameraPostProcesses: boolean;
  100227. /**
  100228. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  100229. */
  100230. ignoreCameraViewport: boolean;
  100231. private _postProcessManager;
  100232. private _postProcesses;
  100233. private _resizeObserver;
  100234. /**
  100235. * An event triggered when the texture is unbind.
  100236. */
  100237. onBeforeBindObservable: Observable<RenderTargetTexture>;
  100238. /**
  100239. * An event triggered when the texture is unbind.
  100240. */
  100241. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  100242. private _onAfterUnbindObserver;
  100243. /**
  100244. * Set a after unbind callback in the texture.
  100245. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  100246. */
  100247. set onAfterUnbind(callback: () => void);
  100248. /**
  100249. * An event triggered before rendering the texture
  100250. */
  100251. onBeforeRenderObservable: Observable<number>;
  100252. private _onBeforeRenderObserver;
  100253. /**
  100254. * Set a before render callback in the texture.
  100255. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  100256. */
  100257. set onBeforeRender(callback: (faceIndex: number) => void);
  100258. /**
  100259. * An event triggered after rendering the texture
  100260. */
  100261. onAfterRenderObservable: Observable<number>;
  100262. private _onAfterRenderObserver;
  100263. /**
  100264. * Set a after render callback in the texture.
  100265. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  100266. */
  100267. set onAfterRender(callback: (faceIndex: number) => void);
  100268. /**
  100269. * An event triggered after the texture clear
  100270. */
  100271. onClearObservable: Observable<Engine>;
  100272. private _onClearObserver;
  100273. /**
  100274. * Set a clear callback in the texture.
  100275. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  100276. */
  100277. set onClear(callback: (Engine: Engine) => void);
  100278. /**
  100279. * An event triggered when the texture is resized.
  100280. */
  100281. onResizeObservable: Observable<RenderTargetTexture>;
  100282. /**
  100283. * Define the clear color of the Render Target if it should be different from the scene.
  100284. */
  100285. clearColor: Color4;
  100286. protected _size: number | {
  100287. width: number;
  100288. height: number;
  100289. layers?: number;
  100290. };
  100291. protected _initialSizeParameter: number | {
  100292. width: number;
  100293. height: number;
  100294. } | {
  100295. ratio: number;
  100296. };
  100297. protected _sizeRatio: Nullable<number>;
  100298. /** @hidden */
  100299. _generateMipMaps: boolean;
  100300. protected _renderingManager: RenderingManager;
  100301. /** @hidden */
  100302. _waitingRenderList: string[];
  100303. protected _doNotChangeAspectRatio: boolean;
  100304. protected _currentRefreshId: number;
  100305. protected _refreshRate: number;
  100306. protected _textureMatrix: Matrix;
  100307. protected _samples: number;
  100308. protected _renderTargetOptions: RenderTargetCreationOptions;
  100309. /**
  100310. * Gets render target creation options that were used.
  100311. */
  100312. get renderTargetOptions(): RenderTargetCreationOptions;
  100313. protected _onRatioRescale(): void;
  100314. /**
  100315. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  100316. * It must define where the camera used to render the texture is set
  100317. */
  100318. boundingBoxPosition: Vector3;
  100319. private _boundingBoxSize;
  100320. /**
  100321. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  100322. * When defined, the cubemap will switch to local mode
  100323. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  100324. * @example https://www.babylonjs-playground.com/#RNASML
  100325. */
  100326. set boundingBoxSize(value: Vector3);
  100327. get boundingBoxSize(): Vector3;
  100328. /**
  100329. * In case the RTT has been created with a depth texture, get the associated
  100330. * depth texture.
  100331. * Otherwise, return null.
  100332. */
  100333. get depthStencilTexture(): Nullable<InternalTexture>;
  100334. /**
  100335. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  100336. * or used a shadow, depth texture...
  100337. * @param name The friendly name of the texture
  100338. * @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)
  100339. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  100340. * @param generateMipMaps True if mip maps need to be generated after render.
  100341. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  100342. * @param type The type of the buffer in the RTT (int, half float, float...)
  100343. * @param isCube True if a cube texture needs to be created
  100344. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  100345. * @param generateDepthBuffer True to generate a depth buffer
  100346. * @param generateStencilBuffer True to generate a stencil buffer
  100347. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  100348. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  100349. * @param delayAllocation if the texture allocation should be delayed (default: false)
  100350. */
  100351. constructor(name: string, size: number | {
  100352. width: number;
  100353. height: number;
  100354. layers?: number;
  100355. } | {
  100356. ratio: number;
  100357. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  100358. /**
  100359. * Creates a depth stencil texture.
  100360. * This is only available in WebGL 2 or with the depth texture extension available.
  100361. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  100362. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  100363. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  100364. */
  100365. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  100366. private _processSizeParameter;
  100367. /**
  100368. * Define the number of samples to use in case of MSAA.
  100369. * It defaults to one meaning no MSAA has been enabled.
  100370. */
  100371. get samples(): number;
  100372. set samples(value: number);
  100373. /**
  100374. * Resets the refresh counter of the texture and start bak from scratch.
  100375. * Could be useful to regenerate the texture if it is setup to render only once.
  100376. */
  100377. resetRefreshCounter(): void;
  100378. /**
  100379. * Define the refresh rate of the texture or the rendering frequency.
  100380. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  100381. */
  100382. get refreshRate(): number;
  100383. set refreshRate(value: number);
  100384. /**
  100385. * Adds a post process to the render target rendering passes.
  100386. * @param postProcess define the post process to add
  100387. */
  100388. addPostProcess(postProcess: PostProcess): void;
  100389. /**
  100390. * Clear all the post processes attached to the render target
  100391. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  100392. */
  100393. clearPostProcesses(dispose?: boolean): void;
  100394. /**
  100395. * Remove one of the post process from the list of attached post processes to the texture
  100396. * @param postProcess define the post process to remove from the list
  100397. */
  100398. removePostProcess(postProcess: PostProcess): void;
  100399. /** @hidden */
  100400. _shouldRender(): boolean;
  100401. /**
  100402. * Gets the actual render size of the texture.
  100403. * @returns the width of the render size
  100404. */
  100405. getRenderSize(): number;
  100406. /**
  100407. * Gets the actual render width of the texture.
  100408. * @returns the width of the render size
  100409. */
  100410. getRenderWidth(): number;
  100411. /**
  100412. * Gets the actual render height of the texture.
  100413. * @returns the height of the render size
  100414. */
  100415. getRenderHeight(): number;
  100416. /**
  100417. * Gets the actual number of layers of the texture.
  100418. * @returns the number of layers
  100419. */
  100420. getRenderLayers(): number;
  100421. /**
  100422. * Get if the texture can be rescaled or not.
  100423. */
  100424. get canRescale(): boolean;
  100425. /**
  100426. * Resize the texture using a ratio.
  100427. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  100428. */
  100429. scale(ratio: number): void;
  100430. /**
  100431. * Get the texture reflection matrix used to rotate/transform the reflection.
  100432. * @returns the reflection matrix
  100433. */
  100434. getReflectionTextureMatrix(): Matrix;
  100435. /**
  100436. * Resize the texture to a new desired size.
  100437. * Be carrefull as it will recreate all the data in the new texture.
  100438. * @param size Define the new size. It can be:
  100439. * - a number for squared texture,
  100440. * - an object containing { width: number, height: number }
  100441. * - or an object containing a ratio { ratio: number }
  100442. */
  100443. resize(size: number | {
  100444. width: number;
  100445. height: number;
  100446. } | {
  100447. ratio: number;
  100448. }): void;
  100449. private _defaultRenderListPrepared;
  100450. /**
  100451. * Renders all the objects from the render list into the texture.
  100452. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  100453. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  100454. */
  100455. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  100456. private _bestReflectionRenderTargetDimension;
  100457. private _prepareRenderingManager;
  100458. /**
  100459. * @hidden
  100460. * @param faceIndex face index to bind to if this is a cubetexture
  100461. * @param layer defines the index of the texture to bind in the array
  100462. */
  100463. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  100464. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  100465. private renderToTarget;
  100466. /**
  100467. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  100468. * This allowed control for front to back rendering or reversly depending of the special needs.
  100469. *
  100470. * @param renderingGroupId The rendering group id corresponding to its index
  100471. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  100472. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  100473. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  100474. */
  100475. 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;
  100476. /**
  100477. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  100478. *
  100479. * @param renderingGroupId The rendering group id corresponding to its index
  100480. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  100481. */
  100482. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  100483. /**
  100484. * Clones the texture.
  100485. * @returns the cloned texture
  100486. */
  100487. clone(): RenderTargetTexture;
  100488. /**
  100489. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  100490. * @returns The JSON representation of the texture
  100491. */
  100492. serialize(): any;
  100493. /**
  100494. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  100495. */
  100496. disposeFramebufferObjects(): void;
  100497. /**
  100498. * Dispose the texture and release its associated resources.
  100499. */
  100500. dispose(): void;
  100501. /** @hidden */
  100502. _rebuild(): void;
  100503. /**
  100504. * Clear the info related to rendering groups preventing retention point in material dispose.
  100505. */
  100506. freeRenderingGroups(): void;
  100507. /**
  100508. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  100509. * @returns the view count
  100510. */
  100511. getViewCount(): number;
  100512. }
  100513. }
  100514. declare module BABYLON {
  100515. /**
  100516. * Class used to manipulate GUIDs
  100517. */
  100518. export class GUID {
  100519. /**
  100520. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  100521. * Be aware Math.random() could cause collisions, but:
  100522. * "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"
  100523. * @returns a pseudo random id
  100524. */
  100525. static RandomId(): string;
  100526. }
  100527. }
  100528. declare module BABYLON {
  100529. /**
  100530. * Options to be used when creating a shadow depth material
  100531. */
  100532. export interface IIOptionShadowDepthMaterial {
  100533. /** Variables in the vertex shader code that need to have their names remapped.
  100534. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  100535. * "var_name" should be either: worldPos or vNormalW
  100536. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  100537. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  100538. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  100539. */
  100540. remappedVariables?: string[];
  100541. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  100542. standalone?: boolean;
  100543. }
  100544. /**
  100545. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  100546. */
  100547. export class ShadowDepthWrapper {
  100548. private _scene;
  100549. private _options?;
  100550. private _baseMaterial;
  100551. private _onEffectCreatedObserver;
  100552. private _subMeshToEffect;
  100553. private _subMeshToDepthEffect;
  100554. private _meshes;
  100555. /** @hidden */
  100556. _matriceNames: any;
  100557. /** Gets the standalone status of the wrapper */
  100558. get standalone(): boolean;
  100559. /** Gets the base material the wrapper is built upon */
  100560. get baseMaterial(): Material;
  100561. /**
  100562. * Instantiate a new shadow depth wrapper.
  100563. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  100564. * generate the shadow depth map. For more information, please refer to the documentation:
  100565. * https://doc.babylonjs.com/babylon101/shadows
  100566. * @param baseMaterial Material to wrap
  100567. * @param scene Define the scene the material belongs to
  100568. * @param options Options used to create the wrapper
  100569. */
  100570. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  100571. /**
  100572. * Gets the effect to use to generate the depth map
  100573. * @param subMesh subMesh to get the effect for
  100574. * @param shadowGenerator shadow generator to get the effect for
  100575. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  100576. */
  100577. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  100578. /**
  100579. * Specifies that the submesh is ready to be used for depth rendering
  100580. * @param subMesh submesh to check
  100581. * @param defines the list of defines to take into account when checking the effect
  100582. * @param shadowGenerator combined with subMesh, it defines the effect to check
  100583. * @param useInstances specifies that instances should be used
  100584. * @returns a boolean indicating that the submesh is ready or not
  100585. */
  100586. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  100587. /**
  100588. * Disposes the resources
  100589. */
  100590. dispose(): void;
  100591. private _makeEffect;
  100592. }
  100593. }
  100594. declare module BABYLON {
  100595. /**
  100596. * Options for compiling materials.
  100597. */
  100598. export interface IMaterialCompilationOptions {
  100599. /**
  100600. * Defines whether clip planes are enabled.
  100601. */
  100602. clipPlane: boolean;
  100603. /**
  100604. * Defines whether instances are enabled.
  100605. */
  100606. useInstances: boolean;
  100607. }
  100608. /**
  100609. * Base class for the main features of a material in Babylon.js
  100610. */
  100611. export class Material implements IAnimatable {
  100612. /**
  100613. * Returns the triangle fill mode
  100614. */
  100615. static readonly TriangleFillMode: number;
  100616. /**
  100617. * Returns the wireframe mode
  100618. */
  100619. static readonly WireFrameFillMode: number;
  100620. /**
  100621. * Returns the point fill mode
  100622. */
  100623. static readonly PointFillMode: number;
  100624. /**
  100625. * Returns the point list draw mode
  100626. */
  100627. static readonly PointListDrawMode: number;
  100628. /**
  100629. * Returns the line list draw mode
  100630. */
  100631. static readonly LineListDrawMode: number;
  100632. /**
  100633. * Returns the line loop draw mode
  100634. */
  100635. static readonly LineLoopDrawMode: number;
  100636. /**
  100637. * Returns the line strip draw mode
  100638. */
  100639. static readonly LineStripDrawMode: number;
  100640. /**
  100641. * Returns the triangle strip draw mode
  100642. */
  100643. static readonly TriangleStripDrawMode: number;
  100644. /**
  100645. * Returns the triangle fan draw mode
  100646. */
  100647. static readonly TriangleFanDrawMode: number;
  100648. /**
  100649. * Stores the clock-wise side orientation
  100650. */
  100651. static readonly ClockWiseSideOrientation: number;
  100652. /**
  100653. * Stores the counter clock-wise side orientation
  100654. */
  100655. static readonly CounterClockWiseSideOrientation: number;
  100656. /**
  100657. * The dirty texture flag value
  100658. */
  100659. static readonly TextureDirtyFlag: number;
  100660. /**
  100661. * The dirty light flag value
  100662. */
  100663. static readonly LightDirtyFlag: number;
  100664. /**
  100665. * The dirty fresnel flag value
  100666. */
  100667. static readonly FresnelDirtyFlag: number;
  100668. /**
  100669. * The dirty attribute flag value
  100670. */
  100671. static readonly AttributesDirtyFlag: number;
  100672. /**
  100673. * The dirty misc flag value
  100674. */
  100675. static readonly MiscDirtyFlag: number;
  100676. /**
  100677. * The all dirty flag value
  100678. */
  100679. static readonly AllDirtyFlag: number;
  100680. /**
  100681. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  100682. */
  100683. static readonly MATERIAL_OPAQUE: number;
  100684. /**
  100685. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  100686. */
  100687. static readonly MATERIAL_ALPHATEST: number;
  100688. /**
  100689. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  100690. */
  100691. static readonly MATERIAL_ALPHABLEND: number;
  100692. /**
  100693. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  100694. * They are also discarded below the alpha cutoff threshold to improve performances.
  100695. */
  100696. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  100697. /**
  100698. * Custom callback helping to override the default shader used in the material.
  100699. */
  100700. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[]) => string;
  100701. /**
  100702. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  100703. */
  100704. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  100705. /**
  100706. * The ID of the material
  100707. */
  100708. id: string;
  100709. /**
  100710. * Gets or sets the unique id of the material
  100711. */
  100712. uniqueId: number;
  100713. /**
  100714. * The name of the material
  100715. */
  100716. name: string;
  100717. /**
  100718. * Gets or sets user defined metadata
  100719. */
  100720. metadata: any;
  100721. /**
  100722. * For internal use only. Please do not use.
  100723. */
  100724. reservedDataStore: any;
  100725. /**
  100726. * Specifies if the ready state should be checked on each call
  100727. */
  100728. checkReadyOnEveryCall: boolean;
  100729. /**
  100730. * Specifies if the ready state should be checked once
  100731. */
  100732. checkReadyOnlyOnce: boolean;
  100733. /**
  100734. * The state of the material
  100735. */
  100736. state: string;
  100737. /**
  100738. * The alpha value of the material
  100739. */
  100740. protected _alpha: number;
  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: IInspectable[];
  100746. /**
  100747. * Sets the alpha value of the material
  100748. */
  100749. set alpha(value: number);
  100750. /**
  100751. * Gets the alpha value of the material
  100752. */
  100753. get alpha(): number;
  100754. /**
  100755. * Specifies if back face culling is enabled
  100756. */
  100757. protected _backFaceCulling: boolean;
  100758. /**
  100759. * Sets the back-face culling state
  100760. */
  100761. set backFaceCulling(value: boolean);
  100762. /**
  100763. * Gets the back-face culling state
  100764. */
  100765. get backFaceCulling(): boolean;
  100766. /**
  100767. * Stores the value for side orientation
  100768. */
  100769. sideOrientation: number;
  100770. /**
  100771. * Callback triggered when the material is compiled
  100772. */
  100773. onCompiled: Nullable<(effect: Effect) => void>;
  100774. /**
  100775. * Callback triggered when an error occurs
  100776. */
  100777. onError: Nullable<(effect: Effect, errors: string) => void>;
  100778. /**
  100779. * Callback triggered to get the render target textures
  100780. */
  100781. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  100782. /**
  100783. * Gets a boolean indicating that current material needs to register RTT
  100784. */
  100785. get hasRenderTargetTextures(): boolean;
  100786. /**
  100787. * Specifies if the material should be serialized
  100788. */
  100789. doNotSerialize: boolean;
  100790. /**
  100791. * @hidden
  100792. */
  100793. _storeEffectOnSubMeshes: boolean;
  100794. /**
  100795. * Stores the animations for the material
  100796. */
  100797. animations: Nullable<Array<Animation>>;
  100798. /**
  100799. * An event triggered when the material is disposed
  100800. */
  100801. onDisposeObservable: Observable<Material>;
  100802. /**
  100803. * An observer which watches for dispose events
  100804. */
  100805. private _onDisposeObserver;
  100806. private _onUnBindObservable;
  100807. /**
  100808. * Called during a dispose event
  100809. */
  100810. set onDispose(callback: () => void);
  100811. private _onBindObservable;
  100812. /**
  100813. * An event triggered when the material is bound
  100814. */
  100815. get onBindObservable(): Observable<AbstractMesh>;
  100816. /**
  100817. * An observer which watches for bind events
  100818. */
  100819. private _onBindObserver;
  100820. /**
  100821. * Called during a bind event
  100822. */
  100823. set onBind(callback: (Mesh: AbstractMesh) => void);
  100824. /**
  100825. * An event triggered when the material is unbound
  100826. */
  100827. get onUnBindObservable(): Observable<Material>;
  100828. protected _onEffectCreatedObservable: Nullable<Observable<{
  100829. effect: Effect;
  100830. subMesh: Nullable<SubMesh>;
  100831. }>>;
  100832. /**
  100833. * An event triggered when the effect is (re)created
  100834. */
  100835. get onEffectCreatedObservable(): Observable<{
  100836. effect: Effect;
  100837. subMesh: Nullable<SubMesh>;
  100838. }>;
  100839. /**
  100840. * Stores the value of the alpha mode
  100841. */
  100842. private _alphaMode;
  100843. /**
  100844. * Sets the value of the alpha mode.
  100845. *
  100846. * | Value | Type | Description |
  100847. * | --- | --- | --- |
  100848. * | 0 | ALPHA_DISABLE | |
  100849. * | 1 | ALPHA_ADD | |
  100850. * | 2 | ALPHA_COMBINE | |
  100851. * | 3 | ALPHA_SUBTRACT | |
  100852. * | 4 | ALPHA_MULTIPLY | |
  100853. * | 5 | ALPHA_MAXIMIZED | |
  100854. * | 6 | ALPHA_ONEONE | |
  100855. * | 7 | ALPHA_PREMULTIPLIED | |
  100856. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  100857. * | 9 | ALPHA_INTERPOLATE | |
  100858. * | 10 | ALPHA_SCREENMODE | |
  100859. *
  100860. */
  100861. set alphaMode(value: number);
  100862. /**
  100863. * Gets the value of the alpha mode
  100864. */
  100865. get alphaMode(): number;
  100866. /**
  100867. * Stores the state of the need depth pre-pass value
  100868. */
  100869. private _needDepthPrePass;
  100870. /**
  100871. * Sets the need depth pre-pass value
  100872. */
  100873. set needDepthPrePass(value: boolean);
  100874. /**
  100875. * Gets the depth pre-pass value
  100876. */
  100877. get needDepthPrePass(): boolean;
  100878. /**
  100879. * Specifies if depth writing should be disabled
  100880. */
  100881. disableDepthWrite: boolean;
  100882. /**
  100883. * Specifies if color writing should be disabled
  100884. */
  100885. disableColorWrite: boolean;
  100886. /**
  100887. * Specifies if depth writing should be forced
  100888. */
  100889. forceDepthWrite: boolean;
  100890. /**
  100891. * Specifies the depth function that should be used. 0 means the default engine function
  100892. */
  100893. depthFunction: number;
  100894. /**
  100895. * Specifies if there should be a separate pass for culling
  100896. */
  100897. separateCullingPass: boolean;
  100898. /**
  100899. * Stores the state specifing if fog should be enabled
  100900. */
  100901. private _fogEnabled;
  100902. /**
  100903. * Sets the state for enabling fog
  100904. */
  100905. set fogEnabled(value: boolean);
  100906. /**
  100907. * Gets the value of the fog enabled state
  100908. */
  100909. get fogEnabled(): boolean;
  100910. /**
  100911. * Stores the size of points
  100912. */
  100913. pointSize: number;
  100914. /**
  100915. * Stores the z offset value
  100916. */
  100917. zOffset: number;
  100918. get wireframe(): boolean;
  100919. /**
  100920. * Sets the state of wireframe mode
  100921. */
  100922. set wireframe(value: boolean);
  100923. /**
  100924. * Gets the value specifying if point clouds are enabled
  100925. */
  100926. get pointsCloud(): boolean;
  100927. /**
  100928. * Sets the state of point cloud mode
  100929. */
  100930. set pointsCloud(value: boolean);
  100931. /**
  100932. * Gets the material fill mode
  100933. */
  100934. get fillMode(): number;
  100935. /**
  100936. * Sets the material fill mode
  100937. */
  100938. set fillMode(value: number);
  100939. /**
  100940. * @hidden
  100941. * Stores the effects for the material
  100942. */
  100943. _effect: Nullable<Effect>;
  100944. /**
  100945. * Specifies if uniform buffers should be used
  100946. */
  100947. private _useUBO;
  100948. /**
  100949. * Stores a reference to the scene
  100950. */
  100951. private _scene;
  100952. /**
  100953. * Stores the fill mode state
  100954. */
  100955. private _fillMode;
  100956. /**
  100957. * Specifies if the depth write state should be cached
  100958. */
  100959. private _cachedDepthWriteState;
  100960. /**
  100961. * Specifies if the color write state should be cached
  100962. */
  100963. private _cachedColorWriteState;
  100964. /**
  100965. * Specifies if the depth function state should be cached
  100966. */
  100967. private _cachedDepthFunctionState;
  100968. /**
  100969. * Stores the uniform buffer
  100970. */
  100971. protected _uniformBuffer: UniformBuffer;
  100972. /** @hidden */
  100973. _indexInSceneMaterialArray: number;
  100974. /** @hidden */
  100975. meshMap: Nullable<{
  100976. [id: string]: AbstractMesh | undefined;
  100977. }>;
  100978. /**
  100979. * Creates a material instance
  100980. * @param name defines the name of the material
  100981. * @param scene defines the scene to reference
  100982. * @param doNotAdd specifies if the material should be added to the scene
  100983. */
  100984. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  100985. /**
  100986. * Returns a string representation of the current material
  100987. * @param fullDetails defines a boolean indicating which levels of logging is desired
  100988. * @returns a string with material information
  100989. */
  100990. toString(fullDetails?: boolean): string;
  100991. /**
  100992. * Gets the class name of the material
  100993. * @returns a string with the class name of the material
  100994. */
  100995. getClassName(): string;
  100996. /**
  100997. * Specifies if updates for the material been locked
  100998. */
  100999. get isFrozen(): boolean;
  101000. /**
  101001. * Locks updates for the material
  101002. */
  101003. freeze(): void;
  101004. /**
  101005. * Unlocks updates for the material
  101006. */
  101007. unfreeze(): void;
  101008. /**
  101009. * Specifies if the material is ready to be used
  101010. * @param mesh defines the mesh to check
  101011. * @param useInstances specifies if instances should be used
  101012. * @returns a boolean indicating if the material is ready to be used
  101013. */
  101014. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  101015. /**
  101016. * Specifies that the submesh is ready to be used
  101017. * @param mesh defines the mesh to check
  101018. * @param subMesh defines which submesh to check
  101019. * @param useInstances specifies that instances should be used
  101020. * @returns a boolean indicating that the submesh is ready or not
  101021. */
  101022. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  101023. /**
  101024. * Returns the material effect
  101025. * @returns the effect associated with the material
  101026. */
  101027. getEffect(): Nullable<Effect>;
  101028. /**
  101029. * Returns the current scene
  101030. * @returns a Scene
  101031. */
  101032. getScene(): Scene;
  101033. /**
  101034. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  101035. */
  101036. protected _forceAlphaTest: boolean;
  101037. /**
  101038. * The transparency mode of the material.
  101039. */
  101040. protected _transparencyMode: Nullable<number>;
  101041. /**
  101042. * Gets the current transparency mode.
  101043. */
  101044. get transparencyMode(): Nullable<number>;
  101045. /**
  101046. * Sets the transparency mode of the material.
  101047. *
  101048. * | Value | Type | Description |
  101049. * | ----- | ----------------------------------- | ----------- |
  101050. * | 0 | OPAQUE | |
  101051. * | 1 | ALPHATEST | |
  101052. * | 2 | ALPHABLEND | |
  101053. * | 3 | ALPHATESTANDBLEND | |
  101054. *
  101055. */
  101056. set transparencyMode(value: Nullable<number>);
  101057. /**
  101058. * Returns true if alpha blending should be disabled.
  101059. */
  101060. protected get _disableAlphaBlending(): boolean;
  101061. /**
  101062. * Specifies whether or not this material should be rendered in alpha blend mode.
  101063. * @returns a boolean specifying if alpha blending is needed
  101064. */
  101065. needAlphaBlending(): boolean;
  101066. /**
  101067. * Specifies if the mesh will require alpha blending
  101068. * @param mesh defines the mesh to check
  101069. * @returns a boolean specifying if alpha blending is needed for the mesh
  101070. */
  101071. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  101072. /**
  101073. * Specifies whether or not this material should be rendered in alpha test mode.
  101074. * @returns a boolean specifying if an alpha test is needed.
  101075. */
  101076. needAlphaTesting(): boolean;
  101077. /**
  101078. * Specifies if material alpha testing should be turned on for the mesh
  101079. * @param mesh defines the mesh to check
  101080. */
  101081. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  101082. /**
  101083. * Gets the texture used for the alpha test
  101084. * @returns the texture to use for alpha testing
  101085. */
  101086. getAlphaTestTexture(): Nullable<BaseTexture>;
  101087. /**
  101088. * Marks the material to indicate that it needs to be re-calculated
  101089. */
  101090. markDirty(): void;
  101091. /** @hidden */
  101092. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  101093. /**
  101094. * Binds the material to the mesh
  101095. * @param world defines the world transformation matrix
  101096. * @param mesh defines the mesh to bind the material to
  101097. */
  101098. bind(world: Matrix, mesh?: Mesh): void;
  101099. /**
  101100. * Binds the submesh to the material
  101101. * @param world defines the world transformation matrix
  101102. * @param mesh defines the mesh containing the submesh
  101103. * @param subMesh defines the submesh to bind the material to
  101104. */
  101105. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  101106. /**
  101107. * Binds the world matrix to the material
  101108. * @param world defines the world transformation matrix
  101109. */
  101110. bindOnlyWorldMatrix(world: Matrix): void;
  101111. /**
  101112. * Binds the scene's uniform buffer to the effect.
  101113. * @param effect defines the effect to bind to the scene uniform buffer
  101114. * @param sceneUbo defines the uniform buffer storing scene data
  101115. */
  101116. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  101117. /**
  101118. * Binds the view matrix to the effect
  101119. * @param effect defines the effect to bind the view matrix to
  101120. */
  101121. bindView(effect: Effect): void;
  101122. /**
  101123. * Binds the view projection matrix to the effect
  101124. * @param effect defines the effect to bind the view projection matrix to
  101125. */
  101126. bindViewProjection(effect: Effect): void;
  101127. /**
  101128. * Processes to execute after binding the material to a mesh
  101129. * @param mesh defines the rendered mesh
  101130. */
  101131. protected _afterBind(mesh?: Mesh): void;
  101132. /**
  101133. * Unbinds the material from the mesh
  101134. */
  101135. unbind(): void;
  101136. /**
  101137. * Gets the active textures from the material
  101138. * @returns an array of textures
  101139. */
  101140. getActiveTextures(): BaseTexture[];
  101141. /**
  101142. * Specifies if the material uses a texture
  101143. * @param texture defines the texture to check against the material
  101144. * @returns a boolean specifying if the material uses the texture
  101145. */
  101146. hasTexture(texture: BaseTexture): boolean;
  101147. /**
  101148. * Makes a duplicate of the material, and gives it a new name
  101149. * @param name defines the new name for the duplicated material
  101150. * @returns the cloned material
  101151. */
  101152. clone(name: string): Nullable<Material>;
  101153. /**
  101154. * Gets the meshes bound to the material
  101155. * @returns an array of meshes bound to the material
  101156. */
  101157. getBindedMeshes(): AbstractMesh[];
  101158. /**
  101159. * Force shader compilation
  101160. * @param mesh defines the mesh associated with this material
  101161. * @param onCompiled defines a function to execute once the material is compiled
  101162. * @param options defines the options to configure the compilation
  101163. * @param onError defines a function to execute if the material fails compiling
  101164. */
  101165. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  101166. /**
  101167. * Force shader compilation
  101168. * @param mesh defines the mesh that will use this material
  101169. * @param options defines additional options for compiling the shaders
  101170. * @returns a promise that resolves when the compilation completes
  101171. */
  101172. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  101173. private static readonly _AllDirtyCallBack;
  101174. private static readonly _ImageProcessingDirtyCallBack;
  101175. private static readonly _TextureDirtyCallBack;
  101176. private static readonly _FresnelDirtyCallBack;
  101177. private static readonly _MiscDirtyCallBack;
  101178. private static readonly _LightsDirtyCallBack;
  101179. private static readonly _AttributeDirtyCallBack;
  101180. private static _FresnelAndMiscDirtyCallBack;
  101181. private static _TextureAndMiscDirtyCallBack;
  101182. private static readonly _DirtyCallbackArray;
  101183. private static readonly _RunDirtyCallBacks;
  101184. /**
  101185. * Marks a define in the material to indicate that it needs to be re-computed
  101186. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  101187. */
  101188. markAsDirty(flag: number): void;
  101189. /**
  101190. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  101191. * @param func defines a function which checks material defines against the submeshes
  101192. */
  101193. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  101194. /**
  101195. * Indicates that we need to re-calculated for all submeshes
  101196. */
  101197. protected _markAllSubMeshesAsAllDirty(): void;
  101198. /**
  101199. * Indicates that image processing needs to be re-calculated for all submeshes
  101200. */
  101201. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  101202. /**
  101203. * Indicates that textures need to be re-calculated for all submeshes
  101204. */
  101205. protected _markAllSubMeshesAsTexturesDirty(): void;
  101206. /**
  101207. * Indicates that fresnel needs to be re-calculated for all submeshes
  101208. */
  101209. protected _markAllSubMeshesAsFresnelDirty(): void;
  101210. /**
  101211. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  101212. */
  101213. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  101214. /**
  101215. * Indicates that lights need to be re-calculated for all submeshes
  101216. */
  101217. protected _markAllSubMeshesAsLightsDirty(): void;
  101218. /**
  101219. * Indicates that attributes need to be re-calculated for all submeshes
  101220. */
  101221. protected _markAllSubMeshesAsAttributesDirty(): void;
  101222. /**
  101223. * Indicates that misc needs to be re-calculated for all submeshes
  101224. */
  101225. protected _markAllSubMeshesAsMiscDirty(): void;
  101226. /**
  101227. * Indicates that textures and misc need to be re-calculated for all submeshes
  101228. */
  101229. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  101230. /**
  101231. * Disposes the material
  101232. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  101233. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  101234. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  101235. */
  101236. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  101237. /** @hidden */
  101238. private releaseVertexArrayObject;
  101239. /**
  101240. * Serializes this material
  101241. * @returns the serialized material object
  101242. */
  101243. serialize(): any;
  101244. /**
  101245. * Creates a material from parsed material data
  101246. * @param parsedMaterial defines parsed material data
  101247. * @param scene defines the hosting scene
  101248. * @param rootUrl defines the root URL to use to load textures
  101249. * @returns a new material
  101250. */
  101251. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  101252. }
  101253. }
  101254. declare module BABYLON {
  101255. /**
  101256. * A multi-material is used to apply different materials to different parts of the same object without the need of
  101257. * separate meshes. This can be use to improve performances.
  101258. * @see http://doc.babylonjs.com/how_to/multi_materials
  101259. */
  101260. export class MultiMaterial extends Material {
  101261. private _subMaterials;
  101262. /**
  101263. * Gets or Sets the list of Materials used within the multi material.
  101264. * They need to be ordered according to the submeshes order in the associated mesh
  101265. */
  101266. get subMaterials(): Nullable<Material>[];
  101267. set subMaterials(value: Nullable<Material>[]);
  101268. /**
  101269. * Function used to align with Node.getChildren()
  101270. * @returns the list of Materials used within the multi material
  101271. */
  101272. getChildren(): Nullable<Material>[];
  101273. /**
  101274. * Instantiates a new Multi Material
  101275. * A multi-material is used to apply different materials to different parts of the same object without the need of
  101276. * separate meshes. This can be use to improve performances.
  101277. * @see http://doc.babylonjs.com/how_to/multi_materials
  101278. * @param name Define the name in the scene
  101279. * @param scene Define the scene the material belongs to
  101280. */
  101281. constructor(name: string, scene: Scene);
  101282. private _hookArray;
  101283. /**
  101284. * Get one of the submaterial by its index in the submaterials array
  101285. * @param index The index to look the sub material at
  101286. * @returns The Material if the index has been defined
  101287. */
  101288. getSubMaterial(index: number): Nullable<Material>;
  101289. /**
  101290. * Get the list of active textures for the whole sub materials list.
  101291. * @returns All the textures that will be used during the rendering
  101292. */
  101293. getActiveTextures(): BaseTexture[];
  101294. /**
  101295. * Gets the current class name of the material e.g. "MultiMaterial"
  101296. * Mainly use in serialization.
  101297. * @returns the class name
  101298. */
  101299. getClassName(): string;
  101300. /**
  101301. * Checks if the material is ready to render the requested sub mesh
  101302. * @param mesh Define the mesh the submesh belongs to
  101303. * @param subMesh Define the sub mesh to look readyness for
  101304. * @param useInstances Define whether or not the material is used with instances
  101305. * @returns true if ready, otherwise false
  101306. */
  101307. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  101308. /**
  101309. * Clones the current material and its related sub materials
  101310. * @param name Define the name of the newly cloned material
  101311. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  101312. * @returns the cloned material
  101313. */
  101314. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  101315. /**
  101316. * Serializes the materials into a JSON representation.
  101317. * @returns the JSON representation
  101318. */
  101319. serialize(): any;
  101320. /**
  101321. * Dispose the material and release its associated resources
  101322. * @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)
  101323. * @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)
  101324. * @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)
  101325. */
  101326. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  101327. /**
  101328. * Creates a MultiMaterial from parsed MultiMaterial data.
  101329. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  101330. * @param scene defines the hosting scene
  101331. * @returns a new MultiMaterial
  101332. */
  101333. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  101334. }
  101335. }
  101336. declare module BABYLON {
  101337. /**
  101338. * Base class for submeshes
  101339. */
  101340. export class BaseSubMesh {
  101341. /** @hidden */
  101342. _materialDefines: Nullable<MaterialDefines>;
  101343. /** @hidden */
  101344. _materialEffect: Nullable<Effect>;
  101345. /** @hidden */
  101346. _effectOverride: Nullable<Effect>;
  101347. /**
  101348. * Gets material defines used by the effect associated to the sub mesh
  101349. */
  101350. get materialDefines(): Nullable<MaterialDefines>;
  101351. /**
  101352. * Sets material defines used by the effect associated to the sub mesh
  101353. */
  101354. set materialDefines(defines: Nullable<MaterialDefines>);
  101355. /**
  101356. * Gets associated effect
  101357. */
  101358. get effect(): Nullable<Effect>;
  101359. /**
  101360. * Sets associated effect (effect used to render this submesh)
  101361. * @param effect defines the effect to associate with
  101362. * @param defines defines the set of defines used to compile this effect
  101363. */
  101364. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  101365. }
  101366. /**
  101367. * Defines a subdivision inside a mesh
  101368. */
  101369. export class SubMesh extends BaseSubMesh implements ICullable {
  101370. /** the material index to use */
  101371. materialIndex: number;
  101372. /** vertex index start */
  101373. verticesStart: number;
  101374. /** vertices count */
  101375. verticesCount: number;
  101376. /** index start */
  101377. indexStart: number;
  101378. /** indices count */
  101379. indexCount: number;
  101380. /** @hidden */
  101381. _linesIndexCount: number;
  101382. private _mesh;
  101383. private _renderingMesh;
  101384. private _boundingInfo;
  101385. private _linesIndexBuffer;
  101386. /** @hidden */
  101387. _lastColliderWorldVertices: Nullable<Vector3[]>;
  101388. /** @hidden */
  101389. _trianglePlanes: Plane[];
  101390. /** @hidden */
  101391. _lastColliderTransformMatrix: Nullable<Matrix>;
  101392. /** @hidden */
  101393. _renderId: number;
  101394. /** @hidden */
  101395. _alphaIndex: number;
  101396. /** @hidden */
  101397. _distanceToCamera: number;
  101398. /** @hidden */
  101399. _id: number;
  101400. private _currentMaterial;
  101401. /**
  101402. * Add a new submesh to a mesh
  101403. * @param materialIndex defines the material index to use
  101404. * @param verticesStart defines vertex index start
  101405. * @param verticesCount defines vertices count
  101406. * @param indexStart defines index start
  101407. * @param indexCount defines indices count
  101408. * @param mesh defines the parent mesh
  101409. * @param renderingMesh defines an optional rendering mesh
  101410. * @param createBoundingBox defines if bounding box should be created for this submesh
  101411. * @returns the new submesh
  101412. */
  101413. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  101414. /**
  101415. * Creates a new submesh
  101416. * @param materialIndex defines the material index to use
  101417. * @param verticesStart defines vertex index start
  101418. * @param verticesCount defines vertices count
  101419. * @param indexStart defines index start
  101420. * @param indexCount defines indices count
  101421. * @param mesh defines the parent mesh
  101422. * @param renderingMesh defines an optional rendering mesh
  101423. * @param createBoundingBox defines if bounding box should be created for this submesh
  101424. */
  101425. constructor(
  101426. /** the material index to use */
  101427. materialIndex: number,
  101428. /** vertex index start */
  101429. verticesStart: number,
  101430. /** vertices count */
  101431. verticesCount: number,
  101432. /** index start */
  101433. indexStart: number,
  101434. /** indices count */
  101435. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  101436. /**
  101437. * Returns true if this submesh covers the entire parent mesh
  101438. * @ignorenaming
  101439. */
  101440. get IsGlobal(): boolean;
  101441. /**
  101442. * Returns the submesh BoudingInfo object
  101443. * @returns current bounding info (or mesh's one if the submesh is global)
  101444. */
  101445. getBoundingInfo(): BoundingInfo;
  101446. /**
  101447. * Sets the submesh BoundingInfo
  101448. * @param boundingInfo defines the new bounding info to use
  101449. * @returns the SubMesh
  101450. */
  101451. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  101452. /**
  101453. * Returns the mesh of the current submesh
  101454. * @return the parent mesh
  101455. */
  101456. getMesh(): AbstractMesh;
  101457. /**
  101458. * Returns the rendering mesh of the submesh
  101459. * @returns the rendering mesh (could be different from parent mesh)
  101460. */
  101461. getRenderingMesh(): Mesh;
  101462. /**
  101463. * Returns the submesh material
  101464. * @returns null or the current material
  101465. */
  101466. getMaterial(): Nullable<Material>;
  101467. /**
  101468. * Sets a new updated BoundingInfo object to the submesh
  101469. * @param data defines an optional position array to use to determine the bounding info
  101470. * @returns the SubMesh
  101471. */
  101472. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  101473. /** @hidden */
  101474. _checkCollision(collider: Collider): boolean;
  101475. /**
  101476. * Updates the submesh BoundingInfo
  101477. * @param world defines the world matrix to use to update the bounding info
  101478. * @returns the submesh
  101479. */
  101480. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  101481. /**
  101482. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  101483. * @param frustumPlanes defines the frustum planes
  101484. * @returns true if the submesh is intersecting with the frustum
  101485. */
  101486. isInFrustum(frustumPlanes: Plane[]): boolean;
  101487. /**
  101488. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  101489. * @param frustumPlanes defines the frustum planes
  101490. * @returns true if the submesh is inside the frustum
  101491. */
  101492. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  101493. /**
  101494. * Renders the submesh
  101495. * @param enableAlphaMode defines if alpha needs to be used
  101496. * @returns the submesh
  101497. */
  101498. render(enableAlphaMode: boolean): SubMesh;
  101499. /**
  101500. * @hidden
  101501. */
  101502. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  101503. /**
  101504. * Checks if the submesh intersects with a ray
  101505. * @param ray defines the ray to test
  101506. * @returns true is the passed ray intersects the submesh bounding box
  101507. */
  101508. canIntersects(ray: Ray): boolean;
  101509. /**
  101510. * Intersects current submesh with a ray
  101511. * @param ray defines the ray to test
  101512. * @param positions defines mesh's positions array
  101513. * @param indices defines mesh's indices array
  101514. * @param fastCheck defines if the first intersection will be used (and not the closest)
  101515. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  101516. * @returns intersection info or null if no intersection
  101517. */
  101518. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  101519. /** @hidden */
  101520. private _intersectLines;
  101521. /** @hidden */
  101522. private _intersectUnIndexedLines;
  101523. /** @hidden */
  101524. private _intersectTriangles;
  101525. /** @hidden */
  101526. private _intersectUnIndexedTriangles;
  101527. /** @hidden */
  101528. _rebuild(): void;
  101529. /**
  101530. * Creates a new submesh from the passed mesh
  101531. * @param newMesh defines the new hosting mesh
  101532. * @param newRenderingMesh defines an optional rendering mesh
  101533. * @returns the new submesh
  101534. */
  101535. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  101536. /**
  101537. * Release associated resources
  101538. */
  101539. dispose(): void;
  101540. /**
  101541. * Gets the class name
  101542. * @returns the string "SubMesh".
  101543. */
  101544. getClassName(): string;
  101545. /**
  101546. * Creates a new submesh from indices data
  101547. * @param materialIndex the index of the main mesh material
  101548. * @param startIndex the index where to start the copy in the mesh indices array
  101549. * @param indexCount the number of indices to copy then from the startIndex
  101550. * @param mesh the main mesh to create the submesh from
  101551. * @param renderingMesh the optional rendering mesh
  101552. * @returns a new submesh
  101553. */
  101554. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  101555. }
  101556. }
  101557. declare module BABYLON {
  101558. /**
  101559. * Class used to represent data loading progression
  101560. */
  101561. export class SceneLoaderFlags {
  101562. private static _ForceFullSceneLoadingForIncremental;
  101563. private static _ShowLoadingScreen;
  101564. private static _CleanBoneMatrixWeights;
  101565. private static _loggingLevel;
  101566. /**
  101567. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  101568. */
  101569. static get ForceFullSceneLoadingForIncremental(): boolean;
  101570. static set ForceFullSceneLoadingForIncremental(value: boolean);
  101571. /**
  101572. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  101573. */
  101574. static get ShowLoadingScreen(): boolean;
  101575. static set ShowLoadingScreen(value: boolean);
  101576. /**
  101577. * Defines the current logging level (while loading the scene)
  101578. * @ignorenaming
  101579. */
  101580. static get loggingLevel(): number;
  101581. static set loggingLevel(value: number);
  101582. /**
  101583. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  101584. */
  101585. static get CleanBoneMatrixWeights(): boolean;
  101586. static set CleanBoneMatrixWeights(value: boolean);
  101587. }
  101588. }
  101589. declare module BABYLON {
  101590. /**
  101591. * Class used to store geometry data (vertex buffers + index buffer)
  101592. */
  101593. export class Geometry implements IGetSetVerticesData {
  101594. /**
  101595. * Gets or sets the ID of the geometry
  101596. */
  101597. id: string;
  101598. /**
  101599. * Gets or sets the unique ID of the geometry
  101600. */
  101601. uniqueId: number;
  101602. /**
  101603. * Gets the delay loading state of the geometry (none by default which means not delayed)
  101604. */
  101605. delayLoadState: number;
  101606. /**
  101607. * Gets the file containing the data to load when running in delay load state
  101608. */
  101609. delayLoadingFile: Nullable<string>;
  101610. /**
  101611. * Callback called when the geometry is updated
  101612. */
  101613. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  101614. private _scene;
  101615. private _engine;
  101616. private _meshes;
  101617. private _totalVertices;
  101618. /** @hidden */
  101619. _indices: IndicesArray;
  101620. /** @hidden */
  101621. _vertexBuffers: {
  101622. [key: string]: VertexBuffer;
  101623. };
  101624. private _isDisposed;
  101625. private _extend;
  101626. private _boundingBias;
  101627. /** @hidden */
  101628. _delayInfo: Array<string>;
  101629. private _indexBuffer;
  101630. private _indexBufferIsUpdatable;
  101631. /** @hidden */
  101632. _boundingInfo: Nullable<BoundingInfo>;
  101633. /** @hidden */
  101634. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  101635. /** @hidden */
  101636. _softwareSkinningFrameId: number;
  101637. private _vertexArrayObjects;
  101638. private _updatable;
  101639. /** @hidden */
  101640. _positions: Nullable<Vector3[]>;
  101641. /**
  101642. * 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
  101643. */
  101644. get boundingBias(): Vector2;
  101645. /**
  101646. * 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
  101647. */
  101648. set boundingBias(value: Vector2);
  101649. /**
  101650. * Static function used to attach a new empty geometry to a mesh
  101651. * @param mesh defines the mesh to attach the geometry to
  101652. * @returns the new Geometry
  101653. */
  101654. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  101655. /** Get the list of meshes using this geometry */
  101656. get meshes(): Mesh[];
  101657. /**
  101658. * Creates a new geometry
  101659. * @param id defines the unique ID
  101660. * @param scene defines the hosting scene
  101661. * @param vertexData defines the VertexData used to get geometry data
  101662. * @param updatable defines if geometry must be updatable (false by default)
  101663. * @param mesh defines the mesh that will be associated with the geometry
  101664. */
  101665. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  101666. /**
  101667. * Gets the current extend of the geometry
  101668. */
  101669. get extend(): {
  101670. minimum: Vector3;
  101671. maximum: Vector3;
  101672. };
  101673. /**
  101674. * Gets the hosting scene
  101675. * @returns the hosting Scene
  101676. */
  101677. getScene(): Scene;
  101678. /**
  101679. * Gets the hosting engine
  101680. * @returns the hosting Engine
  101681. */
  101682. getEngine(): Engine;
  101683. /**
  101684. * Defines if the geometry is ready to use
  101685. * @returns true if the geometry is ready to be used
  101686. */
  101687. isReady(): boolean;
  101688. /**
  101689. * Gets a value indicating that the geometry should not be serialized
  101690. */
  101691. get doNotSerialize(): boolean;
  101692. /** @hidden */
  101693. _rebuild(): void;
  101694. /**
  101695. * Affects all geometry data in one call
  101696. * @param vertexData defines the geometry data
  101697. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  101698. */
  101699. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  101700. /**
  101701. * Set specific vertex data
  101702. * @param kind defines the data kind (Position, normal, etc...)
  101703. * @param data defines the vertex data to use
  101704. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  101705. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  101706. */
  101707. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  101708. /**
  101709. * Removes a specific vertex data
  101710. * @param kind defines the data kind (Position, normal, etc...)
  101711. */
  101712. removeVerticesData(kind: string): void;
  101713. /**
  101714. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  101715. * @param buffer defines the vertex buffer to use
  101716. * @param totalVertices defines the total number of vertices for position kind (could be null)
  101717. */
  101718. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  101719. /**
  101720. * Update a specific vertex buffer
  101721. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  101722. * It will do nothing if the buffer is not updatable
  101723. * @param kind defines the data kind (Position, normal, etc...)
  101724. * @param data defines the data to use
  101725. * @param offset defines the offset in the target buffer where to store the data
  101726. * @param useBytes set to true if the offset is in bytes
  101727. */
  101728. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  101729. /**
  101730. * Update a specific vertex buffer
  101731. * This function will create a new buffer if the current one is not updatable
  101732. * @param kind defines the data kind (Position, normal, etc...)
  101733. * @param data defines the data to use
  101734. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  101735. */
  101736. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  101737. private _updateBoundingInfo;
  101738. /** @hidden */
  101739. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  101740. /**
  101741. * Gets total number of vertices
  101742. * @returns the total number of vertices
  101743. */
  101744. getTotalVertices(): number;
  101745. /**
  101746. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  101747. * @param kind defines the data kind (Position, normal, etc...)
  101748. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  101749. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  101750. * @returns a float array containing vertex data
  101751. */
  101752. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  101753. /**
  101754. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  101755. * @param kind defines the data kind (Position, normal, etc...)
  101756. * @returns true if the vertex buffer with the specified kind is updatable
  101757. */
  101758. isVertexBufferUpdatable(kind: string): boolean;
  101759. /**
  101760. * Gets a specific vertex buffer
  101761. * @param kind defines the data kind (Position, normal, etc...)
  101762. * @returns a VertexBuffer
  101763. */
  101764. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  101765. /**
  101766. * Returns all vertex buffers
  101767. * @return an object holding all vertex buffers indexed by kind
  101768. */
  101769. getVertexBuffers(): Nullable<{
  101770. [key: string]: VertexBuffer;
  101771. }>;
  101772. /**
  101773. * Gets a boolean indicating if specific vertex buffer is present
  101774. * @param kind defines the data kind (Position, normal, etc...)
  101775. * @returns true if data is present
  101776. */
  101777. isVerticesDataPresent(kind: string): boolean;
  101778. /**
  101779. * Gets a list of all attached data kinds (Position, normal, etc...)
  101780. * @returns a list of string containing all kinds
  101781. */
  101782. getVerticesDataKinds(): string[];
  101783. /**
  101784. * Update index buffer
  101785. * @param indices defines the indices to store in the index buffer
  101786. * @param offset defines the offset in the target buffer where to store the data
  101787. * @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)
  101788. */
  101789. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  101790. /**
  101791. * Creates a new index buffer
  101792. * @param indices defines the indices to store in the index buffer
  101793. * @param totalVertices defines the total number of vertices (could be null)
  101794. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  101795. */
  101796. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  101797. /**
  101798. * Return the total number of indices
  101799. * @returns the total number of indices
  101800. */
  101801. getTotalIndices(): number;
  101802. /**
  101803. * Gets the index buffer array
  101804. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  101805. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  101806. * @returns the index buffer array
  101807. */
  101808. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  101809. /**
  101810. * Gets the index buffer
  101811. * @return the index buffer
  101812. */
  101813. getIndexBuffer(): Nullable<DataBuffer>;
  101814. /** @hidden */
  101815. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  101816. /**
  101817. * Release the associated resources for a specific mesh
  101818. * @param mesh defines the source mesh
  101819. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  101820. */
  101821. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  101822. /**
  101823. * Apply current geometry to a given mesh
  101824. * @param mesh defines the mesh to apply geometry to
  101825. */
  101826. applyToMesh(mesh: Mesh): void;
  101827. private _updateExtend;
  101828. private _applyToMesh;
  101829. private notifyUpdate;
  101830. /**
  101831. * Load the geometry if it was flagged as delay loaded
  101832. * @param scene defines the hosting scene
  101833. * @param onLoaded defines a callback called when the geometry is loaded
  101834. */
  101835. load(scene: Scene, onLoaded?: () => void): void;
  101836. private _queueLoad;
  101837. /**
  101838. * Invert the geometry to move from a right handed system to a left handed one.
  101839. */
  101840. toLeftHanded(): void;
  101841. /** @hidden */
  101842. _resetPointsArrayCache(): void;
  101843. /** @hidden */
  101844. _generatePointsArray(): boolean;
  101845. /**
  101846. * Gets a value indicating if the geometry is disposed
  101847. * @returns true if the geometry was disposed
  101848. */
  101849. isDisposed(): boolean;
  101850. private _disposeVertexArrayObjects;
  101851. /**
  101852. * Free all associated resources
  101853. */
  101854. dispose(): void;
  101855. /**
  101856. * Clone the current geometry into a new geometry
  101857. * @param id defines the unique ID of the new geometry
  101858. * @returns a new geometry object
  101859. */
  101860. copy(id: string): Geometry;
  101861. /**
  101862. * Serialize the current geometry info (and not the vertices data) into a JSON object
  101863. * @return a JSON representation of the current geometry data (without the vertices data)
  101864. */
  101865. serialize(): any;
  101866. private toNumberArray;
  101867. /**
  101868. * Serialize all vertices data into a JSON oject
  101869. * @returns a JSON representation of the current geometry data
  101870. */
  101871. serializeVerticeData(): any;
  101872. /**
  101873. * Extracts a clone of a mesh geometry
  101874. * @param mesh defines the source mesh
  101875. * @param id defines the unique ID of the new geometry object
  101876. * @returns the new geometry object
  101877. */
  101878. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  101879. /**
  101880. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  101881. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  101882. * Be aware Math.random() could cause collisions, but:
  101883. * "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"
  101884. * @returns a string containing a new GUID
  101885. */
  101886. static RandomId(): string;
  101887. /** @hidden */
  101888. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  101889. private static _CleanMatricesWeights;
  101890. /**
  101891. * Create a new geometry from persisted data (Using .babylon file format)
  101892. * @param parsedVertexData defines the persisted data
  101893. * @param scene defines the hosting scene
  101894. * @param rootUrl defines the root url to use to load assets (like delayed data)
  101895. * @returns the new geometry object
  101896. */
  101897. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  101898. }
  101899. }
  101900. declare module BABYLON {
  101901. /**
  101902. * Define an interface for all classes that will get and set the data on vertices
  101903. */
  101904. export interface IGetSetVerticesData {
  101905. /**
  101906. * Gets a boolean indicating if specific vertex data is present
  101907. * @param kind defines the vertex data kind to use
  101908. * @returns true is data kind is present
  101909. */
  101910. isVerticesDataPresent(kind: string): boolean;
  101911. /**
  101912. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  101913. * @param kind defines the data kind (Position, normal, etc...)
  101914. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  101915. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  101916. * @returns a float array containing vertex data
  101917. */
  101918. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  101919. /**
  101920. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  101921. * @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.
  101922. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  101923. * @returns the indices array or an empty array if the mesh has no geometry
  101924. */
  101925. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  101926. /**
  101927. * Set specific vertex data
  101928. * @param kind defines the data kind (Position, normal, etc...)
  101929. * @param data defines the vertex data to use
  101930. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  101931. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  101932. */
  101933. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  101934. /**
  101935. * Update a specific associated vertex buffer
  101936. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  101937. * - VertexBuffer.PositionKind
  101938. * - VertexBuffer.UVKind
  101939. * - VertexBuffer.UV2Kind
  101940. * - VertexBuffer.UV3Kind
  101941. * - VertexBuffer.UV4Kind
  101942. * - VertexBuffer.UV5Kind
  101943. * - VertexBuffer.UV6Kind
  101944. * - VertexBuffer.ColorKind
  101945. * - VertexBuffer.MatricesIndicesKind
  101946. * - VertexBuffer.MatricesIndicesExtraKind
  101947. * - VertexBuffer.MatricesWeightsKind
  101948. * - VertexBuffer.MatricesWeightsExtraKind
  101949. * @param data defines the data source
  101950. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  101951. * @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)
  101952. */
  101953. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  101954. /**
  101955. * Creates a new index buffer
  101956. * @param indices defines the indices to store in the index buffer
  101957. * @param totalVertices defines the total number of vertices (could be null)
  101958. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  101959. */
  101960. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  101961. }
  101962. /**
  101963. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  101964. */
  101965. export class VertexData {
  101966. /**
  101967. * Mesh side orientation : usually the external or front surface
  101968. */
  101969. static readonly FRONTSIDE: number;
  101970. /**
  101971. * Mesh side orientation : usually the internal or back surface
  101972. */
  101973. static readonly BACKSIDE: number;
  101974. /**
  101975. * Mesh side orientation : both internal and external or front and back surfaces
  101976. */
  101977. static readonly DOUBLESIDE: number;
  101978. /**
  101979. * Mesh side orientation : by default, `FRONTSIDE`
  101980. */
  101981. static readonly DEFAULTSIDE: number;
  101982. /**
  101983. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  101984. */
  101985. positions: Nullable<FloatArray>;
  101986. /**
  101987. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  101988. */
  101989. normals: Nullable<FloatArray>;
  101990. /**
  101991. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  101992. */
  101993. tangents: Nullable<FloatArray>;
  101994. /**
  101995. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  101996. */
  101997. uvs: Nullable<FloatArray>;
  101998. /**
  101999. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  102000. */
  102001. uvs2: Nullable<FloatArray>;
  102002. /**
  102003. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  102004. */
  102005. uvs3: Nullable<FloatArray>;
  102006. /**
  102007. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  102008. */
  102009. uvs4: Nullable<FloatArray>;
  102010. /**
  102011. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  102012. */
  102013. uvs5: Nullable<FloatArray>;
  102014. /**
  102015. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  102016. */
  102017. uvs6: Nullable<FloatArray>;
  102018. /**
  102019. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  102020. */
  102021. colors: Nullable<FloatArray>;
  102022. /**
  102023. * 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).
  102024. */
  102025. matricesIndices: Nullable<FloatArray>;
  102026. /**
  102027. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  102028. */
  102029. matricesWeights: Nullable<FloatArray>;
  102030. /**
  102031. * An array extending the number of possible indices
  102032. */
  102033. matricesIndicesExtra: Nullable<FloatArray>;
  102034. /**
  102035. * An array extending the number of possible weights when the number of indices is extended
  102036. */
  102037. matricesWeightsExtra: Nullable<FloatArray>;
  102038. /**
  102039. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  102040. */
  102041. indices: Nullable<IndicesArray>;
  102042. /**
  102043. * Uses the passed data array to set the set the values for the specified kind of data
  102044. * @param data a linear array of floating numbers
  102045. * @param kind the type of data that is being set, eg positions, colors etc
  102046. */
  102047. set(data: FloatArray, kind: string): void;
  102048. /**
  102049. * Associates the vertexData to the passed Mesh.
  102050. * Sets it as updatable or not (default `false`)
  102051. * @param mesh the mesh the vertexData is applied to
  102052. * @param updatable when used and having the value true allows new data to update the vertexData
  102053. * @returns the VertexData
  102054. */
  102055. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  102056. /**
  102057. * Associates the vertexData to the passed Geometry.
  102058. * Sets it as updatable or not (default `false`)
  102059. * @param geometry the geometry the vertexData is applied to
  102060. * @param updatable when used and having the value true allows new data to update the vertexData
  102061. * @returns VertexData
  102062. */
  102063. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  102064. /**
  102065. * Updates the associated mesh
  102066. * @param mesh the mesh to be updated
  102067. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  102068. * @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
  102069. * @returns VertexData
  102070. */
  102071. updateMesh(mesh: Mesh): VertexData;
  102072. /**
  102073. * Updates the associated geometry
  102074. * @param geometry the geometry to be updated
  102075. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  102076. * @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
  102077. * @returns VertexData.
  102078. */
  102079. updateGeometry(geometry: Geometry): VertexData;
  102080. private _applyTo;
  102081. private _update;
  102082. /**
  102083. * Transforms each position and each normal of the vertexData according to the passed Matrix
  102084. * @param matrix the transforming matrix
  102085. * @returns the VertexData
  102086. */
  102087. transform(matrix: Matrix): VertexData;
  102088. /**
  102089. * Merges the passed VertexData into the current one
  102090. * @param other the VertexData to be merged into the current one
  102091. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  102092. * @returns the modified VertexData
  102093. */
  102094. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  102095. private _mergeElement;
  102096. private _validate;
  102097. /**
  102098. * Serializes the VertexData
  102099. * @returns a serialized object
  102100. */
  102101. serialize(): any;
  102102. /**
  102103. * Extracts the vertexData from a mesh
  102104. * @param mesh the mesh from which to extract the VertexData
  102105. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  102106. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  102107. * @returns the object VertexData associated to the passed mesh
  102108. */
  102109. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  102110. /**
  102111. * Extracts the vertexData from the geometry
  102112. * @param geometry the geometry from which to extract the VertexData
  102113. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  102114. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  102115. * @returns the object VertexData associated to the passed mesh
  102116. */
  102117. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  102118. private static _ExtractFrom;
  102119. /**
  102120. * Creates the VertexData for a Ribbon
  102121. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  102122. * * pathArray array of paths, each of which an array of successive Vector3
  102123. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  102124. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  102125. * * 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
  102126. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  102127. * * 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)
  102128. * * 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)
  102129. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  102130. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  102131. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  102132. * @returns the VertexData of the ribbon
  102133. */
  102134. static CreateRibbon(options: {
  102135. pathArray: Vector3[][];
  102136. closeArray?: boolean;
  102137. closePath?: boolean;
  102138. offset?: number;
  102139. sideOrientation?: number;
  102140. frontUVs?: Vector4;
  102141. backUVs?: Vector4;
  102142. invertUV?: boolean;
  102143. uvs?: Vector2[];
  102144. colors?: Color4[];
  102145. }): VertexData;
  102146. /**
  102147. * Creates the VertexData for a box
  102148. * @param options an object used to set the following optional parameters for the box, required but can be empty
  102149. * * size sets the width, height and depth of the box to the value of size, optional default 1
  102150. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  102151. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  102152. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  102153. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  102154. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  102155. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  102156. * * 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)
  102157. * * 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)
  102158. * @returns the VertexData of the box
  102159. */
  102160. static CreateBox(options: {
  102161. size?: number;
  102162. width?: number;
  102163. height?: number;
  102164. depth?: number;
  102165. faceUV?: Vector4[];
  102166. faceColors?: Color4[];
  102167. sideOrientation?: number;
  102168. frontUVs?: Vector4;
  102169. backUVs?: Vector4;
  102170. }): VertexData;
  102171. /**
  102172. * Creates the VertexData for a tiled box
  102173. * @param options an object used to set the following optional parameters for the box, required but can be empty
  102174. * * faceTiles sets the pattern, tile size and number of tiles for a face
  102175. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  102176. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  102177. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  102178. * @returns the VertexData of the box
  102179. */
  102180. static CreateTiledBox(options: {
  102181. pattern?: number;
  102182. width?: number;
  102183. height?: number;
  102184. depth?: number;
  102185. tileSize?: number;
  102186. tileWidth?: number;
  102187. tileHeight?: number;
  102188. alignHorizontal?: number;
  102189. alignVertical?: number;
  102190. faceUV?: Vector4[];
  102191. faceColors?: Color4[];
  102192. sideOrientation?: number;
  102193. }): VertexData;
  102194. /**
  102195. * Creates the VertexData for a tiled plane
  102196. * @param options an object used to set the following optional parameters for the box, required but can be empty
  102197. * * pattern a limited pattern arrangement depending on the number
  102198. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  102199. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  102200. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  102201. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  102202. * * 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)
  102203. * * 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)
  102204. * @returns the VertexData of the tiled plane
  102205. */
  102206. static CreateTiledPlane(options: {
  102207. pattern?: number;
  102208. tileSize?: number;
  102209. tileWidth?: number;
  102210. tileHeight?: number;
  102211. size?: number;
  102212. width?: number;
  102213. height?: number;
  102214. alignHorizontal?: number;
  102215. alignVertical?: number;
  102216. sideOrientation?: number;
  102217. frontUVs?: Vector4;
  102218. backUVs?: Vector4;
  102219. }): VertexData;
  102220. /**
  102221. * Creates the VertexData for an ellipsoid, defaults to a sphere
  102222. * @param options an object used to set the following optional parameters for the box, required but can be empty
  102223. * * segments sets the number of horizontal strips optional, default 32
  102224. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  102225. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  102226. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  102227. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  102228. * * 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
  102229. * * 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
  102230. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  102231. * * 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)
  102232. * * 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)
  102233. * @returns the VertexData of the ellipsoid
  102234. */
  102235. static CreateSphere(options: {
  102236. segments?: number;
  102237. diameter?: number;
  102238. diameterX?: number;
  102239. diameterY?: number;
  102240. diameterZ?: number;
  102241. arc?: number;
  102242. slice?: number;
  102243. sideOrientation?: number;
  102244. frontUVs?: Vector4;
  102245. backUVs?: Vector4;
  102246. }): VertexData;
  102247. /**
  102248. * Creates the VertexData for a cylinder, cone or prism
  102249. * @param options an object used to set the following optional parameters for the box, required but can be empty
  102250. * * height sets the height (y direction) of the cylinder, optional, default 2
  102251. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  102252. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  102253. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  102254. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  102255. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  102256. * * 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
  102257. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  102258. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  102259. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  102260. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  102261. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  102262. * * 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)
  102263. * * 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)
  102264. * @returns the VertexData of the cylinder, cone or prism
  102265. */
  102266. static CreateCylinder(options: {
  102267. height?: number;
  102268. diameterTop?: number;
  102269. diameterBottom?: number;
  102270. diameter?: number;
  102271. tessellation?: number;
  102272. subdivisions?: number;
  102273. arc?: number;
  102274. faceColors?: Color4[];
  102275. faceUV?: Vector4[];
  102276. hasRings?: boolean;
  102277. enclose?: boolean;
  102278. sideOrientation?: number;
  102279. frontUVs?: Vector4;
  102280. backUVs?: Vector4;
  102281. }): VertexData;
  102282. /**
  102283. * Creates the VertexData for a torus
  102284. * @param options an object used to set the following optional parameters for the box, required but can be empty
  102285. * * diameter the diameter of the torus, optional default 1
  102286. * * thickness the diameter of the tube forming the torus, optional default 0.5
  102287. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  102288. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  102289. * * 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)
  102290. * * 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)
  102291. * @returns the VertexData of the torus
  102292. */
  102293. static CreateTorus(options: {
  102294. diameter?: number;
  102295. thickness?: number;
  102296. tessellation?: number;
  102297. sideOrientation?: number;
  102298. frontUVs?: Vector4;
  102299. backUVs?: Vector4;
  102300. }): VertexData;
  102301. /**
  102302. * Creates the VertexData of the LineSystem
  102303. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  102304. * - lines an array of lines, each line being an array of successive Vector3
  102305. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  102306. * @returns the VertexData of the LineSystem
  102307. */
  102308. static CreateLineSystem(options: {
  102309. lines: Vector3[][];
  102310. colors?: Nullable<Color4[][]>;
  102311. }): VertexData;
  102312. /**
  102313. * Create the VertexData for a DashedLines
  102314. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  102315. * - points an array successive Vector3
  102316. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  102317. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  102318. * - dashNb the intended total number of dashes, optional, default 200
  102319. * @returns the VertexData for the DashedLines
  102320. */
  102321. static CreateDashedLines(options: {
  102322. points: Vector3[];
  102323. dashSize?: number;
  102324. gapSize?: number;
  102325. dashNb?: number;
  102326. }): VertexData;
  102327. /**
  102328. * Creates the VertexData for a Ground
  102329. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  102330. * - width the width (x direction) of the ground, optional, default 1
  102331. * - height the height (z direction) of the ground, optional, default 1
  102332. * - subdivisions the number of subdivisions per side, optional, default 1
  102333. * @returns the VertexData of the Ground
  102334. */
  102335. static CreateGround(options: {
  102336. width?: number;
  102337. height?: number;
  102338. subdivisions?: number;
  102339. subdivisionsX?: number;
  102340. subdivisionsY?: number;
  102341. }): VertexData;
  102342. /**
  102343. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  102344. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  102345. * * xmin the ground minimum X coordinate, optional, default -1
  102346. * * zmin the ground minimum Z coordinate, optional, default -1
  102347. * * xmax the ground maximum X coordinate, optional, default 1
  102348. * * zmax the ground maximum Z coordinate, optional, default 1
  102349. * * 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}
  102350. * * 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}
  102351. * @returns the VertexData of the TiledGround
  102352. */
  102353. static CreateTiledGround(options: {
  102354. xmin: number;
  102355. zmin: number;
  102356. xmax: number;
  102357. zmax: number;
  102358. subdivisions?: {
  102359. w: number;
  102360. h: number;
  102361. };
  102362. precision?: {
  102363. w: number;
  102364. h: number;
  102365. };
  102366. }): VertexData;
  102367. /**
  102368. * Creates the VertexData of the Ground designed from a heightmap
  102369. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  102370. * * width the width (x direction) of the ground
  102371. * * height the height (z direction) of the ground
  102372. * * subdivisions the number of subdivisions per side
  102373. * * minHeight the minimum altitude on the ground, optional, default 0
  102374. * * maxHeight the maximum altitude on the ground, optional default 1
  102375. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  102376. * * buffer the array holding the image color data
  102377. * * bufferWidth the width of image
  102378. * * bufferHeight the height of image
  102379. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  102380. * @returns the VertexData of the Ground designed from a heightmap
  102381. */
  102382. static CreateGroundFromHeightMap(options: {
  102383. width: number;
  102384. height: number;
  102385. subdivisions: number;
  102386. minHeight: number;
  102387. maxHeight: number;
  102388. colorFilter: Color3;
  102389. buffer: Uint8Array;
  102390. bufferWidth: number;
  102391. bufferHeight: number;
  102392. alphaFilter: number;
  102393. }): VertexData;
  102394. /**
  102395. * Creates the VertexData for a Plane
  102396. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  102397. * * size sets the width and height of the plane to the value of size, optional default 1
  102398. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  102399. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  102400. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  102401. * * 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)
  102402. * * 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)
  102403. * @returns the VertexData of the box
  102404. */
  102405. static CreatePlane(options: {
  102406. size?: number;
  102407. width?: number;
  102408. height?: number;
  102409. sideOrientation?: number;
  102410. frontUVs?: Vector4;
  102411. backUVs?: Vector4;
  102412. }): VertexData;
  102413. /**
  102414. * Creates the VertexData of the Disc or regular Polygon
  102415. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  102416. * * radius the radius of the disc, optional default 0.5
  102417. * * tessellation the number of polygon sides, optional, default 64
  102418. * * 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
  102419. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  102420. * * 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)
  102421. * * 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)
  102422. * @returns the VertexData of the box
  102423. */
  102424. static CreateDisc(options: {
  102425. radius?: number;
  102426. tessellation?: number;
  102427. arc?: number;
  102428. sideOrientation?: number;
  102429. frontUVs?: Vector4;
  102430. backUVs?: Vector4;
  102431. }): VertexData;
  102432. /**
  102433. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  102434. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  102435. * @param polygon a mesh built from polygonTriangulation.build()
  102436. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  102437. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  102438. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  102439. * @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)
  102440. * @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)
  102441. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  102442. * @returns the VertexData of the Polygon
  102443. */
  102444. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  102445. /**
  102446. * Creates the VertexData of the IcoSphere
  102447. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  102448. * * radius the radius of the IcoSphere, optional default 1
  102449. * * radiusX allows stretching in the x direction, optional, default radius
  102450. * * radiusY allows stretching in the y direction, optional, default radius
  102451. * * radiusZ allows stretching in the z direction, optional, default radius
  102452. * * flat when true creates a flat shaded mesh, optional, default true
  102453. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  102454. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  102455. * * 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)
  102456. * * 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)
  102457. * @returns the VertexData of the IcoSphere
  102458. */
  102459. static CreateIcoSphere(options: {
  102460. radius?: number;
  102461. radiusX?: number;
  102462. radiusY?: number;
  102463. radiusZ?: number;
  102464. flat?: boolean;
  102465. subdivisions?: number;
  102466. sideOrientation?: number;
  102467. frontUVs?: Vector4;
  102468. backUVs?: Vector4;
  102469. }): VertexData;
  102470. /**
  102471. * Creates the VertexData for a Polyhedron
  102472. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  102473. * * type provided types are:
  102474. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  102475. * * 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)
  102476. * * size the size of the IcoSphere, optional default 1
  102477. * * sizeX allows stretching in the x direction, optional, default size
  102478. * * sizeY allows stretching in the y direction, optional, default size
  102479. * * sizeZ allows stretching in the z direction, optional, default size
  102480. * * 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
  102481. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  102482. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  102483. * * flat when true creates a flat shaded mesh, optional, default true
  102484. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  102485. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  102486. * * 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)
  102487. * * 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)
  102488. * @returns the VertexData of the Polyhedron
  102489. */
  102490. static CreatePolyhedron(options: {
  102491. type?: number;
  102492. size?: number;
  102493. sizeX?: number;
  102494. sizeY?: number;
  102495. sizeZ?: number;
  102496. custom?: any;
  102497. faceUV?: Vector4[];
  102498. faceColors?: Color4[];
  102499. flat?: boolean;
  102500. sideOrientation?: number;
  102501. frontUVs?: Vector4;
  102502. backUVs?: Vector4;
  102503. }): VertexData;
  102504. /**
  102505. * Creates the VertexData for a TorusKnot
  102506. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  102507. * * radius the radius of the torus knot, optional, default 2
  102508. * * tube the thickness of the tube, optional, default 0.5
  102509. * * radialSegments the number of sides on each tube segments, optional, default 32
  102510. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  102511. * * p the number of windings around the z axis, optional, default 2
  102512. * * q the number of windings around the x axis, optional, default 3
  102513. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  102514. * * 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)
  102515. * * 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)
  102516. * @returns the VertexData of the Torus Knot
  102517. */
  102518. static CreateTorusKnot(options: {
  102519. radius?: number;
  102520. tube?: number;
  102521. radialSegments?: number;
  102522. tubularSegments?: number;
  102523. p?: number;
  102524. q?: number;
  102525. sideOrientation?: number;
  102526. frontUVs?: Vector4;
  102527. backUVs?: Vector4;
  102528. }): VertexData;
  102529. /**
  102530. * Compute normals for given positions and indices
  102531. * @param positions an array of vertex positions, [...., x, y, z, ......]
  102532. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  102533. * @param normals an array of vertex normals, [...., x, y, z, ......]
  102534. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  102535. * * facetNormals : optional array of facet normals (vector3)
  102536. * * facetPositions : optional array of facet positions (vector3)
  102537. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  102538. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  102539. * * bInfo : optional bounding info, required for facetPartitioning computation
  102540. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  102541. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  102542. * * useRightHandedSystem: optional boolean to for right handed system computation
  102543. * * depthSort : optional boolean to enable the facet depth sort computation
  102544. * * distanceTo : optional Vector3 to compute the facet depth from this location
  102545. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  102546. */
  102547. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  102548. facetNormals?: any;
  102549. facetPositions?: any;
  102550. facetPartitioning?: any;
  102551. ratio?: number;
  102552. bInfo?: any;
  102553. bbSize?: Vector3;
  102554. subDiv?: any;
  102555. useRightHandedSystem?: boolean;
  102556. depthSort?: boolean;
  102557. distanceTo?: Vector3;
  102558. depthSortedFacets?: any;
  102559. }): void;
  102560. /** @hidden */
  102561. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  102562. /**
  102563. * Applies VertexData created from the imported parameters to the geometry
  102564. * @param parsedVertexData the parsed data from an imported file
  102565. * @param geometry the geometry to apply the VertexData to
  102566. */
  102567. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  102568. }
  102569. }
  102570. declare module BABYLON {
  102571. /**
  102572. * Defines a target to use with MorphTargetManager
  102573. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  102574. */
  102575. export class MorphTarget implements IAnimatable {
  102576. /** defines the name of the target */
  102577. name: string;
  102578. /**
  102579. * Gets or sets the list of animations
  102580. */
  102581. animations: Animation[];
  102582. private _scene;
  102583. private _positions;
  102584. private _normals;
  102585. private _tangents;
  102586. private _uvs;
  102587. private _influence;
  102588. private _uniqueId;
  102589. /**
  102590. * Observable raised when the influence changes
  102591. */
  102592. onInfluenceChanged: Observable<boolean>;
  102593. /** @hidden */
  102594. _onDataLayoutChanged: Observable<void>;
  102595. /**
  102596. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  102597. */
  102598. get influence(): number;
  102599. set influence(influence: number);
  102600. /**
  102601. * Gets or sets the id of the morph Target
  102602. */
  102603. id: string;
  102604. private _animationPropertiesOverride;
  102605. /**
  102606. * Gets or sets the animation properties override
  102607. */
  102608. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  102609. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  102610. /**
  102611. * Creates a new MorphTarget
  102612. * @param name defines the name of the target
  102613. * @param influence defines the influence to use
  102614. * @param scene defines the scene the morphtarget belongs to
  102615. */
  102616. constructor(
  102617. /** defines the name of the target */
  102618. name: string, influence?: number, scene?: Nullable<Scene>);
  102619. /**
  102620. * Gets the unique ID of this manager
  102621. */
  102622. get uniqueId(): number;
  102623. /**
  102624. * Gets a boolean defining if the target contains position data
  102625. */
  102626. get hasPositions(): boolean;
  102627. /**
  102628. * Gets a boolean defining if the target contains normal data
  102629. */
  102630. get hasNormals(): boolean;
  102631. /**
  102632. * Gets a boolean defining if the target contains tangent data
  102633. */
  102634. get hasTangents(): boolean;
  102635. /**
  102636. * Gets a boolean defining if the target contains texture coordinates data
  102637. */
  102638. get hasUVs(): boolean;
  102639. /**
  102640. * Affects position data to this target
  102641. * @param data defines the position data to use
  102642. */
  102643. setPositions(data: Nullable<FloatArray>): void;
  102644. /**
  102645. * Gets the position data stored in this target
  102646. * @returns a FloatArray containing the position data (or null if not present)
  102647. */
  102648. getPositions(): Nullable<FloatArray>;
  102649. /**
  102650. * Affects normal data to this target
  102651. * @param data defines the normal data to use
  102652. */
  102653. setNormals(data: Nullable<FloatArray>): void;
  102654. /**
  102655. * Gets the normal data stored in this target
  102656. * @returns a FloatArray containing the normal data (or null if not present)
  102657. */
  102658. getNormals(): Nullable<FloatArray>;
  102659. /**
  102660. * Affects tangent data to this target
  102661. * @param data defines the tangent data to use
  102662. */
  102663. setTangents(data: Nullable<FloatArray>): void;
  102664. /**
  102665. * Gets the tangent data stored in this target
  102666. * @returns a FloatArray containing the tangent data (or null if not present)
  102667. */
  102668. getTangents(): Nullable<FloatArray>;
  102669. /**
  102670. * Affects texture coordinates data to this target
  102671. * @param data defines the texture coordinates data to use
  102672. */
  102673. setUVs(data: Nullable<FloatArray>): void;
  102674. /**
  102675. * Gets the texture coordinates data stored in this target
  102676. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  102677. */
  102678. getUVs(): Nullable<FloatArray>;
  102679. /**
  102680. * Clone the current target
  102681. * @returns a new MorphTarget
  102682. */
  102683. clone(): MorphTarget;
  102684. /**
  102685. * Serializes the current target into a Serialization object
  102686. * @returns the serialized object
  102687. */
  102688. serialize(): any;
  102689. /**
  102690. * Returns the string "MorphTarget"
  102691. * @returns "MorphTarget"
  102692. */
  102693. getClassName(): string;
  102694. /**
  102695. * Creates a new target from serialized data
  102696. * @param serializationObject defines the serialized data to use
  102697. * @returns a new MorphTarget
  102698. */
  102699. static Parse(serializationObject: any): MorphTarget;
  102700. /**
  102701. * Creates a MorphTarget from mesh data
  102702. * @param mesh defines the source mesh
  102703. * @param name defines the name to use for the new target
  102704. * @param influence defines the influence to attach to the target
  102705. * @returns a new MorphTarget
  102706. */
  102707. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  102708. }
  102709. }
  102710. declare module BABYLON {
  102711. /**
  102712. * This class is used to deform meshes using morphing between different targets
  102713. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  102714. */
  102715. export class MorphTargetManager {
  102716. private _targets;
  102717. private _targetInfluenceChangedObservers;
  102718. private _targetDataLayoutChangedObservers;
  102719. private _activeTargets;
  102720. private _scene;
  102721. private _influences;
  102722. private _supportsNormals;
  102723. private _supportsTangents;
  102724. private _supportsUVs;
  102725. private _vertexCount;
  102726. private _uniqueId;
  102727. private _tempInfluences;
  102728. /**
  102729. * Gets or sets a boolean indicating if normals must be morphed
  102730. */
  102731. enableNormalMorphing: boolean;
  102732. /**
  102733. * Gets or sets a boolean indicating if tangents must be morphed
  102734. */
  102735. enableTangentMorphing: boolean;
  102736. /**
  102737. * Gets or sets a boolean indicating if UV must be morphed
  102738. */
  102739. enableUVMorphing: boolean;
  102740. /**
  102741. * Creates a new MorphTargetManager
  102742. * @param scene defines the current scene
  102743. */
  102744. constructor(scene?: Nullable<Scene>);
  102745. /**
  102746. * Gets the unique ID of this manager
  102747. */
  102748. get uniqueId(): number;
  102749. /**
  102750. * Gets the number of vertices handled by this manager
  102751. */
  102752. get vertexCount(): number;
  102753. /**
  102754. * Gets a boolean indicating if this manager supports morphing of normals
  102755. */
  102756. get supportsNormals(): boolean;
  102757. /**
  102758. * Gets a boolean indicating if this manager supports morphing of tangents
  102759. */
  102760. get supportsTangents(): boolean;
  102761. /**
  102762. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  102763. */
  102764. get supportsUVs(): boolean;
  102765. /**
  102766. * Gets the number of targets stored in this manager
  102767. */
  102768. get numTargets(): number;
  102769. /**
  102770. * Gets the number of influencers (ie. the number of targets with influences > 0)
  102771. */
  102772. get numInfluencers(): number;
  102773. /**
  102774. * Gets the list of influences (one per target)
  102775. */
  102776. get influences(): Float32Array;
  102777. /**
  102778. * Gets the active target at specified index. An active target is a target with an influence > 0
  102779. * @param index defines the index to check
  102780. * @returns the requested target
  102781. */
  102782. getActiveTarget(index: number): MorphTarget;
  102783. /**
  102784. * Gets the target at specified index
  102785. * @param index defines the index to check
  102786. * @returns the requested target
  102787. */
  102788. getTarget(index: number): MorphTarget;
  102789. /**
  102790. * Add a new target to this manager
  102791. * @param target defines the target to add
  102792. */
  102793. addTarget(target: MorphTarget): void;
  102794. /**
  102795. * Removes a target from the manager
  102796. * @param target defines the target to remove
  102797. */
  102798. removeTarget(target: MorphTarget): void;
  102799. /**
  102800. * Clone the current manager
  102801. * @returns a new MorphTargetManager
  102802. */
  102803. clone(): MorphTargetManager;
  102804. /**
  102805. * Serializes the current manager into a Serialization object
  102806. * @returns the serialized object
  102807. */
  102808. serialize(): any;
  102809. private _syncActiveTargets;
  102810. /**
  102811. * Syncrhonize the targets with all the meshes using this morph target manager
  102812. */
  102813. synchronize(): void;
  102814. /**
  102815. * Creates a new MorphTargetManager from serialized data
  102816. * @param serializationObject defines the serialized data
  102817. * @param scene defines the hosting scene
  102818. * @returns the new MorphTargetManager
  102819. */
  102820. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  102821. }
  102822. }
  102823. declare module BABYLON {
  102824. /**
  102825. * Class used to represent a specific level of detail of a mesh
  102826. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  102827. */
  102828. export class MeshLODLevel {
  102829. /** Defines the distance where this level should start being displayed */
  102830. distance: number;
  102831. /** Defines the mesh to use to render this level */
  102832. mesh: Nullable<Mesh>;
  102833. /**
  102834. * Creates a new LOD level
  102835. * @param distance defines the distance where this level should star being displayed
  102836. * @param mesh defines the mesh to use to render this level
  102837. */
  102838. constructor(
  102839. /** Defines the distance where this level should start being displayed */
  102840. distance: number,
  102841. /** Defines the mesh to use to render this level */
  102842. mesh: Nullable<Mesh>);
  102843. }
  102844. }
  102845. declare module BABYLON {
  102846. /**
  102847. * Mesh representing the gorund
  102848. */
  102849. export class GroundMesh extends Mesh {
  102850. /** If octree should be generated */
  102851. generateOctree: boolean;
  102852. private _heightQuads;
  102853. /** @hidden */
  102854. _subdivisionsX: number;
  102855. /** @hidden */
  102856. _subdivisionsY: number;
  102857. /** @hidden */
  102858. _width: number;
  102859. /** @hidden */
  102860. _height: number;
  102861. /** @hidden */
  102862. _minX: number;
  102863. /** @hidden */
  102864. _maxX: number;
  102865. /** @hidden */
  102866. _minZ: number;
  102867. /** @hidden */
  102868. _maxZ: number;
  102869. constructor(name: string, scene: Scene);
  102870. /**
  102871. * "GroundMesh"
  102872. * @returns "GroundMesh"
  102873. */
  102874. getClassName(): string;
  102875. /**
  102876. * The minimum of x and y subdivisions
  102877. */
  102878. get subdivisions(): number;
  102879. /**
  102880. * X subdivisions
  102881. */
  102882. get subdivisionsX(): number;
  102883. /**
  102884. * Y subdivisions
  102885. */
  102886. get subdivisionsY(): number;
  102887. /**
  102888. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  102889. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  102890. * @param chunksCount the number of subdivisions for x and y
  102891. * @param octreeBlocksSize (Default: 32)
  102892. */
  102893. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  102894. /**
  102895. * Returns a height (y) value in the Worl system :
  102896. * the ground altitude at the coordinates (x, z) expressed in the World system.
  102897. * @param x x coordinate
  102898. * @param z z coordinate
  102899. * @returns the ground y position if (x, z) are outside the ground surface.
  102900. */
  102901. getHeightAtCoordinates(x: number, z: number): number;
  102902. /**
  102903. * Returns a normalized vector (Vector3) orthogonal to the ground
  102904. * at the ground coordinates (x, z) expressed in the World system.
  102905. * @param x x coordinate
  102906. * @param z z coordinate
  102907. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  102908. */
  102909. getNormalAtCoordinates(x: number, z: number): Vector3;
  102910. /**
  102911. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  102912. * at the ground coordinates (x, z) expressed in the World system.
  102913. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  102914. * @param x x coordinate
  102915. * @param z z coordinate
  102916. * @param ref vector to store the result
  102917. * @returns the GroundMesh.
  102918. */
  102919. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  102920. /**
  102921. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  102922. * if the ground has been updated.
  102923. * This can be used in the render loop.
  102924. * @returns the GroundMesh.
  102925. */
  102926. updateCoordinateHeights(): GroundMesh;
  102927. private _getFacetAt;
  102928. private _initHeightQuads;
  102929. private _computeHeightQuads;
  102930. /**
  102931. * Serializes this ground mesh
  102932. * @param serializationObject object to write serialization to
  102933. */
  102934. serialize(serializationObject: any): void;
  102935. /**
  102936. * Parses a serialized ground mesh
  102937. * @param parsedMesh the serialized mesh
  102938. * @param scene the scene to create the ground mesh in
  102939. * @returns the created ground mesh
  102940. */
  102941. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  102942. }
  102943. }
  102944. declare module BABYLON {
  102945. /**
  102946. * Interface for Physics-Joint data
  102947. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  102948. */
  102949. export interface PhysicsJointData {
  102950. /**
  102951. * The main pivot of the joint
  102952. */
  102953. mainPivot?: Vector3;
  102954. /**
  102955. * The connected pivot of the joint
  102956. */
  102957. connectedPivot?: Vector3;
  102958. /**
  102959. * The main axis of the joint
  102960. */
  102961. mainAxis?: Vector3;
  102962. /**
  102963. * The connected axis of the joint
  102964. */
  102965. connectedAxis?: Vector3;
  102966. /**
  102967. * The collision of the joint
  102968. */
  102969. collision?: boolean;
  102970. /**
  102971. * Native Oimo/Cannon/Energy data
  102972. */
  102973. nativeParams?: any;
  102974. }
  102975. /**
  102976. * This is a holder class for the physics joint created by the physics plugin
  102977. * It holds a set of functions to control the underlying joint
  102978. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  102979. */
  102980. export class PhysicsJoint {
  102981. /**
  102982. * The type of the physics joint
  102983. */
  102984. type: number;
  102985. /**
  102986. * The data for the physics joint
  102987. */
  102988. jointData: PhysicsJointData;
  102989. private _physicsJoint;
  102990. protected _physicsPlugin: IPhysicsEnginePlugin;
  102991. /**
  102992. * Initializes the physics joint
  102993. * @param type The type of the physics joint
  102994. * @param jointData The data for the physics joint
  102995. */
  102996. constructor(
  102997. /**
  102998. * The type of the physics joint
  102999. */
  103000. type: number,
  103001. /**
  103002. * The data for the physics joint
  103003. */
  103004. jointData: PhysicsJointData);
  103005. /**
  103006. * Gets the physics joint
  103007. */
  103008. get physicsJoint(): any;
  103009. /**
  103010. * Sets the physics joint
  103011. */
  103012. set physicsJoint(newJoint: any);
  103013. /**
  103014. * Sets the physics plugin
  103015. */
  103016. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  103017. /**
  103018. * Execute a function that is physics-plugin specific.
  103019. * @param {Function} func the function that will be executed.
  103020. * It accepts two parameters: the physics world and the physics joint
  103021. */
  103022. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  103023. /**
  103024. * Distance-Joint type
  103025. */
  103026. static DistanceJoint: number;
  103027. /**
  103028. * Hinge-Joint type
  103029. */
  103030. static HingeJoint: number;
  103031. /**
  103032. * Ball-and-Socket joint type
  103033. */
  103034. static BallAndSocketJoint: number;
  103035. /**
  103036. * Wheel-Joint type
  103037. */
  103038. static WheelJoint: number;
  103039. /**
  103040. * Slider-Joint type
  103041. */
  103042. static SliderJoint: number;
  103043. /**
  103044. * Prismatic-Joint type
  103045. */
  103046. static PrismaticJoint: number;
  103047. /**
  103048. * Universal-Joint type
  103049. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  103050. */
  103051. static UniversalJoint: number;
  103052. /**
  103053. * Hinge-Joint 2 type
  103054. */
  103055. static Hinge2Joint: number;
  103056. /**
  103057. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  103058. */
  103059. static PointToPointJoint: number;
  103060. /**
  103061. * Spring-Joint type
  103062. */
  103063. static SpringJoint: number;
  103064. /**
  103065. * Lock-Joint type
  103066. */
  103067. static LockJoint: number;
  103068. }
  103069. /**
  103070. * A class representing a physics distance joint
  103071. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  103072. */
  103073. export class DistanceJoint extends PhysicsJoint {
  103074. /**
  103075. *
  103076. * @param jointData The data for the Distance-Joint
  103077. */
  103078. constructor(jointData: DistanceJointData);
  103079. /**
  103080. * Update the predefined distance.
  103081. * @param maxDistance The maximum preferred distance
  103082. * @param minDistance The minimum preferred distance
  103083. */
  103084. updateDistance(maxDistance: number, minDistance?: number): void;
  103085. }
  103086. /**
  103087. * Represents a Motor-Enabled Joint
  103088. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  103089. */
  103090. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  103091. /**
  103092. * Initializes the Motor-Enabled Joint
  103093. * @param type The type of the joint
  103094. * @param jointData The physica joint data for the joint
  103095. */
  103096. constructor(type: number, jointData: PhysicsJointData);
  103097. /**
  103098. * Set the motor values.
  103099. * Attention, this function is plugin specific. Engines won't react 100% the same.
  103100. * @param force the force to apply
  103101. * @param maxForce max force for this motor.
  103102. */
  103103. setMotor(force?: number, maxForce?: number): void;
  103104. /**
  103105. * Set the motor's limits.
  103106. * Attention, this function is plugin specific. Engines won't react 100% the same.
  103107. * @param upperLimit The upper limit of the motor
  103108. * @param lowerLimit The lower limit of the motor
  103109. */
  103110. setLimit(upperLimit: number, lowerLimit?: number): void;
  103111. }
  103112. /**
  103113. * This class represents a single physics Hinge-Joint
  103114. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  103115. */
  103116. export class HingeJoint extends MotorEnabledJoint {
  103117. /**
  103118. * Initializes the Hinge-Joint
  103119. * @param jointData The joint data for the Hinge-Joint
  103120. */
  103121. constructor(jointData: PhysicsJointData);
  103122. /**
  103123. * Set the motor values.
  103124. * Attention, this function is plugin specific. Engines won't react 100% the same.
  103125. * @param {number} force the force to apply
  103126. * @param {number} maxForce max force for this motor.
  103127. */
  103128. setMotor(force?: number, maxForce?: number): void;
  103129. /**
  103130. * Set the motor's limits.
  103131. * Attention, this function is plugin specific. Engines won't react 100% the same.
  103132. * @param upperLimit The upper limit of the motor
  103133. * @param lowerLimit The lower limit of the motor
  103134. */
  103135. setLimit(upperLimit: number, lowerLimit?: number): void;
  103136. }
  103137. /**
  103138. * This class represents a dual hinge physics joint (same as wheel joint)
  103139. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  103140. */
  103141. export class Hinge2Joint extends MotorEnabledJoint {
  103142. /**
  103143. * Initializes the Hinge2-Joint
  103144. * @param jointData The joint data for the Hinge2-Joint
  103145. */
  103146. constructor(jointData: PhysicsJointData);
  103147. /**
  103148. * Set the motor values.
  103149. * Attention, this function is plugin specific. Engines won't react 100% the same.
  103150. * @param {number} targetSpeed the speed the motor is to reach
  103151. * @param {number} maxForce max force for this motor.
  103152. * @param {motorIndex} the motor's index, 0 or 1.
  103153. */
  103154. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  103155. /**
  103156. * Set the motor limits.
  103157. * Attention, this function is plugin specific. Engines won't react 100% the same.
  103158. * @param {number} upperLimit the upper limit
  103159. * @param {number} lowerLimit lower limit
  103160. * @param {motorIndex} the motor's index, 0 or 1.
  103161. */
  103162. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  103163. }
  103164. /**
  103165. * Interface for a motor enabled joint
  103166. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  103167. */
  103168. export interface IMotorEnabledJoint {
  103169. /**
  103170. * Physics joint
  103171. */
  103172. physicsJoint: any;
  103173. /**
  103174. * Sets the motor of the motor-enabled joint
  103175. * @param force The force of the motor
  103176. * @param maxForce The maximum force of the motor
  103177. * @param motorIndex The index of the motor
  103178. */
  103179. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  103180. /**
  103181. * Sets the limit of the motor
  103182. * @param upperLimit The upper limit of the motor
  103183. * @param lowerLimit The lower limit of the motor
  103184. * @param motorIndex The index of the motor
  103185. */
  103186. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  103187. }
  103188. /**
  103189. * Joint data for a Distance-Joint
  103190. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  103191. */
  103192. export interface DistanceJointData extends PhysicsJointData {
  103193. /**
  103194. * Max distance the 2 joint objects can be apart
  103195. */
  103196. maxDistance: number;
  103197. }
  103198. /**
  103199. * Joint data from a spring joint
  103200. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  103201. */
  103202. export interface SpringJointData extends PhysicsJointData {
  103203. /**
  103204. * Length of the spring
  103205. */
  103206. length: number;
  103207. /**
  103208. * Stiffness of the spring
  103209. */
  103210. stiffness: number;
  103211. /**
  103212. * Damping of the spring
  103213. */
  103214. damping: number;
  103215. /** this callback will be called when applying the force to the impostors. */
  103216. forceApplicationCallback: () => void;
  103217. }
  103218. }
  103219. declare module BABYLON {
  103220. /**
  103221. * Holds the data for the raycast result
  103222. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  103223. */
  103224. export class PhysicsRaycastResult {
  103225. private _hasHit;
  103226. private _hitDistance;
  103227. private _hitNormalWorld;
  103228. private _hitPointWorld;
  103229. private _rayFromWorld;
  103230. private _rayToWorld;
  103231. /**
  103232. * Gets if there was a hit
  103233. */
  103234. get hasHit(): boolean;
  103235. /**
  103236. * Gets the distance from the hit
  103237. */
  103238. get hitDistance(): number;
  103239. /**
  103240. * Gets the hit normal/direction in the world
  103241. */
  103242. get hitNormalWorld(): Vector3;
  103243. /**
  103244. * Gets the hit point in the world
  103245. */
  103246. get hitPointWorld(): Vector3;
  103247. /**
  103248. * Gets the ray "start point" of the ray in the world
  103249. */
  103250. get rayFromWorld(): Vector3;
  103251. /**
  103252. * Gets the ray "end point" of the ray in the world
  103253. */
  103254. get rayToWorld(): Vector3;
  103255. /**
  103256. * Sets the hit data (normal & point in world space)
  103257. * @param hitNormalWorld defines the normal in world space
  103258. * @param hitPointWorld defines the point in world space
  103259. */
  103260. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  103261. /**
  103262. * Sets the distance from the start point to the hit point
  103263. * @param distance
  103264. */
  103265. setHitDistance(distance: number): void;
  103266. /**
  103267. * Calculates the distance manually
  103268. */
  103269. calculateHitDistance(): void;
  103270. /**
  103271. * Resets all the values to default
  103272. * @param from The from point on world space
  103273. * @param to The to point on world space
  103274. */
  103275. reset(from?: Vector3, to?: Vector3): void;
  103276. }
  103277. /**
  103278. * Interface for the size containing width and height
  103279. */
  103280. interface IXYZ {
  103281. /**
  103282. * X
  103283. */
  103284. x: number;
  103285. /**
  103286. * Y
  103287. */
  103288. y: number;
  103289. /**
  103290. * Z
  103291. */
  103292. z: number;
  103293. }
  103294. }
  103295. declare module BABYLON {
  103296. /**
  103297. * Interface used to describe a physics joint
  103298. */
  103299. export interface PhysicsImpostorJoint {
  103300. /** Defines the main impostor to which the joint is linked */
  103301. mainImpostor: PhysicsImpostor;
  103302. /** Defines the impostor that is connected to the main impostor using this joint */
  103303. connectedImpostor: PhysicsImpostor;
  103304. /** Defines the joint itself */
  103305. joint: PhysicsJoint;
  103306. }
  103307. /** @hidden */
  103308. export interface IPhysicsEnginePlugin {
  103309. world: any;
  103310. name: string;
  103311. setGravity(gravity: Vector3): void;
  103312. setTimeStep(timeStep: number): void;
  103313. getTimeStep(): number;
  103314. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  103315. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  103316. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  103317. generatePhysicsBody(impostor: PhysicsImpostor): void;
  103318. removePhysicsBody(impostor: PhysicsImpostor): void;
  103319. generateJoint(joint: PhysicsImpostorJoint): void;
  103320. removeJoint(joint: PhysicsImpostorJoint): void;
  103321. isSupported(): boolean;
  103322. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  103323. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  103324. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  103325. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  103326. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  103327. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  103328. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  103329. getBodyMass(impostor: PhysicsImpostor): number;
  103330. getBodyFriction(impostor: PhysicsImpostor): number;
  103331. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  103332. getBodyRestitution(impostor: PhysicsImpostor): number;
  103333. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  103334. getBodyPressure?(impostor: PhysicsImpostor): number;
  103335. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  103336. getBodyStiffness?(impostor: PhysicsImpostor): number;
  103337. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  103338. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  103339. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  103340. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  103341. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  103342. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  103343. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  103344. sleepBody(impostor: PhysicsImpostor): void;
  103345. wakeUpBody(impostor: PhysicsImpostor): void;
  103346. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  103347. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  103348. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  103349. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  103350. getRadius(impostor: PhysicsImpostor): number;
  103351. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  103352. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  103353. dispose(): void;
  103354. }
  103355. /**
  103356. * Interface used to define a physics engine
  103357. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  103358. */
  103359. export interface IPhysicsEngine {
  103360. /**
  103361. * Gets the gravity vector used by the simulation
  103362. */
  103363. gravity: Vector3;
  103364. /**
  103365. * Sets the gravity vector used by the simulation
  103366. * @param gravity defines the gravity vector to use
  103367. */
  103368. setGravity(gravity: Vector3): void;
  103369. /**
  103370. * Set the time step of the physics engine.
  103371. * Default is 1/60.
  103372. * To slow it down, enter 1/600 for example.
  103373. * To speed it up, 1/30
  103374. * @param newTimeStep the new timestep to apply to this world.
  103375. */
  103376. setTimeStep(newTimeStep: number): void;
  103377. /**
  103378. * Get the time step of the physics engine.
  103379. * @returns the current time step
  103380. */
  103381. getTimeStep(): number;
  103382. /**
  103383. * Set the sub time step of the physics engine.
  103384. * Default is 0 meaning there is no sub steps
  103385. * To increase physics resolution precision, set a small value (like 1 ms)
  103386. * @param subTimeStep defines the new sub timestep used for physics resolution.
  103387. */
  103388. setSubTimeStep(subTimeStep: number): void;
  103389. /**
  103390. * Get the sub time step of the physics engine.
  103391. * @returns the current sub time step
  103392. */
  103393. getSubTimeStep(): number;
  103394. /**
  103395. * Release all resources
  103396. */
  103397. dispose(): void;
  103398. /**
  103399. * Gets the name of the current physics plugin
  103400. * @returns the name of the plugin
  103401. */
  103402. getPhysicsPluginName(): string;
  103403. /**
  103404. * Adding a new impostor for the impostor tracking.
  103405. * This will be done by the impostor itself.
  103406. * @param impostor the impostor to add
  103407. */
  103408. addImpostor(impostor: PhysicsImpostor): void;
  103409. /**
  103410. * Remove an impostor from the engine.
  103411. * This impostor and its mesh will not longer be updated by the physics engine.
  103412. * @param impostor the impostor to remove
  103413. */
  103414. removeImpostor(impostor: PhysicsImpostor): void;
  103415. /**
  103416. * Add a joint to the physics engine
  103417. * @param mainImpostor defines the main impostor to which the joint is added.
  103418. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  103419. * @param joint defines the joint that will connect both impostors.
  103420. */
  103421. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  103422. /**
  103423. * Removes a joint from the simulation
  103424. * @param mainImpostor defines the impostor used with the joint
  103425. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  103426. * @param joint defines the joint to remove
  103427. */
  103428. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  103429. /**
  103430. * Gets the current plugin used to run the simulation
  103431. * @returns current plugin
  103432. */
  103433. getPhysicsPlugin(): IPhysicsEnginePlugin;
  103434. /**
  103435. * Gets the list of physic impostors
  103436. * @returns an array of PhysicsImpostor
  103437. */
  103438. getImpostors(): Array<PhysicsImpostor>;
  103439. /**
  103440. * Gets the impostor for a physics enabled object
  103441. * @param object defines the object impersonated by the impostor
  103442. * @returns the PhysicsImpostor or null if not found
  103443. */
  103444. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  103445. /**
  103446. * Gets the impostor for a physics body object
  103447. * @param body defines physics body used by the impostor
  103448. * @returns the PhysicsImpostor or null if not found
  103449. */
  103450. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  103451. /**
  103452. * Does a raycast in the physics world
  103453. * @param from when should the ray start?
  103454. * @param to when should the ray end?
  103455. * @returns PhysicsRaycastResult
  103456. */
  103457. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  103458. /**
  103459. * Called by the scene. No need to call it.
  103460. * @param delta defines the timespam between frames
  103461. */
  103462. _step(delta: number): void;
  103463. }
  103464. }
  103465. declare module BABYLON {
  103466. /**
  103467. * The interface for the physics imposter parameters
  103468. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  103469. */
  103470. export interface PhysicsImpostorParameters {
  103471. /**
  103472. * The mass of the physics imposter
  103473. */
  103474. mass: number;
  103475. /**
  103476. * The friction of the physics imposter
  103477. */
  103478. friction?: number;
  103479. /**
  103480. * The coefficient of restitution of the physics imposter
  103481. */
  103482. restitution?: number;
  103483. /**
  103484. * The native options of the physics imposter
  103485. */
  103486. nativeOptions?: any;
  103487. /**
  103488. * Specifies if the parent should be ignored
  103489. */
  103490. ignoreParent?: boolean;
  103491. /**
  103492. * Specifies if bi-directional transformations should be disabled
  103493. */
  103494. disableBidirectionalTransformation?: boolean;
  103495. /**
  103496. * The pressure inside the physics imposter, soft object only
  103497. */
  103498. pressure?: number;
  103499. /**
  103500. * The stiffness the physics imposter, soft object only
  103501. */
  103502. stiffness?: number;
  103503. /**
  103504. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  103505. */
  103506. velocityIterations?: number;
  103507. /**
  103508. * The number of iterations used in maintaining consistent vertex positions, soft object only
  103509. */
  103510. positionIterations?: number;
  103511. /**
  103512. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  103513. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  103514. * Add to fix multiple points
  103515. */
  103516. fixedPoints?: number;
  103517. /**
  103518. * The collision margin around a soft object
  103519. */
  103520. margin?: number;
  103521. /**
  103522. * The collision margin around a soft object
  103523. */
  103524. damping?: number;
  103525. /**
  103526. * The path for a rope based on an extrusion
  103527. */
  103528. path?: any;
  103529. /**
  103530. * The shape of an extrusion used for a rope based on an extrusion
  103531. */
  103532. shape?: any;
  103533. }
  103534. /**
  103535. * Interface for a physics-enabled object
  103536. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  103537. */
  103538. export interface IPhysicsEnabledObject {
  103539. /**
  103540. * The position of the physics-enabled object
  103541. */
  103542. position: Vector3;
  103543. /**
  103544. * The rotation of the physics-enabled object
  103545. */
  103546. rotationQuaternion: Nullable<Quaternion>;
  103547. /**
  103548. * The scale of the physics-enabled object
  103549. */
  103550. scaling: Vector3;
  103551. /**
  103552. * The rotation of the physics-enabled object
  103553. */
  103554. rotation?: Vector3;
  103555. /**
  103556. * The parent of the physics-enabled object
  103557. */
  103558. parent?: any;
  103559. /**
  103560. * The bounding info of the physics-enabled object
  103561. * @returns The bounding info of the physics-enabled object
  103562. */
  103563. getBoundingInfo(): BoundingInfo;
  103564. /**
  103565. * Computes the world matrix
  103566. * @param force Specifies if the world matrix should be computed by force
  103567. * @returns A world matrix
  103568. */
  103569. computeWorldMatrix(force: boolean): Matrix;
  103570. /**
  103571. * Gets the world matrix
  103572. * @returns A world matrix
  103573. */
  103574. getWorldMatrix?(): Matrix;
  103575. /**
  103576. * Gets the child meshes
  103577. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  103578. * @returns An array of abstract meshes
  103579. */
  103580. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  103581. /**
  103582. * Gets the vertex data
  103583. * @param kind The type of vertex data
  103584. * @returns A nullable array of numbers, or a float32 array
  103585. */
  103586. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  103587. /**
  103588. * Gets the indices from the mesh
  103589. * @returns A nullable array of index arrays
  103590. */
  103591. getIndices?(): Nullable<IndicesArray>;
  103592. /**
  103593. * Gets the scene from the mesh
  103594. * @returns the indices array or null
  103595. */
  103596. getScene?(): Scene;
  103597. /**
  103598. * Gets the absolute position from the mesh
  103599. * @returns the absolute position
  103600. */
  103601. getAbsolutePosition(): Vector3;
  103602. /**
  103603. * Gets the absolute pivot point from the mesh
  103604. * @returns the absolute pivot point
  103605. */
  103606. getAbsolutePivotPoint(): Vector3;
  103607. /**
  103608. * Rotates the mesh
  103609. * @param axis The axis of rotation
  103610. * @param amount The amount of rotation
  103611. * @param space The space of the rotation
  103612. * @returns The rotation transform node
  103613. */
  103614. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  103615. /**
  103616. * Translates the mesh
  103617. * @param axis The axis of translation
  103618. * @param distance The distance of translation
  103619. * @param space The space of the translation
  103620. * @returns The transform node
  103621. */
  103622. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  103623. /**
  103624. * Sets the absolute position of the mesh
  103625. * @param absolutePosition The absolute position of the mesh
  103626. * @returns The transform node
  103627. */
  103628. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  103629. /**
  103630. * Gets the class name of the mesh
  103631. * @returns The class name
  103632. */
  103633. getClassName(): string;
  103634. }
  103635. /**
  103636. * Represents a physics imposter
  103637. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  103638. */
  103639. export class PhysicsImpostor {
  103640. /**
  103641. * The physics-enabled object used as the physics imposter
  103642. */
  103643. object: IPhysicsEnabledObject;
  103644. /**
  103645. * The type of the physics imposter
  103646. */
  103647. type: number;
  103648. private _options;
  103649. private _scene?;
  103650. /**
  103651. * The default object size of the imposter
  103652. */
  103653. static DEFAULT_OBJECT_SIZE: Vector3;
  103654. /**
  103655. * The identity quaternion of the imposter
  103656. */
  103657. static IDENTITY_QUATERNION: Quaternion;
  103658. /** @hidden */
  103659. _pluginData: any;
  103660. private _physicsEngine;
  103661. private _physicsBody;
  103662. private _bodyUpdateRequired;
  103663. private _onBeforePhysicsStepCallbacks;
  103664. private _onAfterPhysicsStepCallbacks;
  103665. /** @hidden */
  103666. _onPhysicsCollideCallbacks: Array<{
  103667. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  103668. otherImpostors: Array<PhysicsImpostor>;
  103669. }>;
  103670. private _deltaPosition;
  103671. private _deltaRotation;
  103672. private _deltaRotationConjugated;
  103673. /** @hidden */
  103674. _isFromLine: boolean;
  103675. private _parent;
  103676. private _isDisposed;
  103677. private static _tmpVecs;
  103678. private static _tmpQuat;
  103679. /**
  103680. * Specifies if the physics imposter is disposed
  103681. */
  103682. get isDisposed(): boolean;
  103683. /**
  103684. * Gets the mass of the physics imposter
  103685. */
  103686. get mass(): number;
  103687. set mass(value: number);
  103688. /**
  103689. * Gets the coefficient of friction
  103690. */
  103691. get friction(): number;
  103692. /**
  103693. * Sets the coefficient of friction
  103694. */
  103695. set friction(value: number);
  103696. /**
  103697. * Gets the coefficient of restitution
  103698. */
  103699. get restitution(): number;
  103700. /**
  103701. * Sets the coefficient of restitution
  103702. */
  103703. set restitution(value: number);
  103704. /**
  103705. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  103706. */
  103707. get pressure(): number;
  103708. /**
  103709. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  103710. */
  103711. set pressure(value: number);
  103712. /**
  103713. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  103714. */
  103715. get stiffness(): number;
  103716. /**
  103717. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  103718. */
  103719. set stiffness(value: number);
  103720. /**
  103721. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  103722. */
  103723. get velocityIterations(): number;
  103724. /**
  103725. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  103726. */
  103727. set velocityIterations(value: number);
  103728. /**
  103729. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  103730. */
  103731. get positionIterations(): number;
  103732. /**
  103733. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  103734. */
  103735. set positionIterations(value: number);
  103736. /**
  103737. * The unique id of the physics imposter
  103738. * set by the physics engine when adding this impostor to the array
  103739. */
  103740. uniqueId: number;
  103741. /**
  103742. * @hidden
  103743. */
  103744. soft: boolean;
  103745. /**
  103746. * @hidden
  103747. */
  103748. segments: number;
  103749. private _joints;
  103750. /**
  103751. * Initializes the physics imposter
  103752. * @param object The physics-enabled object used as the physics imposter
  103753. * @param type The type of the physics imposter
  103754. * @param _options The options for the physics imposter
  103755. * @param _scene The Babylon scene
  103756. */
  103757. constructor(
  103758. /**
  103759. * The physics-enabled object used as the physics imposter
  103760. */
  103761. object: IPhysicsEnabledObject,
  103762. /**
  103763. * The type of the physics imposter
  103764. */
  103765. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  103766. /**
  103767. * This function will completly initialize this impostor.
  103768. * It will create a new body - but only if this mesh has no parent.
  103769. * If it has, this impostor will not be used other than to define the impostor
  103770. * of the child mesh.
  103771. * @hidden
  103772. */
  103773. _init(): void;
  103774. private _getPhysicsParent;
  103775. /**
  103776. * Should a new body be generated.
  103777. * @returns boolean specifying if body initialization is required
  103778. */
  103779. isBodyInitRequired(): boolean;
  103780. /**
  103781. * Sets the updated scaling
  103782. * @param updated Specifies if the scaling is updated
  103783. */
  103784. setScalingUpdated(): void;
  103785. /**
  103786. * Force a regeneration of this or the parent's impostor's body.
  103787. * Use under cautious - This will remove all joints already implemented.
  103788. */
  103789. forceUpdate(): void;
  103790. /**
  103791. * Gets the body that holds this impostor. Either its own, or its parent.
  103792. */
  103793. get physicsBody(): any;
  103794. /**
  103795. * Get the parent of the physics imposter
  103796. * @returns Physics imposter or null
  103797. */
  103798. get parent(): Nullable<PhysicsImpostor>;
  103799. /**
  103800. * Sets the parent of the physics imposter
  103801. */
  103802. set parent(value: Nullable<PhysicsImpostor>);
  103803. /**
  103804. * Set the physics body. Used mainly by the physics engine/plugin
  103805. */
  103806. set physicsBody(physicsBody: any);
  103807. /**
  103808. * Resets the update flags
  103809. */
  103810. resetUpdateFlags(): void;
  103811. /**
  103812. * Gets the object extend size
  103813. * @returns the object extend size
  103814. */
  103815. getObjectExtendSize(): Vector3;
  103816. /**
  103817. * Gets the object center
  103818. * @returns The object center
  103819. */
  103820. getObjectCenter(): Vector3;
  103821. /**
  103822. * Get a specific parameter from the options parameters
  103823. * @param paramName The object parameter name
  103824. * @returns The object parameter
  103825. */
  103826. getParam(paramName: string): any;
  103827. /**
  103828. * Sets a specific parameter in the options given to the physics plugin
  103829. * @param paramName The parameter name
  103830. * @param value The value of the parameter
  103831. */
  103832. setParam(paramName: string, value: number): void;
  103833. /**
  103834. * Specifically change the body's mass option. Won't recreate the physics body object
  103835. * @param mass The mass of the physics imposter
  103836. */
  103837. setMass(mass: number): void;
  103838. /**
  103839. * Gets the linear velocity
  103840. * @returns linear velocity or null
  103841. */
  103842. getLinearVelocity(): Nullable<Vector3>;
  103843. /**
  103844. * Sets the linear velocity
  103845. * @param velocity linear velocity or null
  103846. */
  103847. setLinearVelocity(velocity: Nullable<Vector3>): void;
  103848. /**
  103849. * Gets the angular velocity
  103850. * @returns angular velocity or null
  103851. */
  103852. getAngularVelocity(): Nullable<Vector3>;
  103853. /**
  103854. * Sets the angular velocity
  103855. * @param velocity The velocity or null
  103856. */
  103857. setAngularVelocity(velocity: Nullable<Vector3>): void;
  103858. /**
  103859. * Execute a function with the physics plugin native code
  103860. * Provide a function the will have two variables - the world object and the physics body object
  103861. * @param func The function to execute with the physics plugin native code
  103862. */
  103863. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  103864. /**
  103865. * Register a function that will be executed before the physics world is stepping forward
  103866. * @param func The function to execute before the physics world is stepped forward
  103867. */
  103868. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  103869. /**
  103870. * Unregister a function that will be executed before the physics world is stepping forward
  103871. * @param func The function to execute before the physics world is stepped forward
  103872. */
  103873. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  103874. /**
  103875. * Register a function that will be executed after the physics step
  103876. * @param func The function to execute after physics step
  103877. */
  103878. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  103879. /**
  103880. * Unregisters a function that will be executed after the physics step
  103881. * @param func The function to execute after physics step
  103882. */
  103883. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  103884. /**
  103885. * register a function that will be executed when this impostor collides against a different body
  103886. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  103887. * @param func Callback that is executed on collision
  103888. */
  103889. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  103890. /**
  103891. * Unregisters the physics imposter on contact
  103892. * @param collideAgainst The physics object to collide against
  103893. * @param func Callback to execute on collision
  103894. */
  103895. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  103896. private _tmpQuat;
  103897. private _tmpQuat2;
  103898. /**
  103899. * Get the parent rotation
  103900. * @returns The parent rotation
  103901. */
  103902. getParentsRotation(): Quaternion;
  103903. /**
  103904. * this function is executed by the physics engine.
  103905. */
  103906. beforeStep: () => void;
  103907. /**
  103908. * this function is executed by the physics engine
  103909. */
  103910. afterStep: () => void;
  103911. /**
  103912. * Legacy collision detection event support
  103913. */
  103914. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  103915. /**
  103916. * event and body object due to cannon's event-based architecture.
  103917. */
  103918. onCollide: (e: {
  103919. body: any;
  103920. }) => void;
  103921. /**
  103922. * Apply a force
  103923. * @param force The force to apply
  103924. * @param contactPoint The contact point for the force
  103925. * @returns The physics imposter
  103926. */
  103927. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  103928. /**
  103929. * Apply an impulse
  103930. * @param force The impulse force
  103931. * @param contactPoint The contact point for the impulse force
  103932. * @returns The physics imposter
  103933. */
  103934. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  103935. /**
  103936. * A help function to create a joint
  103937. * @param otherImpostor A physics imposter used to create a joint
  103938. * @param jointType The type of joint
  103939. * @param jointData The data for the joint
  103940. * @returns The physics imposter
  103941. */
  103942. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  103943. /**
  103944. * Add a joint to this impostor with a different impostor
  103945. * @param otherImpostor A physics imposter used to add a joint
  103946. * @param joint The joint to add
  103947. * @returns The physics imposter
  103948. */
  103949. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  103950. /**
  103951. * Add an anchor to a cloth impostor
  103952. * @param otherImpostor rigid impostor to anchor to
  103953. * @param width ratio across width from 0 to 1
  103954. * @param height ratio up height from 0 to 1
  103955. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  103956. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  103957. * @returns impostor the soft imposter
  103958. */
  103959. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  103960. /**
  103961. * Add a hook to a rope impostor
  103962. * @param otherImpostor rigid impostor to anchor to
  103963. * @param length ratio across rope from 0 to 1
  103964. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  103965. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  103966. * @returns impostor the rope imposter
  103967. */
  103968. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  103969. /**
  103970. * Will keep this body still, in a sleep mode.
  103971. * @returns the physics imposter
  103972. */
  103973. sleep(): PhysicsImpostor;
  103974. /**
  103975. * Wake the body up.
  103976. * @returns The physics imposter
  103977. */
  103978. wakeUp(): PhysicsImpostor;
  103979. /**
  103980. * Clones the physics imposter
  103981. * @param newObject The physics imposter clones to this physics-enabled object
  103982. * @returns A nullable physics imposter
  103983. */
  103984. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  103985. /**
  103986. * Disposes the physics imposter
  103987. */
  103988. dispose(): void;
  103989. /**
  103990. * Sets the delta position
  103991. * @param position The delta position amount
  103992. */
  103993. setDeltaPosition(position: Vector3): void;
  103994. /**
  103995. * Sets the delta rotation
  103996. * @param rotation The delta rotation amount
  103997. */
  103998. setDeltaRotation(rotation: Quaternion): void;
  103999. /**
  104000. * Gets the box size of the physics imposter and stores the result in the input parameter
  104001. * @param result Stores the box size
  104002. * @returns The physics imposter
  104003. */
  104004. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  104005. /**
  104006. * Gets the radius of the physics imposter
  104007. * @returns Radius of the physics imposter
  104008. */
  104009. getRadius(): number;
  104010. /**
  104011. * Sync a bone with this impostor
  104012. * @param bone The bone to sync to the impostor.
  104013. * @param boneMesh The mesh that the bone is influencing.
  104014. * @param jointPivot The pivot of the joint / bone in local space.
  104015. * @param distToJoint Optional distance from the impostor to the joint.
  104016. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  104017. */
  104018. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  104019. /**
  104020. * Sync impostor to a bone
  104021. * @param bone The bone that the impostor will be synced to.
  104022. * @param boneMesh The mesh that the bone is influencing.
  104023. * @param jointPivot The pivot of the joint / bone in local space.
  104024. * @param distToJoint Optional distance from the impostor to the joint.
  104025. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  104026. * @param boneAxis Optional vector3 axis the bone is aligned with
  104027. */
  104028. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  104029. /**
  104030. * No-Imposter type
  104031. */
  104032. static NoImpostor: number;
  104033. /**
  104034. * Sphere-Imposter type
  104035. */
  104036. static SphereImpostor: number;
  104037. /**
  104038. * Box-Imposter type
  104039. */
  104040. static BoxImpostor: number;
  104041. /**
  104042. * Plane-Imposter type
  104043. */
  104044. static PlaneImpostor: number;
  104045. /**
  104046. * Mesh-imposter type
  104047. */
  104048. static MeshImpostor: number;
  104049. /**
  104050. * Capsule-Impostor type (Ammo.js plugin only)
  104051. */
  104052. static CapsuleImpostor: number;
  104053. /**
  104054. * Cylinder-Imposter type
  104055. */
  104056. static CylinderImpostor: number;
  104057. /**
  104058. * Particle-Imposter type
  104059. */
  104060. static ParticleImpostor: number;
  104061. /**
  104062. * Heightmap-Imposter type
  104063. */
  104064. static HeightmapImpostor: number;
  104065. /**
  104066. * ConvexHull-Impostor type (Ammo.js plugin only)
  104067. */
  104068. static ConvexHullImpostor: number;
  104069. /**
  104070. * Custom-Imposter type (Ammo.js plugin only)
  104071. */
  104072. static CustomImpostor: number;
  104073. /**
  104074. * Rope-Imposter type
  104075. */
  104076. static RopeImpostor: number;
  104077. /**
  104078. * Cloth-Imposter type
  104079. */
  104080. static ClothImpostor: number;
  104081. /**
  104082. * Softbody-Imposter type
  104083. */
  104084. static SoftbodyImpostor: number;
  104085. }
  104086. }
  104087. declare module BABYLON {
  104088. /**
  104089. * @hidden
  104090. **/
  104091. export class _CreationDataStorage {
  104092. closePath?: boolean;
  104093. closeArray?: boolean;
  104094. idx: number[];
  104095. dashSize: number;
  104096. gapSize: number;
  104097. path3D: Path3D;
  104098. pathArray: Vector3[][];
  104099. arc: number;
  104100. radius: number;
  104101. cap: number;
  104102. tessellation: number;
  104103. }
  104104. /**
  104105. * @hidden
  104106. **/
  104107. class _InstanceDataStorage {
  104108. visibleInstances: any;
  104109. batchCache: _InstancesBatch;
  104110. instancesBufferSize: number;
  104111. instancesBuffer: Nullable<Buffer>;
  104112. instancesData: Float32Array;
  104113. overridenInstanceCount: number;
  104114. isFrozen: boolean;
  104115. previousBatch: Nullable<_InstancesBatch>;
  104116. hardwareInstancedRendering: boolean;
  104117. sideOrientation: number;
  104118. manualUpdate: boolean;
  104119. }
  104120. /**
  104121. * @hidden
  104122. **/
  104123. export class _InstancesBatch {
  104124. mustReturn: boolean;
  104125. visibleInstances: Nullable<InstancedMesh[]>[];
  104126. renderSelf: boolean[];
  104127. hardwareInstancedRendering: boolean[];
  104128. }
  104129. /**
  104130. * Class used to represent renderable models
  104131. */
  104132. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  104133. /**
  104134. * Mesh side orientation : usually the external or front surface
  104135. */
  104136. static readonly FRONTSIDE: number;
  104137. /**
  104138. * Mesh side orientation : usually the internal or back surface
  104139. */
  104140. static readonly BACKSIDE: number;
  104141. /**
  104142. * Mesh side orientation : both internal and external or front and back surfaces
  104143. */
  104144. static readonly DOUBLESIDE: number;
  104145. /**
  104146. * Mesh side orientation : by default, `FRONTSIDE`
  104147. */
  104148. static readonly DEFAULTSIDE: number;
  104149. /**
  104150. * Mesh cap setting : no cap
  104151. */
  104152. static readonly NO_CAP: number;
  104153. /**
  104154. * Mesh cap setting : one cap at the beginning of the mesh
  104155. */
  104156. static readonly CAP_START: number;
  104157. /**
  104158. * Mesh cap setting : one cap at the end of the mesh
  104159. */
  104160. static readonly CAP_END: number;
  104161. /**
  104162. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  104163. */
  104164. static readonly CAP_ALL: number;
  104165. /**
  104166. * Mesh pattern setting : no flip or rotate
  104167. */
  104168. static readonly NO_FLIP: number;
  104169. /**
  104170. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  104171. */
  104172. static readonly FLIP_TILE: number;
  104173. /**
  104174. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  104175. */
  104176. static readonly ROTATE_TILE: number;
  104177. /**
  104178. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  104179. */
  104180. static readonly FLIP_ROW: number;
  104181. /**
  104182. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  104183. */
  104184. static readonly ROTATE_ROW: number;
  104185. /**
  104186. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  104187. */
  104188. static readonly FLIP_N_ROTATE_TILE: number;
  104189. /**
  104190. * Mesh pattern setting : rotate pattern and rotate
  104191. */
  104192. static readonly FLIP_N_ROTATE_ROW: number;
  104193. /**
  104194. * Mesh tile positioning : part tiles same on left/right or top/bottom
  104195. */
  104196. static readonly CENTER: number;
  104197. /**
  104198. * Mesh tile positioning : part tiles on left
  104199. */
  104200. static readonly LEFT: number;
  104201. /**
  104202. * Mesh tile positioning : part tiles on right
  104203. */
  104204. static readonly RIGHT: number;
  104205. /**
  104206. * Mesh tile positioning : part tiles on top
  104207. */
  104208. static readonly TOP: number;
  104209. /**
  104210. * Mesh tile positioning : part tiles on bottom
  104211. */
  104212. static readonly BOTTOM: number;
  104213. /**
  104214. * Gets the default side orientation.
  104215. * @param orientation the orientation to value to attempt to get
  104216. * @returns the default orientation
  104217. * @hidden
  104218. */
  104219. static _GetDefaultSideOrientation(orientation?: number): number;
  104220. private _internalMeshDataInfo;
  104221. /**
  104222. * An event triggered before rendering the mesh
  104223. */
  104224. get onBeforeRenderObservable(): Observable<Mesh>;
  104225. /**
  104226. * An event triggered before binding the mesh
  104227. */
  104228. get onBeforeBindObservable(): Observable<Mesh>;
  104229. /**
  104230. * An event triggered after rendering the mesh
  104231. */
  104232. get onAfterRenderObservable(): Observable<Mesh>;
  104233. /**
  104234. * An event triggered before drawing the mesh
  104235. */
  104236. get onBeforeDrawObservable(): Observable<Mesh>;
  104237. private _onBeforeDrawObserver;
  104238. /**
  104239. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  104240. */
  104241. set onBeforeDraw(callback: () => void);
  104242. get hasInstances(): boolean;
  104243. /**
  104244. * Gets the delay loading state of the mesh (when delay loading is turned on)
  104245. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  104246. */
  104247. delayLoadState: number;
  104248. /**
  104249. * Gets the list of instances created from this mesh
  104250. * it is not supposed to be modified manually.
  104251. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  104252. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  104253. */
  104254. instances: InstancedMesh[];
  104255. /**
  104256. * Gets the file containing delay loading data for this mesh
  104257. */
  104258. delayLoadingFile: string;
  104259. /** @hidden */
  104260. _binaryInfo: any;
  104261. /**
  104262. * User defined function used to change how LOD level selection is done
  104263. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  104264. */
  104265. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  104266. /**
  104267. * Gets or sets the morph target manager
  104268. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  104269. */
  104270. get morphTargetManager(): Nullable<MorphTargetManager>;
  104271. set morphTargetManager(value: Nullable<MorphTargetManager>);
  104272. /** @hidden */
  104273. _creationDataStorage: Nullable<_CreationDataStorage>;
  104274. /** @hidden */
  104275. _geometry: Nullable<Geometry>;
  104276. /** @hidden */
  104277. _delayInfo: Array<string>;
  104278. /** @hidden */
  104279. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  104280. /** @hidden */
  104281. _instanceDataStorage: _InstanceDataStorage;
  104282. private _effectiveMaterial;
  104283. /** @hidden */
  104284. _shouldGenerateFlatShading: boolean;
  104285. /** @hidden */
  104286. _originalBuilderSideOrientation: number;
  104287. /**
  104288. * Use this property to change the original side orientation defined at construction time
  104289. */
  104290. overrideMaterialSideOrientation: Nullable<number>;
  104291. /**
  104292. * Gets the source mesh (the one used to clone this one from)
  104293. */
  104294. get source(): Nullable<Mesh>;
  104295. /**
  104296. * Gets or sets a boolean indicating that this mesh does not use index buffer
  104297. */
  104298. get isUnIndexed(): boolean;
  104299. set isUnIndexed(value: boolean);
  104300. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  104301. get worldMatrixInstancedBuffer(): Float32Array;
  104302. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  104303. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  104304. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  104305. /**
  104306. * @constructor
  104307. * @param name The value used by scene.getMeshByName() to do a lookup.
  104308. * @param scene The scene to add this mesh to.
  104309. * @param parent The parent of this mesh, if it has one
  104310. * @param source An optional Mesh from which geometry is shared, cloned.
  104311. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  104312. * When false, achieved by calling a clone(), also passing False.
  104313. * This will make creation of children, recursive.
  104314. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  104315. */
  104316. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  104317. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  104318. doNotInstantiate: boolean;
  104319. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  104320. /**
  104321. * Gets the class name
  104322. * @returns the string "Mesh".
  104323. */
  104324. getClassName(): string;
  104325. /** @hidden */
  104326. get _isMesh(): boolean;
  104327. /**
  104328. * Returns a description of this mesh
  104329. * @param fullDetails define if full details about this mesh must be used
  104330. * @returns a descriptive string representing this mesh
  104331. */
  104332. toString(fullDetails?: boolean): string;
  104333. /** @hidden */
  104334. _unBindEffect(): void;
  104335. /**
  104336. * Gets a boolean indicating if this mesh has LOD
  104337. */
  104338. get hasLODLevels(): boolean;
  104339. /**
  104340. * Gets the list of MeshLODLevel associated with the current mesh
  104341. * @returns an array of MeshLODLevel
  104342. */
  104343. getLODLevels(): MeshLODLevel[];
  104344. private _sortLODLevels;
  104345. /**
  104346. * Add a mesh as LOD level triggered at the given distance.
  104347. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  104348. * @param distance The distance from the center of the object to show this level
  104349. * @param mesh The mesh to be added as LOD level (can be null)
  104350. * @return This mesh (for chaining)
  104351. */
  104352. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  104353. /**
  104354. * Returns the LOD level mesh at the passed distance or null if not found.
  104355. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  104356. * @param distance The distance from the center of the object to show this level
  104357. * @returns a Mesh or `null`
  104358. */
  104359. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  104360. /**
  104361. * Remove a mesh from the LOD array
  104362. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  104363. * @param mesh defines the mesh to be removed
  104364. * @return This mesh (for chaining)
  104365. */
  104366. removeLODLevel(mesh: Mesh): Mesh;
  104367. /**
  104368. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  104369. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  104370. * @param camera defines the camera to use to compute distance
  104371. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  104372. * @return This mesh (for chaining)
  104373. */
  104374. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  104375. /**
  104376. * Gets the mesh internal Geometry object
  104377. */
  104378. get geometry(): Nullable<Geometry>;
  104379. /**
  104380. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  104381. * @returns the total number of vertices
  104382. */
  104383. getTotalVertices(): number;
  104384. /**
  104385. * Returns the content of an associated vertex buffer
  104386. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  104387. * - VertexBuffer.PositionKind
  104388. * - VertexBuffer.UVKind
  104389. * - VertexBuffer.UV2Kind
  104390. * - VertexBuffer.UV3Kind
  104391. * - VertexBuffer.UV4Kind
  104392. * - VertexBuffer.UV5Kind
  104393. * - VertexBuffer.UV6Kind
  104394. * - VertexBuffer.ColorKind
  104395. * - VertexBuffer.MatricesIndicesKind
  104396. * - VertexBuffer.MatricesIndicesExtraKind
  104397. * - VertexBuffer.MatricesWeightsKind
  104398. * - VertexBuffer.MatricesWeightsExtraKind
  104399. * @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
  104400. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  104401. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  104402. */
  104403. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  104404. /**
  104405. * Returns the mesh VertexBuffer object from the requested `kind`
  104406. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  104407. * - VertexBuffer.PositionKind
  104408. * - VertexBuffer.NormalKind
  104409. * - VertexBuffer.UVKind
  104410. * - VertexBuffer.UV2Kind
  104411. * - VertexBuffer.UV3Kind
  104412. * - VertexBuffer.UV4Kind
  104413. * - VertexBuffer.UV5Kind
  104414. * - VertexBuffer.UV6Kind
  104415. * - VertexBuffer.ColorKind
  104416. * - VertexBuffer.MatricesIndicesKind
  104417. * - VertexBuffer.MatricesIndicesExtraKind
  104418. * - VertexBuffer.MatricesWeightsKind
  104419. * - VertexBuffer.MatricesWeightsExtraKind
  104420. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  104421. */
  104422. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  104423. /**
  104424. * Tests if a specific vertex buffer is associated with this mesh
  104425. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  104426. * - VertexBuffer.PositionKind
  104427. * - VertexBuffer.NormalKind
  104428. * - VertexBuffer.UVKind
  104429. * - VertexBuffer.UV2Kind
  104430. * - VertexBuffer.UV3Kind
  104431. * - VertexBuffer.UV4Kind
  104432. * - VertexBuffer.UV5Kind
  104433. * - VertexBuffer.UV6Kind
  104434. * - VertexBuffer.ColorKind
  104435. * - VertexBuffer.MatricesIndicesKind
  104436. * - VertexBuffer.MatricesIndicesExtraKind
  104437. * - VertexBuffer.MatricesWeightsKind
  104438. * - VertexBuffer.MatricesWeightsExtraKind
  104439. * @returns a boolean
  104440. */
  104441. isVerticesDataPresent(kind: string): boolean;
  104442. /**
  104443. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  104444. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  104445. * - VertexBuffer.PositionKind
  104446. * - VertexBuffer.UVKind
  104447. * - VertexBuffer.UV2Kind
  104448. * - VertexBuffer.UV3Kind
  104449. * - VertexBuffer.UV4Kind
  104450. * - VertexBuffer.UV5Kind
  104451. * - VertexBuffer.UV6Kind
  104452. * - VertexBuffer.ColorKind
  104453. * - VertexBuffer.MatricesIndicesKind
  104454. * - VertexBuffer.MatricesIndicesExtraKind
  104455. * - VertexBuffer.MatricesWeightsKind
  104456. * - VertexBuffer.MatricesWeightsExtraKind
  104457. * @returns a boolean
  104458. */
  104459. isVertexBufferUpdatable(kind: string): boolean;
  104460. /**
  104461. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  104462. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  104463. * - VertexBuffer.PositionKind
  104464. * - VertexBuffer.NormalKind
  104465. * - VertexBuffer.UVKind
  104466. * - VertexBuffer.UV2Kind
  104467. * - VertexBuffer.UV3Kind
  104468. * - VertexBuffer.UV4Kind
  104469. * - VertexBuffer.UV5Kind
  104470. * - VertexBuffer.UV6Kind
  104471. * - VertexBuffer.ColorKind
  104472. * - VertexBuffer.MatricesIndicesKind
  104473. * - VertexBuffer.MatricesIndicesExtraKind
  104474. * - VertexBuffer.MatricesWeightsKind
  104475. * - VertexBuffer.MatricesWeightsExtraKind
  104476. * @returns an array of strings
  104477. */
  104478. getVerticesDataKinds(): string[];
  104479. /**
  104480. * Returns a positive integer : the total number of indices in this mesh geometry.
  104481. * @returns the numner of indices or zero if the mesh has no geometry.
  104482. */
  104483. getTotalIndices(): number;
  104484. /**
  104485. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  104486. * @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.
  104487. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  104488. * @returns the indices array or an empty array if the mesh has no geometry
  104489. */
  104490. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  104491. get isBlocked(): boolean;
  104492. /**
  104493. * Determine if the current mesh is ready to be rendered
  104494. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  104495. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  104496. * @returns true if all associated assets are ready (material, textures, shaders)
  104497. */
  104498. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  104499. /**
  104500. * 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.
  104501. */
  104502. get areNormalsFrozen(): boolean;
  104503. /**
  104504. * 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.
  104505. * @returns the current mesh
  104506. */
  104507. freezeNormals(): Mesh;
  104508. /**
  104509. * 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
  104510. * @returns the current mesh
  104511. */
  104512. unfreezeNormals(): Mesh;
  104513. /**
  104514. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  104515. */
  104516. set overridenInstanceCount(count: number);
  104517. /** @hidden */
  104518. _preActivate(): Mesh;
  104519. /** @hidden */
  104520. _preActivateForIntermediateRendering(renderId: number): Mesh;
  104521. /** @hidden */
  104522. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  104523. /**
  104524. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  104525. * This means the mesh underlying bounding box and sphere are recomputed.
  104526. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  104527. * @returns the current mesh
  104528. */
  104529. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  104530. /** @hidden */
  104531. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  104532. /**
  104533. * This function will subdivide the mesh into multiple submeshes
  104534. * @param count defines the expected number of submeshes
  104535. */
  104536. subdivide(count: number): void;
  104537. /**
  104538. * Copy a FloatArray into a specific associated vertex buffer
  104539. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  104540. * - VertexBuffer.PositionKind
  104541. * - VertexBuffer.UVKind
  104542. * - VertexBuffer.UV2Kind
  104543. * - VertexBuffer.UV3Kind
  104544. * - VertexBuffer.UV4Kind
  104545. * - VertexBuffer.UV5Kind
  104546. * - VertexBuffer.UV6Kind
  104547. * - VertexBuffer.ColorKind
  104548. * - VertexBuffer.MatricesIndicesKind
  104549. * - VertexBuffer.MatricesIndicesExtraKind
  104550. * - VertexBuffer.MatricesWeightsKind
  104551. * - VertexBuffer.MatricesWeightsExtraKind
  104552. * @param data defines the data source
  104553. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  104554. * @param stride defines the data stride size (can be null)
  104555. * @returns the current mesh
  104556. */
  104557. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  104558. /**
  104559. * Delete a vertex buffer associated with this mesh
  104560. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  104561. * - VertexBuffer.PositionKind
  104562. * - VertexBuffer.UVKind
  104563. * - VertexBuffer.UV2Kind
  104564. * - VertexBuffer.UV3Kind
  104565. * - VertexBuffer.UV4Kind
  104566. * - VertexBuffer.UV5Kind
  104567. * - VertexBuffer.UV6Kind
  104568. * - VertexBuffer.ColorKind
  104569. * - VertexBuffer.MatricesIndicesKind
  104570. * - VertexBuffer.MatricesIndicesExtraKind
  104571. * - VertexBuffer.MatricesWeightsKind
  104572. * - VertexBuffer.MatricesWeightsExtraKind
  104573. */
  104574. removeVerticesData(kind: string): void;
  104575. /**
  104576. * Flags an associated vertex buffer as updatable
  104577. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  104578. * - VertexBuffer.PositionKind
  104579. * - VertexBuffer.UVKind
  104580. * - VertexBuffer.UV2Kind
  104581. * - VertexBuffer.UV3Kind
  104582. * - VertexBuffer.UV4Kind
  104583. * - VertexBuffer.UV5Kind
  104584. * - VertexBuffer.UV6Kind
  104585. * - VertexBuffer.ColorKind
  104586. * - VertexBuffer.MatricesIndicesKind
  104587. * - VertexBuffer.MatricesIndicesExtraKind
  104588. * - VertexBuffer.MatricesWeightsKind
  104589. * - VertexBuffer.MatricesWeightsExtraKind
  104590. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  104591. */
  104592. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  104593. /**
  104594. * Sets the mesh global Vertex Buffer
  104595. * @param buffer defines the buffer to use
  104596. * @returns the current mesh
  104597. */
  104598. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  104599. /**
  104600. * Update a specific associated vertex buffer
  104601. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  104602. * - VertexBuffer.PositionKind
  104603. * - VertexBuffer.UVKind
  104604. * - VertexBuffer.UV2Kind
  104605. * - VertexBuffer.UV3Kind
  104606. * - VertexBuffer.UV4Kind
  104607. * - VertexBuffer.UV5Kind
  104608. * - VertexBuffer.UV6Kind
  104609. * - VertexBuffer.ColorKind
  104610. * - VertexBuffer.MatricesIndicesKind
  104611. * - VertexBuffer.MatricesIndicesExtraKind
  104612. * - VertexBuffer.MatricesWeightsKind
  104613. * - VertexBuffer.MatricesWeightsExtraKind
  104614. * @param data defines the data source
  104615. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  104616. * @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)
  104617. * @returns the current mesh
  104618. */
  104619. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  104620. /**
  104621. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  104622. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  104623. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  104624. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  104625. * @returns the current mesh
  104626. */
  104627. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  104628. /**
  104629. * Creates a un-shared specific occurence of the geometry for the mesh.
  104630. * @returns the current mesh
  104631. */
  104632. makeGeometryUnique(): Mesh;
  104633. /**
  104634. * Set the index buffer of this mesh
  104635. * @param indices defines the source data
  104636. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  104637. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  104638. * @returns the current mesh
  104639. */
  104640. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  104641. /**
  104642. * Update the current index buffer
  104643. * @param indices defines the source data
  104644. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  104645. * @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)
  104646. * @returns the current mesh
  104647. */
  104648. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  104649. /**
  104650. * Invert the geometry to move from a right handed system to a left handed one.
  104651. * @returns the current mesh
  104652. */
  104653. toLeftHanded(): Mesh;
  104654. /** @hidden */
  104655. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  104656. /** @hidden */
  104657. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  104658. /**
  104659. * Registers for this mesh a javascript function called just before the rendering process
  104660. * @param func defines the function to call before rendering this mesh
  104661. * @returns the current mesh
  104662. */
  104663. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  104664. /**
  104665. * Disposes a previously registered javascript function called before the rendering
  104666. * @param func defines the function to remove
  104667. * @returns the current mesh
  104668. */
  104669. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  104670. /**
  104671. * Registers for this mesh a javascript function called just after the rendering is complete
  104672. * @param func defines the function to call after rendering this mesh
  104673. * @returns the current mesh
  104674. */
  104675. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  104676. /**
  104677. * Disposes a previously registered javascript function called after the rendering.
  104678. * @param func defines the function to remove
  104679. * @returns the current mesh
  104680. */
  104681. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  104682. /** @hidden */
  104683. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  104684. /** @hidden */
  104685. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  104686. /** @hidden */
  104687. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  104688. /** @hidden */
  104689. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  104690. /** @hidden */
  104691. _rebuild(): void;
  104692. /** @hidden */
  104693. _freeze(): void;
  104694. /** @hidden */
  104695. _unFreeze(): void;
  104696. /**
  104697. * 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
  104698. * @param subMesh defines the subMesh to render
  104699. * @param enableAlphaMode defines if alpha mode can be changed
  104700. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  104701. * @returns the current mesh
  104702. */
  104703. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  104704. private _onBeforeDraw;
  104705. /**
  104706. * Renormalize the mesh and patch it up if there are no weights
  104707. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  104708. * However in the case of zero weights then we set just a single influence to 1.
  104709. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  104710. */
  104711. cleanMatrixWeights(): void;
  104712. private normalizeSkinFourWeights;
  104713. private normalizeSkinWeightsAndExtra;
  104714. /**
  104715. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  104716. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  104717. * the user know there was an issue with importing the mesh
  104718. * @returns a validation object with skinned, valid and report string
  104719. */
  104720. validateSkinning(): {
  104721. skinned: boolean;
  104722. valid: boolean;
  104723. report: string;
  104724. };
  104725. /** @hidden */
  104726. _checkDelayState(): Mesh;
  104727. private _queueLoad;
  104728. /**
  104729. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  104730. * A mesh is in the frustum if its bounding box intersects the frustum
  104731. * @param frustumPlanes defines the frustum to test
  104732. * @returns true if the mesh is in the frustum planes
  104733. */
  104734. isInFrustum(frustumPlanes: Plane[]): boolean;
  104735. /**
  104736. * Sets the mesh material by the material or multiMaterial `id` property
  104737. * @param id is a string identifying the material or the multiMaterial
  104738. * @returns the current mesh
  104739. */
  104740. setMaterialByID(id: string): Mesh;
  104741. /**
  104742. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  104743. * @returns an array of IAnimatable
  104744. */
  104745. getAnimatables(): IAnimatable[];
  104746. /**
  104747. * Modifies the mesh geometry according to the passed transformation matrix.
  104748. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  104749. * The mesh normals are modified using the same transformation.
  104750. * Note that, under the hood, this method sets a new VertexBuffer each call.
  104751. * @param transform defines the transform matrix to use
  104752. * @see http://doc.babylonjs.com/resources/baking_transformations
  104753. * @returns the current mesh
  104754. */
  104755. bakeTransformIntoVertices(transform: Matrix): Mesh;
  104756. /**
  104757. * Modifies the mesh geometry according to its own current World Matrix.
  104758. * The mesh World Matrix is then reset.
  104759. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  104760. * Note that, under the hood, this method sets a new VertexBuffer each call.
  104761. * @see http://doc.babylonjs.com/resources/baking_transformations
  104762. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  104763. * @returns the current mesh
  104764. */
  104765. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  104766. /** @hidden */
  104767. get _positions(): Nullable<Vector3[]>;
  104768. /** @hidden */
  104769. _resetPointsArrayCache(): Mesh;
  104770. /** @hidden */
  104771. _generatePointsArray(): boolean;
  104772. /**
  104773. * Returns a new Mesh object generated from the current mesh properties.
  104774. * This method must not get confused with createInstance()
  104775. * @param name is a string, the name given to the new mesh
  104776. * @param newParent can be any Node object (default `null`)
  104777. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  104778. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  104779. * @returns a new mesh
  104780. */
  104781. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  104782. /**
  104783. * Releases resources associated with this mesh.
  104784. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  104785. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  104786. */
  104787. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  104788. /** @hidden */
  104789. _disposeInstanceSpecificData(): void;
  104790. /**
  104791. * Modifies the mesh geometry according to a displacement map.
  104792. * 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.
  104793. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  104794. * @param url is a string, the URL from the image file is to be downloaded.
  104795. * @param minHeight is the lower limit of the displacement.
  104796. * @param maxHeight is the upper limit of the displacement.
  104797. * @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.
  104798. * @param uvOffset is an optional vector2 used to offset UV.
  104799. * @param uvScale is an optional vector2 used to scale UV.
  104800. * @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.
  104801. * @returns the Mesh.
  104802. */
  104803. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  104804. /**
  104805. * Modifies the mesh geometry according to a displacementMap buffer.
  104806. * 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.
  104807. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  104808. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  104809. * @param heightMapWidth is the width of the buffer image.
  104810. * @param heightMapHeight is the height of the buffer image.
  104811. * @param minHeight is the lower limit of the displacement.
  104812. * @param maxHeight is the upper limit of the displacement.
  104813. * @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.
  104814. * @param uvOffset is an optional vector2 used to offset UV.
  104815. * @param uvScale is an optional vector2 used to scale UV.
  104816. * @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.
  104817. * @returns the Mesh.
  104818. */
  104819. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  104820. /**
  104821. * Modify the mesh to get a flat shading rendering.
  104822. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  104823. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  104824. * @returns current mesh
  104825. */
  104826. convertToFlatShadedMesh(): Mesh;
  104827. /**
  104828. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  104829. * In other words, more vertices, no more indices and a single bigger VBO.
  104830. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  104831. * @returns current mesh
  104832. */
  104833. convertToUnIndexedMesh(): Mesh;
  104834. /**
  104835. * Inverses facet orientations.
  104836. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  104837. * @param flipNormals will also inverts the normals
  104838. * @returns current mesh
  104839. */
  104840. flipFaces(flipNormals?: boolean): Mesh;
  104841. /**
  104842. * Increase the number of facets and hence vertices in a mesh
  104843. * Vertex normals are interpolated from existing vertex normals
  104844. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  104845. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  104846. */
  104847. increaseVertices(numberPerEdge: number): void;
  104848. /**
  104849. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  104850. * This will undo any application of covertToFlatShadedMesh
  104851. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  104852. */
  104853. forceSharedVertices(): void;
  104854. /** @hidden */
  104855. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  104856. /** @hidden */
  104857. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  104858. /**
  104859. * Creates a new InstancedMesh object from the mesh model.
  104860. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  104861. * @param name defines the name of the new instance
  104862. * @returns a new InstancedMesh
  104863. */
  104864. createInstance(name: string): InstancedMesh;
  104865. /**
  104866. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  104867. * After this call, all the mesh instances have the same submeshes than the current mesh.
  104868. * @returns the current mesh
  104869. */
  104870. synchronizeInstances(): Mesh;
  104871. /**
  104872. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  104873. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  104874. * This should be used together with the simplification to avoid disappearing triangles.
  104875. * @param successCallback an optional success callback to be called after the optimization finished.
  104876. * @returns the current mesh
  104877. */
  104878. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  104879. /**
  104880. * Serialize current mesh
  104881. * @param serializationObject defines the object which will receive the serialization data
  104882. */
  104883. serialize(serializationObject: any): void;
  104884. /** @hidden */
  104885. _syncGeometryWithMorphTargetManager(): void;
  104886. /** @hidden */
  104887. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  104888. /**
  104889. * Returns a new Mesh object parsed from the source provided.
  104890. * @param parsedMesh is the source
  104891. * @param scene defines the hosting scene
  104892. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  104893. * @returns a new Mesh
  104894. */
  104895. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  104896. /**
  104897. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  104898. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  104899. * @param name defines the name of the mesh to create
  104900. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  104901. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  104902. * @param closePath creates a seam between the first and the last points of each path of the path array
  104903. * @param offset is taken in account only if the `pathArray` is containing a single path
  104904. * @param scene defines the hosting scene
  104905. * @param updatable defines if the mesh must be flagged as updatable
  104906. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  104907. * @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)
  104908. * @returns a new Mesh
  104909. */
  104910. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  104911. /**
  104912. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  104913. * @param name defines the name of the mesh to create
  104914. * @param radius sets the radius size (float) of the polygon (default 0.5)
  104915. * @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
  104916. * @param scene defines the hosting scene
  104917. * @param updatable defines if the mesh must be flagged as updatable
  104918. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  104919. * @returns a new Mesh
  104920. */
  104921. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  104922. /**
  104923. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  104924. * @param name defines the name of the mesh to create
  104925. * @param size sets the size (float) of each box side (default 1)
  104926. * @param scene defines the hosting scene
  104927. * @param updatable defines if the mesh must be flagged as updatable
  104928. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  104929. * @returns a new Mesh
  104930. */
  104931. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  104932. /**
  104933. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  104934. * @param name defines the name of the mesh to create
  104935. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  104936. * @param diameter sets the diameter size (float) of the sphere (default 1)
  104937. * @param scene defines the hosting scene
  104938. * @param updatable defines if the mesh must be flagged as updatable
  104939. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  104940. * @returns a new Mesh
  104941. */
  104942. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  104943. /**
  104944. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  104945. * @param name defines the name of the mesh to create
  104946. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  104947. * @param diameter sets the diameter size (float) of the sphere (default 1)
  104948. * @param scene defines the hosting scene
  104949. * @returns a new Mesh
  104950. */
  104951. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  104952. /**
  104953. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  104954. * @param name defines the name of the mesh to create
  104955. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  104956. * @param diameterTop set the top cap diameter (floats, default 1)
  104957. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  104958. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  104959. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  104960. * @param scene defines the hosting scene
  104961. * @param updatable defines if the mesh must be flagged as updatable
  104962. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  104963. * @returns a new Mesh
  104964. */
  104965. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  104966. /**
  104967. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  104968. * @param name defines the name of the mesh to create
  104969. * @param diameter sets the diameter size (float) of the torus (default 1)
  104970. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  104971. * @param tessellation sets the number of torus sides (postive integer, default 16)
  104972. * @param scene defines the hosting scene
  104973. * @param updatable defines if the mesh must be flagged as updatable
  104974. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  104975. * @returns a new Mesh
  104976. */
  104977. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  104978. /**
  104979. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  104980. * @param name defines the name of the mesh to create
  104981. * @param radius sets the global radius size (float) of the torus knot (default 2)
  104982. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  104983. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  104984. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  104985. * @param p the number of windings on X axis (positive integers, default 2)
  104986. * @param q the number of windings on Y axis (positive integers, default 3)
  104987. * @param scene defines the hosting scene
  104988. * @param updatable defines if the mesh must be flagged as updatable
  104989. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  104990. * @returns a new Mesh
  104991. */
  104992. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  104993. /**
  104994. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  104995. * @param name defines the name of the mesh to create
  104996. * @param points is an array successive Vector3
  104997. * @param scene defines the hosting scene
  104998. * @param updatable defines if the mesh must be flagged as updatable
  104999. * @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).
  105000. * @returns a new Mesh
  105001. */
  105002. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  105003. /**
  105004. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  105005. * @param name defines the name of the mesh to create
  105006. * @param points is an array successive Vector3
  105007. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  105008. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  105009. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  105010. * @param scene defines the hosting scene
  105011. * @param updatable defines if the mesh must be flagged as updatable
  105012. * @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)
  105013. * @returns a new Mesh
  105014. */
  105015. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  105016. /**
  105017. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  105018. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  105019. * 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.
  105020. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105021. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  105022. * Remember you can only change the shape positions, not their number when updating a polygon.
  105023. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  105024. * @param name defines the name of the mesh to create
  105025. * @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
  105026. * @param scene defines the hosting scene
  105027. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  105028. * @param updatable defines if the mesh must be flagged as updatable
  105029. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105030. * @param earcutInjection can be used to inject your own earcut reference
  105031. * @returns a new Mesh
  105032. */
  105033. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  105034. /**
  105035. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  105036. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  105037. * @param name defines the name of the mesh to create
  105038. * @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
  105039. * @param depth defines the height of extrusion
  105040. * @param scene defines the hosting scene
  105041. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  105042. * @param updatable defines if the mesh must be flagged as updatable
  105043. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105044. * @param earcutInjection can be used to inject your own earcut reference
  105045. * @returns a new Mesh
  105046. */
  105047. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  105048. /**
  105049. * Creates an extruded shape mesh.
  105050. * 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
  105051. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  105052. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  105053. * @param name defines the name of the mesh to create
  105054. * @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
  105055. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  105056. * @param scale is the value to scale the shape
  105057. * @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
  105058. * @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
  105059. * @param scene defines the hosting scene
  105060. * @param updatable defines if the mesh must be flagged as updatable
  105061. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105062. * @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)
  105063. * @returns a new Mesh
  105064. */
  105065. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  105066. /**
  105067. * Creates an custom extruded shape mesh.
  105068. * The custom extrusion is a parametric shape.
  105069. * It has no predefined shape. Its final shape will depend on the input parameters.
  105070. * Please consider using the same method from the MeshBuilder class instead
  105071. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  105072. * @param name defines the name of the mesh to create
  105073. * @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
  105074. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  105075. * @param scaleFunction is a custom Javascript function called on each path point
  105076. * @param rotationFunction is a custom Javascript function called on each path point
  105077. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  105078. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  105079. * @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
  105080. * @param scene defines the hosting scene
  105081. * @param updatable defines if the mesh must be flagged as updatable
  105082. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105083. * @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)
  105084. * @returns a new Mesh
  105085. */
  105086. 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;
  105087. /**
  105088. * Creates lathe mesh.
  105089. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  105090. * Please consider using the same method from the MeshBuilder class instead
  105091. * @param name defines the name of the mesh to create
  105092. * @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
  105093. * @param radius is the radius value of the lathe
  105094. * @param tessellation is the side number of the lathe.
  105095. * @param scene defines the hosting scene
  105096. * @param updatable defines if the mesh must be flagged as updatable
  105097. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105098. * @returns a new Mesh
  105099. */
  105100. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  105101. /**
  105102. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  105103. * @param name defines the name of the mesh to create
  105104. * @param size sets the size (float) of both sides of the plane at once (default 1)
  105105. * @param scene defines the hosting scene
  105106. * @param updatable defines if the mesh must be flagged as updatable
  105107. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105108. * @returns a new Mesh
  105109. */
  105110. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  105111. /**
  105112. * Creates a ground mesh.
  105113. * Please consider using the same method from the MeshBuilder class instead
  105114. * @param name defines the name of the mesh to create
  105115. * @param width set the width of the ground
  105116. * @param height set the height of the ground
  105117. * @param subdivisions sets the number of subdivisions per side
  105118. * @param scene defines the hosting scene
  105119. * @param updatable defines if the mesh must be flagged as updatable
  105120. * @returns a new Mesh
  105121. */
  105122. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  105123. /**
  105124. * Creates a tiled ground mesh.
  105125. * Please consider using the same method from the MeshBuilder class instead
  105126. * @param name defines the name of the mesh to create
  105127. * @param xmin set the ground minimum X coordinate
  105128. * @param zmin set the ground minimum Y coordinate
  105129. * @param xmax set the ground maximum X coordinate
  105130. * @param zmax set the ground maximum Z coordinate
  105131. * @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
  105132. * @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
  105133. * @param scene defines the hosting scene
  105134. * @param updatable defines if the mesh must be flagged as updatable
  105135. * @returns a new Mesh
  105136. */
  105137. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  105138. w: number;
  105139. h: number;
  105140. }, precision: {
  105141. w: number;
  105142. h: number;
  105143. }, scene: Scene, updatable?: boolean): Mesh;
  105144. /**
  105145. * Creates a ground mesh from a height map.
  105146. * Please consider using the same method from the MeshBuilder class instead
  105147. * @see http://doc.babylonjs.com/babylon101/height_map
  105148. * @param name defines the name of the mesh to create
  105149. * @param url sets the URL of the height map image resource
  105150. * @param width set the ground width size
  105151. * @param height set the ground height size
  105152. * @param subdivisions sets the number of subdivision per side
  105153. * @param minHeight is the minimum altitude on the ground
  105154. * @param maxHeight is the maximum altitude on the ground
  105155. * @param scene defines the hosting scene
  105156. * @param updatable defines if the mesh must be flagged as updatable
  105157. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  105158. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  105159. * @returns a new Mesh
  105160. */
  105161. 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;
  105162. /**
  105163. * Creates a tube mesh.
  105164. * The tube is a parametric shape.
  105165. * It has no predefined shape. Its final shape will depend on the input parameters.
  105166. * Please consider using the same method from the MeshBuilder class instead
  105167. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  105168. * @param name defines the name of the mesh to create
  105169. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  105170. * @param radius sets the tube radius size
  105171. * @param tessellation is the number of sides on the tubular surface
  105172. * @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
  105173. * @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
  105174. * @param scene defines the hosting scene
  105175. * @param updatable defines if the mesh must be flagged as updatable
  105176. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105177. * @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)
  105178. * @returns a new Mesh
  105179. */
  105180. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  105181. (i: number, distance: number): number;
  105182. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  105183. /**
  105184. * Creates a polyhedron mesh.
  105185. * Please consider using the same method from the MeshBuilder class instead.
  105186. * * 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
  105187. * * The parameter `size` (positive float, default 1) sets the polygon size
  105188. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  105189. * * 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`
  105190. * * 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
  105191. * * 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)`)
  105192. * * 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
  105193. * * 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
  105194. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105195. * * If you create a double-sided mesh, you can choose what parts of 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
  105196. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105197. * @param name defines the name of the mesh to create
  105198. * @param options defines the options used to create the mesh
  105199. * @param scene defines the hosting scene
  105200. * @returns a new Mesh
  105201. */
  105202. static CreatePolyhedron(name: string, options: {
  105203. type?: number;
  105204. size?: number;
  105205. sizeX?: number;
  105206. sizeY?: number;
  105207. sizeZ?: number;
  105208. custom?: any;
  105209. faceUV?: Vector4[];
  105210. faceColors?: Color4[];
  105211. updatable?: boolean;
  105212. sideOrientation?: number;
  105213. }, scene: Scene): Mesh;
  105214. /**
  105215. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  105216. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  105217. * * 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`)
  105218. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  105219. * * 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
  105220. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105221. * * If you create a double-sided mesh, you can choose what parts of 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
  105222. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105223. * @param name defines the name of the mesh
  105224. * @param options defines the options used to create the mesh
  105225. * @param scene defines the hosting scene
  105226. * @returns a new Mesh
  105227. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  105228. */
  105229. static CreateIcoSphere(name: string, options: {
  105230. radius?: number;
  105231. flat?: boolean;
  105232. subdivisions?: number;
  105233. sideOrientation?: number;
  105234. updatable?: boolean;
  105235. }, scene: Scene): Mesh;
  105236. /**
  105237. * Creates a decal mesh.
  105238. * Please consider using the same method from the MeshBuilder class instead.
  105239. * A decal is a mesh usually applied as a model onto the surface of another mesh
  105240. * @param name defines the name of the mesh
  105241. * @param sourceMesh defines the mesh receiving the decal
  105242. * @param position sets the position of the decal in world coordinates
  105243. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  105244. * @param size sets the decal scaling
  105245. * @param angle sets the angle to rotate the decal
  105246. * @returns a new Mesh
  105247. */
  105248. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  105249. /**
  105250. * Prepare internal position array for software CPU skinning
  105251. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  105252. */
  105253. setPositionsForCPUSkinning(): Float32Array;
  105254. /**
  105255. * Prepare internal normal array for software CPU skinning
  105256. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  105257. */
  105258. setNormalsForCPUSkinning(): Float32Array;
  105259. /**
  105260. * Updates the vertex buffer by applying transformation from the bones
  105261. * @param skeleton defines the skeleton to apply to current mesh
  105262. * @returns the current mesh
  105263. */
  105264. applySkeleton(skeleton: Skeleton): Mesh;
  105265. /**
  105266. * 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
  105267. * @param meshes defines the list of meshes to scan
  105268. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  105269. */
  105270. static MinMax(meshes: AbstractMesh[]): {
  105271. min: Vector3;
  105272. max: Vector3;
  105273. };
  105274. /**
  105275. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  105276. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  105277. * @returns a vector3
  105278. */
  105279. static Center(meshesOrMinMaxVector: {
  105280. min: Vector3;
  105281. max: Vector3;
  105282. } | AbstractMesh[]): Vector3;
  105283. /**
  105284. * Merge the array of meshes into a single mesh for performance reasons.
  105285. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  105286. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  105287. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  105288. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  105289. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  105290. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  105291. * @returns a new mesh
  105292. */
  105293. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  105294. /** @hidden */
  105295. addInstance(instance: InstancedMesh): void;
  105296. /** @hidden */
  105297. removeInstance(instance: InstancedMesh): void;
  105298. }
  105299. }
  105300. declare module BABYLON {
  105301. /**
  105302. * This is the base class of all the camera used in the application.
  105303. * @see http://doc.babylonjs.com/features/cameras
  105304. */
  105305. export class Camera extends Node {
  105306. /** @hidden */
  105307. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  105308. /**
  105309. * This is the default projection mode used by the cameras.
  105310. * It helps recreating a feeling of perspective and better appreciate depth.
  105311. * This is the best way to simulate real life cameras.
  105312. */
  105313. static readonly PERSPECTIVE_CAMERA: number;
  105314. /**
  105315. * This helps creating camera with an orthographic mode.
  105316. * 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.
  105317. */
  105318. static readonly ORTHOGRAPHIC_CAMERA: number;
  105319. /**
  105320. * This is the default FOV mode for perspective cameras.
  105321. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  105322. */
  105323. static readonly FOVMODE_VERTICAL_FIXED: number;
  105324. /**
  105325. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  105326. */
  105327. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  105328. /**
  105329. * This specifies ther is no need for a camera rig.
  105330. * Basically only one eye is rendered corresponding to the camera.
  105331. */
  105332. static readonly RIG_MODE_NONE: number;
  105333. /**
  105334. * Simulates a camera Rig with one blue eye and one red eye.
  105335. * This can be use with 3d blue and red glasses.
  105336. */
  105337. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  105338. /**
  105339. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  105340. */
  105341. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  105342. /**
  105343. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  105344. */
  105345. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  105346. /**
  105347. * Defines that both eyes of the camera will be rendered over under each other.
  105348. */
  105349. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  105350. /**
  105351. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  105352. */
  105353. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  105354. /**
  105355. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  105356. */
  105357. static readonly RIG_MODE_VR: number;
  105358. /**
  105359. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  105360. */
  105361. static readonly RIG_MODE_WEBVR: number;
  105362. /**
  105363. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  105364. */
  105365. static readonly RIG_MODE_CUSTOM: number;
  105366. /**
  105367. * Defines if by default attaching controls should prevent the default javascript event to continue.
  105368. */
  105369. static ForceAttachControlToAlwaysPreventDefault: boolean;
  105370. /**
  105371. * Define the input manager associated with the camera.
  105372. */
  105373. inputs: CameraInputsManager<Camera>;
  105374. /** @hidden */
  105375. _position: Vector3;
  105376. /**
  105377. * Define the current local position of the camera in the scene
  105378. */
  105379. get position(): Vector3;
  105380. set position(newPosition: Vector3);
  105381. /**
  105382. * The vector the camera should consider as up.
  105383. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  105384. */
  105385. upVector: Vector3;
  105386. /**
  105387. * Define the current limit on the left side for an orthographic camera
  105388. * In scene unit
  105389. */
  105390. orthoLeft: Nullable<number>;
  105391. /**
  105392. * Define the current limit on the right side for an orthographic camera
  105393. * In scene unit
  105394. */
  105395. orthoRight: Nullable<number>;
  105396. /**
  105397. * Define the current limit on the bottom side for an orthographic camera
  105398. * In scene unit
  105399. */
  105400. orthoBottom: Nullable<number>;
  105401. /**
  105402. * Define the current limit on the top side for an orthographic camera
  105403. * In scene unit
  105404. */
  105405. orthoTop: Nullable<number>;
  105406. /**
  105407. * Field Of View is set in Radians. (default is 0.8)
  105408. */
  105409. fov: number;
  105410. /**
  105411. * Define the minimum distance the camera can see from.
  105412. * This is important to note that the depth buffer are not infinite and the closer it starts
  105413. * the more your scene might encounter depth fighting issue.
  105414. */
  105415. minZ: number;
  105416. /**
  105417. * Define the maximum distance the camera can see to.
  105418. * This is important to note that the depth buffer are not infinite and the further it end
  105419. * the more your scene might encounter depth fighting issue.
  105420. */
  105421. maxZ: number;
  105422. /**
  105423. * Define the default inertia of the camera.
  105424. * This helps giving a smooth feeling to the camera movement.
  105425. */
  105426. inertia: number;
  105427. /**
  105428. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  105429. */
  105430. mode: number;
  105431. /**
  105432. * Define whether the camera is intermediate.
  105433. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  105434. */
  105435. isIntermediate: boolean;
  105436. /**
  105437. * Define the viewport of the camera.
  105438. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  105439. */
  105440. viewport: Viewport;
  105441. /**
  105442. * Restricts the camera to viewing objects with the same layerMask.
  105443. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  105444. */
  105445. layerMask: number;
  105446. /**
  105447. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  105448. */
  105449. fovMode: number;
  105450. /**
  105451. * Rig mode of the camera.
  105452. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  105453. * This is normally controlled byt the camera themselves as internal use.
  105454. */
  105455. cameraRigMode: number;
  105456. /**
  105457. * Defines the distance between both "eyes" in case of a RIG
  105458. */
  105459. interaxialDistance: number;
  105460. /**
  105461. * Defines if stereoscopic rendering is done side by side or over under.
  105462. */
  105463. isStereoscopicSideBySide: boolean;
  105464. /**
  105465. * 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
  105466. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  105467. * else in the scene. (Eg. security camera)
  105468. *
  105469. * 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)
  105470. */
  105471. customRenderTargets: RenderTargetTexture[];
  105472. /**
  105473. * When set, the camera will render to this render target instead of the default canvas
  105474. *
  105475. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  105476. */
  105477. outputRenderTarget: Nullable<RenderTargetTexture>;
  105478. /**
  105479. * Observable triggered when the camera view matrix has changed.
  105480. */
  105481. onViewMatrixChangedObservable: Observable<Camera>;
  105482. /**
  105483. * Observable triggered when the camera Projection matrix has changed.
  105484. */
  105485. onProjectionMatrixChangedObservable: Observable<Camera>;
  105486. /**
  105487. * Observable triggered when the inputs have been processed.
  105488. */
  105489. onAfterCheckInputsObservable: Observable<Camera>;
  105490. /**
  105491. * Observable triggered when reset has been called and applied to the camera.
  105492. */
  105493. onRestoreStateObservable: Observable<Camera>;
  105494. /**
  105495. * Is this camera a part of a rig system?
  105496. */
  105497. isRigCamera: boolean;
  105498. /**
  105499. * If isRigCamera set to true this will be set with the parent camera.
  105500. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  105501. */
  105502. rigParent?: Camera;
  105503. /** @hidden */
  105504. _cameraRigParams: any;
  105505. /** @hidden */
  105506. _rigCameras: Camera[];
  105507. /** @hidden */
  105508. _rigPostProcess: Nullable<PostProcess>;
  105509. protected _webvrViewMatrix: Matrix;
  105510. /** @hidden */
  105511. _skipRendering: boolean;
  105512. /** @hidden */
  105513. _projectionMatrix: Matrix;
  105514. /** @hidden */
  105515. _postProcesses: Nullable<PostProcess>[];
  105516. /** @hidden */
  105517. _activeMeshes: SmartArray<AbstractMesh>;
  105518. protected _globalPosition: Vector3;
  105519. /** @hidden */
  105520. _computedViewMatrix: Matrix;
  105521. private _doNotComputeProjectionMatrix;
  105522. private _transformMatrix;
  105523. private _frustumPlanes;
  105524. private _refreshFrustumPlanes;
  105525. private _storedFov;
  105526. private _stateStored;
  105527. /**
  105528. * Instantiates a new camera object.
  105529. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  105530. * @see http://doc.babylonjs.com/features/cameras
  105531. * @param name Defines the name of the camera in the scene
  105532. * @param position Defines the position of the camera
  105533. * @param scene Defines the scene the camera belongs too
  105534. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  105535. */
  105536. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  105537. /**
  105538. * Store current camera state (fov, position, etc..)
  105539. * @returns the camera
  105540. */
  105541. storeState(): Camera;
  105542. /**
  105543. * Restores the camera state values if it has been stored. You must call storeState() first
  105544. */
  105545. protected _restoreStateValues(): boolean;
  105546. /**
  105547. * Restored camera state. You must call storeState() first.
  105548. * @returns true if restored and false otherwise
  105549. */
  105550. restoreState(): boolean;
  105551. /**
  105552. * Gets the class name of the camera.
  105553. * @returns the class name
  105554. */
  105555. getClassName(): string;
  105556. /** @hidden */
  105557. readonly _isCamera: boolean;
  105558. /**
  105559. * Gets a string representation of the camera useful for debug purpose.
  105560. * @param fullDetails Defines that a more verboe level of logging is required
  105561. * @returns the string representation
  105562. */
  105563. toString(fullDetails?: boolean): string;
  105564. /**
  105565. * Gets the current world space position of the camera.
  105566. */
  105567. get globalPosition(): Vector3;
  105568. /**
  105569. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  105570. * @returns the active meshe list
  105571. */
  105572. getActiveMeshes(): SmartArray<AbstractMesh>;
  105573. /**
  105574. * Check whether a mesh is part of the current active mesh list of the camera
  105575. * @param mesh Defines the mesh to check
  105576. * @returns true if active, false otherwise
  105577. */
  105578. isActiveMesh(mesh: Mesh): boolean;
  105579. /**
  105580. * Is this camera ready to be used/rendered
  105581. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  105582. * @return true if the camera is ready
  105583. */
  105584. isReady(completeCheck?: boolean): boolean;
  105585. /** @hidden */
  105586. _initCache(): void;
  105587. /** @hidden */
  105588. _updateCache(ignoreParentClass?: boolean): void;
  105589. /** @hidden */
  105590. _isSynchronized(): boolean;
  105591. /** @hidden */
  105592. _isSynchronizedViewMatrix(): boolean;
  105593. /** @hidden */
  105594. _isSynchronizedProjectionMatrix(): boolean;
  105595. /**
  105596. * Attach the input controls to a specific dom element to get the input from.
  105597. * @param element Defines the element the controls should be listened from
  105598. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105599. */
  105600. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105601. /**
  105602. * Detach the current controls from the specified dom element.
  105603. * @param element Defines the element to stop listening the inputs from
  105604. */
  105605. detachControl(element: HTMLElement): void;
  105606. /**
  105607. * Update the camera state according to the different inputs gathered during the frame.
  105608. */
  105609. update(): void;
  105610. /** @hidden */
  105611. _checkInputs(): void;
  105612. /** @hidden */
  105613. get rigCameras(): Camera[];
  105614. /**
  105615. * Gets the post process used by the rig cameras
  105616. */
  105617. get rigPostProcess(): Nullable<PostProcess>;
  105618. /**
  105619. * Internal, gets the first post proces.
  105620. * @returns the first post process to be run on this camera.
  105621. */
  105622. _getFirstPostProcess(): Nullable<PostProcess>;
  105623. private _cascadePostProcessesToRigCams;
  105624. /**
  105625. * Attach a post process to the camera.
  105626. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  105627. * @param postProcess The post process to attach to the camera
  105628. * @param insertAt The position of the post process in case several of them are in use in the scene
  105629. * @returns the position the post process has been inserted at
  105630. */
  105631. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  105632. /**
  105633. * Detach a post process to the camera.
  105634. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  105635. * @param postProcess The post process to detach from the camera
  105636. */
  105637. detachPostProcess(postProcess: PostProcess): void;
  105638. /**
  105639. * Gets the current world matrix of the camera
  105640. */
  105641. getWorldMatrix(): Matrix;
  105642. /** @hidden */
  105643. _getViewMatrix(): Matrix;
  105644. /**
  105645. * Gets the current view matrix of the camera.
  105646. * @param force forces the camera to recompute the matrix without looking at the cached state
  105647. * @returns the view matrix
  105648. */
  105649. getViewMatrix(force?: boolean): Matrix;
  105650. /**
  105651. * Freeze the projection matrix.
  105652. * It will prevent the cache check of the camera projection compute and can speed up perf
  105653. * if no parameter of the camera are meant to change
  105654. * @param projection Defines manually a projection if necessary
  105655. */
  105656. freezeProjectionMatrix(projection?: Matrix): void;
  105657. /**
  105658. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  105659. */
  105660. unfreezeProjectionMatrix(): void;
  105661. /**
  105662. * Gets the current projection matrix of the camera.
  105663. * @param force forces the camera to recompute the matrix without looking at the cached state
  105664. * @returns the projection matrix
  105665. */
  105666. getProjectionMatrix(force?: boolean): Matrix;
  105667. /**
  105668. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  105669. * @returns a Matrix
  105670. */
  105671. getTransformationMatrix(): Matrix;
  105672. private _updateFrustumPlanes;
  105673. /**
  105674. * Checks if a cullable object (mesh...) is in the camera frustum
  105675. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  105676. * @param target The object to check
  105677. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  105678. * @returns true if the object is in frustum otherwise false
  105679. */
  105680. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  105681. /**
  105682. * Checks if a cullable object (mesh...) is in the camera frustum
  105683. * Unlike isInFrustum this cheks the full bounding box
  105684. * @param target The object to check
  105685. * @returns true if the object is in frustum otherwise false
  105686. */
  105687. isCompletelyInFrustum(target: ICullable): boolean;
  105688. /**
  105689. * Gets a ray in the forward direction from the camera.
  105690. * @param length Defines the length of the ray to create
  105691. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  105692. * @param origin Defines the start point of the ray which defaults to the camera position
  105693. * @returns the forward ray
  105694. */
  105695. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  105696. /**
  105697. * Releases resources associated with this node.
  105698. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  105699. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  105700. */
  105701. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  105702. /** @hidden */
  105703. _isLeftCamera: boolean;
  105704. /**
  105705. * Gets the left camera of a rig setup in case of Rigged Camera
  105706. */
  105707. get isLeftCamera(): boolean;
  105708. /** @hidden */
  105709. _isRightCamera: boolean;
  105710. /**
  105711. * Gets the right camera of a rig setup in case of Rigged Camera
  105712. */
  105713. get isRightCamera(): boolean;
  105714. /**
  105715. * Gets the left camera of a rig setup in case of Rigged Camera
  105716. */
  105717. get leftCamera(): Nullable<FreeCamera>;
  105718. /**
  105719. * Gets the right camera of a rig setup in case of Rigged Camera
  105720. */
  105721. get rightCamera(): Nullable<FreeCamera>;
  105722. /**
  105723. * Gets the left camera target of a rig setup in case of Rigged Camera
  105724. * @returns the target position
  105725. */
  105726. getLeftTarget(): Nullable<Vector3>;
  105727. /**
  105728. * Gets the right camera target of a rig setup in case of Rigged Camera
  105729. * @returns the target position
  105730. */
  105731. getRightTarget(): Nullable<Vector3>;
  105732. /**
  105733. * @hidden
  105734. */
  105735. setCameraRigMode(mode: number, rigParams: any): void;
  105736. /** @hidden */
  105737. static _setStereoscopicRigMode(camera: Camera): void;
  105738. /** @hidden */
  105739. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  105740. /** @hidden */
  105741. static _setVRRigMode(camera: Camera, rigParams: any): void;
  105742. /** @hidden */
  105743. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  105744. /** @hidden */
  105745. _getVRProjectionMatrix(): Matrix;
  105746. protected _updateCameraRotationMatrix(): void;
  105747. protected _updateWebVRCameraRotationMatrix(): void;
  105748. /**
  105749. * This function MUST be overwritten by the different WebVR cameras available.
  105750. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  105751. * @hidden
  105752. */
  105753. _getWebVRProjectionMatrix(): Matrix;
  105754. /**
  105755. * This function MUST be overwritten by the different WebVR cameras available.
  105756. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  105757. * @hidden
  105758. */
  105759. _getWebVRViewMatrix(): Matrix;
  105760. /** @hidden */
  105761. setCameraRigParameter(name: string, value: any): void;
  105762. /**
  105763. * needs to be overridden by children so sub has required properties to be copied
  105764. * @hidden
  105765. */
  105766. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  105767. /**
  105768. * May need to be overridden by children
  105769. * @hidden
  105770. */
  105771. _updateRigCameras(): void;
  105772. /** @hidden */
  105773. _setupInputs(): void;
  105774. /**
  105775. * Serialiaze the camera setup to a json represention
  105776. * @returns the JSON representation
  105777. */
  105778. serialize(): any;
  105779. /**
  105780. * Clones the current camera.
  105781. * @param name The cloned camera name
  105782. * @returns the cloned camera
  105783. */
  105784. clone(name: string): Camera;
  105785. /**
  105786. * Gets the direction of the camera relative to a given local axis.
  105787. * @param localAxis Defines the reference axis to provide a relative direction.
  105788. * @return the direction
  105789. */
  105790. getDirection(localAxis: Vector3): Vector3;
  105791. /**
  105792. * Returns the current camera absolute rotation
  105793. */
  105794. get absoluteRotation(): Quaternion;
  105795. /**
  105796. * Gets the direction of the camera relative to a given local axis into a passed vector.
  105797. * @param localAxis Defines the reference axis to provide a relative direction.
  105798. * @param result Defines the vector to store the result in
  105799. */
  105800. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  105801. /**
  105802. * Gets a camera constructor for a given camera type
  105803. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  105804. * @param name The name of the camera the result will be able to instantiate
  105805. * @param scene The scene the result will construct the camera in
  105806. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  105807. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  105808. * @returns a factory method to construc the camera
  105809. */
  105810. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  105811. /**
  105812. * Compute the world matrix of the camera.
  105813. * @returns the camera world matrix
  105814. */
  105815. computeWorldMatrix(): Matrix;
  105816. /**
  105817. * Parse a JSON and creates the camera from the parsed information
  105818. * @param parsedCamera The JSON to parse
  105819. * @param scene The scene to instantiate the camera in
  105820. * @returns the newly constructed camera
  105821. */
  105822. static Parse(parsedCamera: any, scene: Scene): Camera;
  105823. }
  105824. }
  105825. declare module BABYLON {
  105826. /**
  105827. * Class containing static functions to help procedurally build meshes
  105828. */
  105829. export class DiscBuilder {
  105830. /**
  105831. * Creates a plane polygonal mesh. By default, this is a disc
  105832. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  105833. * * 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
  105834. * * 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
  105835. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105836. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105837. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105838. * @param name defines the name of the mesh
  105839. * @param options defines the options used to create the mesh
  105840. * @param scene defines the hosting scene
  105841. * @returns the plane polygonal mesh
  105842. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  105843. */
  105844. static CreateDisc(name: string, options: {
  105845. radius?: number;
  105846. tessellation?: number;
  105847. arc?: number;
  105848. updatable?: boolean;
  105849. sideOrientation?: number;
  105850. frontUVs?: Vector4;
  105851. backUVs?: Vector4;
  105852. }, scene?: Nullable<Scene>): Mesh;
  105853. }
  105854. }
  105855. declare module BABYLON {
  105856. /**
  105857. * Options to be used when creating a FresnelParameters.
  105858. */
  105859. export type IFresnelParametersCreationOptions = {
  105860. /**
  105861. * Define the color used on edges (grazing angle)
  105862. */
  105863. leftColor?: Color3;
  105864. /**
  105865. * Define the color used on center
  105866. */
  105867. rightColor?: Color3;
  105868. /**
  105869. * Define bias applied to computed fresnel term
  105870. */
  105871. bias?: number;
  105872. /**
  105873. * Defined the power exponent applied to fresnel term
  105874. */
  105875. power?: number;
  105876. /**
  105877. * Define if the fresnel effect is enable or not.
  105878. */
  105879. isEnabled?: boolean;
  105880. };
  105881. /**
  105882. * Serialized format for FresnelParameters.
  105883. */
  105884. export type IFresnelParametersSerialized = {
  105885. /**
  105886. * Define the color used on edges (grazing angle) [as an array]
  105887. */
  105888. leftColor: number[];
  105889. /**
  105890. * Define the color used on center [as an array]
  105891. */
  105892. rightColor: number[];
  105893. /**
  105894. * Define bias applied to computed fresnel term
  105895. */
  105896. bias: number;
  105897. /**
  105898. * Defined the power exponent applied to fresnel term
  105899. */
  105900. power?: number;
  105901. /**
  105902. * Define if the fresnel effect is enable or not.
  105903. */
  105904. isEnabled: boolean;
  105905. };
  105906. /**
  105907. * This represents all the required information to add a fresnel effect on a material:
  105908. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  105909. */
  105910. export class FresnelParameters {
  105911. private _isEnabled;
  105912. /**
  105913. * Define if the fresnel effect is enable or not.
  105914. */
  105915. get isEnabled(): boolean;
  105916. set isEnabled(value: boolean);
  105917. /**
  105918. * Define the color used on edges (grazing angle)
  105919. */
  105920. leftColor: Color3;
  105921. /**
  105922. * Define the color used on center
  105923. */
  105924. rightColor: Color3;
  105925. /**
  105926. * Define bias applied to computed fresnel term
  105927. */
  105928. bias: number;
  105929. /**
  105930. * Defined the power exponent applied to fresnel term
  105931. */
  105932. power: number;
  105933. /**
  105934. * Creates a new FresnelParameters object.
  105935. *
  105936. * @param options provide your own settings to optionally to override defaults
  105937. */
  105938. constructor(options?: IFresnelParametersCreationOptions);
  105939. /**
  105940. * Clones the current fresnel and its valuues
  105941. * @returns a clone fresnel configuration
  105942. */
  105943. clone(): FresnelParameters;
  105944. /**
  105945. * Determines equality between FresnelParameters objects
  105946. * @param otherFresnelParameters defines the second operand
  105947. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  105948. */
  105949. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  105950. /**
  105951. * Serializes the current fresnel parameters to a JSON representation.
  105952. * @return the JSON serialization
  105953. */
  105954. serialize(): IFresnelParametersSerialized;
  105955. /**
  105956. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  105957. * @param parsedFresnelParameters Define the JSON representation
  105958. * @returns the parsed parameters
  105959. */
  105960. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  105961. }
  105962. }
  105963. declare module BABYLON {
  105964. /**
  105965. * This groups all the flags used to control the materials channel.
  105966. */
  105967. export class MaterialFlags {
  105968. private static _DiffuseTextureEnabled;
  105969. /**
  105970. * Are diffuse textures enabled in the application.
  105971. */
  105972. static get DiffuseTextureEnabled(): boolean;
  105973. static set DiffuseTextureEnabled(value: boolean);
  105974. private static _AmbientTextureEnabled;
  105975. /**
  105976. * Are ambient textures enabled in the application.
  105977. */
  105978. static get AmbientTextureEnabled(): boolean;
  105979. static set AmbientTextureEnabled(value: boolean);
  105980. private static _OpacityTextureEnabled;
  105981. /**
  105982. * Are opacity textures enabled in the application.
  105983. */
  105984. static get OpacityTextureEnabled(): boolean;
  105985. static set OpacityTextureEnabled(value: boolean);
  105986. private static _ReflectionTextureEnabled;
  105987. /**
  105988. * Are reflection textures enabled in the application.
  105989. */
  105990. static get ReflectionTextureEnabled(): boolean;
  105991. static set ReflectionTextureEnabled(value: boolean);
  105992. private static _EmissiveTextureEnabled;
  105993. /**
  105994. * Are emissive textures enabled in the application.
  105995. */
  105996. static get EmissiveTextureEnabled(): boolean;
  105997. static set EmissiveTextureEnabled(value: boolean);
  105998. private static _SpecularTextureEnabled;
  105999. /**
  106000. * Are specular textures enabled in the application.
  106001. */
  106002. static get SpecularTextureEnabled(): boolean;
  106003. static set SpecularTextureEnabled(value: boolean);
  106004. private static _BumpTextureEnabled;
  106005. /**
  106006. * Are bump textures enabled in the application.
  106007. */
  106008. static get BumpTextureEnabled(): boolean;
  106009. static set BumpTextureEnabled(value: boolean);
  106010. private static _LightmapTextureEnabled;
  106011. /**
  106012. * Are lightmap textures enabled in the application.
  106013. */
  106014. static get LightmapTextureEnabled(): boolean;
  106015. static set LightmapTextureEnabled(value: boolean);
  106016. private static _RefractionTextureEnabled;
  106017. /**
  106018. * Are refraction textures enabled in the application.
  106019. */
  106020. static get RefractionTextureEnabled(): boolean;
  106021. static set RefractionTextureEnabled(value: boolean);
  106022. private static _ColorGradingTextureEnabled;
  106023. /**
  106024. * Are color grading textures enabled in the application.
  106025. */
  106026. static get ColorGradingTextureEnabled(): boolean;
  106027. static set ColorGradingTextureEnabled(value: boolean);
  106028. private static _FresnelEnabled;
  106029. /**
  106030. * Are fresnels enabled in the application.
  106031. */
  106032. static get FresnelEnabled(): boolean;
  106033. static set FresnelEnabled(value: boolean);
  106034. private static _ClearCoatTextureEnabled;
  106035. /**
  106036. * Are clear coat textures enabled in the application.
  106037. */
  106038. static get ClearCoatTextureEnabled(): boolean;
  106039. static set ClearCoatTextureEnabled(value: boolean);
  106040. private static _ClearCoatBumpTextureEnabled;
  106041. /**
  106042. * Are clear coat bump textures enabled in the application.
  106043. */
  106044. static get ClearCoatBumpTextureEnabled(): boolean;
  106045. static set ClearCoatBumpTextureEnabled(value: boolean);
  106046. private static _ClearCoatTintTextureEnabled;
  106047. /**
  106048. * Are clear coat tint textures enabled in the application.
  106049. */
  106050. static get ClearCoatTintTextureEnabled(): boolean;
  106051. static set ClearCoatTintTextureEnabled(value: boolean);
  106052. private static _SheenTextureEnabled;
  106053. /**
  106054. * Are sheen textures enabled in the application.
  106055. */
  106056. static get SheenTextureEnabled(): boolean;
  106057. static set SheenTextureEnabled(value: boolean);
  106058. private static _AnisotropicTextureEnabled;
  106059. /**
  106060. * Are anisotropic textures enabled in the application.
  106061. */
  106062. static get AnisotropicTextureEnabled(): boolean;
  106063. static set AnisotropicTextureEnabled(value: boolean);
  106064. private static _ThicknessTextureEnabled;
  106065. /**
  106066. * Are thickness textures enabled in the application.
  106067. */
  106068. static get ThicknessTextureEnabled(): boolean;
  106069. static set ThicknessTextureEnabled(value: boolean);
  106070. }
  106071. }
  106072. declare module BABYLON {
  106073. /** @hidden */
  106074. export var defaultFragmentDeclaration: {
  106075. name: string;
  106076. shader: string;
  106077. };
  106078. }
  106079. declare module BABYLON {
  106080. /** @hidden */
  106081. export var defaultUboDeclaration: {
  106082. name: string;
  106083. shader: string;
  106084. };
  106085. }
  106086. declare module BABYLON {
  106087. /** @hidden */
  106088. export var lightFragmentDeclaration: {
  106089. name: string;
  106090. shader: string;
  106091. };
  106092. }
  106093. declare module BABYLON {
  106094. /** @hidden */
  106095. export var lightUboDeclaration: {
  106096. name: string;
  106097. shader: string;
  106098. };
  106099. }
  106100. declare module BABYLON {
  106101. /** @hidden */
  106102. export var lightsFragmentFunctions: {
  106103. name: string;
  106104. shader: string;
  106105. };
  106106. }
  106107. declare module BABYLON {
  106108. /** @hidden */
  106109. export var shadowsFragmentFunctions: {
  106110. name: string;
  106111. shader: string;
  106112. };
  106113. }
  106114. declare module BABYLON {
  106115. /** @hidden */
  106116. export var fresnelFunction: {
  106117. name: string;
  106118. shader: string;
  106119. };
  106120. }
  106121. declare module BABYLON {
  106122. /** @hidden */
  106123. export var bumpFragmentMainFunctions: {
  106124. name: string;
  106125. shader: string;
  106126. };
  106127. }
  106128. declare module BABYLON {
  106129. /** @hidden */
  106130. export var bumpFragmentFunctions: {
  106131. name: string;
  106132. shader: string;
  106133. };
  106134. }
  106135. declare module BABYLON {
  106136. /** @hidden */
  106137. export var logDepthDeclaration: {
  106138. name: string;
  106139. shader: string;
  106140. };
  106141. }
  106142. declare module BABYLON {
  106143. /** @hidden */
  106144. export var bumpFragment: {
  106145. name: string;
  106146. shader: string;
  106147. };
  106148. }
  106149. declare module BABYLON {
  106150. /** @hidden */
  106151. export var depthPrePass: {
  106152. name: string;
  106153. shader: string;
  106154. };
  106155. }
  106156. declare module BABYLON {
  106157. /** @hidden */
  106158. export var lightFragment: {
  106159. name: string;
  106160. shader: string;
  106161. };
  106162. }
  106163. declare module BABYLON {
  106164. /** @hidden */
  106165. export var logDepthFragment: {
  106166. name: string;
  106167. shader: string;
  106168. };
  106169. }
  106170. declare module BABYLON {
  106171. /** @hidden */
  106172. export var defaultPixelShader: {
  106173. name: string;
  106174. shader: string;
  106175. };
  106176. }
  106177. declare module BABYLON {
  106178. /** @hidden */
  106179. export var defaultVertexDeclaration: {
  106180. name: string;
  106181. shader: string;
  106182. };
  106183. }
  106184. declare module BABYLON {
  106185. /** @hidden */
  106186. export var bumpVertexDeclaration: {
  106187. name: string;
  106188. shader: string;
  106189. };
  106190. }
  106191. declare module BABYLON {
  106192. /** @hidden */
  106193. export var bumpVertex: {
  106194. name: string;
  106195. shader: string;
  106196. };
  106197. }
  106198. declare module BABYLON {
  106199. /** @hidden */
  106200. export var fogVertex: {
  106201. name: string;
  106202. shader: string;
  106203. };
  106204. }
  106205. declare module BABYLON {
  106206. /** @hidden */
  106207. export var shadowsVertex: {
  106208. name: string;
  106209. shader: string;
  106210. };
  106211. }
  106212. declare module BABYLON {
  106213. /** @hidden */
  106214. export var pointCloudVertex: {
  106215. name: string;
  106216. shader: string;
  106217. };
  106218. }
  106219. declare module BABYLON {
  106220. /** @hidden */
  106221. export var logDepthVertex: {
  106222. name: string;
  106223. shader: string;
  106224. };
  106225. }
  106226. declare module BABYLON {
  106227. /** @hidden */
  106228. export var defaultVertexShader: {
  106229. name: string;
  106230. shader: string;
  106231. };
  106232. }
  106233. declare module BABYLON {
  106234. /** @hidden */
  106235. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  106236. MAINUV1: boolean;
  106237. MAINUV2: boolean;
  106238. DIFFUSE: boolean;
  106239. DIFFUSEDIRECTUV: number;
  106240. AMBIENT: boolean;
  106241. AMBIENTDIRECTUV: number;
  106242. OPACITY: boolean;
  106243. OPACITYDIRECTUV: number;
  106244. OPACITYRGB: boolean;
  106245. REFLECTION: boolean;
  106246. EMISSIVE: boolean;
  106247. EMISSIVEDIRECTUV: number;
  106248. SPECULAR: boolean;
  106249. SPECULARDIRECTUV: number;
  106250. BUMP: boolean;
  106251. BUMPDIRECTUV: number;
  106252. PARALLAX: boolean;
  106253. PARALLAXOCCLUSION: boolean;
  106254. SPECULAROVERALPHA: boolean;
  106255. CLIPPLANE: boolean;
  106256. CLIPPLANE2: boolean;
  106257. CLIPPLANE3: boolean;
  106258. CLIPPLANE4: boolean;
  106259. CLIPPLANE5: boolean;
  106260. CLIPPLANE6: boolean;
  106261. ALPHATEST: boolean;
  106262. DEPTHPREPASS: boolean;
  106263. ALPHAFROMDIFFUSE: boolean;
  106264. POINTSIZE: boolean;
  106265. FOG: boolean;
  106266. SPECULARTERM: boolean;
  106267. DIFFUSEFRESNEL: boolean;
  106268. OPACITYFRESNEL: boolean;
  106269. REFLECTIONFRESNEL: boolean;
  106270. REFRACTIONFRESNEL: boolean;
  106271. EMISSIVEFRESNEL: boolean;
  106272. FRESNEL: boolean;
  106273. NORMAL: boolean;
  106274. UV1: boolean;
  106275. UV2: boolean;
  106276. VERTEXCOLOR: boolean;
  106277. VERTEXALPHA: boolean;
  106278. NUM_BONE_INFLUENCERS: number;
  106279. BonesPerMesh: number;
  106280. BONETEXTURE: boolean;
  106281. INSTANCES: boolean;
  106282. GLOSSINESS: boolean;
  106283. ROUGHNESS: boolean;
  106284. EMISSIVEASILLUMINATION: boolean;
  106285. LINKEMISSIVEWITHDIFFUSE: boolean;
  106286. REFLECTIONFRESNELFROMSPECULAR: boolean;
  106287. LIGHTMAP: boolean;
  106288. LIGHTMAPDIRECTUV: number;
  106289. OBJECTSPACE_NORMALMAP: boolean;
  106290. USELIGHTMAPASSHADOWMAP: boolean;
  106291. REFLECTIONMAP_3D: boolean;
  106292. REFLECTIONMAP_SPHERICAL: boolean;
  106293. REFLECTIONMAP_PLANAR: boolean;
  106294. REFLECTIONMAP_CUBIC: boolean;
  106295. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  106296. REFLECTIONMAP_PROJECTION: boolean;
  106297. REFLECTIONMAP_SKYBOX: boolean;
  106298. REFLECTIONMAP_EXPLICIT: boolean;
  106299. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  106300. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  106301. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  106302. INVERTCUBICMAP: boolean;
  106303. LOGARITHMICDEPTH: boolean;
  106304. REFRACTION: boolean;
  106305. REFRACTIONMAP_3D: boolean;
  106306. REFLECTIONOVERALPHA: boolean;
  106307. TWOSIDEDLIGHTING: boolean;
  106308. SHADOWFLOAT: boolean;
  106309. MORPHTARGETS: boolean;
  106310. MORPHTARGETS_NORMAL: boolean;
  106311. MORPHTARGETS_TANGENT: boolean;
  106312. MORPHTARGETS_UV: boolean;
  106313. NUM_MORPH_INFLUENCERS: number;
  106314. NONUNIFORMSCALING: boolean;
  106315. PREMULTIPLYALPHA: boolean;
  106316. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  106317. ALPHABLEND: boolean;
  106318. RGBDLIGHTMAP: boolean;
  106319. RGBDREFLECTION: boolean;
  106320. RGBDREFRACTION: boolean;
  106321. IMAGEPROCESSING: boolean;
  106322. VIGNETTE: boolean;
  106323. VIGNETTEBLENDMODEMULTIPLY: boolean;
  106324. VIGNETTEBLENDMODEOPAQUE: boolean;
  106325. TONEMAPPING: boolean;
  106326. TONEMAPPING_ACES: boolean;
  106327. CONTRAST: boolean;
  106328. COLORCURVES: boolean;
  106329. COLORGRADING: boolean;
  106330. COLORGRADING3D: boolean;
  106331. SAMPLER3DGREENDEPTH: boolean;
  106332. SAMPLER3DBGRMAP: boolean;
  106333. IMAGEPROCESSINGPOSTPROCESS: boolean;
  106334. MULTIVIEW: boolean;
  106335. /**
  106336. * If the reflection texture on this material is in linear color space
  106337. * @hidden
  106338. */
  106339. IS_REFLECTION_LINEAR: boolean;
  106340. /**
  106341. * If the refraction texture on this material is in linear color space
  106342. * @hidden
  106343. */
  106344. IS_REFRACTION_LINEAR: boolean;
  106345. EXPOSURE: boolean;
  106346. constructor();
  106347. setReflectionMode(modeToEnable: string): void;
  106348. }
  106349. /**
  106350. * This is the default material used in Babylon. It is the best trade off between quality
  106351. * and performances.
  106352. * @see http://doc.babylonjs.com/babylon101/materials
  106353. */
  106354. export class StandardMaterial extends PushMaterial {
  106355. private _diffuseTexture;
  106356. /**
  106357. * The basic texture of the material as viewed under a light.
  106358. */
  106359. diffuseTexture: Nullable<BaseTexture>;
  106360. private _ambientTexture;
  106361. /**
  106362. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  106363. */
  106364. ambientTexture: Nullable<BaseTexture>;
  106365. private _opacityTexture;
  106366. /**
  106367. * Define the transparency of the material from a texture.
  106368. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  106369. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  106370. */
  106371. opacityTexture: Nullable<BaseTexture>;
  106372. private _reflectionTexture;
  106373. /**
  106374. * Define the texture used to display the reflection.
  106375. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  106376. */
  106377. reflectionTexture: Nullable<BaseTexture>;
  106378. private _emissiveTexture;
  106379. /**
  106380. * Define texture of the material as if self lit.
  106381. * This will be mixed in the final result even in the absence of light.
  106382. */
  106383. emissiveTexture: Nullable<BaseTexture>;
  106384. private _specularTexture;
  106385. /**
  106386. * Define how the color and intensity of the highlight given by the light in the material.
  106387. */
  106388. specularTexture: Nullable<BaseTexture>;
  106389. private _bumpTexture;
  106390. /**
  106391. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  106392. * 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.
  106393. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  106394. */
  106395. bumpTexture: Nullable<BaseTexture>;
  106396. private _lightmapTexture;
  106397. /**
  106398. * Complex lighting can be computationally expensive to compute at runtime.
  106399. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  106400. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  106401. */
  106402. lightmapTexture: Nullable<BaseTexture>;
  106403. private _refractionTexture;
  106404. /**
  106405. * Define the texture used to display the refraction.
  106406. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  106407. */
  106408. refractionTexture: Nullable<BaseTexture>;
  106409. /**
  106410. * The color of the material lit by the environmental background lighting.
  106411. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  106412. */
  106413. ambientColor: Color3;
  106414. /**
  106415. * The basic color of the material as viewed under a light.
  106416. */
  106417. diffuseColor: Color3;
  106418. /**
  106419. * Define how the color and intensity of the highlight given by the light in the material.
  106420. */
  106421. specularColor: Color3;
  106422. /**
  106423. * Define the color of the material as if self lit.
  106424. * This will be mixed in the final result even in the absence of light.
  106425. */
  106426. emissiveColor: Color3;
  106427. /**
  106428. * Defines how sharp are the highlights in the material.
  106429. * The bigger the value the sharper giving a more glossy feeling to the result.
  106430. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  106431. */
  106432. specularPower: number;
  106433. private _useAlphaFromDiffuseTexture;
  106434. /**
  106435. * Does the transparency come from the diffuse texture alpha channel.
  106436. */
  106437. useAlphaFromDiffuseTexture: boolean;
  106438. private _useEmissiveAsIllumination;
  106439. /**
  106440. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  106441. */
  106442. useEmissiveAsIllumination: boolean;
  106443. private _linkEmissiveWithDiffuse;
  106444. /**
  106445. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  106446. * the emissive level when the final color is close to one.
  106447. */
  106448. linkEmissiveWithDiffuse: boolean;
  106449. private _useSpecularOverAlpha;
  106450. /**
  106451. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  106452. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  106453. */
  106454. useSpecularOverAlpha: boolean;
  106455. private _useReflectionOverAlpha;
  106456. /**
  106457. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  106458. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  106459. */
  106460. useReflectionOverAlpha: boolean;
  106461. private _disableLighting;
  106462. /**
  106463. * Does lights from the scene impacts this material.
  106464. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  106465. */
  106466. disableLighting: boolean;
  106467. private _useObjectSpaceNormalMap;
  106468. /**
  106469. * Allows using an object space normal map (instead of tangent space).
  106470. */
  106471. useObjectSpaceNormalMap: boolean;
  106472. private _useParallax;
  106473. /**
  106474. * Is parallax enabled or not.
  106475. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  106476. */
  106477. useParallax: boolean;
  106478. private _useParallaxOcclusion;
  106479. /**
  106480. * Is parallax occlusion enabled or not.
  106481. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  106482. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  106483. */
  106484. useParallaxOcclusion: boolean;
  106485. /**
  106486. * 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.
  106487. */
  106488. parallaxScaleBias: number;
  106489. private _roughness;
  106490. /**
  106491. * Helps to define how blurry the reflections should appears in the material.
  106492. */
  106493. roughness: number;
  106494. /**
  106495. * In case of refraction, define the value of the index of refraction.
  106496. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  106497. */
  106498. indexOfRefraction: number;
  106499. /**
  106500. * Invert the refraction texture alongside the y axis.
  106501. * It can be useful with procedural textures or probe for instance.
  106502. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  106503. */
  106504. invertRefractionY: boolean;
  106505. /**
  106506. * Defines the alpha limits in alpha test mode.
  106507. */
  106508. alphaCutOff: number;
  106509. private _useLightmapAsShadowmap;
  106510. /**
  106511. * In case of light mapping, define whether the map contains light or shadow informations.
  106512. */
  106513. useLightmapAsShadowmap: boolean;
  106514. private _diffuseFresnelParameters;
  106515. /**
  106516. * Define the diffuse fresnel parameters of the material.
  106517. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  106518. */
  106519. diffuseFresnelParameters: FresnelParameters;
  106520. private _opacityFresnelParameters;
  106521. /**
  106522. * Define the opacity fresnel parameters of the material.
  106523. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  106524. */
  106525. opacityFresnelParameters: FresnelParameters;
  106526. private _reflectionFresnelParameters;
  106527. /**
  106528. * Define the reflection fresnel parameters of the material.
  106529. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  106530. */
  106531. reflectionFresnelParameters: FresnelParameters;
  106532. private _refractionFresnelParameters;
  106533. /**
  106534. * Define the refraction fresnel parameters of the material.
  106535. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  106536. */
  106537. refractionFresnelParameters: FresnelParameters;
  106538. private _emissiveFresnelParameters;
  106539. /**
  106540. * Define the emissive fresnel parameters of the material.
  106541. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  106542. */
  106543. emissiveFresnelParameters: FresnelParameters;
  106544. private _useReflectionFresnelFromSpecular;
  106545. /**
  106546. * If true automatically deducts the fresnels values from the material specularity.
  106547. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  106548. */
  106549. useReflectionFresnelFromSpecular: boolean;
  106550. private _useGlossinessFromSpecularMapAlpha;
  106551. /**
  106552. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  106553. */
  106554. useGlossinessFromSpecularMapAlpha: boolean;
  106555. private _maxSimultaneousLights;
  106556. /**
  106557. * Defines the maximum number of lights that can be used in the material
  106558. */
  106559. maxSimultaneousLights: number;
  106560. private _invertNormalMapX;
  106561. /**
  106562. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  106563. */
  106564. invertNormalMapX: boolean;
  106565. private _invertNormalMapY;
  106566. /**
  106567. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  106568. */
  106569. invertNormalMapY: boolean;
  106570. private _twoSidedLighting;
  106571. /**
  106572. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  106573. */
  106574. twoSidedLighting: boolean;
  106575. /**
  106576. * Default configuration related to image processing available in the standard Material.
  106577. */
  106578. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  106579. /**
  106580. * Gets the image processing configuration used either in this material.
  106581. */
  106582. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  106583. /**
  106584. * Sets the Default image processing configuration used either in the this material.
  106585. *
  106586. * If sets to null, the scene one is in use.
  106587. */
  106588. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  106589. /**
  106590. * Keep track of the image processing observer to allow dispose and replace.
  106591. */
  106592. private _imageProcessingObserver;
  106593. /**
  106594. * Attaches a new image processing configuration to the Standard Material.
  106595. * @param configuration
  106596. */
  106597. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  106598. /**
  106599. * Gets wether the color curves effect is enabled.
  106600. */
  106601. get cameraColorCurvesEnabled(): boolean;
  106602. /**
  106603. * Sets wether the color curves effect is enabled.
  106604. */
  106605. set cameraColorCurvesEnabled(value: boolean);
  106606. /**
  106607. * Gets wether the color grading effect is enabled.
  106608. */
  106609. get cameraColorGradingEnabled(): boolean;
  106610. /**
  106611. * Gets wether the color grading effect is enabled.
  106612. */
  106613. set cameraColorGradingEnabled(value: boolean);
  106614. /**
  106615. * Gets wether tonemapping is enabled or not.
  106616. */
  106617. get cameraToneMappingEnabled(): boolean;
  106618. /**
  106619. * Sets wether tonemapping is enabled or not
  106620. */
  106621. set cameraToneMappingEnabled(value: boolean);
  106622. /**
  106623. * The camera exposure used on this material.
  106624. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  106625. * This corresponds to a photographic exposure.
  106626. */
  106627. get cameraExposure(): number;
  106628. /**
  106629. * The camera exposure used on this material.
  106630. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  106631. * This corresponds to a photographic exposure.
  106632. */
  106633. set cameraExposure(value: number);
  106634. /**
  106635. * Gets The camera contrast used on this material.
  106636. */
  106637. get cameraContrast(): number;
  106638. /**
  106639. * Sets The camera contrast used on this material.
  106640. */
  106641. set cameraContrast(value: number);
  106642. /**
  106643. * Gets the Color Grading 2D Lookup Texture.
  106644. */
  106645. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  106646. /**
  106647. * Sets the Color Grading 2D Lookup Texture.
  106648. */
  106649. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  106650. /**
  106651. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  106652. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  106653. * 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;
  106654. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  106655. */
  106656. get cameraColorCurves(): Nullable<ColorCurves>;
  106657. /**
  106658. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  106659. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  106660. * 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;
  106661. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  106662. */
  106663. set cameraColorCurves(value: Nullable<ColorCurves>);
  106664. protected _renderTargets: SmartArray<RenderTargetTexture>;
  106665. protected _worldViewProjectionMatrix: Matrix;
  106666. protected _globalAmbientColor: Color3;
  106667. protected _useLogarithmicDepth: boolean;
  106668. protected _rebuildInParallel: boolean;
  106669. /**
  106670. * Instantiates a new standard material.
  106671. * This is the default material used in Babylon. It is the best trade off between quality
  106672. * and performances.
  106673. * @see http://doc.babylonjs.com/babylon101/materials
  106674. * @param name Define the name of the material in the scene
  106675. * @param scene Define the scene the material belong to
  106676. */
  106677. constructor(name: string, scene: Scene);
  106678. /**
  106679. * Gets a boolean indicating that current material needs to register RTT
  106680. */
  106681. get hasRenderTargetTextures(): boolean;
  106682. /**
  106683. * Gets the current class name of the material e.g. "StandardMaterial"
  106684. * Mainly use in serialization.
  106685. * @returns the class name
  106686. */
  106687. getClassName(): string;
  106688. /**
  106689. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  106690. * You can try switching to logarithmic depth.
  106691. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  106692. */
  106693. get useLogarithmicDepth(): boolean;
  106694. set useLogarithmicDepth(value: boolean);
  106695. /**
  106696. * Specifies if the material will require alpha blending
  106697. * @returns a boolean specifying if alpha blending is needed
  106698. */
  106699. needAlphaBlending(): boolean;
  106700. /**
  106701. * Specifies if this material should be rendered in alpha test mode
  106702. * @returns a boolean specifying if an alpha test is needed.
  106703. */
  106704. needAlphaTesting(): boolean;
  106705. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  106706. /**
  106707. * Get the texture used for alpha test purpose.
  106708. * @returns the diffuse texture in case of the standard material.
  106709. */
  106710. getAlphaTestTexture(): Nullable<BaseTexture>;
  106711. /**
  106712. * Get if the submesh is ready to be used and all its information available.
  106713. * Child classes can use it to update shaders
  106714. * @param mesh defines the mesh to check
  106715. * @param subMesh defines which submesh to check
  106716. * @param useInstances specifies that instances should be used
  106717. * @returns a boolean indicating that the submesh is ready or not
  106718. */
  106719. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  106720. /**
  106721. * Builds the material UBO layouts.
  106722. * Used internally during the effect preparation.
  106723. */
  106724. buildUniformLayout(): void;
  106725. /**
  106726. * Unbinds the material from the mesh
  106727. */
  106728. unbind(): void;
  106729. /**
  106730. * Binds the submesh to this material by preparing the effect and shader to draw
  106731. * @param world defines the world transformation matrix
  106732. * @param mesh defines the mesh containing the submesh
  106733. * @param subMesh defines the submesh to bind the material to
  106734. */
  106735. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  106736. /**
  106737. * Get the list of animatables in the material.
  106738. * @returns the list of animatables object used in the material
  106739. */
  106740. getAnimatables(): IAnimatable[];
  106741. /**
  106742. * Gets the active textures from the material
  106743. * @returns an array of textures
  106744. */
  106745. getActiveTextures(): BaseTexture[];
  106746. /**
  106747. * Specifies if the material uses a texture
  106748. * @param texture defines the texture to check against the material
  106749. * @returns a boolean specifying if the material uses the texture
  106750. */
  106751. hasTexture(texture: BaseTexture): boolean;
  106752. /**
  106753. * Disposes the material
  106754. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  106755. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  106756. */
  106757. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  106758. /**
  106759. * Makes a duplicate of the material, and gives it a new name
  106760. * @param name defines the new name for the duplicated material
  106761. * @returns the cloned material
  106762. */
  106763. clone(name: string): StandardMaterial;
  106764. /**
  106765. * Serializes this material in a JSON representation
  106766. * @returns the serialized material object
  106767. */
  106768. serialize(): any;
  106769. /**
  106770. * Creates a standard material from parsed material data
  106771. * @param source defines the JSON representation of the material
  106772. * @param scene defines the hosting scene
  106773. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  106774. * @returns a new standard material
  106775. */
  106776. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  106777. /**
  106778. * Are diffuse textures enabled in the application.
  106779. */
  106780. static get DiffuseTextureEnabled(): boolean;
  106781. static set DiffuseTextureEnabled(value: boolean);
  106782. /**
  106783. * Are ambient textures enabled in the application.
  106784. */
  106785. static get AmbientTextureEnabled(): boolean;
  106786. static set AmbientTextureEnabled(value: boolean);
  106787. /**
  106788. * Are opacity textures enabled in the application.
  106789. */
  106790. static get OpacityTextureEnabled(): boolean;
  106791. static set OpacityTextureEnabled(value: boolean);
  106792. /**
  106793. * Are reflection textures enabled in the application.
  106794. */
  106795. static get ReflectionTextureEnabled(): boolean;
  106796. static set ReflectionTextureEnabled(value: boolean);
  106797. /**
  106798. * Are emissive textures enabled in the application.
  106799. */
  106800. static get EmissiveTextureEnabled(): boolean;
  106801. static set EmissiveTextureEnabled(value: boolean);
  106802. /**
  106803. * Are specular textures enabled in the application.
  106804. */
  106805. static get SpecularTextureEnabled(): boolean;
  106806. static set SpecularTextureEnabled(value: boolean);
  106807. /**
  106808. * Are bump textures enabled in the application.
  106809. */
  106810. static get BumpTextureEnabled(): boolean;
  106811. static set BumpTextureEnabled(value: boolean);
  106812. /**
  106813. * Are lightmap textures enabled in the application.
  106814. */
  106815. static get LightmapTextureEnabled(): boolean;
  106816. static set LightmapTextureEnabled(value: boolean);
  106817. /**
  106818. * Are refraction textures enabled in the application.
  106819. */
  106820. static get RefractionTextureEnabled(): boolean;
  106821. static set RefractionTextureEnabled(value: boolean);
  106822. /**
  106823. * Are color grading textures enabled in the application.
  106824. */
  106825. static get ColorGradingTextureEnabled(): boolean;
  106826. static set ColorGradingTextureEnabled(value: boolean);
  106827. /**
  106828. * Are fresnels enabled in the application.
  106829. */
  106830. static get FresnelEnabled(): boolean;
  106831. static set FresnelEnabled(value: boolean);
  106832. }
  106833. }
  106834. declare module BABYLON {
  106835. /**
  106836. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  106837. *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.
  106838. * The SPS is also a particle system. It provides some methods to manage the particles.
  106839. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  106840. *
  106841. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  106842. */
  106843. export class SolidParticleSystem implements IDisposable {
  106844. /**
  106845. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  106846. * Example : var p = SPS.particles[i];
  106847. */
  106848. particles: SolidParticle[];
  106849. /**
  106850. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  106851. */
  106852. nbParticles: number;
  106853. /**
  106854. * If the particles must ever face the camera (default false). Useful for planar particles.
  106855. */
  106856. billboard: boolean;
  106857. /**
  106858. * Recompute normals when adding a shape
  106859. */
  106860. recomputeNormals: boolean;
  106861. /**
  106862. * This a counter ofr your own usage. It's not set by any SPS functions.
  106863. */
  106864. counter: number;
  106865. /**
  106866. * The SPS name. This name is also given to the underlying mesh.
  106867. */
  106868. name: string;
  106869. /**
  106870. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  106871. */
  106872. mesh: Mesh;
  106873. /**
  106874. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  106875. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  106876. */
  106877. vars: any;
  106878. /**
  106879. * This array is populated when the SPS is set as 'pickable'.
  106880. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  106881. * Each element of this array is an object `{idx: int, faceId: int}`.
  106882. * `idx` is the picked particle index in the `SPS.particles` array
  106883. * `faceId` is the picked face index counted within this particle.
  106884. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  106885. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  106886. * Use the method SPS.pickedParticle(pickingInfo) instead.
  106887. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  106888. */
  106889. pickedParticles: {
  106890. idx: number;
  106891. faceId: number;
  106892. }[];
  106893. /**
  106894. * This array is populated when the SPS is set as 'pickable'
  106895. * Each key of this array is a submesh index.
  106896. * Each element of this array is a second array defined like this :
  106897. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  106898. * Each element of this second array is an object `{idx: int, faceId: int}`.
  106899. * `idx` is the picked particle index in the `SPS.particles` array
  106900. * `faceId` is the picked face index counted within this particle.
  106901. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  106902. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  106903. */
  106904. pickedBySubMesh: {
  106905. idx: number;
  106906. faceId: number;
  106907. }[][];
  106908. /**
  106909. * This array is populated when `enableDepthSort` is set to true.
  106910. * Each element of this array is an instance of the class DepthSortedParticle.
  106911. */
  106912. depthSortedParticles: DepthSortedParticle[];
  106913. /**
  106914. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  106915. * @hidden
  106916. */
  106917. _bSphereOnly: boolean;
  106918. /**
  106919. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  106920. * @hidden
  106921. */
  106922. _bSphereRadiusFactor: number;
  106923. private _scene;
  106924. private _positions;
  106925. private _indices;
  106926. private _normals;
  106927. private _colors;
  106928. private _uvs;
  106929. private _indices32;
  106930. private _positions32;
  106931. private _normals32;
  106932. private _fixedNormal32;
  106933. private _colors32;
  106934. private _uvs32;
  106935. private _index;
  106936. private _updatable;
  106937. private _pickable;
  106938. private _isVisibilityBoxLocked;
  106939. private _alwaysVisible;
  106940. private _depthSort;
  106941. private _expandable;
  106942. private _shapeCounter;
  106943. private _copy;
  106944. private _color;
  106945. private _computeParticleColor;
  106946. private _computeParticleTexture;
  106947. private _computeParticleRotation;
  106948. private _computeParticleVertex;
  106949. private _computeBoundingBox;
  106950. private _depthSortParticles;
  106951. private _camera;
  106952. private _mustUnrotateFixedNormals;
  106953. private _particlesIntersect;
  106954. private _needs32Bits;
  106955. private _isNotBuilt;
  106956. private _lastParticleId;
  106957. private _idxOfId;
  106958. private _multimaterialEnabled;
  106959. private _useModelMaterial;
  106960. private _indicesByMaterial;
  106961. private _materialIndexes;
  106962. private _depthSortFunction;
  106963. private _materialSortFunction;
  106964. private _materials;
  106965. private _multimaterial;
  106966. private _materialIndexesById;
  106967. private _defaultMaterial;
  106968. private _autoUpdateSubMeshes;
  106969. private _tmpVertex;
  106970. /**
  106971. * Creates a SPS (Solid Particle System) object.
  106972. * @param name (String) is the SPS name, this will be the underlying mesh name.
  106973. * @param scene (Scene) is the scene in which the SPS is added.
  106974. * @param options defines the options of the sps e.g.
  106975. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  106976. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  106977. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  106978. * * 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.
  106979. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  106980. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  106981. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  106982. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  106983. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  106984. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  106985. */
  106986. constructor(name: string, scene: Scene, options?: {
  106987. updatable?: boolean;
  106988. isPickable?: boolean;
  106989. enableDepthSort?: boolean;
  106990. particleIntersection?: boolean;
  106991. boundingSphereOnly?: boolean;
  106992. bSphereRadiusFactor?: number;
  106993. expandable?: boolean;
  106994. useModelMaterial?: boolean;
  106995. enableMultiMaterial?: boolean;
  106996. });
  106997. /**
  106998. * Builds the SPS underlying mesh. Returns a standard Mesh.
  106999. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  107000. * @returns the created mesh
  107001. */
  107002. buildMesh(): Mesh;
  107003. /**
  107004. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  107005. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  107006. * Thus the particles generated from `digest()` have their property `position` set yet.
  107007. * @param mesh ( Mesh ) is the mesh to be digested
  107008. * @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
  107009. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  107010. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  107011. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  107012. * @returns the current SPS
  107013. */
  107014. digest(mesh: Mesh, options?: {
  107015. facetNb?: number;
  107016. number?: number;
  107017. delta?: number;
  107018. storage?: [];
  107019. }): SolidParticleSystem;
  107020. /**
  107021. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  107022. * @hidden
  107023. */
  107024. private _unrotateFixedNormals;
  107025. /**
  107026. * Resets the temporary working copy particle
  107027. * @hidden
  107028. */
  107029. private _resetCopy;
  107030. /**
  107031. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  107032. * @param p the current index in the positions array to be updated
  107033. * @param ind the current index in the indices array
  107034. * @param shape a Vector3 array, the shape geometry
  107035. * @param positions the positions array to be updated
  107036. * @param meshInd the shape indices array
  107037. * @param indices the indices array to be updated
  107038. * @param meshUV the shape uv array
  107039. * @param uvs the uv array to be updated
  107040. * @param meshCol the shape color array
  107041. * @param colors the color array to be updated
  107042. * @param meshNor the shape normals array
  107043. * @param normals the normals array to be updated
  107044. * @param idx the particle index
  107045. * @param idxInShape the particle index in its shape
  107046. * @param options the addShape() method passed options
  107047. * @model the particle model
  107048. * @hidden
  107049. */
  107050. private _meshBuilder;
  107051. /**
  107052. * Returns a shape Vector3 array from positions float array
  107053. * @param positions float array
  107054. * @returns a vector3 array
  107055. * @hidden
  107056. */
  107057. private _posToShape;
  107058. /**
  107059. * Returns a shapeUV array from a float uvs (array deep copy)
  107060. * @param uvs as a float array
  107061. * @returns a shapeUV array
  107062. * @hidden
  107063. */
  107064. private _uvsToShapeUV;
  107065. /**
  107066. * Adds a new particle object in the particles array
  107067. * @param idx particle index in particles array
  107068. * @param id particle id
  107069. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  107070. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  107071. * @param model particle ModelShape object
  107072. * @param shapeId model shape identifier
  107073. * @param idxInShape index of the particle in the current model
  107074. * @param bInfo model bounding info object
  107075. * @param storage target storage array, if any
  107076. * @hidden
  107077. */
  107078. private _addParticle;
  107079. /**
  107080. * Adds some particles to the SPS from the model shape. Returns the shape id.
  107081. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  107082. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  107083. * @param nb (positive integer) the number of particles to be created from this model
  107084. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  107085. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  107086. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  107087. * @returns the number of shapes in the system
  107088. */
  107089. addShape(mesh: Mesh, nb: number, options?: {
  107090. positionFunction?: any;
  107091. vertexFunction?: any;
  107092. storage?: [];
  107093. }): number;
  107094. /**
  107095. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  107096. * @hidden
  107097. */
  107098. private _rebuildParticle;
  107099. /**
  107100. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  107101. * @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.
  107102. * @returns the SPS.
  107103. */
  107104. rebuildMesh(reset?: boolean): SolidParticleSystem;
  107105. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  107106. * Returns an array with the removed particles.
  107107. * 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.
  107108. * The SPS can't be empty so at least one particle needs to remain in place.
  107109. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  107110. * @param start index of the first particle to remove
  107111. * @param end index of the last particle to remove (included)
  107112. * @returns an array populated with the removed particles
  107113. */
  107114. removeParticles(start: number, end: number): SolidParticle[];
  107115. /**
  107116. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  107117. * @param solidParticleArray an array populated with Solid Particles objects
  107118. * @returns the SPS
  107119. */
  107120. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  107121. /**
  107122. * Creates a new particle and modifies the SPS mesh geometry :
  107123. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  107124. * - calls _addParticle() to populate the particle array
  107125. * factorized code from addShape() and insertParticlesFromArray()
  107126. * @param idx particle index in the particles array
  107127. * @param i particle index in its shape
  107128. * @param modelShape particle ModelShape object
  107129. * @param shape shape vertex array
  107130. * @param meshInd shape indices array
  107131. * @param meshUV shape uv array
  107132. * @param meshCol shape color array
  107133. * @param meshNor shape normals array
  107134. * @param bbInfo shape bounding info
  107135. * @param storage target particle storage
  107136. * @options addShape() passed options
  107137. * @hidden
  107138. */
  107139. private _insertNewParticle;
  107140. /**
  107141. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  107142. * This method calls `updateParticle()` for each particle of the SPS.
  107143. * For an animated SPS, it is usually called within the render loop.
  107144. * 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.
  107145. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  107146. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  107147. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  107148. * @returns the SPS.
  107149. */
  107150. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  107151. /**
  107152. * Disposes the SPS.
  107153. */
  107154. dispose(): void;
  107155. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  107156. * idx is the particle index in the SPS
  107157. * faceId is the picked face index counted within this particle.
  107158. * Returns null if the pickInfo can't identify a picked particle.
  107159. * @param pickingInfo (PickingInfo object)
  107160. * @returns {idx: number, faceId: number} or null
  107161. */
  107162. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  107163. idx: number;
  107164. faceId: number;
  107165. }>;
  107166. /**
  107167. * Returns a SolidParticle object from its identifier : particle.id
  107168. * @param id (integer) the particle Id
  107169. * @returns the searched particle or null if not found in the SPS.
  107170. */
  107171. getParticleById(id: number): Nullable<SolidParticle>;
  107172. /**
  107173. * Returns a new array populated with the particles having the passed shapeId.
  107174. * @param shapeId (integer) the shape identifier
  107175. * @returns a new solid particle array
  107176. */
  107177. getParticlesByShapeId(shapeId: number): SolidParticle[];
  107178. /**
  107179. * Populates the passed array "ref" with the particles having the passed shapeId.
  107180. * @param shapeId the shape identifier
  107181. * @returns the SPS
  107182. * @param ref
  107183. */
  107184. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  107185. /**
  107186. * Computes the required SubMeshes according the materials assigned to the particles.
  107187. * @returns the solid particle system.
  107188. * Does nothing if called before the SPS mesh is built.
  107189. */
  107190. computeSubMeshes(): SolidParticleSystem;
  107191. /**
  107192. * Sorts the solid particles by material when MultiMaterial is enabled.
  107193. * Updates the indices32 array.
  107194. * Updates the indicesByMaterial array.
  107195. * Updates the mesh indices array.
  107196. * @returns the SPS
  107197. * @hidden
  107198. */
  107199. private _sortParticlesByMaterial;
  107200. /**
  107201. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  107202. * @hidden
  107203. */
  107204. private _setMaterialIndexesById;
  107205. /**
  107206. * Returns an array with unique values of Materials from the passed array
  107207. * @param array the material array to be checked and filtered
  107208. * @hidden
  107209. */
  107210. private _filterUniqueMaterialId;
  107211. /**
  107212. * Sets a new Standard Material as _defaultMaterial if not already set.
  107213. * @hidden
  107214. */
  107215. private _setDefaultMaterial;
  107216. /**
  107217. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  107218. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  107219. * @returns the SPS.
  107220. */
  107221. refreshVisibleSize(): SolidParticleSystem;
  107222. /**
  107223. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  107224. * @param size the size (float) of the visibility box
  107225. * note : this doesn't lock the SPS mesh bounding box.
  107226. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  107227. */
  107228. setVisibilityBox(size: number): void;
  107229. /**
  107230. * Gets whether the SPS as always visible or not
  107231. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  107232. */
  107233. get isAlwaysVisible(): boolean;
  107234. /**
  107235. * Sets the SPS as always visible or not
  107236. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  107237. */
  107238. set isAlwaysVisible(val: boolean);
  107239. /**
  107240. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  107241. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  107242. */
  107243. set isVisibilityBoxLocked(val: boolean);
  107244. /**
  107245. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  107246. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  107247. */
  107248. get isVisibilityBoxLocked(): boolean;
  107249. /**
  107250. * Tells to `setParticles()` to compute the particle rotations or not.
  107251. * Default value : true. The SPS is faster when it's set to false.
  107252. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  107253. */
  107254. set computeParticleRotation(val: boolean);
  107255. /**
  107256. * Tells to `setParticles()` to compute the particle colors or not.
  107257. * Default value : true. The SPS is faster when it's set to false.
  107258. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  107259. */
  107260. set computeParticleColor(val: boolean);
  107261. set computeParticleTexture(val: boolean);
  107262. /**
  107263. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  107264. * Default value : false. The SPS is faster when it's set to false.
  107265. * Note : the particle custom vertex positions aren't stored values.
  107266. */
  107267. set computeParticleVertex(val: boolean);
  107268. /**
  107269. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  107270. */
  107271. set computeBoundingBox(val: boolean);
  107272. /**
  107273. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  107274. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  107275. * Default : `true`
  107276. */
  107277. set depthSortParticles(val: boolean);
  107278. /**
  107279. * Gets if `setParticles()` computes the particle rotations or not.
  107280. * Default value : true. The SPS is faster when it's set to false.
  107281. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  107282. */
  107283. get computeParticleRotation(): boolean;
  107284. /**
  107285. * Gets if `setParticles()` computes the particle colors or not.
  107286. * Default value : true. The SPS is faster when it's set to false.
  107287. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  107288. */
  107289. get computeParticleColor(): boolean;
  107290. /**
  107291. * Gets if `setParticles()` computes the particle textures or not.
  107292. * Default value : true. The SPS is faster when it's set to false.
  107293. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  107294. */
  107295. get computeParticleTexture(): boolean;
  107296. /**
  107297. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  107298. * Default value : false. The SPS is faster when it's set to false.
  107299. * Note : the particle custom vertex positions aren't stored values.
  107300. */
  107301. get computeParticleVertex(): boolean;
  107302. /**
  107303. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  107304. */
  107305. get computeBoundingBox(): boolean;
  107306. /**
  107307. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  107308. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  107309. * Default : `true`
  107310. */
  107311. get depthSortParticles(): boolean;
  107312. /**
  107313. * Gets if the SPS is created as expandable at construction time.
  107314. * Default : `false`
  107315. */
  107316. get expandable(): boolean;
  107317. /**
  107318. * Gets if the SPS supports the Multi Materials
  107319. */
  107320. get multimaterialEnabled(): boolean;
  107321. /**
  107322. * Gets if the SPS uses the model materials for its own multimaterial.
  107323. */
  107324. get useModelMaterial(): boolean;
  107325. /**
  107326. * The SPS used material array.
  107327. */
  107328. get materials(): Material[];
  107329. /**
  107330. * Sets the SPS MultiMaterial from the passed materials.
  107331. * Note : the passed array is internally copied and not used then by reference.
  107332. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  107333. */
  107334. setMultiMaterial(materials: Material[]): void;
  107335. /**
  107336. * The SPS computed multimaterial object
  107337. */
  107338. get multimaterial(): MultiMaterial;
  107339. set multimaterial(mm: MultiMaterial);
  107340. /**
  107341. * If the subMeshes must be updated on the next call to setParticles()
  107342. */
  107343. get autoUpdateSubMeshes(): boolean;
  107344. set autoUpdateSubMeshes(val: boolean);
  107345. /**
  107346. * This function does nothing. It may be overwritten to set all the particle first values.
  107347. * The SPS doesn't call this function, you may have to call it by your own.
  107348. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  107349. */
  107350. initParticles(): void;
  107351. /**
  107352. * This function does nothing. It may be overwritten to recycle a particle.
  107353. * The SPS doesn't call this function, you may have to call it by your own.
  107354. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  107355. * @param particle The particle to recycle
  107356. * @returns the recycled particle
  107357. */
  107358. recycleParticle(particle: SolidParticle): SolidParticle;
  107359. /**
  107360. * Updates a particle : this function should be overwritten by the user.
  107361. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  107362. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  107363. * @example : just set a particle position or velocity and recycle conditions
  107364. * @param particle The particle to update
  107365. * @returns the updated particle
  107366. */
  107367. updateParticle(particle: SolidParticle): SolidParticle;
  107368. /**
  107369. * Updates a vertex of a particle : it can be overwritten by the user.
  107370. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  107371. * @param particle the current particle
  107372. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  107373. * @param pt the index of the current vertex in the particle shape
  107374. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  107375. * @example : just set a vertex particle position or color
  107376. * @returns the sps
  107377. */
  107378. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  107379. /**
  107380. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  107381. * This does nothing and may be overwritten by the user.
  107382. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  107383. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  107384. * @param update the boolean update value actually passed to setParticles()
  107385. */
  107386. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  107387. /**
  107388. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  107389. * This will be passed three parameters.
  107390. * This does nothing and may be overwritten by the user.
  107391. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  107392. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  107393. * @param update the boolean update value actually passed to setParticles()
  107394. */
  107395. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  107396. }
  107397. }
  107398. declare module BABYLON {
  107399. /**
  107400. * Represents one particle of a solid particle system.
  107401. */
  107402. export class SolidParticle {
  107403. /**
  107404. * particle global index
  107405. */
  107406. idx: number;
  107407. /**
  107408. * particle identifier
  107409. */
  107410. id: number;
  107411. /**
  107412. * The color of the particle
  107413. */
  107414. color: Nullable<Color4>;
  107415. /**
  107416. * The world space position of the particle.
  107417. */
  107418. position: Vector3;
  107419. /**
  107420. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  107421. */
  107422. rotation: Vector3;
  107423. /**
  107424. * The world space rotation quaternion of the particle.
  107425. */
  107426. rotationQuaternion: Nullable<Quaternion>;
  107427. /**
  107428. * The scaling of the particle.
  107429. */
  107430. scaling: Vector3;
  107431. /**
  107432. * The uvs of the particle.
  107433. */
  107434. uvs: Vector4;
  107435. /**
  107436. * The current speed of the particle.
  107437. */
  107438. velocity: Vector3;
  107439. /**
  107440. * The pivot point in the particle local space.
  107441. */
  107442. pivot: Vector3;
  107443. /**
  107444. * Must the particle be translated from its pivot point in its local space ?
  107445. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  107446. * Default : false
  107447. */
  107448. translateFromPivot: boolean;
  107449. /**
  107450. * Is the particle active or not ?
  107451. */
  107452. alive: boolean;
  107453. /**
  107454. * Is the particle visible or not ?
  107455. */
  107456. isVisible: boolean;
  107457. /**
  107458. * Index of this particle in the global "positions" array (Internal use)
  107459. * @hidden
  107460. */
  107461. _pos: number;
  107462. /**
  107463. * @hidden Index of this particle in the global "indices" array (Internal use)
  107464. */
  107465. _ind: number;
  107466. /**
  107467. * @hidden ModelShape of this particle (Internal use)
  107468. */
  107469. _model: ModelShape;
  107470. /**
  107471. * ModelShape id of this particle
  107472. */
  107473. shapeId: number;
  107474. /**
  107475. * Index of the particle in its shape id
  107476. */
  107477. idxInShape: number;
  107478. /**
  107479. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  107480. */
  107481. _modelBoundingInfo: BoundingInfo;
  107482. /**
  107483. * @hidden Particle BoundingInfo object (Internal use)
  107484. */
  107485. _boundingInfo: BoundingInfo;
  107486. /**
  107487. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  107488. */
  107489. _sps: SolidParticleSystem;
  107490. /**
  107491. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  107492. */
  107493. _stillInvisible: boolean;
  107494. /**
  107495. * @hidden Last computed particle rotation matrix
  107496. */
  107497. _rotationMatrix: number[];
  107498. /**
  107499. * Parent particle Id, if any.
  107500. * Default null.
  107501. */
  107502. parentId: Nullable<number>;
  107503. /**
  107504. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  107505. */
  107506. materialIndex: Nullable<number>;
  107507. /**
  107508. * Custom object or properties.
  107509. */
  107510. props: Nullable<any>;
  107511. /**
  107512. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  107513. * The possible values are :
  107514. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  107515. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  107516. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  107517. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  107518. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  107519. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  107520. * */
  107521. cullingStrategy: number;
  107522. /**
  107523. * @hidden Internal global position in the SPS.
  107524. */
  107525. _globalPosition: Vector3;
  107526. /**
  107527. * Creates a Solid Particle object.
  107528. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  107529. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  107530. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  107531. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  107532. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  107533. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  107534. * @param shapeId (integer) is the model shape identifier in the SPS.
  107535. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  107536. * @param sps defines the sps it is associated to
  107537. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  107538. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  107539. */
  107540. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  107541. /**
  107542. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  107543. * @param target the particle target
  107544. * @returns the current particle
  107545. */
  107546. copyToRef(target: SolidParticle): SolidParticle;
  107547. /**
  107548. * Legacy support, changed scale to scaling
  107549. */
  107550. get scale(): Vector3;
  107551. /**
  107552. * Legacy support, changed scale to scaling
  107553. */
  107554. set scale(scale: Vector3);
  107555. /**
  107556. * Legacy support, changed quaternion to rotationQuaternion
  107557. */
  107558. get quaternion(): Nullable<Quaternion>;
  107559. /**
  107560. * Legacy support, changed quaternion to rotationQuaternion
  107561. */
  107562. set quaternion(q: Nullable<Quaternion>);
  107563. /**
  107564. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  107565. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  107566. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  107567. * @returns true if it intersects
  107568. */
  107569. intersectsMesh(target: Mesh | SolidParticle): boolean;
  107570. /**
  107571. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  107572. * A particle is in the frustum if its bounding box intersects the frustum
  107573. * @param frustumPlanes defines the frustum to test
  107574. * @returns true if the particle is in the frustum planes
  107575. */
  107576. isInFrustum(frustumPlanes: Plane[]): boolean;
  107577. /**
  107578. * get the rotation matrix of the particle
  107579. * @hidden
  107580. */
  107581. getRotationMatrix(m: Matrix): void;
  107582. }
  107583. /**
  107584. * Represents the shape of the model used by one particle of a solid particle system.
  107585. * SPS internal tool, don't use it manually.
  107586. */
  107587. export class ModelShape {
  107588. /**
  107589. * The shape id
  107590. * @hidden
  107591. */
  107592. shapeID: number;
  107593. /**
  107594. * flat array of model positions (internal use)
  107595. * @hidden
  107596. */
  107597. _shape: Vector3[];
  107598. /**
  107599. * flat array of model UVs (internal use)
  107600. * @hidden
  107601. */
  107602. _shapeUV: number[];
  107603. /**
  107604. * color array of the model
  107605. * @hidden
  107606. */
  107607. _shapeColors: number[];
  107608. /**
  107609. * indices array of the model
  107610. * @hidden
  107611. */
  107612. _indices: number[];
  107613. /**
  107614. * normals array of the model
  107615. * @hidden
  107616. */
  107617. _normals: number[];
  107618. /**
  107619. * length of the shape in the model indices array (internal use)
  107620. * @hidden
  107621. */
  107622. _indicesLength: number;
  107623. /**
  107624. * Custom position function (internal use)
  107625. * @hidden
  107626. */
  107627. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  107628. /**
  107629. * Custom vertex function (internal use)
  107630. * @hidden
  107631. */
  107632. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  107633. /**
  107634. * Model material (internal use)
  107635. * @hidden
  107636. */
  107637. _material: Nullable<Material>;
  107638. /**
  107639. * 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.
  107640. * SPS internal tool, don't use it manually.
  107641. * @hidden
  107642. */
  107643. 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>);
  107644. }
  107645. /**
  107646. * Represents a Depth Sorted Particle in the solid particle system.
  107647. * @hidden
  107648. */
  107649. export class DepthSortedParticle {
  107650. /**
  107651. * Particle index
  107652. */
  107653. idx: number;
  107654. /**
  107655. * Index of the particle in the "indices" array
  107656. */
  107657. ind: number;
  107658. /**
  107659. * Length of the particle shape in the "indices" array
  107660. */
  107661. indicesLength: number;
  107662. /**
  107663. * Squared distance from the particle to the camera
  107664. */
  107665. sqDistance: number;
  107666. /**
  107667. * Material index when used with MultiMaterials
  107668. */
  107669. materialIndex: number;
  107670. /**
  107671. * Creates a new sorted particle
  107672. * @param materialIndex
  107673. */
  107674. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  107675. }
  107676. /**
  107677. * Represents a solid particle vertex
  107678. */
  107679. export class SolidParticleVertex {
  107680. /**
  107681. * Vertex position
  107682. */
  107683. position: Vector3;
  107684. /**
  107685. * Vertex color
  107686. */
  107687. color: Color4;
  107688. /**
  107689. * Vertex UV
  107690. */
  107691. uv: Vector2;
  107692. /**
  107693. * Creates a new solid particle vertex
  107694. */
  107695. constructor();
  107696. /** Vertex x coordinate */
  107697. get x(): number;
  107698. set x(val: number);
  107699. /** Vertex y coordinate */
  107700. get y(): number;
  107701. set y(val: number);
  107702. /** Vertex z coordinate */
  107703. get z(): number;
  107704. set z(val: number);
  107705. }
  107706. }
  107707. declare module BABYLON {
  107708. /**
  107709. * @hidden
  107710. */
  107711. export class _MeshCollisionData {
  107712. _checkCollisions: boolean;
  107713. _collisionMask: number;
  107714. _collisionGroup: number;
  107715. _surroundingMeshes: Nullable<AbstractMesh[]>;
  107716. _collider: Nullable<Collider>;
  107717. _oldPositionForCollisions: Vector3;
  107718. _diffPositionForCollisions: Vector3;
  107719. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  107720. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  107721. }
  107722. }
  107723. declare module BABYLON {
  107724. /** @hidden */
  107725. class _FacetDataStorage {
  107726. facetPositions: Vector3[];
  107727. facetNormals: Vector3[];
  107728. facetPartitioning: number[][];
  107729. facetNb: number;
  107730. partitioningSubdivisions: number;
  107731. partitioningBBoxRatio: number;
  107732. facetDataEnabled: boolean;
  107733. facetParameters: any;
  107734. bbSize: Vector3;
  107735. subDiv: {
  107736. max: number;
  107737. X: number;
  107738. Y: number;
  107739. Z: number;
  107740. };
  107741. facetDepthSort: boolean;
  107742. facetDepthSortEnabled: boolean;
  107743. depthSortedIndices: IndicesArray;
  107744. depthSortedFacets: {
  107745. ind: number;
  107746. sqDistance: number;
  107747. }[];
  107748. facetDepthSortFunction: (f1: {
  107749. ind: number;
  107750. sqDistance: number;
  107751. }, f2: {
  107752. ind: number;
  107753. sqDistance: number;
  107754. }) => number;
  107755. facetDepthSortFrom: Vector3;
  107756. facetDepthSortOrigin: Vector3;
  107757. invertedMatrix: Matrix;
  107758. }
  107759. /**
  107760. * @hidden
  107761. **/
  107762. class _InternalAbstractMeshDataInfo {
  107763. _hasVertexAlpha: boolean;
  107764. _useVertexColors: boolean;
  107765. _numBoneInfluencers: number;
  107766. _applyFog: boolean;
  107767. _receiveShadows: boolean;
  107768. _facetData: _FacetDataStorage;
  107769. _visibility: number;
  107770. _skeleton: Nullable<Skeleton>;
  107771. _layerMask: number;
  107772. _computeBonesUsingShaders: boolean;
  107773. _isActive: boolean;
  107774. _onlyForInstances: boolean;
  107775. _isActiveIntermediate: boolean;
  107776. _onlyForInstancesIntermediate: boolean;
  107777. _actAsRegularMesh: boolean;
  107778. }
  107779. /**
  107780. * Class used to store all common mesh properties
  107781. */
  107782. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  107783. /** No occlusion */
  107784. static OCCLUSION_TYPE_NONE: number;
  107785. /** Occlusion set to optimisitic */
  107786. static OCCLUSION_TYPE_OPTIMISTIC: number;
  107787. /** Occlusion set to strict */
  107788. static OCCLUSION_TYPE_STRICT: number;
  107789. /** Use an accurante occlusion algorithm */
  107790. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  107791. /** Use a conservative occlusion algorithm */
  107792. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  107793. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  107794. * Test order :
  107795. * Is the bounding sphere outside the frustum ?
  107796. * If not, are the bounding box vertices outside the frustum ?
  107797. * It not, then the cullable object is in the frustum.
  107798. */
  107799. static readonly CULLINGSTRATEGY_STANDARD: number;
  107800. /** Culling strategy : Bounding Sphere Only.
  107801. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  107802. * It's also less accurate than the standard because some not visible objects can still be selected.
  107803. * Test : is the bounding sphere outside the frustum ?
  107804. * If not, then the cullable object is in the frustum.
  107805. */
  107806. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  107807. /** Culling strategy : Optimistic Inclusion.
  107808. * This in an inclusion test first, then the standard exclusion test.
  107809. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  107810. * 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.
  107811. * Anyway, it's as accurate as the standard strategy.
  107812. * Test :
  107813. * Is the cullable object bounding sphere center in the frustum ?
  107814. * If not, apply the default culling strategy.
  107815. */
  107816. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  107817. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  107818. * This in an inclusion test first, then the bounding sphere only exclusion test.
  107819. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  107820. * 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.
  107821. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  107822. * Test :
  107823. * Is the cullable object bounding sphere center in the frustum ?
  107824. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  107825. */
  107826. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  107827. /**
  107828. * No billboard
  107829. */
  107830. static get BILLBOARDMODE_NONE(): number;
  107831. /** Billboard on X axis */
  107832. static get BILLBOARDMODE_X(): number;
  107833. /** Billboard on Y axis */
  107834. static get BILLBOARDMODE_Y(): number;
  107835. /** Billboard on Z axis */
  107836. static get BILLBOARDMODE_Z(): number;
  107837. /** Billboard on all axes */
  107838. static get BILLBOARDMODE_ALL(): number;
  107839. /** Billboard on using position instead of orientation */
  107840. static get BILLBOARDMODE_USE_POSITION(): number;
  107841. /** @hidden */
  107842. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  107843. /**
  107844. * The culling strategy to use to check whether the mesh must be rendered or not.
  107845. * This value can be changed at any time and will be used on the next render mesh selection.
  107846. * The possible values are :
  107847. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  107848. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  107849. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  107850. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  107851. * Please read each static variable documentation to get details about the culling process.
  107852. * */
  107853. cullingStrategy: number;
  107854. /**
  107855. * Gets the number of facets in the mesh
  107856. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  107857. */
  107858. get facetNb(): number;
  107859. /**
  107860. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  107861. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  107862. */
  107863. get partitioningSubdivisions(): number;
  107864. set partitioningSubdivisions(nb: number);
  107865. /**
  107866. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  107867. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  107868. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  107869. */
  107870. get partitioningBBoxRatio(): number;
  107871. set partitioningBBoxRatio(ratio: number);
  107872. /**
  107873. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  107874. * Works only for updatable meshes.
  107875. * Doesn't work with multi-materials
  107876. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  107877. */
  107878. get mustDepthSortFacets(): boolean;
  107879. set mustDepthSortFacets(sort: boolean);
  107880. /**
  107881. * The location (Vector3) where the facet depth sort must be computed from.
  107882. * By default, the active camera position.
  107883. * Used only when facet depth sort is enabled
  107884. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  107885. */
  107886. get facetDepthSortFrom(): Vector3;
  107887. set facetDepthSortFrom(location: Vector3);
  107888. /**
  107889. * gets a boolean indicating if facetData is enabled
  107890. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  107891. */
  107892. get isFacetDataEnabled(): boolean;
  107893. /** @hidden */
  107894. _updateNonUniformScalingState(value: boolean): boolean;
  107895. /**
  107896. * An event triggered when this mesh collides with another one
  107897. */
  107898. onCollideObservable: Observable<AbstractMesh>;
  107899. /** Set a function to call when this mesh collides with another one */
  107900. set onCollide(callback: () => void);
  107901. /**
  107902. * An event triggered when the collision's position changes
  107903. */
  107904. onCollisionPositionChangeObservable: Observable<Vector3>;
  107905. /** Set a function to call when the collision's position changes */
  107906. set onCollisionPositionChange(callback: () => void);
  107907. /**
  107908. * An event triggered when material is changed
  107909. */
  107910. onMaterialChangedObservable: Observable<AbstractMesh>;
  107911. /**
  107912. * Gets or sets the orientation for POV movement & rotation
  107913. */
  107914. definedFacingForward: boolean;
  107915. /** @hidden */
  107916. _occlusionQuery: Nullable<WebGLQuery>;
  107917. /** @hidden */
  107918. _renderingGroup: Nullable<RenderingGroup>;
  107919. /**
  107920. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  107921. */
  107922. get visibility(): number;
  107923. /**
  107924. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  107925. */
  107926. set visibility(value: number);
  107927. /** Gets or sets the alpha index used to sort transparent meshes
  107928. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  107929. */
  107930. alphaIndex: number;
  107931. /**
  107932. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  107933. */
  107934. isVisible: boolean;
  107935. /**
  107936. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  107937. */
  107938. isPickable: boolean;
  107939. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  107940. showSubMeshesBoundingBox: boolean;
  107941. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  107942. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  107943. */
  107944. isBlocker: boolean;
  107945. /**
  107946. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  107947. */
  107948. enablePointerMoveEvents: boolean;
  107949. /**
  107950. * Specifies the rendering group id for this mesh (0 by default)
  107951. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  107952. */
  107953. renderingGroupId: number;
  107954. private _material;
  107955. /** Gets or sets current material */
  107956. get material(): Nullable<Material>;
  107957. set material(value: Nullable<Material>);
  107958. /**
  107959. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  107960. * @see http://doc.babylonjs.com/babylon101/shadows
  107961. */
  107962. get receiveShadows(): boolean;
  107963. set receiveShadows(value: boolean);
  107964. /** Defines color to use when rendering outline */
  107965. outlineColor: Color3;
  107966. /** Define width to use when rendering outline */
  107967. outlineWidth: number;
  107968. /** Defines color to use when rendering overlay */
  107969. overlayColor: Color3;
  107970. /** Defines alpha to use when rendering overlay */
  107971. overlayAlpha: number;
  107972. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  107973. get hasVertexAlpha(): boolean;
  107974. set hasVertexAlpha(value: boolean);
  107975. /** 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) */
  107976. get useVertexColors(): boolean;
  107977. set useVertexColors(value: boolean);
  107978. /**
  107979. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  107980. */
  107981. get computeBonesUsingShaders(): boolean;
  107982. set computeBonesUsingShaders(value: boolean);
  107983. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  107984. get numBoneInfluencers(): number;
  107985. set numBoneInfluencers(value: number);
  107986. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  107987. get applyFog(): boolean;
  107988. set applyFog(value: boolean);
  107989. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  107990. useOctreeForRenderingSelection: boolean;
  107991. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  107992. useOctreeForPicking: boolean;
  107993. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  107994. useOctreeForCollisions: boolean;
  107995. /**
  107996. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  107997. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  107998. */
  107999. get layerMask(): number;
  108000. set layerMask(value: number);
  108001. /**
  108002. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  108003. */
  108004. alwaysSelectAsActiveMesh: boolean;
  108005. /**
  108006. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  108007. */
  108008. doNotSyncBoundingInfo: boolean;
  108009. /**
  108010. * Gets or sets the current action manager
  108011. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  108012. */
  108013. actionManager: Nullable<AbstractActionManager>;
  108014. private _meshCollisionData;
  108015. /**
  108016. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  108017. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  108018. */
  108019. ellipsoid: Vector3;
  108020. /**
  108021. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  108022. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  108023. */
  108024. ellipsoidOffset: Vector3;
  108025. /**
  108026. * Gets or sets a collision mask used to mask collisions (default is -1).
  108027. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  108028. */
  108029. get collisionMask(): number;
  108030. set collisionMask(mask: number);
  108031. /**
  108032. * Gets or sets the current collision group mask (-1 by default).
  108033. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  108034. */
  108035. get collisionGroup(): number;
  108036. set collisionGroup(mask: number);
  108037. /**
  108038. * Gets or sets current surrounding meshes (null by default).
  108039. *
  108040. * By default collision detection is tested against every mesh in the scene.
  108041. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  108042. * meshes will be tested for the collision.
  108043. *
  108044. * Note: if set to an empty array no collision will happen when this mesh is moved.
  108045. */
  108046. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  108047. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  108048. /**
  108049. * Defines edge width used when edgesRenderer is enabled
  108050. * @see https://www.babylonjs-playground.com/#10OJSG#13
  108051. */
  108052. edgesWidth: number;
  108053. /**
  108054. * Defines edge color used when edgesRenderer is enabled
  108055. * @see https://www.babylonjs-playground.com/#10OJSG#13
  108056. */
  108057. edgesColor: Color4;
  108058. /** @hidden */
  108059. _edgesRenderer: Nullable<IEdgesRenderer>;
  108060. /** @hidden */
  108061. _masterMesh: Nullable<AbstractMesh>;
  108062. /** @hidden */
  108063. _boundingInfo: Nullable<BoundingInfo>;
  108064. /** @hidden */
  108065. _renderId: number;
  108066. /**
  108067. * Gets or sets the list of subMeshes
  108068. * @see http://doc.babylonjs.com/how_to/multi_materials
  108069. */
  108070. subMeshes: SubMesh[];
  108071. /** @hidden */
  108072. _intersectionsInProgress: AbstractMesh[];
  108073. /** @hidden */
  108074. _unIndexed: boolean;
  108075. /** @hidden */
  108076. _lightSources: Light[];
  108077. /** Gets the list of lights affecting that mesh */
  108078. get lightSources(): Light[];
  108079. /** @hidden */
  108080. get _positions(): Nullable<Vector3[]>;
  108081. /** @hidden */
  108082. _waitingData: {
  108083. lods: Nullable<any>;
  108084. actions: Nullable<any>;
  108085. freezeWorldMatrix: Nullable<boolean>;
  108086. };
  108087. /** @hidden */
  108088. _bonesTransformMatrices: Nullable<Float32Array>;
  108089. /** @hidden */
  108090. _transformMatrixTexture: Nullable<RawTexture>;
  108091. /**
  108092. * Gets or sets a skeleton to apply skining transformations
  108093. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  108094. */
  108095. set skeleton(value: Nullable<Skeleton>);
  108096. get skeleton(): Nullable<Skeleton>;
  108097. /**
  108098. * An event triggered when the mesh is rebuilt.
  108099. */
  108100. onRebuildObservable: Observable<AbstractMesh>;
  108101. /**
  108102. * Creates a new AbstractMesh
  108103. * @param name defines the name of the mesh
  108104. * @param scene defines the hosting scene
  108105. */
  108106. constructor(name: string, scene?: Nullable<Scene>);
  108107. /**
  108108. * Returns the string "AbstractMesh"
  108109. * @returns "AbstractMesh"
  108110. */
  108111. getClassName(): string;
  108112. /**
  108113. * Gets a string representation of the current mesh
  108114. * @param fullDetails defines a boolean indicating if full details must be included
  108115. * @returns a string representation of the current mesh
  108116. */
  108117. toString(fullDetails?: boolean): string;
  108118. /**
  108119. * @hidden
  108120. */
  108121. protected _getEffectiveParent(): Nullable<Node>;
  108122. /** @hidden */
  108123. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  108124. /** @hidden */
  108125. _rebuild(): void;
  108126. /** @hidden */
  108127. _resyncLightSources(): void;
  108128. /** @hidden */
  108129. _resyncLightSource(light: Light): void;
  108130. /** @hidden */
  108131. _unBindEffect(): void;
  108132. /** @hidden */
  108133. _removeLightSource(light: Light, dispose: boolean): void;
  108134. private _markSubMeshesAsDirty;
  108135. /** @hidden */
  108136. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  108137. /** @hidden */
  108138. _markSubMeshesAsAttributesDirty(): void;
  108139. /** @hidden */
  108140. _markSubMeshesAsMiscDirty(): void;
  108141. /**
  108142. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  108143. */
  108144. get scaling(): Vector3;
  108145. set scaling(newScaling: Vector3);
  108146. /**
  108147. * Returns true if the mesh is blocked. Implemented by child classes
  108148. */
  108149. get isBlocked(): boolean;
  108150. /**
  108151. * Returns the mesh itself by default. Implemented by child classes
  108152. * @param camera defines the camera to use to pick the right LOD level
  108153. * @returns the currentAbstractMesh
  108154. */
  108155. getLOD(camera: Camera): Nullable<AbstractMesh>;
  108156. /**
  108157. * Returns 0 by default. Implemented by child classes
  108158. * @returns an integer
  108159. */
  108160. getTotalVertices(): number;
  108161. /**
  108162. * Returns a positive integer : the total number of indices in this mesh geometry.
  108163. * @returns the numner of indices or zero if the mesh has no geometry.
  108164. */
  108165. getTotalIndices(): number;
  108166. /**
  108167. * Returns null by default. Implemented by child classes
  108168. * @returns null
  108169. */
  108170. getIndices(): Nullable<IndicesArray>;
  108171. /**
  108172. * Returns the array of the requested vertex data kind. Implemented by child classes
  108173. * @param kind defines the vertex data kind to use
  108174. * @returns null
  108175. */
  108176. getVerticesData(kind: string): Nullable<FloatArray>;
  108177. /**
  108178. * Sets the vertex data of the mesh geometry for the requested `kind`.
  108179. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  108180. * Note that a new underlying VertexBuffer object is created each call.
  108181. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  108182. * @param kind defines vertex data kind:
  108183. * * VertexBuffer.PositionKind
  108184. * * VertexBuffer.UVKind
  108185. * * VertexBuffer.UV2Kind
  108186. * * VertexBuffer.UV3Kind
  108187. * * VertexBuffer.UV4Kind
  108188. * * VertexBuffer.UV5Kind
  108189. * * VertexBuffer.UV6Kind
  108190. * * VertexBuffer.ColorKind
  108191. * * VertexBuffer.MatricesIndicesKind
  108192. * * VertexBuffer.MatricesIndicesExtraKind
  108193. * * VertexBuffer.MatricesWeightsKind
  108194. * * VertexBuffer.MatricesWeightsExtraKind
  108195. * @param data defines the data source
  108196. * @param updatable defines if the data must be flagged as updatable (or static)
  108197. * @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
  108198. * @returns the current mesh
  108199. */
  108200. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  108201. /**
  108202. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  108203. * If the mesh has no geometry, it is simply returned as it is.
  108204. * @param kind defines vertex data kind:
  108205. * * VertexBuffer.PositionKind
  108206. * * VertexBuffer.UVKind
  108207. * * VertexBuffer.UV2Kind
  108208. * * VertexBuffer.UV3Kind
  108209. * * VertexBuffer.UV4Kind
  108210. * * VertexBuffer.UV5Kind
  108211. * * VertexBuffer.UV6Kind
  108212. * * VertexBuffer.ColorKind
  108213. * * VertexBuffer.MatricesIndicesKind
  108214. * * VertexBuffer.MatricesIndicesExtraKind
  108215. * * VertexBuffer.MatricesWeightsKind
  108216. * * VertexBuffer.MatricesWeightsExtraKind
  108217. * @param data defines the data source
  108218. * @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
  108219. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  108220. * @returns the current mesh
  108221. */
  108222. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  108223. /**
  108224. * Sets the mesh indices,
  108225. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  108226. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  108227. * @param totalVertices Defines the total number of vertices
  108228. * @returns the current mesh
  108229. */
  108230. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  108231. /**
  108232. * Gets a boolean indicating if specific vertex data is present
  108233. * @param kind defines the vertex data kind to use
  108234. * @returns true is data kind is present
  108235. */
  108236. isVerticesDataPresent(kind: string): boolean;
  108237. /**
  108238. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  108239. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  108240. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  108241. * @returns a BoundingInfo
  108242. */
  108243. getBoundingInfo(): BoundingInfo;
  108244. /**
  108245. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  108246. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  108247. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  108248. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  108249. * @returns the current mesh
  108250. */
  108251. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  108252. /**
  108253. * Overwrite the current bounding info
  108254. * @param boundingInfo defines the new bounding info
  108255. * @returns the current mesh
  108256. */
  108257. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  108258. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  108259. get useBones(): boolean;
  108260. /** @hidden */
  108261. _preActivate(): void;
  108262. /** @hidden */
  108263. _preActivateForIntermediateRendering(renderId: number): void;
  108264. /** @hidden */
  108265. _activate(renderId: number, intermediateRendering: boolean): boolean;
  108266. /** @hidden */
  108267. _postActivate(): void;
  108268. /** @hidden */
  108269. _freeze(): void;
  108270. /** @hidden */
  108271. _unFreeze(): void;
  108272. /**
  108273. * Gets the current world matrix
  108274. * @returns a Matrix
  108275. */
  108276. getWorldMatrix(): Matrix;
  108277. /** @hidden */
  108278. _getWorldMatrixDeterminant(): number;
  108279. /**
  108280. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  108281. */
  108282. get isAnInstance(): boolean;
  108283. /**
  108284. * Gets a boolean indicating if this mesh has instances
  108285. */
  108286. get hasInstances(): boolean;
  108287. /**
  108288. * Perform relative position change from the point of view of behind the front of the mesh.
  108289. * This is performed taking into account the meshes current rotation, so you do not have to care.
  108290. * Supports definition of mesh facing forward or backward
  108291. * @param amountRight defines the distance on the right axis
  108292. * @param amountUp defines the distance on the up axis
  108293. * @param amountForward defines the distance on the forward axis
  108294. * @returns the current mesh
  108295. */
  108296. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  108297. /**
  108298. * Calculate relative position change from the point of view of behind the front of the mesh.
  108299. * This is performed taking into account the meshes current rotation, so you do not have to care.
  108300. * Supports definition of mesh facing forward or backward
  108301. * @param amountRight defines the distance on the right axis
  108302. * @param amountUp defines the distance on the up axis
  108303. * @param amountForward defines the distance on the forward axis
  108304. * @returns the new displacement vector
  108305. */
  108306. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  108307. /**
  108308. * Perform relative rotation change from the point of view of behind the front of the mesh.
  108309. * Supports definition of mesh facing forward or backward
  108310. * @param flipBack defines the flip
  108311. * @param twirlClockwise defines the twirl
  108312. * @param tiltRight defines the tilt
  108313. * @returns the current mesh
  108314. */
  108315. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  108316. /**
  108317. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  108318. * Supports definition of mesh facing forward or backward.
  108319. * @param flipBack defines the flip
  108320. * @param twirlClockwise defines the twirl
  108321. * @param tiltRight defines the tilt
  108322. * @returns the new rotation vector
  108323. */
  108324. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  108325. /**
  108326. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  108327. * This means the mesh underlying bounding box and sphere are recomputed.
  108328. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  108329. * @returns the current mesh
  108330. */
  108331. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  108332. /** @hidden */
  108333. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  108334. /** @hidden */
  108335. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  108336. /** @hidden */
  108337. _updateBoundingInfo(): AbstractMesh;
  108338. /** @hidden */
  108339. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  108340. /** @hidden */
  108341. protected _afterComputeWorldMatrix(): void;
  108342. /** @hidden */
  108343. get _effectiveMesh(): AbstractMesh;
  108344. /**
  108345. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  108346. * A mesh is in the frustum if its bounding box intersects the frustum
  108347. * @param frustumPlanes defines the frustum to test
  108348. * @returns true if the mesh is in the frustum planes
  108349. */
  108350. isInFrustum(frustumPlanes: Plane[]): boolean;
  108351. /**
  108352. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  108353. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  108354. * @param frustumPlanes defines the frustum to test
  108355. * @returns true if the mesh is completely in the frustum planes
  108356. */
  108357. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  108358. /**
  108359. * True if the mesh intersects another mesh or a SolidParticle object
  108360. * @param mesh defines a target mesh or SolidParticle to test
  108361. * @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)
  108362. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  108363. * @returns true if there is an intersection
  108364. */
  108365. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  108366. /**
  108367. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  108368. * @param point defines the point to test
  108369. * @returns true if there is an intersection
  108370. */
  108371. intersectsPoint(point: Vector3): boolean;
  108372. /**
  108373. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  108374. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  108375. */
  108376. get checkCollisions(): boolean;
  108377. set checkCollisions(collisionEnabled: boolean);
  108378. /**
  108379. * Gets Collider object used to compute collisions (not physics)
  108380. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  108381. */
  108382. get collider(): Nullable<Collider>;
  108383. /**
  108384. * Move the mesh using collision engine
  108385. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  108386. * @param displacement defines the requested displacement vector
  108387. * @returns the current mesh
  108388. */
  108389. moveWithCollisions(displacement: Vector3): AbstractMesh;
  108390. private _onCollisionPositionChange;
  108391. /** @hidden */
  108392. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  108393. /** @hidden */
  108394. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  108395. /** @hidden */
  108396. _checkCollision(collider: Collider): AbstractMesh;
  108397. /** @hidden */
  108398. _generatePointsArray(): boolean;
  108399. /**
  108400. * Checks if the passed Ray intersects with the mesh
  108401. * @param ray defines the ray to use
  108402. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  108403. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  108404. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  108405. * @returns the picking info
  108406. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  108407. */
  108408. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean): PickingInfo;
  108409. /**
  108410. * Clones the current mesh
  108411. * @param name defines the mesh name
  108412. * @param newParent defines the new mesh parent
  108413. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  108414. * @returns the new mesh
  108415. */
  108416. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  108417. /**
  108418. * Disposes all the submeshes of the current meshnp
  108419. * @returns the current mesh
  108420. */
  108421. releaseSubMeshes(): AbstractMesh;
  108422. /**
  108423. * Releases resources associated with this abstract mesh.
  108424. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  108425. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  108426. */
  108427. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  108428. /**
  108429. * Adds the passed mesh as a child to the current mesh
  108430. * @param mesh defines the child mesh
  108431. * @returns the current mesh
  108432. */
  108433. addChild(mesh: AbstractMesh): AbstractMesh;
  108434. /**
  108435. * Removes the passed mesh from the current mesh children list
  108436. * @param mesh defines the child mesh
  108437. * @returns the current mesh
  108438. */
  108439. removeChild(mesh: AbstractMesh): AbstractMesh;
  108440. /** @hidden */
  108441. private _initFacetData;
  108442. /**
  108443. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  108444. * This method can be called within the render loop.
  108445. * 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
  108446. * @returns the current mesh
  108447. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  108448. */
  108449. updateFacetData(): AbstractMesh;
  108450. /**
  108451. * Returns the facetLocalNormals array.
  108452. * The normals are expressed in the mesh local spac
  108453. * @returns an array of Vector3
  108454. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  108455. */
  108456. getFacetLocalNormals(): Vector3[];
  108457. /**
  108458. * Returns the facetLocalPositions array.
  108459. * The facet positions are expressed in the mesh local space
  108460. * @returns an array of Vector3
  108461. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  108462. */
  108463. getFacetLocalPositions(): Vector3[];
  108464. /**
  108465. * Returns the facetLocalPartioning array
  108466. * @returns an array of array of numbers
  108467. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  108468. */
  108469. getFacetLocalPartitioning(): number[][];
  108470. /**
  108471. * Returns the i-th facet position in the world system.
  108472. * This method allocates a new Vector3 per call
  108473. * @param i defines the facet index
  108474. * @returns a new Vector3
  108475. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  108476. */
  108477. getFacetPosition(i: number): Vector3;
  108478. /**
  108479. * Sets the reference Vector3 with the i-th facet position in the world system
  108480. * @param i defines the facet index
  108481. * @param ref defines the target vector
  108482. * @returns the current mesh
  108483. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  108484. */
  108485. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  108486. /**
  108487. * Returns the i-th facet normal in the world system.
  108488. * This method allocates a new Vector3 per call
  108489. * @param i defines the facet index
  108490. * @returns a new Vector3
  108491. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  108492. */
  108493. getFacetNormal(i: number): Vector3;
  108494. /**
  108495. * Sets the reference Vector3 with the i-th facet normal in the world system
  108496. * @param i defines the facet index
  108497. * @param ref defines the target vector
  108498. * @returns the current mesh
  108499. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  108500. */
  108501. getFacetNormalToRef(i: number, ref: Vector3): this;
  108502. /**
  108503. * 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)
  108504. * @param x defines x coordinate
  108505. * @param y defines y coordinate
  108506. * @param z defines z coordinate
  108507. * @returns the array of facet indexes
  108508. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  108509. */
  108510. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  108511. /**
  108512. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  108513. * @param projected sets as the (x,y,z) world projection on the facet
  108514. * @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
  108515. * @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
  108516. * @param x defines x coordinate
  108517. * @param y defines y coordinate
  108518. * @param z defines z coordinate
  108519. * @returns the face index if found (or null instead)
  108520. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  108521. */
  108522. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  108523. /**
  108524. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  108525. * @param projected sets as the (x,y,z) local projection on the facet
  108526. * @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
  108527. * @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
  108528. * @param x defines x coordinate
  108529. * @param y defines y coordinate
  108530. * @param z defines z coordinate
  108531. * @returns the face index if found (or null instead)
  108532. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  108533. */
  108534. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  108535. /**
  108536. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  108537. * @returns the parameters
  108538. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  108539. */
  108540. getFacetDataParameters(): any;
  108541. /**
  108542. * Disables the feature FacetData and frees the related memory
  108543. * @returns the current mesh
  108544. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  108545. */
  108546. disableFacetData(): AbstractMesh;
  108547. /**
  108548. * Updates the AbstractMesh indices array
  108549. * @param indices defines the data source
  108550. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  108551. * @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)
  108552. * @returns the current mesh
  108553. */
  108554. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  108555. /**
  108556. * Creates new normals data for the mesh
  108557. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  108558. * @returns the current mesh
  108559. */
  108560. createNormals(updatable: boolean): AbstractMesh;
  108561. /**
  108562. * Align the mesh with a normal
  108563. * @param normal defines the normal to use
  108564. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  108565. * @returns the current mesh
  108566. */
  108567. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  108568. /** @hidden */
  108569. _checkOcclusionQuery(): boolean;
  108570. /**
  108571. * Disables the mesh edge rendering mode
  108572. * @returns the currentAbstractMesh
  108573. */
  108574. disableEdgesRendering(): AbstractMesh;
  108575. /**
  108576. * Enables the edge rendering mode on the mesh.
  108577. * This mode makes the mesh edges visible
  108578. * @param epsilon defines the maximal distance between two angles to detect a face
  108579. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  108580. * @returns the currentAbstractMesh
  108581. * @see https://www.babylonjs-playground.com/#19O9TU#0
  108582. */
  108583. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  108584. }
  108585. }
  108586. declare module BABYLON {
  108587. /**
  108588. * Interface used to define ActionEvent
  108589. */
  108590. export interface IActionEvent {
  108591. /** The mesh or sprite that triggered the action */
  108592. source: any;
  108593. /** The X mouse cursor position at the time of the event */
  108594. pointerX: number;
  108595. /** The Y mouse cursor position at the time of the event */
  108596. pointerY: number;
  108597. /** The mesh that is currently pointed at (can be null) */
  108598. meshUnderPointer: Nullable<AbstractMesh>;
  108599. /** the original (browser) event that triggered the ActionEvent */
  108600. sourceEvent?: any;
  108601. /** additional data for the event */
  108602. additionalData?: any;
  108603. }
  108604. /**
  108605. * ActionEvent is the event being sent when an action is triggered.
  108606. */
  108607. export class ActionEvent implements IActionEvent {
  108608. /** The mesh or sprite that triggered the action */
  108609. source: any;
  108610. /** The X mouse cursor position at the time of the event */
  108611. pointerX: number;
  108612. /** The Y mouse cursor position at the time of the event */
  108613. pointerY: number;
  108614. /** The mesh that is currently pointed at (can be null) */
  108615. meshUnderPointer: Nullable<AbstractMesh>;
  108616. /** the original (browser) event that triggered the ActionEvent */
  108617. sourceEvent?: any;
  108618. /** additional data for the event */
  108619. additionalData?: any;
  108620. /**
  108621. * Creates a new ActionEvent
  108622. * @param source The mesh or sprite that triggered the action
  108623. * @param pointerX The X mouse cursor position at the time of the event
  108624. * @param pointerY The Y mouse cursor position at the time of the event
  108625. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  108626. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  108627. * @param additionalData additional data for the event
  108628. */
  108629. constructor(
  108630. /** The mesh or sprite that triggered the action */
  108631. source: any,
  108632. /** The X mouse cursor position at the time of the event */
  108633. pointerX: number,
  108634. /** The Y mouse cursor position at the time of the event */
  108635. pointerY: number,
  108636. /** The mesh that is currently pointed at (can be null) */
  108637. meshUnderPointer: Nullable<AbstractMesh>,
  108638. /** the original (browser) event that triggered the ActionEvent */
  108639. sourceEvent?: any,
  108640. /** additional data for the event */
  108641. additionalData?: any);
  108642. /**
  108643. * Helper function to auto-create an ActionEvent from a source mesh.
  108644. * @param source The source mesh that triggered the event
  108645. * @param evt The original (browser) event
  108646. * @param additionalData additional data for the event
  108647. * @returns the new ActionEvent
  108648. */
  108649. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  108650. /**
  108651. * Helper function to auto-create an ActionEvent from a source sprite
  108652. * @param source The source sprite that triggered the event
  108653. * @param scene Scene associated with the sprite
  108654. * @param evt The original (browser) event
  108655. * @param additionalData additional data for the event
  108656. * @returns the new ActionEvent
  108657. */
  108658. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  108659. /**
  108660. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  108661. * @param scene the scene where the event occurred
  108662. * @param evt The original (browser) event
  108663. * @returns the new ActionEvent
  108664. */
  108665. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  108666. /**
  108667. * Helper function to auto-create an ActionEvent from a primitive
  108668. * @param prim defines the target primitive
  108669. * @param pointerPos defines the pointer position
  108670. * @param evt The original (browser) event
  108671. * @param additionalData additional data for the event
  108672. * @returns the new ActionEvent
  108673. */
  108674. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  108675. }
  108676. }
  108677. declare module BABYLON {
  108678. /**
  108679. * Abstract class used to decouple action Manager from scene and meshes.
  108680. * Do not instantiate.
  108681. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  108682. */
  108683. export abstract class AbstractActionManager implements IDisposable {
  108684. /** Gets the list of active triggers */
  108685. static Triggers: {
  108686. [key: string]: number;
  108687. };
  108688. /** Gets the cursor to use when hovering items */
  108689. hoverCursor: string;
  108690. /** Gets the list of actions */
  108691. actions: IAction[];
  108692. /**
  108693. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  108694. */
  108695. isRecursive: boolean;
  108696. /**
  108697. * Releases all associated resources
  108698. */
  108699. abstract dispose(): void;
  108700. /**
  108701. * Does this action manager has pointer triggers
  108702. */
  108703. abstract get hasPointerTriggers(): boolean;
  108704. /**
  108705. * Does this action manager has pick triggers
  108706. */
  108707. abstract get hasPickTriggers(): boolean;
  108708. /**
  108709. * Process a specific trigger
  108710. * @param trigger defines the trigger to process
  108711. * @param evt defines the event details to be processed
  108712. */
  108713. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  108714. /**
  108715. * Does this action manager handles actions of any of the given triggers
  108716. * @param triggers defines the triggers to be tested
  108717. * @return a boolean indicating whether one (or more) of the triggers is handled
  108718. */
  108719. abstract hasSpecificTriggers(triggers: number[]): boolean;
  108720. /**
  108721. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  108722. * speed.
  108723. * @param triggerA defines the trigger to be tested
  108724. * @param triggerB defines the trigger to be tested
  108725. * @return a boolean indicating whether one (or more) of the triggers is handled
  108726. */
  108727. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  108728. /**
  108729. * Does this action manager handles actions of a given trigger
  108730. * @param trigger defines the trigger to be tested
  108731. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  108732. * @return whether the trigger is handled
  108733. */
  108734. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  108735. /**
  108736. * Serialize this manager to a JSON object
  108737. * @param name defines the property name to store this manager
  108738. * @returns a JSON representation of this manager
  108739. */
  108740. abstract serialize(name: string): any;
  108741. /**
  108742. * Registers an action to this action manager
  108743. * @param action defines the action to be registered
  108744. * @return the action amended (prepared) after registration
  108745. */
  108746. abstract registerAction(action: IAction): Nullable<IAction>;
  108747. /**
  108748. * Unregisters an action to this action manager
  108749. * @param action defines the action to be unregistered
  108750. * @return a boolean indicating whether the action has been unregistered
  108751. */
  108752. abstract unregisterAction(action: IAction): Boolean;
  108753. /**
  108754. * Does exist one action manager with at least one trigger
  108755. **/
  108756. static get HasTriggers(): boolean;
  108757. /**
  108758. * Does exist one action manager with at least one pick trigger
  108759. **/
  108760. static get HasPickTriggers(): boolean;
  108761. /**
  108762. * Does exist one action manager that handles actions of a given trigger
  108763. * @param trigger defines the trigger to be tested
  108764. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  108765. **/
  108766. static HasSpecificTrigger(trigger: number): boolean;
  108767. }
  108768. }
  108769. declare module BABYLON {
  108770. /**
  108771. * Defines how a node can be built from a string name.
  108772. */
  108773. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  108774. /**
  108775. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  108776. */
  108777. export class Node implements IBehaviorAware<Node> {
  108778. /** @hidden */
  108779. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  108780. private static _NodeConstructors;
  108781. /**
  108782. * Add a new node constructor
  108783. * @param type defines the type name of the node to construct
  108784. * @param constructorFunc defines the constructor function
  108785. */
  108786. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  108787. /**
  108788. * Returns a node constructor based on type name
  108789. * @param type defines the type name
  108790. * @param name defines the new node name
  108791. * @param scene defines the hosting scene
  108792. * @param options defines optional options to transmit to constructors
  108793. * @returns the new constructor or null
  108794. */
  108795. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  108796. /**
  108797. * Gets or sets the name of the node
  108798. */
  108799. name: string;
  108800. /**
  108801. * Gets or sets the id of the node
  108802. */
  108803. id: string;
  108804. /**
  108805. * Gets or sets the unique id of the node
  108806. */
  108807. uniqueId: number;
  108808. /**
  108809. * Gets or sets a string used to store user defined state for the node
  108810. */
  108811. state: string;
  108812. /**
  108813. * Gets or sets an object used to store user defined information for the node
  108814. */
  108815. metadata: any;
  108816. /**
  108817. * For internal use only. Please do not use.
  108818. */
  108819. reservedDataStore: any;
  108820. /**
  108821. * List of inspectable custom properties (used by the Inspector)
  108822. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  108823. */
  108824. inspectableCustomProperties: IInspectable[];
  108825. private _doNotSerialize;
  108826. /**
  108827. * Gets or sets a boolean used to define if the node must be serialized
  108828. */
  108829. get doNotSerialize(): boolean;
  108830. set doNotSerialize(value: boolean);
  108831. /** @hidden */
  108832. _isDisposed: boolean;
  108833. /**
  108834. * Gets a list of Animations associated with the node
  108835. */
  108836. animations: Animation[];
  108837. protected _ranges: {
  108838. [name: string]: Nullable<AnimationRange>;
  108839. };
  108840. /**
  108841. * Callback raised when the node is ready to be used
  108842. */
  108843. onReady: Nullable<(node: Node) => void>;
  108844. private _isEnabled;
  108845. private _isParentEnabled;
  108846. private _isReady;
  108847. /** @hidden */
  108848. _currentRenderId: number;
  108849. private _parentUpdateId;
  108850. /** @hidden */
  108851. _childUpdateId: number;
  108852. /** @hidden */
  108853. _waitingParentId: Nullable<string>;
  108854. /** @hidden */
  108855. _scene: Scene;
  108856. /** @hidden */
  108857. _cache: any;
  108858. private _parentNode;
  108859. private _children;
  108860. /** @hidden */
  108861. _worldMatrix: Matrix;
  108862. /** @hidden */
  108863. _worldMatrixDeterminant: number;
  108864. /** @hidden */
  108865. _worldMatrixDeterminantIsDirty: boolean;
  108866. /** @hidden */
  108867. private _sceneRootNodesIndex;
  108868. /**
  108869. * Gets a boolean indicating if the node has been disposed
  108870. * @returns true if the node was disposed
  108871. */
  108872. isDisposed(): boolean;
  108873. /**
  108874. * Gets or sets the parent of the node (without keeping the current position in the scene)
  108875. * @see https://doc.babylonjs.com/how_to/parenting
  108876. */
  108877. set parent(parent: Nullable<Node>);
  108878. get parent(): Nullable<Node>;
  108879. /** @hidden */
  108880. _addToSceneRootNodes(): void;
  108881. /** @hidden */
  108882. _removeFromSceneRootNodes(): void;
  108883. private _animationPropertiesOverride;
  108884. /**
  108885. * Gets or sets the animation properties override
  108886. */
  108887. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  108888. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  108889. /**
  108890. * Gets a string idenfifying the name of the class
  108891. * @returns "Node" string
  108892. */
  108893. getClassName(): string;
  108894. /** @hidden */
  108895. readonly _isNode: boolean;
  108896. /**
  108897. * An event triggered when the mesh is disposed
  108898. */
  108899. onDisposeObservable: Observable<Node>;
  108900. private _onDisposeObserver;
  108901. /**
  108902. * Sets a callback that will be raised when the node will be disposed
  108903. */
  108904. set onDispose(callback: () => void);
  108905. /**
  108906. * Creates a new Node
  108907. * @param name the name and id to be given to this node
  108908. * @param scene the scene this node will be added to
  108909. */
  108910. constructor(name: string, scene?: Nullable<Scene>);
  108911. /**
  108912. * Gets the scene of the node
  108913. * @returns a scene
  108914. */
  108915. getScene(): Scene;
  108916. /**
  108917. * Gets the engine of the node
  108918. * @returns a Engine
  108919. */
  108920. getEngine(): Engine;
  108921. private _behaviors;
  108922. /**
  108923. * Attach a behavior to the node
  108924. * @see http://doc.babylonjs.com/features/behaviour
  108925. * @param behavior defines the behavior to attach
  108926. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  108927. * @returns the current Node
  108928. */
  108929. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  108930. /**
  108931. * Remove an attached behavior
  108932. * @see http://doc.babylonjs.com/features/behaviour
  108933. * @param behavior defines the behavior to attach
  108934. * @returns the current Node
  108935. */
  108936. removeBehavior(behavior: Behavior<Node>): Node;
  108937. /**
  108938. * Gets the list of attached behaviors
  108939. * @see http://doc.babylonjs.com/features/behaviour
  108940. */
  108941. get behaviors(): Behavior<Node>[];
  108942. /**
  108943. * Gets an attached behavior by name
  108944. * @param name defines the name of the behavior to look for
  108945. * @see http://doc.babylonjs.com/features/behaviour
  108946. * @returns null if behavior was not found else the requested behavior
  108947. */
  108948. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  108949. /**
  108950. * Returns the latest update of the World matrix
  108951. * @returns a Matrix
  108952. */
  108953. getWorldMatrix(): Matrix;
  108954. /** @hidden */
  108955. _getWorldMatrixDeterminant(): number;
  108956. /**
  108957. * Returns directly the latest state of the mesh World matrix.
  108958. * A Matrix is returned.
  108959. */
  108960. get worldMatrixFromCache(): Matrix;
  108961. /** @hidden */
  108962. _initCache(): void;
  108963. /** @hidden */
  108964. updateCache(force?: boolean): void;
  108965. /** @hidden */
  108966. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  108967. /** @hidden */
  108968. _updateCache(ignoreParentClass?: boolean): void;
  108969. /** @hidden */
  108970. _isSynchronized(): boolean;
  108971. /** @hidden */
  108972. _markSyncedWithParent(): void;
  108973. /** @hidden */
  108974. isSynchronizedWithParent(): boolean;
  108975. /** @hidden */
  108976. isSynchronized(): boolean;
  108977. /**
  108978. * Is this node ready to be used/rendered
  108979. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  108980. * @return true if the node is ready
  108981. */
  108982. isReady(completeCheck?: boolean): boolean;
  108983. /**
  108984. * Is this node enabled?
  108985. * 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
  108986. * @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
  108987. * @return whether this node (and its parent) is enabled
  108988. */
  108989. isEnabled(checkAncestors?: boolean): boolean;
  108990. /** @hidden */
  108991. protected _syncParentEnabledState(): void;
  108992. /**
  108993. * Set the enabled state of this node
  108994. * @param value defines the new enabled state
  108995. */
  108996. setEnabled(value: boolean): void;
  108997. /**
  108998. * Is this node a descendant of the given node?
  108999. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  109000. * @param ancestor defines the parent node to inspect
  109001. * @returns a boolean indicating if this node is a descendant of the given node
  109002. */
  109003. isDescendantOf(ancestor: Node): boolean;
  109004. /** @hidden */
  109005. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  109006. /**
  109007. * Will return all nodes that have this node as ascendant
  109008. * @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
  109009. * @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
  109010. * @return all children nodes of all types
  109011. */
  109012. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  109013. /**
  109014. * Get all child-meshes of this node
  109015. * @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)
  109016. * @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
  109017. * @returns an array of AbstractMesh
  109018. */
  109019. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  109020. /**
  109021. * Get all direct children of this node
  109022. * @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
  109023. * @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)
  109024. * @returns an array of Node
  109025. */
  109026. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  109027. /** @hidden */
  109028. _setReady(state: boolean): void;
  109029. /**
  109030. * Get an animation by name
  109031. * @param name defines the name of the animation to look for
  109032. * @returns null if not found else the requested animation
  109033. */
  109034. getAnimationByName(name: string): Nullable<Animation>;
  109035. /**
  109036. * Creates an animation range for this node
  109037. * @param name defines the name of the range
  109038. * @param from defines the starting key
  109039. * @param to defines the end key
  109040. */
  109041. createAnimationRange(name: string, from: number, to: number): void;
  109042. /**
  109043. * Delete a specific animation range
  109044. * @param name defines the name of the range to delete
  109045. * @param deleteFrames defines if animation frames from the range must be deleted as well
  109046. */
  109047. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  109048. /**
  109049. * Get an animation range by name
  109050. * @param name defines the name of the animation range to look for
  109051. * @returns null if not found else the requested animation range
  109052. */
  109053. getAnimationRange(name: string): Nullable<AnimationRange>;
  109054. /**
  109055. * Gets the list of all animation ranges defined on this node
  109056. * @returns an array
  109057. */
  109058. getAnimationRanges(): Nullable<AnimationRange>[];
  109059. /**
  109060. * Will start the animation sequence
  109061. * @param name defines the range frames for animation sequence
  109062. * @param loop defines if the animation should loop (false by default)
  109063. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  109064. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  109065. * @returns the object created for this animation. If range does not exist, it will return null
  109066. */
  109067. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  109068. /**
  109069. * Serialize animation ranges into a JSON compatible object
  109070. * @returns serialization object
  109071. */
  109072. serializeAnimationRanges(): any;
  109073. /**
  109074. * Computes the world matrix of the node
  109075. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  109076. * @returns the world matrix
  109077. */
  109078. computeWorldMatrix(force?: boolean): Matrix;
  109079. /**
  109080. * Releases resources associated with this node.
  109081. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  109082. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  109083. */
  109084. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  109085. /**
  109086. * Parse animation range data from a serialization object and store them into a given node
  109087. * @param node defines where to store the animation ranges
  109088. * @param parsedNode defines the serialization object to read data from
  109089. * @param scene defines the hosting scene
  109090. */
  109091. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  109092. /**
  109093. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  109094. * @param includeDescendants Include bounding info from descendants as well (true by default)
  109095. * @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
  109096. * @returns the new bounding vectors
  109097. */
  109098. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  109099. min: Vector3;
  109100. max: Vector3;
  109101. };
  109102. }
  109103. }
  109104. declare module BABYLON {
  109105. /**
  109106. * @hidden
  109107. */
  109108. export class _IAnimationState {
  109109. key: number;
  109110. repeatCount: number;
  109111. workValue?: any;
  109112. loopMode?: number;
  109113. offsetValue?: any;
  109114. highLimitValue?: any;
  109115. }
  109116. /**
  109117. * Class used to store any kind of animation
  109118. */
  109119. export class Animation {
  109120. /**Name of the animation */
  109121. name: string;
  109122. /**Property to animate */
  109123. targetProperty: string;
  109124. /**The frames per second of the animation */
  109125. framePerSecond: number;
  109126. /**The data type of the animation */
  109127. dataType: number;
  109128. /**The loop mode of the animation */
  109129. loopMode?: number | undefined;
  109130. /**Specifies if blending should be enabled */
  109131. enableBlending?: boolean | undefined;
  109132. /**
  109133. * Use matrix interpolation instead of using direct key value when animating matrices
  109134. */
  109135. static AllowMatricesInterpolation: boolean;
  109136. /**
  109137. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  109138. */
  109139. static AllowMatrixDecomposeForInterpolation: boolean;
  109140. /**
  109141. * Stores the key frames of the animation
  109142. */
  109143. private _keys;
  109144. /**
  109145. * Stores the easing function of the animation
  109146. */
  109147. private _easingFunction;
  109148. /**
  109149. * @hidden Internal use only
  109150. */
  109151. _runtimeAnimations: RuntimeAnimation[];
  109152. /**
  109153. * The set of event that will be linked to this animation
  109154. */
  109155. private _events;
  109156. /**
  109157. * Stores an array of target property paths
  109158. */
  109159. targetPropertyPath: string[];
  109160. /**
  109161. * Stores the blending speed of the animation
  109162. */
  109163. blendingSpeed: number;
  109164. /**
  109165. * Stores the animation ranges for the animation
  109166. */
  109167. private _ranges;
  109168. /**
  109169. * @hidden Internal use
  109170. */
  109171. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  109172. /**
  109173. * Sets up an animation
  109174. * @param property The property to animate
  109175. * @param animationType The animation type to apply
  109176. * @param framePerSecond The frames per second of the animation
  109177. * @param easingFunction The easing function used in the animation
  109178. * @returns The created animation
  109179. */
  109180. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  109181. /**
  109182. * Create and start an animation on a node
  109183. * @param name defines the name of the global animation that will be run on all nodes
  109184. * @param node defines the root node where the animation will take place
  109185. * @param targetProperty defines property to animate
  109186. * @param framePerSecond defines the number of frame per second yo use
  109187. * @param totalFrame defines the number of frames in total
  109188. * @param from defines the initial value
  109189. * @param to defines the final value
  109190. * @param loopMode defines which loop mode you want to use (off by default)
  109191. * @param easingFunction defines the easing function to use (linear by default)
  109192. * @param onAnimationEnd defines the callback to call when animation end
  109193. * @returns the animatable created for this animation
  109194. */
  109195. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  109196. /**
  109197. * Create and start an animation on a node and its descendants
  109198. * @param name defines the name of the global animation that will be run on all nodes
  109199. * @param node defines the root node where the animation will take place
  109200. * @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
  109201. * @param targetProperty defines property to animate
  109202. * @param framePerSecond defines the number of frame per second to use
  109203. * @param totalFrame defines the number of frames in total
  109204. * @param from defines the initial value
  109205. * @param to defines the final value
  109206. * @param loopMode defines which loop mode you want to use (off by default)
  109207. * @param easingFunction defines the easing function to use (linear by default)
  109208. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  109209. * @returns the list of animatables created for all nodes
  109210. * @example https://www.babylonjs-playground.com/#MH0VLI
  109211. */
  109212. 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[]>;
  109213. /**
  109214. * Creates a new animation, merges it with the existing animations and starts it
  109215. * @param name Name of the animation
  109216. * @param node Node which contains the scene that begins the animations
  109217. * @param targetProperty Specifies which property to animate
  109218. * @param framePerSecond The frames per second of the animation
  109219. * @param totalFrame The total number of frames
  109220. * @param from The frame at the beginning of the animation
  109221. * @param to The frame at the end of the animation
  109222. * @param loopMode Specifies the loop mode of the animation
  109223. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  109224. * @param onAnimationEnd Callback to run once the animation is complete
  109225. * @returns Nullable animation
  109226. */
  109227. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  109228. /**
  109229. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  109230. * @param sourceAnimation defines the Animation containing keyframes to convert
  109231. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  109232. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  109233. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  109234. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  109235. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  109236. */
  109237. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  109238. /**
  109239. * Transition property of an host to the target Value
  109240. * @param property The property to transition
  109241. * @param targetValue The target Value of the property
  109242. * @param host The object where the property to animate belongs
  109243. * @param scene Scene used to run the animation
  109244. * @param frameRate Framerate (in frame/s) to use
  109245. * @param transition The transition type we want to use
  109246. * @param duration The duration of the animation, in milliseconds
  109247. * @param onAnimationEnd Callback trigger at the end of the animation
  109248. * @returns Nullable animation
  109249. */
  109250. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  109251. /**
  109252. * Return the array of runtime animations currently using this animation
  109253. */
  109254. get runtimeAnimations(): RuntimeAnimation[];
  109255. /**
  109256. * Specifies if any of the runtime animations are currently running
  109257. */
  109258. get hasRunningRuntimeAnimations(): boolean;
  109259. /**
  109260. * Initializes the animation
  109261. * @param name Name of the animation
  109262. * @param targetProperty Property to animate
  109263. * @param framePerSecond The frames per second of the animation
  109264. * @param dataType The data type of the animation
  109265. * @param loopMode The loop mode of the animation
  109266. * @param enableBlending Specifies if blending should be enabled
  109267. */
  109268. constructor(
  109269. /**Name of the animation */
  109270. name: string,
  109271. /**Property to animate */
  109272. targetProperty: string,
  109273. /**The frames per second of the animation */
  109274. framePerSecond: number,
  109275. /**The data type of the animation */
  109276. dataType: number,
  109277. /**The loop mode of the animation */
  109278. loopMode?: number | undefined,
  109279. /**Specifies if blending should be enabled */
  109280. enableBlending?: boolean | undefined);
  109281. /**
  109282. * Converts the animation to a string
  109283. * @param fullDetails support for multiple levels of logging within scene loading
  109284. * @returns String form of the animation
  109285. */
  109286. toString(fullDetails?: boolean): string;
  109287. /**
  109288. * Add an event to this animation
  109289. * @param event Event to add
  109290. */
  109291. addEvent(event: AnimationEvent): void;
  109292. /**
  109293. * Remove all events found at the given frame
  109294. * @param frame The frame to remove events from
  109295. */
  109296. removeEvents(frame: number): void;
  109297. /**
  109298. * Retrieves all the events from the animation
  109299. * @returns Events from the animation
  109300. */
  109301. getEvents(): AnimationEvent[];
  109302. /**
  109303. * Creates an animation range
  109304. * @param name Name of the animation range
  109305. * @param from Starting frame of the animation range
  109306. * @param to Ending frame of the animation
  109307. */
  109308. createRange(name: string, from: number, to: number): void;
  109309. /**
  109310. * Deletes an animation range by name
  109311. * @param name Name of the animation range to delete
  109312. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  109313. */
  109314. deleteRange(name: string, deleteFrames?: boolean): void;
  109315. /**
  109316. * Gets the animation range by name, or null if not defined
  109317. * @param name Name of the animation range
  109318. * @returns Nullable animation range
  109319. */
  109320. getRange(name: string): Nullable<AnimationRange>;
  109321. /**
  109322. * Gets the key frames from the animation
  109323. * @returns The key frames of the animation
  109324. */
  109325. getKeys(): Array<IAnimationKey>;
  109326. /**
  109327. * Gets the highest frame rate of the animation
  109328. * @returns Highest frame rate of the animation
  109329. */
  109330. getHighestFrame(): number;
  109331. /**
  109332. * Gets the easing function of the animation
  109333. * @returns Easing function of the animation
  109334. */
  109335. getEasingFunction(): IEasingFunction;
  109336. /**
  109337. * Sets the easing function of the animation
  109338. * @param easingFunction A custom mathematical formula for animation
  109339. */
  109340. setEasingFunction(easingFunction: EasingFunction): void;
  109341. /**
  109342. * Interpolates a scalar linearly
  109343. * @param startValue Start value of the animation curve
  109344. * @param endValue End value of the animation curve
  109345. * @param gradient Scalar amount to interpolate
  109346. * @returns Interpolated scalar value
  109347. */
  109348. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  109349. /**
  109350. * Interpolates a scalar cubically
  109351. * @param startValue Start value of the animation curve
  109352. * @param outTangent End tangent of the animation
  109353. * @param endValue End value of the animation curve
  109354. * @param inTangent Start tangent of the animation curve
  109355. * @param gradient Scalar amount to interpolate
  109356. * @returns Interpolated scalar value
  109357. */
  109358. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  109359. /**
  109360. * Interpolates a quaternion using a spherical linear interpolation
  109361. * @param startValue Start value of the animation curve
  109362. * @param endValue End value of the animation curve
  109363. * @param gradient Scalar amount to interpolate
  109364. * @returns Interpolated quaternion value
  109365. */
  109366. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  109367. /**
  109368. * Interpolates a quaternion cubically
  109369. * @param startValue Start value of the animation curve
  109370. * @param outTangent End tangent of the animation curve
  109371. * @param endValue End value of the animation curve
  109372. * @param inTangent Start tangent of the animation curve
  109373. * @param gradient Scalar amount to interpolate
  109374. * @returns Interpolated quaternion value
  109375. */
  109376. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  109377. /**
  109378. * Interpolates a Vector3 linearl
  109379. * @param startValue Start value of the animation curve
  109380. * @param endValue End value of the animation curve
  109381. * @param gradient Scalar amount to interpolate
  109382. * @returns Interpolated scalar value
  109383. */
  109384. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  109385. /**
  109386. * Interpolates a Vector3 cubically
  109387. * @param startValue Start value of the animation curve
  109388. * @param outTangent End tangent of the animation
  109389. * @param endValue End value of the animation curve
  109390. * @param inTangent Start tangent of the animation curve
  109391. * @param gradient Scalar amount to interpolate
  109392. * @returns InterpolatedVector3 value
  109393. */
  109394. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  109395. /**
  109396. * Interpolates a Vector2 linearly
  109397. * @param startValue Start value of the animation curve
  109398. * @param endValue End value of the animation curve
  109399. * @param gradient Scalar amount to interpolate
  109400. * @returns Interpolated Vector2 value
  109401. */
  109402. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  109403. /**
  109404. * Interpolates a Vector2 cubically
  109405. * @param startValue Start value of the animation curve
  109406. * @param outTangent End tangent of the animation
  109407. * @param endValue End value of the animation curve
  109408. * @param inTangent Start tangent of the animation curve
  109409. * @param gradient Scalar amount to interpolate
  109410. * @returns Interpolated Vector2 value
  109411. */
  109412. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  109413. /**
  109414. * Interpolates a size linearly
  109415. * @param startValue Start value of the animation curve
  109416. * @param endValue End value of the animation curve
  109417. * @param gradient Scalar amount to interpolate
  109418. * @returns Interpolated Size value
  109419. */
  109420. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  109421. /**
  109422. * Interpolates a Color3 linearly
  109423. * @param startValue Start value of the animation curve
  109424. * @param endValue End value of the animation curve
  109425. * @param gradient Scalar amount to interpolate
  109426. * @returns Interpolated Color3 value
  109427. */
  109428. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  109429. /**
  109430. * Interpolates a Color4 linearly
  109431. * @param startValue Start value of the animation curve
  109432. * @param endValue End value of the animation curve
  109433. * @param gradient Scalar amount to interpolate
  109434. * @returns Interpolated Color3 value
  109435. */
  109436. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  109437. /**
  109438. * @hidden Internal use only
  109439. */
  109440. _getKeyValue(value: any): any;
  109441. /**
  109442. * @hidden Internal use only
  109443. */
  109444. _interpolate(currentFrame: number, state: _IAnimationState): any;
  109445. /**
  109446. * Defines the function to use to interpolate matrices
  109447. * @param startValue defines the start matrix
  109448. * @param endValue defines the end matrix
  109449. * @param gradient defines the gradient between both matrices
  109450. * @param result defines an optional target matrix where to store the interpolation
  109451. * @returns the interpolated matrix
  109452. */
  109453. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  109454. /**
  109455. * Makes a copy of the animation
  109456. * @returns Cloned animation
  109457. */
  109458. clone(): Animation;
  109459. /**
  109460. * Sets the key frames of the animation
  109461. * @param values The animation key frames to set
  109462. */
  109463. setKeys(values: Array<IAnimationKey>): void;
  109464. /**
  109465. * Serializes the animation to an object
  109466. * @returns Serialized object
  109467. */
  109468. serialize(): any;
  109469. /**
  109470. * Float animation type
  109471. */
  109472. static readonly ANIMATIONTYPE_FLOAT: number;
  109473. /**
  109474. * Vector3 animation type
  109475. */
  109476. static readonly ANIMATIONTYPE_VECTOR3: number;
  109477. /**
  109478. * Quaternion animation type
  109479. */
  109480. static readonly ANIMATIONTYPE_QUATERNION: number;
  109481. /**
  109482. * Matrix animation type
  109483. */
  109484. static readonly ANIMATIONTYPE_MATRIX: number;
  109485. /**
  109486. * Color3 animation type
  109487. */
  109488. static readonly ANIMATIONTYPE_COLOR3: number;
  109489. /**
  109490. * Color3 animation type
  109491. */
  109492. static readonly ANIMATIONTYPE_COLOR4: number;
  109493. /**
  109494. * Vector2 animation type
  109495. */
  109496. static readonly ANIMATIONTYPE_VECTOR2: number;
  109497. /**
  109498. * Size animation type
  109499. */
  109500. static readonly ANIMATIONTYPE_SIZE: number;
  109501. /**
  109502. * Relative Loop Mode
  109503. */
  109504. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  109505. /**
  109506. * Cycle Loop Mode
  109507. */
  109508. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  109509. /**
  109510. * Constant Loop Mode
  109511. */
  109512. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  109513. /** @hidden */
  109514. static _UniversalLerp(left: any, right: any, amount: number): any;
  109515. /**
  109516. * Parses an animation object and creates an animation
  109517. * @param parsedAnimation Parsed animation object
  109518. * @returns Animation object
  109519. */
  109520. static Parse(parsedAnimation: any): Animation;
  109521. /**
  109522. * Appends the serialized animations from the source animations
  109523. * @param source Source containing the animations
  109524. * @param destination Target to store the animations
  109525. */
  109526. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  109527. }
  109528. }
  109529. declare module BABYLON {
  109530. /**
  109531. * Interface containing an array of animations
  109532. */
  109533. export interface IAnimatable {
  109534. /**
  109535. * Array of animations
  109536. */
  109537. animations: Nullable<Array<Animation>>;
  109538. }
  109539. }
  109540. declare module BABYLON {
  109541. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  109542. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  109543. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  109544. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  109545. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  109546. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  109547. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  109548. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  109549. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  109550. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  109551. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  109552. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  109553. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  109554. /**
  109555. * Decorator used to define property that can be serialized as reference to a camera
  109556. * @param sourceName defines the name of the property to decorate
  109557. */
  109558. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  109559. /**
  109560. * Class used to help serialization objects
  109561. */
  109562. export class SerializationHelper {
  109563. /** @hidden */
  109564. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  109565. /** @hidden */
  109566. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  109567. /** @hidden */
  109568. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  109569. /** @hidden */
  109570. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  109571. /**
  109572. * Appends the serialized animations from the source animations
  109573. * @param source Source containing the animations
  109574. * @param destination Target to store the animations
  109575. */
  109576. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  109577. /**
  109578. * Static function used to serialized a specific entity
  109579. * @param entity defines the entity to serialize
  109580. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  109581. * @returns a JSON compatible object representing the serialization of the entity
  109582. */
  109583. static Serialize<T>(entity: T, serializationObject?: any): any;
  109584. /**
  109585. * Creates a new entity from a serialization data object
  109586. * @param creationFunction defines a function used to instanciated the new entity
  109587. * @param source defines the source serialization data
  109588. * @param scene defines the hosting scene
  109589. * @param rootUrl defines the root url for resources
  109590. * @returns a new entity
  109591. */
  109592. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  109593. /**
  109594. * Clones an object
  109595. * @param creationFunction defines the function used to instanciate the new object
  109596. * @param source defines the source object
  109597. * @returns the cloned object
  109598. */
  109599. static Clone<T>(creationFunction: () => T, source: T): T;
  109600. /**
  109601. * Instanciates a new object based on a source one (some data will be shared between both object)
  109602. * @param creationFunction defines the function used to instanciate the new object
  109603. * @param source defines the source object
  109604. * @returns the new object
  109605. */
  109606. static Instanciate<T>(creationFunction: () => T, source: T): T;
  109607. }
  109608. }
  109609. declare module BABYLON {
  109610. /**
  109611. * Base class of all the textures in babylon.
  109612. * It groups all the common properties the materials, post process, lights... might need
  109613. * in order to make a correct use of the texture.
  109614. */
  109615. export class BaseTexture implements IAnimatable {
  109616. /**
  109617. * Default anisotropic filtering level for the application.
  109618. * It is set to 4 as a good tradeoff between perf and quality.
  109619. */
  109620. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  109621. /**
  109622. * Gets or sets the unique id of the texture
  109623. */
  109624. uniqueId: number;
  109625. /**
  109626. * Define the name of the texture.
  109627. */
  109628. name: string;
  109629. /**
  109630. * Gets or sets an object used to store user defined information.
  109631. */
  109632. metadata: any;
  109633. /**
  109634. * For internal use only. Please do not use.
  109635. */
  109636. reservedDataStore: any;
  109637. private _hasAlpha;
  109638. /**
  109639. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  109640. */
  109641. set hasAlpha(value: boolean);
  109642. get hasAlpha(): boolean;
  109643. /**
  109644. * Defines if the alpha value should be determined via the rgb values.
  109645. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  109646. */
  109647. getAlphaFromRGB: boolean;
  109648. /**
  109649. * Intensity or strength of the texture.
  109650. * It is commonly used by materials to fine tune the intensity of the texture
  109651. */
  109652. level: number;
  109653. /**
  109654. * Define the UV chanel to use starting from 0 and defaulting to 0.
  109655. * This is part of the texture as textures usually maps to one uv set.
  109656. */
  109657. coordinatesIndex: number;
  109658. private _coordinatesMode;
  109659. /**
  109660. * How a texture is mapped.
  109661. *
  109662. * | Value | Type | Description |
  109663. * | ----- | ----------------------------------- | ----------- |
  109664. * | 0 | EXPLICIT_MODE | |
  109665. * | 1 | SPHERICAL_MODE | |
  109666. * | 2 | PLANAR_MODE | |
  109667. * | 3 | CUBIC_MODE | |
  109668. * | 4 | PROJECTION_MODE | |
  109669. * | 5 | SKYBOX_MODE | |
  109670. * | 6 | INVCUBIC_MODE | |
  109671. * | 7 | EQUIRECTANGULAR_MODE | |
  109672. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  109673. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  109674. */
  109675. set coordinatesMode(value: number);
  109676. get coordinatesMode(): number;
  109677. /**
  109678. * | Value | Type | Description |
  109679. * | ----- | ------------------ | ----------- |
  109680. * | 0 | CLAMP_ADDRESSMODE | |
  109681. * | 1 | WRAP_ADDRESSMODE | |
  109682. * | 2 | MIRROR_ADDRESSMODE | |
  109683. */
  109684. wrapU: number;
  109685. /**
  109686. * | Value | Type | Description |
  109687. * | ----- | ------------------ | ----------- |
  109688. * | 0 | CLAMP_ADDRESSMODE | |
  109689. * | 1 | WRAP_ADDRESSMODE | |
  109690. * | 2 | MIRROR_ADDRESSMODE | |
  109691. */
  109692. wrapV: number;
  109693. /**
  109694. * | Value | Type | Description |
  109695. * | ----- | ------------------ | ----------- |
  109696. * | 0 | CLAMP_ADDRESSMODE | |
  109697. * | 1 | WRAP_ADDRESSMODE | |
  109698. * | 2 | MIRROR_ADDRESSMODE | |
  109699. */
  109700. wrapR: number;
  109701. /**
  109702. * With compliant hardware and browser (supporting anisotropic filtering)
  109703. * this defines the level of anisotropic filtering in the texture.
  109704. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  109705. */
  109706. anisotropicFilteringLevel: number;
  109707. /**
  109708. * Define if the texture is a cube texture or if false a 2d texture.
  109709. */
  109710. get isCube(): boolean;
  109711. set isCube(value: boolean);
  109712. /**
  109713. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  109714. */
  109715. get is3D(): boolean;
  109716. set is3D(value: boolean);
  109717. /**
  109718. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  109719. */
  109720. get is2DArray(): boolean;
  109721. set is2DArray(value: boolean);
  109722. /**
  109723. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  109724. * HDR texture are usually stored in linear space.
  109725. * This only impacts the PBR and Background materials
  109726. */
  109727. gammaSpace: boolean;
  109728. /**
  109729. * Gets or sets whether or not the texture contains RGBD data.
  109730. */
  109731. get isRGBD(): boolean;
  109732. set isRGBD(value: boolean);
  109733. /**
  109734. * Is Z inverted in the texture (useful in a cube texture).
  109735. */
  109736. invertZ: boolean;
  109737. /**
  109738. * Are mip maps generated for this texture or not.
  109739. */
  109740. get noMipmap(): boolean;
  109741. /**
  109742. * @hidden
  109743. */
  109744. lodLevelInAlpha: boolean;
  109745. /**
  109746. * With prefiltered texture, defined the offset used during the prefiltering steps.
  109747. */
  109748. get lodGenerationOffset(): number;
  109749. set lodGenerationOffset(value: number);
  109750. /**
  109751. * With prefiltered texture, defined the scale used during the prefiltering steps.
  109752. */
  109753. get lodGenerationScale(): number;
  109754. set lodGenerationScale(value: number);
  109755. /**
  109756. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  109757. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  109758. * average roughness values.
  109759. */
  109760. get linearSpecularLOD(): boolean;
  109761. set linearSpecularLOD(value: boolean);
  109762. /**
  109763. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  109764. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  109765. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  109766. */
  109767. get irradianceTexture(): Nullable<BaseTexture>;
  109768. set irradianceTexture(value: Nullable<BaseTexture>);
  109769. /**
  109770. * Define if the texture is a render target.
  109771. */
  109772. isRenderTarget: boolean;
  109773. /**
  109774. * Define the unique id of the texture in the scene.
  109775. */
  109776. get uid(): string;
  109777. /** @hidden */
  109778. _prefiltered: boolean;
  109779. /**
  109780. * Return a string representation of the texture.
  109781. * @returns the texture as a string
  109782. */
  109783. toString(): string;
  109784. /**
  109785. * Get the class name of the texture.
  109786. * @returns "BaseTexture"
  109787. */
  109788. getClassName(): string;
  109789. /**
  109790. * Define the list of animation attached to the texture.
  109791. */
  109792. animations: Animation[];
  109793. /**
  109794. * An event triggered when the texture is disposed.
  109795. */
  109796. onDisposeObservable: Observable<BaseTexture>;
  109797. private _onDisposeObserver;
  109798. /**
  109799. * Callback triggered when the texture has been disposed.
  109800. * Kept for back compatibility, you can use the onDisposeObservable instead.
  109801. */
  109802. set onDispose(callback: () => void);
  109803. /**
  109804. * Define the current state of the loading sequence when in delayed load mode.
  109805. */
  109806. delayLoadState: number;
  109807. private _scene;
  109808. private _engine;
  109809. /** @hidden */
  109810. _texture: Nullable<InternalTexture>;
  109811. private _uid;
  109812. /**
  109813. * Define if the texture is preventinga material to render or not.
  109814. * If not and the texture is not ready, the engine will use a default black texture instead.
  109815. */
  109816. get isBlocking(): boolean;
  109817. /**
  109818. * Instantiates a new BaseTexture.
  109819. * Base class of all the textures in babylon.
  109820. * It groups all the common properties the materials, post process, lights... might need
  109821. * in order to make a correct use of the texture.
  109822. * @param sceneOrEngine Define the scene or engine the texture blongs to
  109823. */
  109824. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  109825. /**
  109826. * Get the scene the texture belongs to.
  109827. * @returns the scene or null if undefined
  109828. */
  109829. getScene(): Nullable<Scene>;
  109830. /** @hidden */
  109831. protected _getEngine(): Nullable<ThinEngine>;
  109832. /**
  109833. * Get the texture transform matrix used to offset tile the texture for istance.
  109834. * @returns the transformation matrix
  109835. */
  109836. getTextureMatrix(): Matrix;
  109837. /**
  109838. * Get the texture reflection matrix used to rotate/transform the reflection.
  109839. * @returns the reflection matrix
  109840. */
  109841. getReflectionTextureMatrix(): Matrix;
  109842. /**
  109843. * Get the underlying lower level texture from Babylon.
  109844. * @returns the insternal texture
  109845. */
  109846. getInternalTexture(): Nullable<InternalTexture>;
  109847. /**
  109848. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  109849. * @returns true if ready or not blocking
  109850. */
  109851. isReadyOrNotBlocking(): boolean;
  109852. /**
  109853. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  109854. * @returns true if fully ready
  109855. */
  109856. isReady(): boolean;
  109857. private _cachedSize;
  109858. /**
  109859. * Get the size of the texture.
  109860. * @returns the texture size.
  109861. */
  109862. getSize(): ISize;
  109863. /**
  109864. * Get the base size of the texture.
  109865. * It can be different from the size if the texture has been resized for POT for instance
  109866. * @returns the base size
  109867. */
  109868. getBaseSize(): ISize;
  109869. /**
  109870. * Update the sampling mode of the texture.
  109871. * Default is Trilinear mode.
  109872. *
  109873. * | Value | Type | Description |
  109874. * | ----- | ------------------ | ----------- |
  109875. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  109876. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  109877. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  109878. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  109879. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  109880. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  109881. * | 7 | NEAREST_LINEAR | |
  109882. * | 8 | NEAREST_NEAREST | |
  109883. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  109884. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  109885. * | 11 | LINEAR_LINEAR | |
  109886. * | 12 | LINEAR_NEAREST | |
  109887. *
  109888. * > _mag_: magnification filter (close to the viewer)
  109889. * > _min_: minification filter (far from the viewer)
  109890. * > _mip_: filter used between mip map levels
  109891. *@param samplingMode Define the new sampling mode of the texture
  109892. */
  109893. updateSamplingMode(samplingMode: number): void;
  109894. /**
  109895. * Scales the texture if is `canRescale()`
  109896. * @param ratio the resize factor we want to use to rescale
  109897. */
  109898. scale(ratio: number): void;
  109899. /**
  109900. * Get if the texture can rescale.
  109901. */
  109902. get canRescale(): boolean;
  109903. /** @hidden */
  109904. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  109905. /** @hidden */
  109906. _rebuild(): void;
  109907. /**
  109908. * Triggers the load sequence in delayed load mode.
  109909. */
  109910. delayLoad(): void;
  109911. /**
  109912. * Clones the texture.
  109913. * @returns the cloned texture
  109914. */
  109915. clone(): Nullable<BaseTexture>;
  109916. /**
  109917. * Get the texture underlying type (INT, FLOAT...)
  109918. */
  109919. get textureType(): number;
  109920. /**
  109921. * Get the texture underlying format (RGB, RGBA...)
  109922. */
  109923. get textureFormat(): number;
  109924. /**
  109925. * Indicates that textures need to be re-calculated for all materials
  109926. */
  109927. protected _markAllSubMeshesAsTexturesDirty(): void;
  109928. /**
  109929. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  109930. * This will returns an RGBA array buffer containing either in values (0-255) or
  109931. * float values (0-1) depending of the underlying buffer type.
  109932. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  109933. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  109934. * @param buffer defines a user defined buffer to fill with data (can be null)
  109935. * @returns The Array buffer containing the pixels data.
  109936. */
  109937. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  109938. /**
  109939. * Release and destroy the underlying lower level texture aka internalTexture.
  109940. */
  109941. releaseInternalTexture(): void;
  109942. /** @hidden */
  109943. get _lodTextureHigh(): Nullable<BaseTexture>;
  109944. /** @hidden */
  109945. get _lodTextureMid(): Nullable<BaseTexture>;
  109946. /** @hidden */
  109947. get _lodTextureLow(): Nullable<BaseTexture>;
  109948. /**
  109949. * Dispose the texture and release its associated resources.
  109950. */
  109951. dispose(): void;
  109952. /**
  109953. * Serialize the texture into a JSON representation that can be parsed later on.
  109954. * @returns the JSON representation of the texture
  109955. */
  109956. serialize(): any;
  109957. /**
  109958. * Helper function to be called back once a list of texture contains only ready textures.
  109959. * @param textures Define the list of textures to wait for
  109960. * @param callback Define the callback triggered once the entire list will be ready
  109961. */
  109962. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  109963. private static _isScene;
  109964. }
  109965. }
  109966. declare module BABYLON {
  109967. /**
  109968. * Options to be used when creating an effect.
  109969. */
  109970. export interface IEffectCreationOptions {
  109971. /**
  109972. * Atrributes that will be used in the shader.
  109973. */
  109974. attributes: string[];
  109975. /**
  109976. * Uniform varible names that will be set in the shader.
  109977. */
  109978. uniformsNames: string[];
  109979. /**
  109980. * Uniform buffer variable names that will be set in the shader.
  109981. */
  109982. uniformBuffersNames: string[];
  109983. /**
  109984. * Sampler texture variable names that will be set in the shader.
  109985. */
  109986. samplers: string[];
  109987. /**
  109988. * Define statements that will be set in the shader.
  109989. */
  109990. defines: any;
  109991. /**
  109992. * Possible fallbacks for this effect to improve performance when needed.
  109993. */
  109994. fallbacks: Nullable<IEffectFallbacks>;
  109995. /**
  109996. * Callback that will be called when the shader is compiled.
  109997. */
  109998. onCompiled: Nullable<(effect: Effect) => void>;
  109999. /**
  110000. * Callback that will be called if an error occurs during shader compilation.
  110001. */
  110002. onError: Nullable<(effect: Effect, errors: string) => void>;
  110003. /**
  110004. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  110005. */
  110006. indexParameters?: any;
  110007. /**
  110008. * Max number of lights that can be used in the shader.
  110009. */
  110010. maxSimultaneousLights?: number;
  110011. /**
  110012. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  110013. */
  110014. transformFeedbackVaryings?: Nullable<string[]>;
  110015. }
  110016. /**
  110017. * Effect containing vertex and fragment shader that can be executed on an object.
  110018. */
  110019. export class Effect implements IDisposable {
  110020. /**
  110021. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  110022. */
  110023. static ShadersRepository: string;
  110024. /**
  110025. * Enable logging of the shader code when a compilation error occurs
  110026. */
  110027. static LogShaderCodeOnCompilationError: boolean;
  110028. /**
  110029. * Name of the effect.
  110030. */
  110031. name: any;
  110032. /**
  110033. * String container all the define statements that should be set on the shader.
  110034. */
  110035. defines: string;
  110036. /**
  110037. * Callback that will be called when the shader is compiled.
  110038. */
  110039. onCompiled: Nullable<(effect: Effect) => void>;
  110040. /**
  110041. * Callback that will be called if an error occurs during shader compilation.
  110042. */
  110043. onError: Nullable<(effect: Effect, errors: string) => void>;
  110044. /**
  110045. * Callback that will be called when effect is bound.
  110046. */
  110047. onBind: Nullable<(effect: Effect) => void>;
  110048. /**
  110049. * Unique ID of the effect.
  110050. */
  110051. uniqueId: number;
  110052. /**
  110053. * Observable that will be called when the shader is compiled.
  110054. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  110055. */
  110056. onCompileObservable: Observable<Effect>;
  110057. /**
  110058. * Observable that will be called if an error occurs during shader compilation.
  110059. */
  110060. onErrorObservable: Observable<Effect>;
  110061. /** @hidden */
  110062. _onBindObservable: Nullable<Observable<Effect>>;
  110063. /**
  110064. * @hidden
  110065. * Specifies if the effect was previously ready
  110066. */
  110067. _wasPreviouslyReady: boolean;
  110068. /**
  110069. * Observable that will be called when effect is bound.
  110070. */
  110071. get onBindObservable(): Observable<Effect>;
  110072. /** @hidden */
  110073. _bonesComputationForcedToCPU: boolean;
  110074. private static _uniqueIdSeed;
  110075. private _engine;
  110076. private _uniformBuffersNames;
  110077. private _uniformBuffersNamesList;
  110078. private _uniformsNames;
  110079. private _samplerList;
  110080. private _samplers;
  110081. private _isReady;
  110082. private _compilationError;
  110083. private _allFallbacksProcessed;
  110084. private _attributesNames;
  110085. private _attributes;
  110086. private _attributeLocationByName;
  110087. private _uniforms;
  110088. /**
  110089. * Key for the effect.
  110090. * @hidden
  110091. */
  110092. _key: string;
  110093. private _indexParameters;
  110094. private _fallbacks;
  110095. private _vertexSourceCode;
  110096. private _fragmentSourceCode;
  110097. private _vertexSourceCodeOverride;
  110098. private _fragmentSourceCodeOverride;
  110099. private _transformFeedbackVaryings;
  110100. /**
  110101. * Compiled shader to webGL program.
  110102. * @hidden
  110103. */
  110104. _pipelineContext: Nullable<IPipelineContext>;
  110105. private _valueCache;
  110106. private static _baseCache;
  110107. /**
  110108. * Instantiates an effect.
  110109. * An effect can be used to create/manage/execute vertex and fragment shaders.
  110110. * @param baseName Name of the effect.
  110111. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  110112. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  110113. * @param samplers List of sampler variables that will be passed to the shader.
  110114. * @param engine Engine to be used to render the effect
  110115. * @param defines Define statements to be added to the shader.
  110116. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  110117. * @param onCompiled Callback that will be called when the shader is compiled.
  110118. * @param onError Callback that will be called if an error occurs during shader compilation.
  110119. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  110120. */
  110121. 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);
  110122. private _useFinalCode;
  110123. /**
  110124. * Unique key for this effect
  110125. */
  110126. get key(): string;
  110127. /**
  110128. * If the effect has been compiled and prepared.
  110129. * @returns if the effect is compiled and prepared.
  110130. */
  110131. isReady(): boolean;
  110132. private _isReadyInternal;
  110133. /**
  110134. * The engine the effect was initialized with.
  110135. * @returns the engine.
  110136. */
  110137. getEngine(): Engine;
  110138. /**
  110139. * The pipeline context for this effect
  110140. * @returns the associated pipeline context
  110141. */
  110142. getPipelineContext(): Nullable<IPipelineContext>;
  110143. /**
  110144. * The set of names of attribute variables for the shader.
  110145. * @returns An array of attribute names.
  110146. */
  110147. getAttributesNames(): string[];
  110148. /**
  110149. * Returns the attribute at the given index.
  110150. * @param index The index of the attribute.
  110151. * @returns The location of the attribute.
  110152. */
  110153. getAttributeLocation(index: number): number;
  110154. /**
  110155. * Returns the attribute based on the name of the variable.
  110156. * @param name of the attribute to look up.
  110157. * @returns the attribute location.
  110158. */
  110159. getAttributeLocationByName(name: string): number;
  110160. /**
  110161. * The number of attributes.
  110162. * @returns the numnber of attributes.
  110163. */
  110164. getAttributesCount(): number;
  110165. /**
  110166. * Gets the index of a uniform variable.
  110167. * @param uniformName of the uniform to look up.
  110168. * @returns the index.
  110169. */
  110170. getUniformIndex(uniformName: string): number;
  110171. /**
  110172. * Returns the attribute based on the name of the variable.
  110173. * @param uniformName of the uniform to look up.
  110174. * @returns the location of the uniform.
  110175. */
  110176. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  110177. /**
  110178. * Returns an array of sampler variable names
  110179. * @returns The array of sampler variable names.
  110180. */
  110181. getSamplers(): string[];
  110182. /**
  110183. * Returns an array of uniform variable names
  110184. * @returns The array of uniform variable names.
  110185. */
  110186. getUniformNames(): string[];
  110187. /**
  110188. * Returns an array of uniform buffer variable names
  110189. * @returns The array of uniform buffer variable names.
  110190. */
  110191. getUniformBuffersNames(): string[];
  110192. /**
  110193. * Returns the index parameters used to create the effect
  110194. * @returns The index parameters object
  110195. */
  110196. getIndexParameters(): any;
  110197. /**
  110198. * The error from the last compilation.
  110199. * @returns the error string.
  110200. */
  110201. getCompilationError(): string;
  110202. /**
  110203. * Gets a boolean indicating that all fallbacks were used during compilation
  110204. * @returns true if all fallbacks were used
  110205. */
  110206. allFallbacksProcessed(): boolean;
  110207. /**
  110208. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  110209. * @param func The callback to be used.
  110210. */
  110211. executeWhenCompiled(func: (effect: Effect) => void): void;
  110212. private _checkIsReady;
  110213. private _loadShader;
  110214. /**
  110215. * Gets the vertex shader source code of this effect
  110216. */
  110217. get vertexSourceCode(): string;
  110218. /**
  110219. * Gets the fragment shader source code of this effect
  110220. */
  110221. get fragmentSourceCode(): string;
  110222. /**
  110223. * Recompiles the webGL program
  110224. * @param vertexSourceCode The source code for the vertex shader.
  110225. * @param fragmentSourceCode The source code for the fragment shader.
  110226. * @param onCompiled Callback called when completed.
  110227. * @param onError Callback called on error.
  110228. * @hidden
  110229. */
  110230. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  110231. /**
  110232. * Prepares the effect
  110233. * @hidden
  110234. */
  110235. _prepareEffect(): void;
  110236. private _getShaderCodeAndErrorLine;
  110237. private _processCompilationErrors;
  110238. /**
  110239. * Checks if the effect is supported. (Must be called after compilation)
  110240. */
  110241. get isSupported(): boolean;
  110242. /**
  110243. * Binds a texture to the engine to be used as output of the shader.
  110244. * @param channel Name of the output variable.
  110245. * @param texture Texture to bind.
  110246. * @hidden
  110247. */
  110248. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  110249. /**
  110250. * Sets a texture on the engine to be used in the shader.
  110251. * @param channel Name of the sampler variable.
  110252. * @param texture Texture to set.
  110253. */
  110254. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  110255. /**
  110256. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  110257. * @param channel Name of the sampler variable.
  110258. * @param texture Texture to set.
  110259. */
  110260. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  110261. /**
  110262. * Sets an array of textures on the engine to be used in the shader.
  110263. * @param channel Name of the variable.
  110264. * @param textures Textures to set.
  110265. */
  110266. setTextureArray(channel: string, textures: BaseTexture[]): void;
  110267. /**
  110268. * 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)
  110269. * @param channel Name of the sampler variable.
  110270. * @param postProcess Post process to get the input texture from.
  110271. */
  110272. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  110273. /**
  110274. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  110275. * 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)
  110276. * @param channel Name of the sampler variable.
  110277. * @param postProcess Post process to get the output texture from.
  110278. */
  110279. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  110280. /** @hidden */
  110281. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  110282. /** @hidden */
  110283. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  110284. /** @hidden */
  110285. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  110286. /** @hidden */
  110287. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  110288. /**
  110289. * Binds a buffer to a uniform.
  110290. * @param buffer Buffer to bind.
  110291. * @param name Name of the uniform variable to bind to.
  110292. */
  110293. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  110294. /**
  110295. * Binds block to a uniform.
  110296. * @param blockName Name of the block to bind.
  110297. * @param index Index to bind.
  110298. */
  110299. bindUniformBlock(blockName: string, index: number): void;
  110300. /**
  110301. * Sets an interger value on a uniform variable.
  110302. * @param uniformName Name of the variable.
  110303. * @param value Value to be set.
  110304. * @returns this effect.
  110305. */
  110306. setInt(uniformName: string, value: number): Effect;
  110307. /**
  110308. * Sets an int array on a uniform variable.
  110309. * @param uniformName Name of the variable.
  110310. * @param array array to be set.
  110311. * @returns this effect.
  110312. */
  110313. setIntArray(uniformName: string, array: Int32Array): Effect;
  110314. /**
  110315. * 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)
  110316. * @param uniformName Name of the variable.
  110317. * @param array array to be set.
  110318. * @returns this effect.
  110319. */
  110320. setIntArray2(uniformName: string, array: Int32Array): Effect;
  110321. /**
  110322. * 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)
  110323. * @param uniformName Name of the variable.
  110324. * @param array array to be set.
  110325. * @returns this effect.
  110326. */
  110327. setIntArray3(uniformName: string, array: Int32Array): Effect;
  110328. /**
  110329. * 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)
  110330. * @param uniformName Name of the variable.
  110331. * @param array array to be set.
  110332. * @returns this effect.
  110333. */
  110334. setIntArray4(uniformName: string, array: Int32Array): Effect;
  110335. /**
  110336. * Sets an float array on a uniform variable.
  110337. * @param uniformName Name of the variable.
  110338. * @param array array to be set.
  110339. * @returns this effect.
  110340. */
  110341. setFloatArray(uniformName: string, array: Float32Array): Effect;
  110342. /**
  110343. * 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)
  110344. * @param uniformName Name of the variable.
  110345. * @param array array to be set.
  110346. * @returns this effect.
  110347. */
  110348. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  110349. /**
  110350. * 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)
  110351. * @param uniformName Name of the variable.
  110352. * @param array array to be set.
  110353. * @returns this effect.
  110354. */
  110355. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  110356. /**
  110357. * 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)
  110358. * @param uniformName Name of the variable.
  110359. * @param array array to be set.
  110360. * @returns this effect.
  110361. */
  110362. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  110363. /**
  110364. * Sets an array on a uniform variable.
  110365. * @param uniformName Name of the variable.
  110366. * @param array array to be set.
  110367. * @returns this effect.
  110368. */
  110369. setArray(uniformName: string, array: number[]): Effect;
  110370. /**
  110371. * 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)
  110372. * @param uniformName Name of the variable.
  110373. * @param array array to be set.
  110374. * @returns this effect.
  110375. */
  110376. setArray2(uniformName: string, array: number[]): Effect;
  110377. /**
  110378. * 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)
  110379. * @param uniformName Name of the variable.
  110380. * @param array array to be set.
  110381. * @returns this effect.
  110382. */
  110383. setArray3(uniformName: string, array: number[]): Effect;
  110384. /**
  110385. * 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)
  110386. * @param uniformName Name of the variable.
  110387. * @param array array to be set.
  110388. * @returns this effect.
  110389. */
  110390. setArray4(uniformName: string, array: number[]): Effect;
  110391. /**
  110392. * Sets matrices on a uniform variable.
  110393. * @param uniformName Name of the variable.
  110394. * @param matrices matrices to be set.
  110395. * @returns this effect.
  110396. */
  110397. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  110398. /**
  110399. * Sets matrix on a uniform variable.
  110400. * @param uniformName Name of the variable.
  110401. * @param matrix matrix to be set.
  110402. * @returns this effect.
  110403. */
  110404. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  110405. /**
  110406. * 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)
  110407. * @param uniformName Name of the variable.
  110408. * @param matrix matrix to be set.
  110409. * @returns this effect.
  110410. */
  110411. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  110412. /**
  110413. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  110414. * @param uniformName Name of the variable.
  110415. * @param matrix matrix to be set.
  110416. * @returns this effect.
  110417. */
  110418. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  110419. /**
  110420. * Sets a float on a uniform variable.
  110421. * @param uniformName Name of the variable.
  110422. * @param value value to be set.
  110423. * @returns this effect.
  110424. */
  110425. setFloat(uniformName: string, value: number): Effect;
  110426. /**
  110427. * Sets a boolean on a uniform variable.
  110428. * @param uniformName Name of the variable.
  110429. * @param bool value to be set.
  110430. * @returns this effect.
  110431. */
  110432. setBool(uniformName: string, bool: boolean): Effect;
  110433. /**
  110434. * Sets a Vector2 on a uniform variable.
  110435. * @param uniformName Name of the variable.
  110436. * @param vector2 vector2 to be set.
  110437. * @returns this effect.
  110438. */
  110439. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  110440. /**
  110441. * Sets a float2 on a uniform variable.
  110442. * @param uniformName Name of the variable.
  110443. * @param x First float in float2.
  110444. * @param y Second float in float2.
  110445. * @returns this effect.
  110446. */
  110447. setFloat2(uniformName: string, x: number, y: number): Effect;
  110448. /**
  110449. * Sets a Vector3 on a uniform variable.
  110450. * @param uniformName Name of the variable.
  110451. * @param vector3 Value to be set.
  110452. * @returns this effect.
  110453. */
  110454. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  110455. /**
  110456. * Sets a float3 on a uniform variable.
  110457. * @param uniformName Name of the variable.
  110458. * @param x First float in float3.
  110459. * @param y Second float in float3.
  110460. * @param z Third float in float3.
  110461. * @returns this effect.
  110462. */
  110463. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  110464. /**
  110465. * Sets a Vector4 on a uniform variable.
  110466. * @param uniformName Name of the variable.
  110467. * @param vector4 Value to be set.
  110468. * @returns this effect.
  110469. */
  110470. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  110471. /**
  110472. * Sets a float4 on a uniform variable.
  110473. * @param uniformName Name of the variable.
  110474. * @param x First float in float4.
  110475. * @param y Second float in float4.
  110476. * @param z Third float in float4.
  110477. * @param w Fourth float in float4.
  110478. * @returns this effect.
  110479. */
  110480. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  110481. /**
  110482. * Sets a Color3 on a uniform variable.
  110483. * @param uniformName Name of the variable.
  110484. * @param color3 Value to be set.
  110485. * @returns this effect.
  110486. */
  110487. setColor3(uniformName: string, color3: IColor3Like): Effect;
  110488. /**
  110489. * Sets a Color4 on a uniform variable.
  110490. * @param uniformName Name of the variable.
  110491. * @param color3 Value to be set.
  110492. * @param alpha Alpha value to be set.
  110493. * @returns this effect.
  110494. */
  110495. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  110496. /**
  110497. * Sets a Color4 on a uniform variable
  110498. * @param uniformName defines the name of the variable
  110499. * @param color4 defines the value to be set
  110500. * @returns this effect.
  110501. */
  110502. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  110503. /** Release all associated resources */
  110504. dispose(): void;
  110505. /**
  110506. * This function will add a new shader to the shader store
  110507. * @param name the name of the shader
  110508. * @param pixelShader optional pixel shader content
  110509. * @param vertexShader optional vertex shader content
  110510. */
  110511. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  110512. /**
  110513. * Store of each shader (The can be looked up using effect.key)
  110514. */
  110515. static ShadersStore: {
  110516. [key: string]: string;
  110517. };
  110518. /**
  110519. * Store of each included file for a shader (The can be looked up using effect.key)
  110520. */
  110521. static IncludesShadersStore: {
  110522. [key: string]: string;
  110523. };
  110524. /**
  110525. * Resets the cache of effects.
  110526. */
  110527. static ResetCache(): void;
  110528. }
  110529. }
  110530. declare module BABYLON {
  110531. /**
  110532. * Interface used to describe the capabilities of the engine relatively to the current browser
  110533. */
  110534. export interface EngineCapabilities {
  110535. /** Maximum textures units per fragment shader */
  110536. maxTexturesImageUnits: number;
  110537. /** Maximum texture units per vertex shader */
  110538. maxVertexTextureImageUnits: number;
  110539. /** Maximum textures units in the entire pipeline */
  110540. maxCombinedTexturesImageUnits: number;
  110541. /** Maximum texture size */
  110542. maxTextureSize: number;
  110543. /** Maximum texture samples */
  110544. maxSamples?: number;
  110545. /** Maximum cube texture size */
  110546. maxCubemapTextureSize: number;
  110547. /** Maximum render texture size */
  110548. maxRenderTextureSize: number;
  110549. /** Maximum number of vertex attributes */
  110550. maxVertexAttribs: number;
  110551. /** Maximum number of varyings */
  110552. maxVaryingVectors: number;
  110553. /** Maximum number of uniforms per vertex shader */
  110554. maxVertexUniformVectors: number;
  110555. /** Maximum number of uniforms per fragment shader */
  110556. maxFragmentUniformVectors: number;
  110557. /** Defines if standard derivates (dx/dy) are supported */
  110558. standardDerivatives: boolean;
  110559. /** Defines if s3tc texture compression is supported */
  110560. s3tc?: WEBGL_compressed_texture_s3tc;
  110561. /** Defines if pvrtc texture compression is supported */
  110562. pvrtc: any;
  110563. /** Defines if etc1 texture compression is supported */
  110564. etc1: any;
  110565. /** Defines if etc2 texture compression is supported */
  110566. etc2: any;
  110567. /** Defines if astc texture compression is supported */
  110568. astc: any;
  110569. /** Defines if float textures are supported */
  110570. textureFloat: boolean;
  110571. /** Defines if vertex array objects are supported */
  110572. vertexArrayObject: boolean;
  110573. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  110574. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  110575. /** Gets the maximum level of anisotropy supported */
  110576. maxAnisotropy: number;
  110577. /** Defines if instancing is supported */
  110578. instancedArrays: boolean;
  110579. /** Defines if 32 bits indices are supported */
  110580. uintIndices: boolean;
  110581. /** Defines if high precision shaders are supported */
  110582. highPrecisionShaderSupported: boolean;
  110583. /** Defines if depth reading in the fragment shader is supported */
  110584. fragmentDepthSupported: boolean;
  110585. /** Defines if float texture linear filtering is supported*/
  110586. textureFloatLinearFiltering: boolean;
  110587. /** Defines if rendering to float textures is supported */
  110588. textureFloatRender: boolean;
  110589. /** Defines if half float textures are supported*/
  110590. textureHalfFloat: boolean;
  110591. /** Defines if half float texture linear filtering is supported*/
  110592. textureHalfFloatLinearFiltering: boolean;
  110593. /** Defines if rendering to half float textures is supported */
  110594. textureHalfFloatRender: boolean;
  110595. /** Defines if textureLOD shader command is supported */
  110596. textureLOD: boolean;
  110597. /** Defines if draw buffers extension is supported */
  110598. drawBuffersExtension: boolean;
  110599. /** Defines if depth textures are supported */
  110600. depthTextureExtension: boolean;
  110601. /** Defines if float color buffer are supported */
  110602. colorBufferFloat: boolean;
  110603. /** Gets disjoint timer query extension (null if not supported) */
  110604. timerQuery?: EXT_disjoint_timer_query;
  110605. /** Defines if timestamp can be used with timer query */
  110606. canUseTimestampForTimerQuery: boolean;
  110607. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  110608. multiview?: any;
  110609. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  110610. oculusMultiview?: any;
  110611. /** Function used to let the system compiles shaders in background */
  110612. parallelShaderCompile?: {
  110613. COMPLETION_STATUS_KHR: number;
  110614. };
  110615. /** Max number of texture samples for MSAA */
  110616. maxMSAASamples: number;
  110617. /** Defines if the blend min max extension is supported */
  110618. blendMinMax: boolean;
  110619. }
  110620. }
  110621. declare module BABYLON {
  110622. /**
  110623. * @hidden
  110624. **/
  110625. export class DepthCullingState {
  110626. private _isDepthTestDirty;
  110627. private _isDepthMaskDirty;
  110628. private _isDepthFuncDirty;
  110629. private _isCullFaceDirty;
  110630. private _isCullDirty;
  110631. private _isZOffsetDirty;
  110632. private _isFrontFaceDirty;
  110633. private _depthTest;
  110634. private _depthMask;
  110635. private _depthFunc;
  110636. private _cull;
  110637. private _cullFace;
  110638. private _zOffset;
  110639. private _frontFace;
  110640. /**
  110641. * Initializes the state.
  110642. */
  110643. constructor();
  110644. get isDirty(): boolean;
  110645. get zOffset(): number;
  110646. set zOffset(value: number);
  110647. get cullFace(): Nullable<number>;
  110648. set cullFace(value: Nullable<number>);
  110649. get cull(): Nullable<boolean>;
  110650. set cull(value: Nullable<boolean>);
  110651. get depthFunc(): Nullable<number>;
  110652. set depthFunc(value: Nullable<number>);
  110653. get depthMask(): boolean;
  110654. set depthMask(value: boolean);
  110655. get depthTest(): boolean;
  110656. set depthTest(value: boolean);
  110657. get frontFace(): Nullable<number>;
  110658. set frontFace(value: Nullable<number>);
  110659. reset(): void;
  110660. apply(gl: WebGLRenderingContext): void;
  110661. }
  110662. }
  110663. declare module BABYLON {
  110664. /**
  110665. * @hidden
  110666. **/
  110667. export class StencilState {
  110668. /** 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 */
  110669. static readonly ALWAYS: number;
  110670. /** Passed to stencilOperation to specify that stencil value must be kept */
  110671. static readonly KEEP: number;
  110672. /** Passed to stencilOperation to specify that stencil value must be replaced */
  110673. static readonly REPLACE: number;
  110674. private _isStencilTestDirty;
  110675. private _isStencilMaskDirty;
  110676. private _isStencilFuncDirty;
  110677. private _isStencilOpDirty;
  110678. private _stencilTest;
  110679. private _stencilMask;
  110680. private _stencilFunc;
  110681. private _stencilFuncRef;
  110682. private _stencilFuncMask;
  110683. private _stencilOpStencilFail;
  110684. private _stencilOpDepthFail;
  110685. private _stencilOpStencilDepthPass;
  110686. get isDirty(): boolean;
  110687. get stencilFunc(): number;
  110688. set stencilFunc(value: number);
  110689. get stencilFuncRef(): number;
  110690. set stencilFuncRef(value: number);
  110691. get stencilFuncMask(): number;
  110692. set stencilFuncMask(value: number);
  110693. get stencilOpStencilFail(): number;
  110694. set stencilOpStencilFail(value: number);
  110695. get stencilOpDepthFail(): number;
  110696. set stencilOpDepthFail(value: number);
  110697. get stencilOpStencilDepthPass(): number;
  110698. set stencilOpStencilDepthPass(value: number);
  110699. get stencilMask(): number;
  110700. set stencilMask(value: number);
  110701. get stencilTest(): boolean;
  110702. set stencilTest(value: boolean);
  110703. constructor();
  110704. reset(): void;
  110705. apply(gl: WebGLRenderingContext): void;
  110706. }
  110707. }
  110708. declare module BABYLON {
  110709. /**
  110710. * @hidden
  110711. **/
  110712. export class AlphaState {
  110713. private _isAlphaBlendDirty;
  110714. private _isBlendFunctionParametersDirty;
  110715. private _isBlendEquationParametersDirty;
  110716. private _isBlendConstantsDirty;
  110717. private _alphaBlend;
  110718. private _blendFunctionParameters;
  110719. private _blendEquationParameters;
  110720. private _blendConstants;
  110721. /**
  110722. * Initializes the state.
  110723. */
  110724. constructor();
  110725. get isDirty(): boolean;
  110726. get alphaBlend(): boolean;
  110727. set alphaBlend(value: boolean);
  110728. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  110729. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  110730. setAlphaEquationParameters(rgb: number, alpha: number): void;
  110731. reset(): void;
  110732. apply(gl: WebGLRenderingContext): void;
  110733. }
  110734. }
  110735. declare module BABYLON {
  110736. /** @hidden */
  110737. export class WebGL2ShaderProcessor implements IShaderProcessor {
  110738. attributeProcessor(attribute: string): string;
  110739. varyingProcessor(varying: string, isFragment: boolean): string;
  110740. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  110741. }
  110742. }
  110743. declare module BABYLON {
  110744. /**
  110745. * Interface for attribute information associated with buffer instanciation
  110746. */
  110747. export interface InstancingAttributeInfo {
  110748. /**
  110749. * Name of the GLSL attribute
  110750. * if attribute index is not specified, this is used to retrieve the index from the effect
  110751. */
  110752. attributeName: string;
  110753. /**
  110754. * Index/offset of the attribute in the vertex shader
  110755. * if not specified, this will be computes from the name.
  110756. */
  110757. index?: number;
  110758. /**
  110759. * size of the attribute, 1, 2, 3 or 4
  110760. */
  110761. attributeSize: number;
  110762. /**
  110763. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  110764. */
  110765. offset: number;
  110766. /**
  110767. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  110768. * default to 1
  110769. */
  110770. divisor?: number;
  110771. /**
  110772. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  110773. * default is FLOAT
  110774. */
  110775. attributeType?: number;
  110776. /**
  110777. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  110778. */
  110779. normalized?: boolean;
  110780. }
  110781. }
  110782. declare module BABYLON {
  110783. interface ThinEngine {
  110784. /**
  110785. * Update a video texture
  110786. * @param texture defines the texture to update
  110787. * @param video defines the video element to use
  110788. * @param invertY defines if data must be stored with Y axis inverted
  110789. */
  110790. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  110791. }
  110792. }
  110793. declare module BABYLON {
  110794. /**
  110795. * Settings for finer control over video usage
  110796. */
  110797. export interface VideoTextureSettings {
  110798. /**
  110799. * Applies `autoplay` to video, if specified
  110800. */
  110801. autoPlay?: boolean;
  110802. /**
  110803. * Applies `loop` to video, if specified
  110804. */
  110805. loop?: boolean;
  110806. /**
  110807. * Automatically updates internal texture from video at every frame in the render loop
  110808. */
  110809. autoUpdateTexture: boolean;
  110810. /**
  110811. * Image src displayed during the video loading or until the user interacts with the video.
  110812. */
  110813. poster?: string;
  110814. }
  110815. /**
  110816. * If you want to display a video in your scene, this is the special texture for that.
  110817. * This special texture works similar to other textures, with the exception of a few parameters.
  110818. * @see https://doc.babylonjs.com/how_to/video_texture
  110819. */
  110820. export class VideoTexture extends Texture {
  110821. /**
  110822. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  110823. */
  110824. readonly autoUpdateTexture: boolean;
  110825. /**
  110826. * The video instance used by the texture internally
  110827. */
  110828. readonly video: HTMLVideoElement;
  110829. private _onUserActionRequestedObservable;
  110830. /**
  110831. * Event triggerd when a dom action is required by the user to play the video.
  110832. * This happens due to recent changes in browser policies preventing video to auto start.
  110833. */
  110834. get onUserActionRequestedObservable(): Observable<Texture>;
  110835. private _generateMipMaps;
  110836. private _stillImageCaptured;
  110837. private _displayingPosterTexture;
  110838. private _settings;
  110839. private _createInternalTextureOnEvent;
  110840. private _frameId;
  110841. private _currentSrc;
  110842. /**
  110843. * Creates a video texture.
  110844. * If you want to display a video in your scene, this is the special texture for that.
  110845. * This special texture works similar to other textures, with the exception of a few parameters.
  110846. * @see https://doc.babylonjs.com/how_to/video_texture
  110847. * @param name optional name, will detect from video source, if not defined
  110848. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  110849. * @param scene is obviously the current scene.
  110850. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  110851. * @param invertY is false by default but can be used to invert video on Y axis
  110852. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  110853. * @param settings allows finer control over video usage
  110854. */
  110855. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  110856. private _getName;
  110857. private _getVideo;
  110858. private _createInternalTexture;
  110859. private reset;
  110860. /**
  110861. * @hidden Internal method to initiate `update`.
  110862. */
  110863. _rebuild(): void;
  110864. /**
  110865. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  110866. */
  110867. update(): void;
  110868. /**
  110869. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  110870. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  110871. */
  110872. updateTexture(isVisible: boolean): void;
  110873. protected _updateInternalTexture: () => void;
  110874. /**
  110875. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  110876. * @param url New url.
  110877. */
  110878. updateURL(url: string): void;
  110879. /**
  110880. * Clones the texture.
  110881. * @returns the cloned texture
  110882. */
  110883. clone(): VideoTexture;
  110884. /**
  110885. * Dispose the texture and release its associated resources.
  110886. */
  110887. dispose(): void;
  110888. /**
  110889. * Creates a video texture straight from a stream.
  110890. * @param scene Define the scene the texture should be created in
  110891. * @param stream Define the stream the texture should be created from
  110892. * @returns The created video texture as a promise
  110893. */
  110894. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  110895. /**
  110896. * Creates a video texture straight from your WebCam video feed.
  110897. * @param scene Define the scene the texture should be created in
  110898. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  110899. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  110900. * @returns The created video texture as a promise
  110901. */
  110902. static CreateFromWebCamAsync(scene: Scene, constraints: {
  110903. minWidth: number;
  110904. maxWidth: number;
  110905. minHeight: number;
  110906. maxHeight: number;
  110907. deviceId: string;
  110908. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  110909. /**
  110910. * Creates a video texture straight from your WebCam video feed.
  110911. * @param scene Define the scene the texture should be created in
  110912. * @param onReady Define a callback to triggered once the texture will be ready
  110913. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  110914. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  110915. */
  110916. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  110917. minWidth: number;
  110918. maxWidth: number;
  110919. minHeight: number;
  110920. maxHeight: number;
  110921. deviceId: string;
  110922. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  110923. }
  110924. }
  110925. declare module BABYLON {
  110926. /**
  110927. * Defines the interface used by objects working like Scene
  110928. * @hidden
  110929. */
  110930. export interface ISceneLike {
  110931. _addPendingData(data: any): void;
  110932. _removePendingData(data: any): void;
  110933. offlineProvider: IOfflineProvider;
  110934. }
  110935. /** Interface defining initialization parameters for Engine class */
  110936. export interface EngineOptions extends WebGLContextAttributes {
  110937. /**
  110938. * Defines if the engine should no exceed a specified device ratio
  110939. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  110940. */
  110941. limitDeviceRatio?: number;
  110942. /**
  110943. * Defines if webvr should be enabled automatically
  110944. * @see http://doc.babylonjs.com/how_to/webvr_camera
  110945. */
  110946. autoEnableWebVR?: boolean;
  110947. /**
  110948. * Defines if webgl2 should be turned off even if supported
  110949. * @see http://doc.babylonjs.com/features/webgl2
  110950. */
  110951. disableWebGL2Support?: boolean;
  110952. /**
  110953. * Defines if webaudio should be initialized as well
  110954. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  110955. */
  110956. audioEngine?: boolean;
  110957. /**
  110958. * Defines if animations should run using a deterministic lock step
  110959. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  110960. */
  110961. deterministicLockstep?: boolean;
  110962. /** Defines the maximum steps to use with deterministic lock step mode */
  110963. lockstepMaxSteps?: number;
  110964. /** Defines the seconds between each deterministic lock step */
  110965. timeStep?: number;
  110966. /**
  110967. * Defines that engine should ignore context lost events
  110968. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  110969. */
  110970. doNotHandleContextLost?: boolean;
  110971. /**
  110972. * Defines that engine should ignore modifying touch action attribute and style
  110973. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  110974. */
  110975. doNotHandleTouchAction?: boolean;
  110976. /**
  110977. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  110978. */
  110979. useHighPrecisionFloats?: boolean;
  110980. }
  110981. /**
  110982. * The base engine class (root of all engines)
  110983. */
  110984. export class ThinEngine {
  110985. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  110986. static ExceptionList: ({
  110987. key: string;
  110988. capture: string;
  110989. captureConstraint: number;
  110990. targets: string[];
  110991. } | {
  110992. key: string;
  110993. capture: null;
  110994. captureConstraint: null;
  110995. targets: string[];
  110996. })[];
  110997. /** @hidden */
  110998. static _TextureLoaders: IInternalTextureLoader[];
  110999. /**
  111000. * Returns the current npm package of the sdk
  111001. */
  111002. static get NpmPackage(): string;
  111003. /**
  111004. * Returns the current version of the framework
  111005. */
  111006. static get Version(): string;
  111007. /**
  111008. * Returns a string describing the current engine
  111009. */
  111010. get description(): string;
  111011. /**
  111012. * Gets or sets the epsilon value used by collision engine
  111013. */
  111014. static CollisionsEpsilon: number;
  111015. /**
  111016. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  111017. */
  111018. static get ShadersRepository(): string;
  111019. static set ShadersRepository(value: string);
  111020. /** @hidden */
  111021. _shaderProcessor: IShaderProcessor;
  111022. /**
  111023. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  111024. */
  111025. forcePOTTextures: boolean;
  111026. /**
  111027. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  111028. */
  111029. isFullscreen: boolean;
  111030. /**
  111031. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  111032. */
  111033. cullBackFaces: boolean;
  111034. /**
  111035. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  111036. */
  111037. renderEvenInBackground: boolean;
  111038. /**
  111039. * Gets or sets a boolean indicating that cache can be kept between frames
  111040. */
  111041. preventCacheWipeBetweenFrames: boolean;
  111042. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  111043. validateShaderPrograms: boolean;
  111044. /**
  111045. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  111046. * This can provide greater z depth for distant objects.
  111047. */
  111048. useReverseDepthBuffer: boolean;
  111049. /**
  111050. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  111051. */
  111052. disableUniformBuffers: boolean;
  111053. /** @hidden */
  111054. _uniformBuffers: UniformBuffer[];
  111055. /**
  111056. * Gets a boolean indicating that the engine supports uniform buffers
  111057. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  111058. */
  111059. get supportsUniformBuffers(): boolean;
  111060. /** @hidden */
  111061. _gl: WebGLRenderingContext;
  111062. /** @hidden */
  111063. _webGLVersion: number;
  111064. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  111065. protected _windowIsBackground: boolean;
  111066. protected _creationOptions: EngineOptions;
  111067. protected _highPrecisionShadersAllowed: boolean;
  111068. /** @hidden */
  111069. get _shouldUseHighPrecisionShader(): boolean;
  111070. /**
  111071. * Gets a boolean indicating that only power of 2 textures are supported
  111072. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  111073. */
  111074. get needPOTTextures(): boolean;
  111075. /** @hidden */
  111076. _badOS: boolean;
  111077. /** @hidden */
  111078. _badDesktopOS: boolean;
  111079. private _hardwareScalingLevel;
  111080. /** @hidden */
  111081. _caps: EngineCapabilities;
  111082. private _isStencilEnable;
  111083. private _glVersion;
  111084. private _glRenderer;
  111085. private _glVendor;
  111086. /** @hidden */
  111087. _videoTextureSupported: boolean;
  111088. protected _renderingQueueLaunched: boolean;
  111089. protected _activeRenderLoops: (() => void)[];
  111090. /**
  111091. * Observable signaled when a context lost event is raised
  111092. */
  111093. onContextLostObservable: Observable<ThinEngine>;
  111094. /**
  111095. * Observable signaled when a context restored event is raised
  111096. */
  111097. onContextRestoredObservable: Observable<ThinEngine>;
  111098. private _onContextLost;
  111099. private _onContextRestored;
  111100. protected _contextWasLost: boolean;
  111101. /** @hidden */
  111102. _doNotHandleContextLost: boolean;
  111103. /**
  111104. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  111105. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  111106. */
  111107. get doNotHandleContextLost(): boolean;
  111108. set doNotHandleContextLost(value: boolean);
  111109. /**
  111110. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  111111. */
  111112. disableVertexArrayObjects: boolean;
  111113. /** @hidden */
  111114. protected _colorWrite: boolean;
  111115. /** @hidden */
  111116. protected _colorWriteChanged: boolean;
  111117. /** @hidden */
  111118. protected _depthCullingState: DepthCullingState;
  111119. /** @hidden */
  111120. protected _stencilState: StencilState;
  111121. /** @hidden */
  111122. _alphaState: AlphaState;
  111123. /** @hidden */
  111124. _alphaMode: number;
  111125. /** @hidden */
  111126. _alphaEquation: number;
  111127. /** @hidden */
  111128. _internalTexturesCache: InternalTexture[];
  111129. /** @hidden */
  111130. protected _activeChannel: number;
  111131. private _currentTextureChannel;
  111132. /** @hidden */
  111133. protected _boundTexturesCache: {
  111134. [key: string]: Nullable<InternalTexture>;
  111135. };
  111136. /** @hidden */
  111137. protected _currentEffect: Nullable<Effect>;
  111138. /** @hidden */
  111139. protected _currentProgram: Nullable<WebGLProgram>;
  111140. private _compiledEffects;
  111141. private _vertexAttribArraysEnabled;
  111142. /** @hidden */
  111143. protected _cachedViewport: Nullable<IViewportLike>;
  111144. private _cachedVertexArrayObject;
  111145. /** @hidden */
  111146. protected _cachedVertexBuffers: any;
  111147. /** @hidden */
  111148. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  111149. /** @hidden */
  111150. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  111151. /** @hidden */
  111152. _currentRenderTarget: Nullable<InternalTexture>;
  111153. private _uintIndicesCurrentlySet;
  111154. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  111155. /** @hidden */
  111156. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  111157. /** @hidden */
  111158. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  111159. private _currentBufferPointers;
  111160. private _currentInstanceLocations;
  111161. private _currentInstanceBuffers;
  111162. private _textureUnits;
  111163. /** @hidden */
  111164. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  111165. /** @hidden */
  111166. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  111167. /** @hidden */
  111168. _boundRenderFunction: any;
  111169. private _vaoRecordInProgress;
  111170. private _mustWipeVertexAttributes;
  111171. private _emptyTexture;
  111172. private _emptyCubeTexture;
  111173. private _emptyTexture3D;
  111174. private _emptyTexture2DArray;
  111175. /** @hidden */
  111176. _frameHandler: number;
  111177. private _nextFreeTextureSlots;
  111178. private _maxSimultaneousTextures;
  111179. private _activeRequests;
  111180. /** @hidden */
  111181. _transformTextureUrl: Nullable<(url: string) => string>;
  111182. protected get _supportsHardwareTextureRescaling(): boolean;
  111183. private _framebufferDimensionsObject;
  111184. /**
  111185. * sets the object from which width and height will be taken from when getting render width and height
  111186. * Will fallback to the gl object
  111187. * @param dimensions the framebuffer width and height that will be used.
  111188. */
  111189. set framebufferDimensionsObject(dimensions: Nullable<{
  111190. framebufferWidth: number;
  111191. framebufferHeight: number;
  111192. }>);
  111193. /**
  111194. * Gets the current viewport
  111195. */
  111196. get currentViewport(): Nullable<IViewportLike>;
  111197. /**
  111198. * Gets the default empty texture
  111199. */
  111200. get emptyTexture(): InternalTexture;
  111201. /**
  111202. * Gets the default empty 3D texture
  111203. */
  111204. get emptyTexture3D(): InternalTexture;
  111205. /**
  111206. * Gets the default empty 2D array texture
  111207. */
  111208. get emptyTexture2DArray(): InternalTexture;
  111209. /**
  111210. * Gets the default empty cube texture
  111211. */
  111212. get emptyCubeTexture(): InternalTexture;
  111213. /**
  111214. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  111215. */
  111216. readonly premultipliedAlpha: boolean;
  111217. /**
  111218. * Observable event triggered before each texture is initialized
  111219. */
  111220. onBeforeTextureInitObservable: Observable<Texture>;
  111221. /**
  111222. * Creates a new engine
  111223. * @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
  111224. * @param antialias defines enable antialiasing (default: false)
  111225. * @param options defines further options to be sent to the getContext() function
  111226. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  111227. */
  111228. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  111229. private _rebuildInternalTextures;
  111230. private _rebuildEffects;
  111231. /**
  111232. * Gets a boolean indicating if all created effects are ready
  111233. * @returns true if all effects are ready
  111234. */
  111235. areAllEffectsReady(): boolean;
  111236. protected _rebuildBuffers(): void;
  111237. protected _initGLContext(): void;
  111238. /**
  111239. * Gets version of the current webGL context
  111240. */
  111241. get webGLVersion(): number;
  111242. /**
  111243. * Gets a string idenfifying the name of the class
  111244. * @returns "Engine" string
  111245. */
  111246. getClassName(): string;
  111247. /**
  111248. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  111249. */
  111250. get isStencilEnable(): boolean;
  111251. /** @hidden */
  111252. _prepareWorkingCanvas(): void;
  111253. /**
  111254. * Reset the texture cache to empty state
  111255. */
  111256. resetTextureCache(): void;
  111257. /**
  111258. * Gets an object containing information about the current webGL context
  111259. * @returns an object containing the vender, the renderer and the version of the current webGL context
  111260. */
  111261. getGlInfo(): {
  111262. vendor: string;
  111263. renderer: string;
  111264. version: string;
  111265. };
  111266. /**
  111267. * Defines the hardware scaling level.
  111268. * By default the hardware scaling level is computed from the window device ratio.
  111269. * 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.
  111270. * @param level defines the level to use
  111271. */
  111272. setHardwareScalingLevel(level: number): void;
  111273. /**
  111274. * Gets the current hardware scaling level.
  111275. * By default the hardware scaling level is computed from the window device ratio.
  111276. * 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.
  111277. * @returns a number indicating the current hardware scaling level
  111278. */
  111279. getHardwareScalingLevel(): number;
  111280. /**
  111281. * Gets the list of loaded textures
  111282. * @returns an array containing all loaded textures
  111283. */
  111284. getLoadedTexturesCache(): InternalTexture[];
  111285. /**
  111286. * Gets the object containing all engine capabilities
  111287. * @returns the EngineCapabilities object
  111288. */
  111289. getCaps(): EngineCapabilities;
  111290. /**
  111291. * stop executing a render loop function and remove it from the execution array
  111292. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  111293. */
  111294. stopRenderLoop(renderFunction?: () => void): void;
  111295. /** @hidden */
  111296. _renderLoop(): void;
  111297. /**
  111298. * Gets the HTML canvas attached with the current webGL context
  111299. * @returns a HTML canvas
  111300. */
  111301. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  111302. /**
  111303. * Gets host window
  111304. * @returns the host window object
  111305. */
  111306. getHostWindow(): Nullable<Window>;
  111307. /**
  111308. * Gets the current render width
  111309. * @param useScreen defines if screen size must be used (or the current render target if any)
  111310. * @returns a number defining the current render width
  111311. */
  111312. getRenderWidth(useScreen?: boolean): number;
  111313. /**
  111314. * Gets the current render height
  111315. * @param useScreen defines if screen size must be used (or the current render target if any)
  111316. * @returns a number defining the current render height
  111317. */
  111318. getRenderHeight(useScreen?: boolean): number;
  111319. /**
  111320. * Can be used to override the current requestAnimationFrame requester.
  111321. * @hidden
  111322. */
  111323. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  111324. /**
  111325. * Register and execute a render loop. The engine can have more than one render function
  111326. * @param renderFunction defines the function to continuously execute
  111327. */
  111328. runRenderLoop(renderFunction: () => void): void;
  111329. /**
  111330. * Clear the current render buffer or the current render target (if any is set up)
  111331. * @param color defines the color to use
  111332. * @param backBuffer defines if the back buffer must be cleared
  111333. * @param depth defines if the depth buffer must be cleared
  111334. * @param stencil defines if the stencil buffer must be cleared
  111335. */
  111336. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  111337. private _viewportCached;
  111338. /** @hidden */
  111339. _viewport(x: number, y: number, width: number, height: number): void;
  111340. /**
  111341. * Set the WebGL's viewport
  111342. * @param viewport defines the viewport element to be used
  111343. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  111344. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  111345. */
  111346. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  111347. /**
  111348. * Begin a new frame
  111349. */
  111350. beginFrame(): void;
  111351. /**
  111352. * Enf the current frame
  111353. */
  111354. endFrame(): void;
  111355. /**
  111356. * Resize the view according to the canvas' size
  111357. */
  111358. resize(): void;
  111359. /**
  111360. * Force a specific size of the canvas
  111361. * @param width defines the new canvas' width
  111362. * @param height defines the new canvas' height
  111363. */
  111364. setSize(width: number, height: number): void;
  111365. /**
  111366. * Binds the frame buffer to the specified texture.
  111367. * @param texture The texture to render to or null for the default canvas
  111368. * @param faceIndex The face of the texture to render to in case of cube texture
  111369. * @param requiredWidth The width of the target to render to
  111370. * @param requiredHeight The height of the target to render to
  111371. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  111372. * @param lodLevel defines the lod level to bind to the frame buffer
  111373. * @param layer defines the 2d array index to bind to frame buffer to
  111374. */
  111375. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  111376. /** @hidden */
  111377. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  111378. /**
  111379. * Unbind the current render target texture from the webGL context
  111380. * @param texture defines the render target texture to unbind
  111381. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  111382. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  111383. */
  111384. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  111385. /**
  111386. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  111387. */
  111388. flushFramebuffer(): void;
  111389. /**
  111390. * Unbind the current render target and bind the default framebuffer
  111391. */
  111392. restoreDefaultFramebuffer(): void;
  111393. /** @hidden */
  111394. protected _resetVertexBufferBinding(): void;
  111395. /**
  111396. * Creates a vertex buffer
  111397. * @param data the data for the vertex buffer
  111398. * @returns the new WebGL static buffer
  111399. */
  111400. createVertexBuffer(data: DataArray): DataBuffer;
  111401. private _createVertexBuffer;
  111402. /**
  111403. * Creates a dynamic vertex buffer
  111404. * @param data the data for the dynamic vertex buffer
  111405. * @returns the new WebGL dynamic buffer
  111406. */
  111407. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  111408. protected _resetIndexBufferBinding(): void;
  111409. /**
  111410. * Creates a new index buffer
  111411. * @param indices defines the content of the index buffer
  111412. * @param updatable defines if the index buffer must be updatable
  111413. * @returns a new webGL buffer
  111414. */
  111415. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  111416. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  111417. /**
  111418. * Bind a webGL buffer to the webGL context
  111419. * @param buffer defines the buffer to bind
  111420. */
  111421. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  111422. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  111423. private bindBuffer;
  111424. /**
  111425. * update the bound buffer with the given data
  111426. * @param data defines the data to update
  111427. */
  111428. updateArrayBuffer(data: Float32Array): void;
  111429. private _vertexAttribPointer;
  111430. /** @hidden */
  111431. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  111432. private _bindVertexBuffersAttributes;
  111433. /**
  111434. * Records a vertex array object
  111435. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  111436. * @param vertexBuffers defines the list of vertex buffers to store
  111437. * @param indexBuffer defines the index buffer to store
  111438. * @param effect defines the effect to store
  111439. * @returns the new vertex array object
  111440. */
  111441. recordVertexArrayObject(vertexBuffers: {
  111442. [key: string]: VertexBuffer;
  111443. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  111444. /**
  111445. * Bind a specific vertex array object
  111446. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  111447. * @param vertexArrayObject defines the vertex array object to bind
  111448. * @param indexBuffer defines the index buffer to bind
  111449. */
  111450. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  111451. /**
  111452. * Bind webGl buffers directly to the webGL context
  111453. * @param vertexBuffer defines the vertex buffer to bind
  111454. * @param indexBuffer defines the index buffer to bind
  111455. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  111456. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  111457. * @param effect defines the effect associated with the vertex buffer
  111458. */
  111459. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  111460. private _unbindVertexArrayObject;
  111461. /**
  111462. * Bind a list of vertex buffers to the webGL context
  111463. * @param vertexBuffers defines the list of vertex buffers to bind
  111464. * @param indexBuffer defines the index buffer to bind
  111465. * @param effect defines the effect associated with the vertex buffers
  111466. */
  111467. bindBuffers(vertexBuffers: {
  111468. [key: string]: Nullable<VertexBuffer>;
  111469. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  111470. /**
  111471. * Unbind all instance attributes
  111472. */
  111473. unbindInstanceAttributes(): void;
  111474. /**
  111475. * Release and free the memory of a vertex array object
  111476. * @param vao defines the vertex array object to delete
  111477. */
  111478. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  111479. /** @hidden */
  111480. _releaseBuffer(buffer: DataBuffer): boolean;
  111481. protected _deleteBuffer(buffer: DataBuffer): void;
  111482. /**
  111483. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  111484. * @param instancesBuffer defines the webGL buffer to update and bind
  111485. * @param data defines the data to store in the buffer
  111486. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  111487. */
  111488. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  111489. /**
  111490. * Bind the content of a webGL buffer used with instantiation
  111491. * @param instancesBuffer defines the webGL buffer to bind
  111492. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  111493. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  111494. */
  111495. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  111496. /**
  111497. * Disable the instance attribute corresponding to the name in parameter
  111498. * @param name defines the name of the attribute to disable
  111499. */
  111500. disableInstanceAttributeByName(name: string): void;
  111501. /**
  111502. * Disable the instance attribute corresponding to the location in parameter
  111503. * @param attributeLocation defines the attribute location of the attribute to disable
  111504. */
  111505. disableInstanceAttribute(attributeLocation: number): void;
  111506. /**
  111507. * Disable the attribute corresponding to the location in parameter
  111508. * @param attributeLocation defines the attribute location of the attribute to disable
  111509. */
  111510. disableAttributeByIndex(attributeLocation: number): void;
  111511. /**
  111512. * Send a draw order
  111513. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  111514. * @param indexStart defines the starting index
  111515. * @param indexCount defines the number of index to draw
  111516. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  111517. */
  111518. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  111519. /**
  111520. * Draw a list of points
  111521. * @param verticesStart defines the index of first vertex to draw
  111522. * @param verticesCount defines the count of vertices to draw
  111523. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  111524. */
  111525. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  111526. /**
  111527. * Draw a list of unindexed primitives
  111528. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  111529. * @param verticesStart defines the index of first vertex to draw
  111530. * @param verticesCount defines the count of vertices to draw
  111531. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  111532. */
  111533. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  111534. /**
  111535. * Draw a list of indexed primitives
  111536. * @param fillMode defines the primitive to use
  111537. * @param indexStart defines the starting index
  111538. * @param indexCount defines the number of index to draw
  111539. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  111540. */
  111541. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  111542. /**
  111543. * Draw a list of unindexed primitives
  111544. * @param fillMode defines the primitive to use
  111545. * @param verticesStart defines the index of first vertex to draw
  111546. * @param verticesCount defines the count of vertices to draw
  111547. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  111548. */
  111549. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  111550. private _drawMode;
  111551. /** @hidden */
  111552. protected _reportDrawCall(): void;
  111553. /** @hidden */
  111554. _releaseEffect(effect: Effect): void;
  111555. /** @hidden */
  111556. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  111557. /**
  111558. * Create a new effect (used to store vertex/fragment shaders)
  111559. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  111560. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  111561. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  111562. * @param samplers defines an array of string used to represent textures
  111563. * @param defines defines the string containing the defines to use to compile the shaders
  111564. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  111565. * @param onCompiled defines a function to call when the effect creation is successful
  111566. * @param onError defines a function to call when the effect creation has failed
  111567. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  111568. * @returns the new Effect
  111569. */
  111570. 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;
  111571. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  111572. private _compileShader;
  111573. private _compileRawShader;
  111574. /** @hidden */
  111575. _getShaderSource(shader: WebGLShader): Nullable<string>;
  111576. /**
  111577. * Directly creates a webGL program
  111578. * @param pipelineContext defines the pipeline context to attach to
  111579. * @param vertexCode defines the vertex shader code to use
  111580. * @param fragmentCode defines the fragment shader code to use
  111581. * @param context defines the webGL context to use (if not set, the current one will be used)
  111582. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  111583. * @returns the new webGL program
  111584. */
  111585. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  111586. /**
  111587. * Creates a webGL program
  111588. * @param pipelineContext defines the pipeline context to attach to
  111589. * @param vertexCode defines the vertex shader code to use
  111590. * @param fragmentCode defines the fragment shader code to use
  111591. * @param defines defines the string containing the defines to use to compile the shaders
  111592. * @param context defines the webGL context to use (if not set, the current one will be used)
  111593. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  111594. * @returns the new webGL program
  111595. */
  111596. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  111597. /**
  111598. * Creates a new pipeline context
  111599. * @returns the new pipeline
  111600. */
  111601. createPipelineContext(): IPipelineContext;
  111602. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  111603. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  111604. /** @hidden */
  111605. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  111606. /** @hidden */
  111607. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  111608. /** @hidden */
  111609. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  111610. /**
  111611. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  111612. * @param pipelineContext defines the pipeline context to use
  111613. * @param uniformsNames defines the list of uniform names
  111614. * @returns an array of webGL uniform locations
  111615. */
  111616. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  111617. /**
  111618. * Gets the lsit of active attributes for a given webGL program
  111619. * @param pipelineContext defines the pipeline context to use
  111620. * @param attributesNames defines the list of attribute names to get
  111621. * @returns an array of indices indicating the offset of each attribute
  111622. */
  111623. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  111624. /**
  111625. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  111626. * @param effect defines the effect to activate
  111627. */
  111628. enableEffect(effect: Nullable<Effect>): void;
  111629. /**
  111630. * Set the value of an uniform to a number (int)
  111631. * @param uniform defines the webGL uniform location where to store the value
  111632. * @param value defines the int number to store
  111633. */
  111634. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  111635. /**
  111636. * Set the value of an uniform to an array of int32
  111637. * @param uniform defines the webGL uniform location where to store the value
  111638. * @param array defines the array of int32 to store
  111639. */
  111640. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  111641. /**
  111642. * Set the value of an uniform to an array of int32 (stored as vec2)
  111643. * @param uniform defines the webGL uniform location where to store the value
  111644. * @param array defines the array of int32 to store
  111645. */
  111646. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  111647. /**
  111648. * Set the value of an uniform to an array of int32 (stored as vec3)
  111649. * @param uniform defines the webGL uniform location where to store the value
  111650. * @param array defines the array of int32 to store
  111651. */
  111652. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  111653. /**
  111654. * Set the value of an uniform to an array of int32 (stored as vec4)
  111655. * @param uniform defines the webGL uniform location where to store the value
  111656. * @param array defines the array of int32 to store
  111657. */
  111658. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  111659. /**
  111660. * Set the value of an uniform to an array of number
  111661. * @param uniform defines the webGL uniform location where to store the value
  111662. * @param array defines the array of number to store
  111663. */
  111664. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  111665. /**
  111666. * Set the value of an uniform to an array of number (stored as vec2)
  111667. * @param uniform defines the webGL uniform location where to store the value
  111668. * @param array defines the array of number to store
  111669. */
  111670. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  111671. /**
  111672. * Set the value of an uniform to an array of number (stored as vec3)
  111673. * @param uniform defines the webGL uniform location where to store the value
  111674. * @param array defines the array of number to store
  111675. */
  111676. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  111677. /**
  111678. * Set the value of an uniform to an array of number (stored as vec4)
  111679. * @param uniform defines the webGL uniform location where to store the value
  111680. * @param array defines the array of number to store
  111681. */
  111682. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  111683. /**
  111684. * Set the value of an uniform to an array of float32 (stored as matrices)
  111685. * @param uniform defines the webGL uniform location where to store the value
  111686. * @param matrices defines the array of float32 to store
  111687. */
  111688. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  111689. /**
  111690. * Set the value of an uniform to a matrix (3x3)
  111691. * @param uniform defines the webGL uniform location where to store the value
  111692. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  111693. */
  111694. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  111695. /**
  111696. * Set the value of an uniform to a matrix (2x2)
  111697. * @param uniform defines the webGL uniform location where to store the value
  111698. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  111699. */
  111700. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  111701. /**
  111702. * Set the value of an uniform to a number (float)
  111703. * @param uniform defines the webGL uniform location where to store the value
  111704. * @param value defines the float number to store
  111705. */
  111706. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  111707. /**
  111708. * Set the value of an uniform to a vec2
  111709. * @param uniform defines the webGL uniform location where to store the value
  111710. * @param x defines the 1st component of the value
  111711. * @param y defines the 2nd component of the value
  111712. */
  111713. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  111714. /**
  111715. * Set the value of an uniform to a vec3
  111716. * @param uniform defines the webGL uniform location where to store the value
  111717. * @param x defines the 1st component of the value
  111718. * @param y defines the 2nd component of the value
  111719. * @param z defines the 3rd component of the value
  111720. */
  111721. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  111722. /**
  111723. * Set the value of an uniform to a vec4
  111724. * @param uniform defines the webGL uniform location where to store the value
  111725. * @param x defines the 1st component of the value
  111726. * @param y defines the 2nd component of the value
  111727. * @param z defines the 3rd component of the value
  111728. * @param w defines the 4th component of the value
  111729. */
  111730. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  111731. /**
  111732. * Apply all cached states (depth, culling, stencil and alpha)
  111733. */
  111734. applyStates(): void;
  111735. /**
  111736. * Enable or disable color writing
  111737. * @param enable defines the state to set
  111738. */
  111739. setColorWrite(enable: boolean): void;
  111740. /**
  111741. * Gets a boolean indicating if color writing is enabled
  111742. * @returns the current color writing state
  111743. */
  111744. getColorWrite(): boolean;
  111745. /**
  111746. * Gets the depth culling state manager
  111747. */
  111748. get depthCullingState(): DepthCullingState;
  111749. /**
  111750. * Gets the alpha state manager
  111751. */
  111752. get alphaState(): AlphaState;
  111753. /**
  111754. * Gets the stencil state manager
  111755. */
  111756. get stencilState(): StencilState;
  111757. /**
  111758. * Clears the list of texture accessible through engine.
  111759. * This can help preventing texture load conflict due to name collision.
  111760. */
  111761. clearInternalTexturesCache(): void;
  111762. /**
  111763. * Force the entire cache to be cleared
  111764. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  111765. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  111766. */
  111767. wipeCaches(bruteForce?: boolean): void;
  111768. /** @hidden */
  111769. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  111770. min: number;
  111771. mag: number;
  111772. };
  111773. /** @hidden */
  111774. _createTexture(): WebGLTexture;
  111775. /**
  111776. * Usually called from Texture.ts.
  111777. * Passed information to create a WebGLTexture
  111778. * @param url defines a value which contains one of the following:
  111779. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  111780. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  111781. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  111782. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  111783. * @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)
  111784. * @param scene needed for loading to the correct scene
  111785. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  111786. * @param onLoad optional callback to be called upon successful completion
  111787. * @param onError optional callback to be called upon failure
  111788. * @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
  111789. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  111790. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  111791. * @param forcedExtension defines the extension to use to pick the right loader
  111792. * @param mimeType defines an optional mime type
  111793. * @returns a InternalTexture for assignment back into BABYLON.Texture
  111794. */
  111795. 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;
  111796. /**
  111797. * Loads an image as an HTMLImageElement.
  111798. * @param input url string, ArrayBuffer, or Blob to load
  111799. * @param onLoad callback called when the image successfully loads
  111800. * @param onError callback called when the image fails to load
  111801. * @param offlineProvider offline provider for caching
  111802. * @param mimeType optional mime type
  111803. * @returns the HTMLImageElement of the loaded image
  111804. * @hidden
  111805. */
  111806. 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>;
  111807. /**
  111808. * @hidden
  111809. */
  111810. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  111811. private _unpackFlipYCached;
  111812. /**
  111813. * In case you are sharing the context with other applications, it might
  111814. * be interested to not cache the unpack flip y state to ensure a consistent
  111815. * value would be set.
  111816. */
  111817. enableUnpackFlipYCached: boolean;
  111818. /** @hidden */
  111819. _unpackFlipY(value: boolean): void;
  111820. /** @hidden */
  111821. _getUnpackAlignement(): number;
  111822. private _getTextureTarget;
  111823. /**
  111824. * Update the sampling mode of a given texture
  111825. * @param samplingMode defines the required sampling mode
  111826. * @param texture defines the texture to update
  111827. * @param generateMipMaps defines whether to generate mipmaps for the texture
  111828. */
  111829. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  111830. /**
  111831. * Update the sampling mode of a given texture
  111832. * @param texture defines the texture to update
  111833. * @param wrapU defines the texture wrap mode of the u coordinates
  111834. * @param wrapV defines the texture wrap mode of the v coordinates
  111835. * @param wrapR defines the texture wrap mode of the r coordinates
  111836. */
  111837. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  111838. /** @hidden */
  111839. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  111840. width: number;
  111841. height: number;
  111842. layers?: number;
  111843. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  111844. /** @hidden */
  111845. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  111846. /** @hidden */
  111847. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  111848. /**
  111849. * Update a portion of an internal texture
  111850. * @param texture defines the texture to update
  111851. * @param imageData defines the data to store into the texture
  111852. * @param xOffset defines the x coordinates of the update rectangle
  111853. * @param yOffset defines the y coordinates of the update rectangle
  111854. * @param width defines the width of the update rectangle
  111855. * @param height defines the height of the update rectangle
  111856. * @param faceIndex defines the face index if texture is a cube (0 by default)
  111857. * @param lod defines the lod level to update (0 by default)
  111858. */
  111859. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  111860. /** @hidden */
  111861. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  111862. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  111863. private _prepareWebGLTexture;
  111864. /** @hidden */
  111865. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  111866. private _getDepthStencilBuffer;
  111867. /** @hidden */
  111868. _releaseFramebufferObjects(texture: InternalTexture): void;
  111869. /** @hidden */
  111870. _releaseTexture(texture: InternalTexture): void;
  111871. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  111872. protected _setProgram(program: WebGLProgram): void;
  111873. protected _boundUniforms: {
  111874. [key: number]: WebGLUniformLocation;
  111875. };
  111876. /**
  111877. * Binds an effect to the webGL context
  111878. * @param effect defines the effect to bind
  111879. */
  111880. bindSamplers(effect: Effect): void;
  111881. private _activateCurrentTexture;
  111882. /** @hidden */
  111883. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  111884. /** @hidden */
  111885. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  111886. /**
  111887. * Unbind all textures from the webGL context
  111888. */
  111889. unbindAllTextures(): void;
  111890. /**
  111891. * Sets a texture to the according uniform.
  111892. * @param channel The texture channel
  111893. * @param uniform The uniform to set
  111894. * @param texture The texture to apply
  111895. */
  111896. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  111897. private _bindSamplerUniformToChannel;
  111898. private _getTextureWrapMode;
  111899. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  111900. /**
  111901. * Sets an array of texture to the webGL context
  111902. * @param channel defines the channel where the texture array must be set
  111903. * @param uniform defines the associated uniform location
  111904. * @param textures defines the array of textures to bind
  111905. */
  111906. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  111907. /** @hidden */
  111908. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  111909. private _setTextureParameterFloat;
  111910. private _setTextureParameterInteger;
  111911. /**
  111912. * Unbind all vertex attributes from the webGL context
  111913. */
  111914. unbindAllAttributes(): void;
  111915. /**
  111916. * 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
  111917. */
  111918. releaseEffects(): void;
  111919. /**
  111920. * Dispose and release all associated resources
  111921. */
  111922. dispose(): void;
  111923. /**
  111924. * Attach a new callback raised when context lost event is fired
  111925. * @param callback defines the callback to call
  111926. */
  111927. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  111928. /**
  111929. * Attach a new callback raised when context restored event is fired
  111930. * @param callback defines the callback to call
  111931. */
  111932. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  111933. /**
  111934. * Get the current error code of the webGL context
  111935. * @returns the error code
  111936. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  111937. */
  111938. getError(): number;
  111939. private _canRenderToFloatFramebuffer;
  111940. private _canRenderToHalfFloatFramebuffer;
  111941. private _canRenderToFramebuffer;
  111942. /** @hidden */
  111943. _getWebGLTextureType(type: number): number;
  111944. /** @hidden */
  111945. _getInternalFormat(format: number): number;
  111946. /** @hidden */
  111947. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  111948. /** @hidden */
  111949. _getRGBAMultiSampleBufferFormat(type: number): number;
  111950. /** @hidden */
  111951. _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;
  111952. /**
  111953. * Loads a file from a url
  111954. * @param url url to load
  111955. * @param onSuccess callback called when the file successfully loads
  111956. * @param onProgress callback called while file is loading (if the server supports this mode)
  111957. * @param offlineProvider defines the offline provider for caching
  111958. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  111959. * @param onError callback called when the file fails to load
  111960. * @returns a file request object
  111961. * @hidden
  111962. */
  111963. 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;
  111964. /**
  111965. * Reads pixels from the current frame buffer. Please note that this function can be slow
  111966. * @param x defines the x coordinate of the rectangle where pixels must be read
  111967. * @param y defines the y coordinate of the rectangle where pixels must be read
  111968. * @param width defines the width of the rectangle where pixels must be read
  111969. * @param height defines the height of the rectangle where pixels must be read
  111970. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  111971. * @returns a Uint8Array containing RGBA colors
  111972. */
  111973. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  111974. private static _isSupported;
  111975. /**
  111976. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  111977. * @returns true if the engine can be created
  111978. * @ignorenaming
  111979. */
  111980. static isSupported(): boolean;
  111981. /**
  111982. * Find the next highest power of two.
  111983. * @param x Number to start search from.
  111984. * @return Next highest power of two.
  111985. */
  111986. static CeilingPOT(x: number): number;
  111987. /**
  111988. * Find the next lowest power of two.
  111989. * @param x Number to start search from.
  111990. * @return Next lowest power of two.
  111991. */
  111992. static FloorPOT(x: number): number;
  111993. /**
  111994. * Find the nearest power of two.
  111995. * @param x Number to start search from.
  111996. * @return Next nearest power of two.
  111997. */
  111998. static NearestPOT(x: number): number;
  111999. /**
  112000. * Get the closest exponent of two
  112001. * @param value defines the value to approximate
  112002. * @param max defines the maximum value to return
  112003. * @param mode defines how to define the closest value
  112004. * @returns closest exponent of two of the given value
  112005. */
  112006. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  112007. /**
  112008. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  112009. * @param func - the function to be called
  112010. * @param requester - the object that will request the next frame. Falls back to window.
  112011. * @returns frame number
  112012. */
  112013. static QueueNewFrame(func: () => void, requester?: any): number;
  112014. /**
  112015. * Gets host document
  112016. * @returns the host document object
  112017. */
  112018. getHostDocument(): Nullable<Document>;
  112019. }
  112020. }
  112021. declare module BABYLON {
  112022. /**
  112023. * Class representing spherical harmonics coefficients to the 3rd degree
  112024. */
  112025. export class SphericalHarmonics {
  112026. /**
  112027. * Defines whether or not the harmonics have been prescaled for rendering.
  112028. */
  112029. preScaled: boolean;
  112030. /**
  112031. * The l0,0 coefficients of the spherical harmonics
  112032. */
  112033. l00: Vector3;
  112034. /**
  112035. * The l1,-1 coefficients of the spherical harmonics
  112036. */
  112037. l1_1: Vector3;
  112038. /**
  112039. * The l1,0 coefficients of the spherical harmonics
  112040. */
  112041. l10: Vector3;
  112042. /**
  112043. * The l1,1 coefficients of the spherical harmonics
  112044. */
  112045. l11: Vector3;
  112046. /**
  112047. * The l2,-2 coefficients of the spherical harmonics
  112048. */
  112049. l2_2: Vector3;
  112050. /**
  112051. * The l2,-1 coefficients of the spherical harmonics
  112052. */
  112053. l2_1: Vector3;
  112054. /**
  112055. * The l2,0 coefficients of the spherical harmonics
  112056. */
  112057. l20: Vector3;
  112058. /**
  112059. * The l2,1 coefficients of the spherical harmonics
  112060. */
  112061. l21: Vector3;
  112062. /**
  112063. * The l2,2 coefficients of the spherical harmonics
  112064. */
  112065. l22: Vector3;
  112066. /**
  112067. * Adds a light to the spherical harmonics
  112068. * @param direction the direction of the light
  112069. * @param color the color of the light
  112070. * @param deltaSolidAngle the delta solid angle of the light
  112071. */
  112072. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  112073. /**
  112074. * Scales the spherical harmonics by the given amount
  112075. * @param scale the amount to scale
  112076. */
  112077. scaleInPlace(scale: number): void;
  112078. /**
  112079. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  112080. *
  112081. * ```
  112082. * E_lm = A_l * L_lm
  112083. * ```
  112084. *
  112085. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  112086. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  112087. * the scaling factors are given in equation 9.
  112088. */
  112089. convertIncidentRadianceToIrradiance(): void;
  112090. /**
  112091. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  112092. *
  112093. * ```
  112094. * L = (1/pi) * E * rho
  112095. * ```
  112096. *
  112097. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  112098. */
  112099. convertIrradianceToLambertianRadiance(): void;
  112100. /**
  112101. * Integrates the reconstruction coefficients directly in to the SH preventing further
  112102. * required operations at run time.
  112103. *
  112104. * This is simply done by scaling back the SH with Ylm constants parameter.
  112105. * The trigonometric part being applied by the shader at run time.
  112106. */
  112107. preScaleForRendering(): void;
  112108. /**
  112109. * Constructs a spherical harmonics from an array.
  112110. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  112111. * @returns the spherical harmonics
  112112. */
  112113. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  112114. /**
  112115. * Gets the spherical harmonics from polynomial
  112116. * @param polynomial the spherical polynomial
  112117. * @returns the spherical harmonics
  112118. */
  112119. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  112120. }
  112121. /**
  112122. * Class representing spherical polynomial coefficients to the 3rd degree
  112123. */
  112124. export class SphericalPolynomial {
  112125. private _harmonics;
  112126. /**
  112127. * The spherical harmonics used to create the polynomials.
  112128. */
  112129. get preScaledHarmonics(): SphericalHarmonics;
  112130. /**
  112131. * The x coefficients of the spherical polynomial
  112132. */
  112133. x: Vector3;
  112134. /**
  112135. * The y coefficients of the spherical polynomial
  112136. */
  112137. y: Vector3;
  112138. /**
  112139. * The z coefficients of the spherical polynomial
  112140. */
  112141. z: Vector3;
  112142. /**
  112143. * The xx coefficients of the spherical polynomial
  112144. */
  112145. xx: Vector3;
  112146. /**
  112147. * The yy coefficients of the spherical polynomial
  112148. */
  112149. yy: Vector3;
  112150. /**
  112151. * The zz coefficients of the spherical polynomial
  112152. */
  112153. zz: Vector3;
  112154. /**
  112155. * The xy coefficients of the spherical polynomial
  112156. */
  112157. xy: Vector3;
  112158. /**
  112159. * The yz coefficients of the spherical polynomial
  112160. */
  112161. yz: Vector3;
  112162. /**
  112163. * The zx coefficients of the spherical polynomial
  112164. */
  112165. zx: Vector3;
  112166. /**
  112167. * Adds an ambient color to the spherical polynomial
  112168. * @param color the color to add
  112169. */
  112170. addAmbient(color: Color3): void;
  112171. /**
  112172. * Scales the spherical polynomial by the given amount
  112173. * @param scale the amount to scale
  112174. */
  112175. scaleInPlace(scale: number): void;
  112176. /**
  112177. * Gets the spherical polynomial from harmonics
  112178. * @param harmonics the spherical harmonics
  112179. * @returns the spherical polynomial
  112180. */
  112181. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  112182. /**
  112183. * Constructs a spherical polynomial from an array.
  112184. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  112185. * @returns the spherical polynomial
  112186. */
  112187. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  112188. }
  112189. }
  112190. declare module BABYLON {
  112191. /**
  112192. * Defines the source of the internal texture
  112193. */
  112194. export enum InternalTextureSource {
  112195. /**
  112196. * The source of the texture data is unknown
  112197. */
  112198. Unknown = 0,
  112199. /**
  112200. * Texture data comes from an URL
  112201. */
  112202. Url = 1,
  112203. /**
  112204. * Texture data is only used for temporary storage
  112205. */
  112206. Temp = 2,
  112207. /**
  112208. * Texture data comes from raw data (ArrayBuffer)
  112209. */
  112210. Raw = 3,
  112211. /**
  112212. * Texture content is dynamic (video or dynamic texture)
  112213. */
  112214. Dynamic = 4,
  112215. /**
  112216. * Texture content is generated by rendering to it
  112217. */
  112218. RenderTarget = 5,
  112219. /**
  112220. * Texture content is part of a multi render target process
  112221. */
  112222. MultiRenderTarget = 6,
  112223. /**
  112224. * Texture data comes from a cube data file
  112225. */
  112226. Cube = 7,
  112227. /**
  112228. * Texture data comes from a raw cube data
  112229. */
  112230. CubeRaw = 8,
  112231. /**
  112232. * Texture data come from a prefiltered cube data file
  112233. */
  112234. CubePrefiltered = 9,
  112235. /**
  112236. * Texture content is raw 3D data
  112237. */
  112238. Raw3D = 10,
  112239. /**
  112240. * Texture content is raw 2D array data
  112241. */
  112242. Raw2DArray = 11,
  112243. /**
  112244. * Texture content is a depth texture
  112245. */
  112246. Depth = 12,
  112247. /**
  112248. * Texture data comes from a raw cube data encoded with RGBD
  112249. */
  112250. CubeRawRGBD = 13
  112251. }
  112252. /**
  112253. * Class used to store data associated with WebGL texture data for the engine
  112254. * This class should not be used directly
  112255. */
  112256. export class InternalTexture {
  112257. /** @hidden */
  112258. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  112259. /**
  112260. * Defines if the texture is ready
  112261. */
  112262. isReady: boolean;
  112263. /**
  112264. * Defines if the texture is a cube texture
  112265. */
  112266. isCube: boolean;
  112267. /**
  112268. * Defines if the texture contains 3D data
  112269. */
  112270. is3D: boolean;
  112271. /**
  112272. * Defines if the texture contains 2D array data
  112273. */
  112274. is2DArray: boolean;
  112275. /**
  112276. * Defines if the texture contains multiview data
  112277. */
  112278. isMultiview: boolean;
  112279. /**
  112280. * Gets the URL used to load this texture
  112281. */
  112282. url: string;
  112283. /**
  112284. * Gets the sampling mode of the texture
  112285. */
  112286. samplingMode: number;
  112287. /**
  112288. * Gets a boolean indicating if the texture needs mipmaps generation
  112289. */
  112290. generateMipMaps: boolean;
  112291. /**
  112292. * Gets the number of samples used by the texture (WebGL2+ only)
  112293. */
  112294. samples: number;
  112295. /**
  112296. * Gets the type of the texture (int, float...)
  112297. */
  112298. type: number;
  112299. /**
  112300. * Gets the format of the texture (RGB, RGBA...)
  112301. */
  112302. format: number;
  112303. /**
  112304. * Observable called when the texture is loaded
  112305. */
  112306. onLoadedObservable: Observable<InternalTexture>;
  112307. /**
  112308. * Gets the width of the texture
  112309. */
  112310. width: number;
  112311. /**
  112312. * Gets the height of the texture
  112313. */
  112314. height: number;
  112315. /**
  112316. * Gets the depth of the texture
  112317. */
  112318. depth: number;
  112319. /**
  112320. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  112321. */
  112322. baseWidth: number;
  112323. /**
  112324. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  112325. */
  112326. baseHeight: number;
  112327. /**
  112328. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  112329. */
  112330. baseDepth: number;
  112331. /**
  112332. * Gets a boolean indicating if the texture is inverted on Y axis
  112333. */
  112334. invertY: boolean;
  112335. /** @hidden */
  112336. _invertVScale: boolean;
  112337. /** @hidden */
  112338. _associatedChannel: number;
  112339. /** @hidden */
  112340. _source: InternalTextureSource;
  112341. /** @hidden */
  112342. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  112343. /** @hidden */
  112344. _bufferView: Nullable<ArrayBufferView>;
  112345. /** @hidden */
  112346. _bufferViewArray: Nullable<ArrayBufferView[]>;
  112347. /** @hidden */
  112348. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  112349. /** @hidden */
  112350. _size: number;
  112351. /** @hidden */
  112352. _extension: string;
  112353. /** @hidden */
  112354. _files: Nullable<string[]>;
  112355. /** @hidden */
  112356. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  112357. /** @hidden */
  112358. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  112359. /** @hidden */
  112360. _framebuffer: Nullable<WebGLFramebuffer>;
  112361. /** @hidden */
  112362. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  112363. /** @hidden */
  112364. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  112365. /** @hidden */
  112366. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  112367. /** @hidden */
  112368. _attachments: Nullable<number[]>;
  112369. /** @hidden */
  112370. _cachedCoordinatesMode: Nullable<number>;
  112371. /** @hidden */
  112372. _cachedWrapU: Nullable<number>;
  112373. /** @hidden */
  112374. _cachedWrapV: Nullable<number>;
  112375. /** @hidden */
  112376. _cachedWrapR: Nullable<number>;
  112377. /** @hidden */
  112378. _cachedAnisotropicFilteringLevel: Nullable<number>;
  112379. /** @hidden */
  112380. _isDisabled: boolean;
  112381. /** @hidden */
  112382. _compression: Nullable<string>;
  112383. /** @hidden */
  112384. _generateStencilBuffer: boolean;
  112385. /** @hidden */
  112386. _generateDepthBuffer: boolean;
  112387. /** @hidden */
  112388. _comparisonFunction: number;
  112389. /** @hidden */
  112390. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  112391. /** @hidden */
  112392. _lodGenerationScale: number;
  112393. /** @hidden */
  112394. _lodGenerationOffset: number;
  112395. /** @hidden */
  112396. _depthStencilTexture: Nullable<InternalTexture>;
  112397. /** @hidden */
  112398. _colorTextureArray: Nullable<WebGLTexture>;
  112399. /** @hidden */
  112400. _depthStencilTextureArray: Nullable<WebGLTexture>;
  112401. /** @hidden */
  112402. _lodTextureHigh: Nullable<BaseTexture>;
  112403. /** @hidden */
  112404. _lodTextureMid: Nullable<BaseTexture>;
  112405. /** @hidden */
  112406. _lodTextureLow: Nullable<BaseTexture>;
  112407. /** @hidden */
  112408. _isRGBD: boolean;
  112409. /** @hidden */
  112410. _linearSpecularLOD: boolean;
  112411. /** @hidden */
  112412. _irradianceTexture: Nullable<BaseTexture>;
  112413. /** @hidden */
  112414. _webGLTexture: Nullable<WebGLTexture>;
  112415. /** @hidden */
  112416. _references: number;
  112417. private _engine;
  112418. /**
  112419. * Gets the Engine the texture belongs to.
  112420. * @returns The babylon engine
  112421. */
  112422. getEngine(): ThinEngine;
  112423. /**
  112424. * Gets the data source type of the texture
  112425. */
  112426. get source(): InternalTextureSource;
  112427. /**
  112428. * Creates a new InternalTexture
  112429. * @param engine defines the engine to use
  112430. * @param source defines the type of data that will be used
  112431. * @param delayAllocation if the texture allocation should be delayed (default: false)
  112432. */
  112433. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  112434. /**
  112435. * Increments the number of references (ie. the number of Texture that point to it)
  112436. */
  112437. incrementReferences(): void;
  112438. /**
  112439. * Change the size of the texture (not the size of the content)
  112440. * @param width defines the new width
  112441. * @param height defines the new height
  112442. * @param depth defines the new depth (1 by default)
  112443. */
  112444. updateSize(width: int, height: int, depth?: int): void;
  112445. /** @hidden */
  112446. _rebuild(): void;
  112447. /** @hidden */
  112448. _swapAndDie(target: InternalTexture): void;
  112449. /**
  112450. * Dispose the current allocated resources
  112451. */
  112452. dispose(): void;
  112453. }
  112454. }
  112455. declare module BABYLON {
  112456. /**
  112457. * Class used to work with sound analyzer using fast fourier transform (FFT)
  112458. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  112459. */
  112460. export class Analyser {
  112461. /**
  112462. * Gets or sets the smoothing
  112463. * @ignorenaming
  112464. */
  112465. SMOOTHING: number;
  112466. /**
  112467. * Gets or sets the FFT table size
  112468. * @ignorenaming
  112469. */
  112470. FFT_SIZE: number;
  112471. /**
  112472. * Gets or sets the bar graph amplitude
  112473. * @ignorenaming
  112474. */
  112475. BARGRAPHAMPLITUDE: number;
  112476. /**
  112477. * Gets or sets the position of the debug canvas
  112478. * @ignorenaming
  112479. */
  112480. DEBUGCANVASPOS: {
  112481. x: number;
  112482. y: number;
  112483. };
  112484. /**
  112485. * Gets or sets the debug canvas size
  112486. * @ignorenaming
  112487. */
  112488. DEBUGCANVASSIZE: {
  112489. width: number;
  112490. height: number;
  112491. };
  112492. private _byteFreqs;
  112493. private _byteTime;
  112494. private _floatFreqs;
  112495. private _webAudioAnalyser;
  112496. private _debugCanvas;
  112497. private _debugCanvasContext;
  112498. private _scene;
  112499. private _registerFunc;
  112500. private _audioEngine;
  112501. /**
  112502. * Creates a new analyser
  112503. * @param scene defines hosting scene
  112504. */
  112505. constructor(scene: Scene);
  112506. /**
  112507. * Get the number of data values you will have to play with for the visualization
  112508. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  112509. * @returns a number
  112510. */
  112511. getFrequencyBinCount(): number;
  112512. /**
  112513. * Gets the current frequency data as a byte array
  112514. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  112515. * @returns a Uint8Array
  112516. */
  112517. getByteFrequencyData(): Uint8Array;
  112518. /**
  112519. * Gets the current waveform as a byte array
  112520. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  112521. * @returns a Uint8Array
  112522. */
  112523. getByteTimeDomainData(): Uint8Array;
  112524. /**
  112525. * Gets the current frequency data as a float array
  112526. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  112527. * @returns a Float32Array
  112528. */
  112529. getFloatFrequencyData(): Float32Array;
  112530. /**
  112531. * Renders the debug canvas
  112532. */
  112533. drawDebugCanvas(): void;
  112534. /**
  112535. * Stops rendering the debug canvas and removes it
  112536. */
  112537. stopDebugCanvas(): void;
  112538. /**
  112539. * Connects two audio nodes
  112540. * @param inputAudioNode defines first node to connect
  112541. * @param outputAudioNode defines second node to connect
  112542. */
  112543. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  112544. /**
  112545. * Releases all associated resources
  112546. */
  112547. dispose(): void;
  112548. }
  112549. }
  112550. declare module BABYLON {
  112551. /**
  112552. * This represents an audio engine and it is responsible
  112553. * to play, synchronize and analyse sounds throughout the application.
  112554. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  112555. */
  112556. export interface IAudioEngine extends IDisposable {
  112557. /**
  112558. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  112559. */
  112560. readonly canUseWebAudio: boolean;
  112561. /**
  112562. * Gets the current AudioContext if available.
  112563. */
  112564. readonly audioContext: Nullable<AudioContext>;
  112565. /**
  112566. * The master gain node defines the global audio volume of your audio engine.
  112567. */
  112568. readonly masterGain: GainNode;
  112569. /**
  112570. * Gets whether or not mp3 are supported by your browser.
  112571. */
  112572. readonly isMP3supported: boolean;
  112573. /**
  112574. * Gets whether or not ogg are supported by your browser.
  112575. */
  112576. readonly isOGGsupported: boolean;
  112577. /**
  112578. * Defines if Babylon should emit a warning if WebAudio is not supported.
  112579. * @ignoreNaming
  112580. */
  112581. WarnedWebAudioUnsupported: boolean;
  112582. /**
  112583. * Defines if the audio engine relies on a custom unlocked button.
  112584. * In this case, the embedded button will not be displayed.
  112585. */
  112586. useCustomUnlockedButton: boolean;
  112587. /**
  112588. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  112589. */
  112590. readonly unlocked: boolean;
  112591. /**
  112592. * Event raised when audio has been unlocked on the browser.
  112593. */
  112594. onAudioUnlockedObservable: Observable<AudioEngine>;
  112595. /**
  112596. * Event raised when audio has been locked on the browser.
  112597. */
  112598. onAudioLockedObservable: Observable<AudioEngine>;
  112599. /**
  112600. * Flags the audio engine in Locked state.
  112601. * This happens due to new browser policies preventing audio to autoplay.
  112602. */
  112603. lock(): void;
  112604. /**
  112605. * Unlocks the audio engine once a user action has been done on the dom.
  112606. * This is helpful to resume play once browser policies have been satisfied.
  112607. */
  112608. unlock(): void;
  112609. /**
  112610. * Gets the global volume sets on the master gain.
  112611. * @returns the global volume if set or -1 otherwise
  112612. */
  112613. getGlobalVolume(): number;
  112614. /**
  112615. * Sets the global volume of your experience (sets on the master gain).
  112616. * @param newVolume Defines the new global volume of the application
  112617. */
  112618. setGlobalVolume(newVolume: number): void;
  112619. /**
  112620. * Connect the audio engine to an audio analyser allowing some amazing
  112621. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  112622. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  112623. * @param analyser The analyser to connect to the engine
  112624. */
  112625. connectToAnalyser(analyser: Analyser): void;
  112626. }
  112627. /**
  112628. * This represents the default audio engine used in babylon.
  112629. * It is responsible to play, synchronize and analyse sounds throughout the application.
  112630. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  112631. */
  112632. export class AudioEngine implements IAudioEngine {
  112633. private _audioContext;
  112634. private _audioContextInitialized;
  112635. private _muteButton;
  112636. private _hostElement;
  112637. /**
  112638. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  112639. */
  112640. canUseWebAudio: boolean;
  112641. /**
  112642. * The master gain node defines the global audio volume of your audio engine.
  112643. */
  112644. masterGain: GainNode;
  112645. /**
  112646. * Defines if Babylon should emit a warning if WebAudio is not supported.
  112647. * @ignoreNaming
  112648. */
  112649. WarnedWebAudioUnsupported: boolean;
  112650. /**
  112651. * Gets whether or not mp3 are supported by your browser.
  112652. */
  112653. isMP3supported: boolean;
  112654. /**
  112655. * Gets whether or not ogg are supported by your browser.
  112656. */
  112657. isOGGsupported: boolean;
  112658. /**
  112659. * Gets whether audio has been unlocked on the device.
  112660. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  112661. * a user interaction has happened.
  112662. */
  112663. unlocked: boolean;
  112664. /**
  112665. * Defines if the audio engine relies on a custom unlocked button.
  112666. * In this case, the embedded button will not be displayed.
  112667. */
  112668. useCustomUnlockedButton: boolean;
  112669. /**
  112670. * Event raised when audio has been unlocked on the browser.
  112671. */
  112672. onAudioUnlockedObservable: Observable<AudioEngine>;
  112673. /**
  112674. * Event raised when audio has been locked on the browser.
  112675. */
  112676. onAudioLockedObservable: Observable<AudioEngine>;
  112677. /**
  112678. * Gets the current AudioContext if available.
  112679. */
  112680. get audioContext(): Nullable<AudioContext>;
  112681. private _connectedAnalyser;
  112682. /**
  112683. * Instantiates a new audio engine.
  112684. *
  112685. * There should be only one per page as some browsers restrict the number
  112686. * of audio contexts you can create.
  112687. * @param hostElement defines the host element where to display the mute icon if necessary
  112688. */
  112689. constructor(hostElement?: Nullable<HTMLElement>);
  112690. /**
  112691. * Flags the audio engine in Locked state.
  112692. * This happens due to new browser policies preventing audio to autoplay.
  112693. */
  112694. lock(): void;
  112695. /**
  112696. * Unlocks the audio engine once a user action has been done on the dom.
  112697. * This is helpful to resume play once browser policies have been satisfied.
  112698. */
  112699. unlock(): void;
  112700. private _resumeAudioContext;
  112701. private _initializeAudioContext;
  112702. private _tryToRun;
  112703. private _triggerRunningState;
  112704. private _triggerSuspendedState;
  112705. private _displayMuteButton;
  112706. private _moveButtonToTopLeft;
  112707. private _onResize;
  112708. private _hideMuteButton;
  112709. /**
  112710. * Destroy and release the resources associated with the audio ccontext.
  112711. */
  112712. dispose(): void;
  112713. /**
  112714. * Gets the global volume sets on the master gain.
  112715. * @returns the global volume if set or -1 otherwise
  112716. */
  112717. getGlobalVolume(): number;
  112718. /**
  112719. * Sets the global volume of your experience (sets on the master gain).
  112720. * @param newVolume Defines the new global volume of the application
  112721. */
  112722. setGlobalVolume(newVolume: number): void;
  112723. /**
  112724. * Connect the audio engine to an audio analyser allowing some amazing
  112725. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  112726. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  112727. * @param analyser The analyser to connect to the engine
  112728. */
  112729. connectToAnalyser(analyser: Analyser): void;
  112730. }
  112731. }
  112732. declare module BABYLON {
  112733. /**
  112734. * Interface used to present a loading screen while loading a scene
  112735. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  112736. */
  112737. export interface ILoadingScreen {
  112738. /**
  112739. * Function called to display the loading screen
  112740. */
  112741. displayLoadingUI: () => void;
  112742. /**
  112743. * Function called to hide the loading screen
  112744. */
  112745. hideLoadingUI: () => void;
  112746. /**
  112747. * Gets or sets the color to use for the background
  112748. */
  112749. loadingUIBackgroundColor: string;
  112750. /**
  112751. * Gets or sets the text to display while loading
  112752. */
  112753. loadingUIText: string;
  112754. }
  112755. /**
  112756. * Class used for the default loading screen
  112757. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  112758. */
  112759. export class DefaultLoadingScreen implements ILoadingScreen {
  112760. private _renderingCanvas;
  112761. private _loadingText;
  112762. private _loadingDivBackgroundColor;
  112763. private _loadingDiv;
  112764. private _loadingTextDiv;
  112765. /** Gets or sets the logo url to use for the default loading screen */
  112766. static DefaultLogoUrl: string;
  112767. /** Gets or sets the spinner url to use for the default loading screen */
  112768. static DefaultSpinnerUrl: string;
  112769. /**
  112770. * Creates a new default loading screen
  112771. * @param _renderingCanvas defines the canvas used to render the scene
  112772. * @param _loadingText defines the default text to display
  112773. * @param _loadingDivBackgroundColor defines the default background color
  112774. */
  112775. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  112776. /**
  112777. * Function called to display the loading screen
  112778. */
  112779. displayLoadingUI(): void;
  112780. /**
  112781. * Function called to hide the loading screen
  112782. */
  112783. hideLoadingUI(): void;
  112784. /**
  112785. * Gets or sets the text to display while loading
  112786. */
  112787. set loadingUIText(text: string);
  112788. get loadingUIText(): string;
  112789. /**
  112790. * Gets or sets the color to use for the background
  112791. */
  112792. get loadingUIBackgroundColor(): string;
  112793. set loadingUIBackgroundColor(color: string);
  112794. private _resizeLoadingUI;
  112795. }
  112796. }
  112797. declare module BABYLON {
  112798. /**
  112799. * Interface for any object that can request an animation frame
  112800. */
  112801. export interface ICustomAnimationFrameRequester {
  112802. /**
  112803. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  112804. */
  112805. renderFunction?: Function;
  112806. /**
  112807. * Called to request the next frame to render to
  112808. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  112809. */
  112810. requestAnimationFrame: Function;
  112811. /**
  112812. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  112813. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  112814. */
  112815. requestID?: number;
  112816. }
  112817. }
  112818. declare module BABYLON {
  112819. /**
  112820. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  112821. */
  112822. export class PerformanceMonitor {
  112823. private _enabled;
  112824. private _rollingFrameTime;
  112825. private _lastFrameTimeMs;
  112826. /**
  112827. * constructor
  112828. * @param frameSampleSize The number of samples required to saturate the sliding window
  112829. */
  112830. constructor(frameSampleSize?: number);
  112831. /**
  112832. * Samples current frame
  112833. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  112834. */
  112835. sampleFrame(timeMs?: number): void;
  112836. /**
  112837. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  112838. */
  112839. get averageFrameTime(): number;
  112840. /**
  112841. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  112842. */
  112843. get averageFrameTimeVariance(): number;
  112844. /**
  112845. * Returns the frame time of the most recent frame
  112846. */
  112847. get instantaneousFrameTime(): number;
  112848. /**
  112849. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  112850. */
  112851. get averageFPS(): number;
  112852. /**
  112853. * Returns the average framerate in frames per second using the most recent frame time
  112854. */
  112855. get instantaneousFPS(): number;
  112856. /**
  112857. * Returns true if enough samples have been taken to completely fill the sliding window
  112858. */
  112859. get isSaturated(): boolean;
  112860. /**
  112861. * Enables contributions to the sliding window sample set
  112862. */
  112863. enable(): void;
  112864. /**
  112865. * Disables contributions to the sliding window sample set
  112866. * Samples will not be interpolated over the disabled period
  112867. */
  112868. disable(): void;
  112869. /**
  112870. * Returns true if sampling is enabled
  112871. */
  112872. get isEnabled(): boolean;
  112873. /**
  112874. * Resets performance monitor
  112875. */
  112876. reset(): void;
  112877. }
  112878. /**
  112879. * RollingAverage
  112880. *
  112881. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  112882. */
  112883. export class RollingAverage {
  112884. /**
  112885. * Current average
  112886. */
  112887. average: number;
  112888. /**
  112889. * Current variance
  112890. */
  112891. variance: number;
  112892. protected _samples: Array<number>;
  112893. protected _sampleCount: number;
  112894. protected _pos: number;
  112895. protected _m2: number;
  112896. /**
  112897. * constructor
  112898. * @param length The number of samples required to saturate the sliding window
  112899. */
  112900. constructor(length: number);
  112901. /**
  112902. * Adds a sample to the sample set
  112903. * @param v The sample value
  112904. */
  112905. add(v: number): void;
  112906. /**
  112907. * Returns previously added values or null if outside of history or outside the sliding window domain
  112908. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  112909. * @return Value previously recorded with add() or null if outside of range
  112910. */
  112911. history(i: number): number;
  112912. /**
  112913. * Returns true if enough samples have been taken to completely fill the sliding window
  112914. * @return true if sample-set saturated
  112915. */
  112916. isSaturated(): boolean;
  112917. /**
  112918. * Resets the rolling average (equivalent to 0 samples taken so far)
  112919. */
  112920. reset(): void;
  112921. /**
  112922. * Wraps a value around the sample range boundaries
  112923. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  112924. * @return Wrapped position in sample range
  112925. */
  112926. protected _wrapPosition(i: number): number;
  112927. }
  112928. }
  112929. declare module BABYLON {
  112930. /**
  112931. * This class is used to track a performance counter which is number based.
  112932. * The user has access to many properties which give statistics of different nature.
  112933. *
  112934. * The implementer can track two kinds of Performance Counter: time and count.
  112935. * 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.
  112936. * 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.
  112937. */
  112938. export class PerfCounter {
  112939. /**
  112940. * Gets or sets a global boolean to turn on and off all the counters
  112941. */
  112942. static Enabled: boolean;
  112943. /**
  112944. * Returns the smallest value ever
  112945. */
  112946. get min(): number;
  112947. /**
  112948. * Returns the biggest value ever
  112949. */
  112950. get max(): number;
  112951. /**
  112952. * Returns the average value since the performance counter is running
  112953. */
  112954. get average(): number;
  112955. /**
  112956. * Returns the average value of the last second the counter was monitored
  112957. */
  112958. get lastSecAverage(): number;
  112959. /**
  112960. * Returns the current value
  112961. */
  112962. get current(): number;
  112963. /**
  112964. * Gets the accumulated total
  112965. */
  112966. get total(): number;
  112967. /**
  112968. * Gets the total value count
  112969. */
  112970. get count(): number;
  112971. /**
  112972. * Creates a new counter
  112973. */
  112974. constructor();
  112975. /**
  112976. * Call this method to start monitoring a new frame.
  112977. * 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.
  112978. */
  112979. fetchNewFrame(): void;
  112980. /**
  112981. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  112982. * @param newCount the count value to add to the monitored count
  112983. * @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.
  112984. */
  112985. addCount(newCount: number, fetchResult: boolean): void;
  112986. /**
  112987. * Start monitoring this performance counter
  112988. */
  112989. beginMonitoring(): void;
  112990. /**
  112991. * Compute the time lapsed since the previous beginMonitoring() call.
  112992. * @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
  112993. */
  112994. endMonitoring(newFrame?: boolean): void;
  112995. private _fetchResult;
  112996. private _startMonitoringTime;
  112997. private _min;
  112998. private _max;
  112999. private _average;
  113000. private _current;
  113001. private _totalValueCount;
  113002. private _totalAccumulated;
  113003. private _lastSecAverage;
  113004. private _lastSecAccumulated;
  113005. private _lastSecTime;
  113006. private _lastSecValueCount;
  113007. }
  113008. }
  113009. declare module BABYLON {
  113010. interface ThinEngine {
  113011. /**
  113012. * Sets alpha constants used by some alpha blending modes
  113013. * @param r defines the red component
  113014. * @param g defines the green component
  113015. * @param b defines the blue component
  113016. * @param a defines the alpha component
  113017. */
  113018. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  113019. /**
  113020. * Sets the current alpha mode
  113021. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  113022. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  113023. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  113024. */
  113025. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  113026. /**
  113027. * Gets the current alpha mode
  113028. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  113029. * @returns the current alpha mode
  113030. */
  113031. getAlphaMode(): number;
  113032. /**
  113033. * Sets the current alpha equation
  113034. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  113035. */
  113036. setAlphaEquation(equation: number): void;
  113037. /**
  113038. * Gets the current alpha equation.
  113039. * @returns the current alpha equation
  113040. */
  113041. getAlphaEquation(): number;
  113042. }
  113043. }
  113044. declare module BABYLON {
  113045. interface ThinEngine {
  113046. /** @hidden */
  113047. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  113048. }
  113049. }
  113050. declare module BABYLON {
  113051. /**
  113052. * Defines the interface used by display changed events
  113053. */
  113054. export interface IDisplayChangedEventArgs {
  113055. /** Gets the vrDisplay object (if any) */
  113056. vrDisplay: Nullable<any>;
  113057. /** Gets a boolean indicating if webVR is supported */
  113058. vrSupported: boolean;
  113059. }
  113060. /**
  113061. * Defines the interface used by objects containing a viewport (like a camera)
  113062. */
  113063. interface IViewportOwnerLike {
  113064. /**
  113065. * Gets or sets the viewport
  113066. */
  113067. viewport: IViewportLike;
  113068. }
  113069. /**
  113070. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  113071. */
  113072. export class Engine extends ThinEngine {
  113073. /** Defines that alpha blending is disabled */
  113074. static readonly ALPHA_DISABLE: number;
  113075. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  113076. static readonly ALPHA_ADD: number;
  113077. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  113078. static readonly ALPHA_COMBINE: number;
  113079. /** Defines that alpha blending to DEST - SRC * DEST */
  113080. static readonly ALPHA_SUBTRACT: number;
  113081. /** Defines that alpha blending to SRC * DEST */
  113082. static readonly ALPHA_MULTIPLY: number;
  113083. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  113084. static readonly ALPHA_MAXIMIZED: number;
  113085. /** Defines that alpha blending to SRC + DEST */
  113086. static readonly ALPHA_ONEONE: number;
  113087. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  113088. static readonly ALPHA_PREMULTIPLIED: number;
  113089. /**
  113090. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  113091. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  113092. */
  113093. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  113094. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  113095. static readonly ALPHA_INTERPOLATE: number;
  113096. /**
  113097. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  113098. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  113099. */
  113100. static readonly ALPHA_SCREENMODE: number;
  113101. /** Defines that the ressource is not delayed*/
  113102. static readonly DELAYLOADSTATE_NONE: number;
  113103. /** Defines that the ressource was successfully delay loaded */
  113104. static readonly DELAYLOADSTATE_LOADED: number;
  113105. /** Defines that the ressource is currently delay loading */
  113106. static readonly DELAYLOADSTATE_LOADING: number;
  113107. /** Defines that the ressource is delayed and has not started loading */
  113108. static readonly DELAYLOADSTATE_NOTLOADED: number;
  113109. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  113110. static readonly NEVER: number;
  113111. /** 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 */
  113112. static readonly ALWAYS: number;
  113113. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  113114. static readonly LESS: number;
  113115. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  113116. static readonly EQUAL: number;
  113117. /** 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 */
  113118. static readonly LEQUAL: number;
  113119. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  113120. static readonly GREATER: number;
  113121. /** 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 */
  113122. static readonly GEQUAL: number;
  113123. /** 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 */
  113124. static readonly NOTEQUAL: number;
  113125. /** Passed to stencilOperation to specify that stencil value must be kept */
  113126. static readonly KEEP: number;
  113127. /** Passed to stencilOperation to specify that stencil value must be replaced */
  113128. static readonly REPLACE: number;
  113129. /** Passed to stencilOperation to specify that stencil value must be incremented */
  113130. static readonly INCR: number;
  113131. /** Passed to stencilOperation to specify that stencil value must be decremented */
  113132. static readonly DECR: number;
  113133. /** Passed to stencilOperation to specify that stencil value must be inverted */
  113134. static readonly INVERT: number;
  113135. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  113136. static readonly INCR_WRAP: number;
  113137. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  113138. static readonly DECR_WRAP: number;
  113139. /** Texture is not repeating outside of 0..1 UVs */
  113140. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  113141. /** Texture is repeating outside of 0..1 UVs */
  113142. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  113143. /** Texture is repeating and mirrored */
  113144. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  113145. /** ALPHA */
  113146. static readonly TEXTUREFORMAT_ALPHA: number;
  113147. /** LUMINANCE */
  113148. static readonly TEXTUREFORMAT_LUMINANCE: number;
  113149. /** LUMINANCE_ALPHA */
  113150. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  113151. /** RGB */
  113152. static readonly TEXTUREFORMAT_RGB: number;
  113153. /** RGBA */
  113154. static readonly TEXTUREFORMAT_RGBA: number;
  113155. /** RED */
  113156. static readonly TEXTUREFORMAT_RED: number;
  113157. /** RED (2nd reference) */
  113158. static readonly TEXTUREFORMAT_R: number;
  113159. /** RG */
  113160. static readonly TEXTUREFORMAT_RG: number;
  113161. /** RED_INTEGER */
  113162. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  113163. /** RED_INTEGER (2nd reference) */
  113164. static readonly TEXTUREFORMAT_R_INTEGER: number;
  113165. /** RG_INTEGER */
  113166. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  113167. /** RGB_INTEGER */
  113168. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  113169. /** RGBA_INTEGER */
  113170. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  113171. /** UNSIGNED_BYTE */
  113172. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  113173. /** UNSIGNED_BYTE (2nd reference) */
  113174. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  113175. /** FLOAT */
  113176. static readonly TEXTURETYPE_FLOAT: number;
  113177. /** HALF_FLOAT */
  113178. static readonly TEXTURETYPE_HALF_FLOAT: number;
  113179. /** BYTE */
  113180. static readonly TEXTURETYPE_BYTE: number;
  113181. /** SHORT */
  113182. static readonly TEXTURETYPE_SHORT: number;
  113183. /** UNSIGNED_SHORT */
  113184. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  113185. /** INT */
  113186. static readonly TEXTURETYPE_INT: number;
  113187. /** UNSIGNED_INT */
  113188. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  113189. /** UNSIGNED_SHORT_4_4_4_4 */
  113190. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  113191. /** UNSIGNED_SHORT_5_5_5_1 */
  113192. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  113193. /** UNSIGNED_SHORT_5_6_5 */
  113194. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  113195. /** UNSIGNED_INT_2_10_10_10_REV */
  113196. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  113197. /** UNSIGNED_INT_24_8 */
  113198. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  113199. /** UNSIGNED_INT_10F_11F_11F_REV */
  113200. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  113201. /** UNSIGNED_INT_5_9_9_9_REV */
  113202. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  113203. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  113204. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  113205. /** nearest is mag = nearest and min = nearest and mip = linear */
  113206. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  113207. /** Bilinear is mag = linear and min = linear and mip = nearest */
  113208. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  113209. /** Trilinear is mag = linear and min = linear and mip = linear */
  113210. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  113211. /** nearest is mag = nearest and min = nearest and mip = linear */
  113212. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  113213. /** Bilinear is mag = linear and min = linear and mip = nearest */
  113214. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  113215. /** Trilinear is mag = linear and min = linear and mip = linear */
  113216. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  113217. /** mag = nearest and min = nearest and mip = nearest */
  113218. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  113219. /** mag = nearest and min = linear and mip = nearest */
  113220. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  113221. /** mag = nearest and min = linear and mip = linear */
  113222. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  113223. /** mag = nearest and min = linear and mip = none */
  113224. static readonly TEXTURE_NEAREST_LINEAR: number;
  113225. /** mag = nearest and min = nearest and mip = none */
  113226. static readonly TEXTURE_NEAREST_NEAREST: number;
  113227. /** mag = linear and min = nearest and mip = nearest */
  113228. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  113229. /** mag = linear and min = nearest and mip = linear */
  113230. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  113231. /** mag = linear and min = linear and mip = none */
  113232. static readonly TEXTURE_LINEAR_LINEAR: number;
  113233. /** mag = linear and min = nearest and mip = none */
  113234. static readonly TEXTURE_LINEAR_NEAREST: number;
  113235. /** Explicit coordinates mode */
  113236. static readonly TEXTURE_EXPLICIT_MODE: number;
  113237. /** Spherical coordinates mode */
  113238. static readonly TEXTURE_SPHERICAL_MODE: number;
  113239. /** Planar coordinates mode */
  113240. static readonly TEXTURE_PLANAR_MODE: number;
  113241. /** Cubic coordinates mode */
  113242. static readonly TEXTURE_CUBIC_MODE: number;
  113243. /** Projection coordinates mode */
  113244. static readonly TEXTURE_PROJECTION_MODE: number;
  113245. /** Skybox coordinates mode */
  113246. static readonly TEXTURE_SKYBOX_MODE: number;
  113247. /** Inverse Cubic coordinates mode */
  113248. static readonly TEXTURE_INVCUBIC_MODE: number;
  113249. /** Equirectangular coordinates mode */
  113250. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  113251. /** Equirectangular Fixed coordinates mode */
  113252. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  113253. /** Equirectangular Fixed Mirrored coordinates mode */
  113254. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  113255. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  113256. static readonly SCALEMODE_FLOOR: number;
  113257. /** Defines that texture rescaling will look for the nearest power of 2 size */
  113258. static readonly SCALEMODE_NEAREST: number;
  113259. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  113260. static readonly SCALEMODE_CEILING: number;
  113261. /**
  113262. * Returns the current npm package of the sdk
  113263. */
  113264. static get NpmPackage(): string;
  113265. /**
  113266. * Returns the current version of the framework
  113267. */
  113268. static get Version(): string;
  113269. /** Gets the list of created engines */
  113270. static get Instances(): Engine[];
  113271. /**
  113272. * Gets the latest created engine
  113273. */
  113274. static get LastCreatedEngine(): Nullable<Engine>;
  113275. /**
  113276. * Gets the latest created scene
  113277. */
  113278. static get LastCreatedScene(): Nullable<Scene>;
  113279. /**
  113280. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  113281. * @param flag defines which part of the materials must be marked as dirty
  113282. * @param predicate defines a predicate used to filter which materials should be affected
  113283. */
  113284. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  113285. /**
  113286. * Method called to create the default loading screen.
  113287. * This can be overriden in your own app.
  113288. * @param canvas The rendering canvas element
  113289. * @returns The loading screen
  113290. */
  113291. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  113292. /**
  113293. * Method called to create the default rescale post process on each engine.
  113294. */
  113295. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  113296. /**
  113297. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  113298. **/
  113299. enableOfflineSupport: boolean;
  113300. /**
  113301. * 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)
  113302. **/
  113303. disableManifestCheck: boolean;
  113304. /**
  113305. * Gets the list of created scenes
  113306. */
  113307. scenes: Scene[];
  113308. /**
  113309. * Event raised when a new scene is created
  113310. */
  113311. onNewSceneAddedObservable: Observable<Scene>;
  113312. /**
  113313. * Gets the list of created postprocesses
  113314. */
  113315. postProcesses: PostProcess[];
  113316. /**
  113317. * Gets a boolean indicating if the pointer is currently locked
  113318. */
  113319. isPointerLock: boolean;
  113320. /**
  113321. * Observable event triggered each time the rendering canvas is resized
  113322. */
  113323. onResizeObservable: Observable<Engine>;
  113324. /**
  113325. * Observable event triggered each time the canvas loses focus
  113326. */
  113327. onCanvasBlurObservable: Observable<Engine>;
  113328. /**
  113329. * Observable event triggered each time the canvas gains focus
  113330. */
  113331. onCanvasFocusObservable: Observable<Engine>;
  113332. /**
  113333. * Observable event triggered each time the canvas receives pointerout event
  113334. */
  113335. onCanvasPointerOutObservable: Observable<PointerEvent>;
  113336. /**
  113337. * Observable raised when the engine begins a new frame
  113338. */
  113339. onBeginFrameObservable: Observable<Engine>;
  113340. /**
  113341. * If set, will be used to request the next animation frame for the render loop
  113342. */
  113343. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  113344. /**
  113345. * Observable raised when the engine ends the current frame
  113346. */
  113347. onEndFrameObservable: Observable<Engine>;
  113348. /**
  113349. * Observable raised when the engine is about to compile a shader
  113350. */
  113351. onBeforeShaderCompilationObservable: Observable<Engine>;
  113352. /**
  113353. * Observable raised when the engine has jsut compiled a shader
  113354. */
  113355. onAfterShaderCompilationObservable: Observable<Engine>;
  113356. /**
  113357. * Gets the audio engine
  113358. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  113359. * @ignorenaming
  113360. */
  113361. static audioEngine: IAudioEngine;
  113362. /**
  113363. * Default AudioEngine factory responsible of creating the Audio Engine.
  113364. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  113365. */
  113366. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  113367. /**
  113368. * Default offline support factory responsible of creating a tool used to store data locally.
  113369. * By default, this will create a Database object if the workload has been embedded.
  113370. */
  113371. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  113372. private _loadingScreen;
  113373. private _pointerLockRequested;
  113374. private _rescalePostProcess;
  113375. private _deterministicLockstep;
  113376. private _lockstepMaxSteps;
  113377. private _timeStep;
  113378. protected get _supportsHardwareTextureRescaling(): boolean;
  113379. private _fps;
  113380. private _deltaTime;
  113381. /** @hidden */
  113382. _drawCalls: PerfCounter;
  113383. /** 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 */
  113384. canvasTabIndex: number;
  113385. /**
  113386. * Turn this value on if you want to pause FPS computation when in background
  113387. */
  113388. disablePerformanceMonitorInBackground: boolean;
  113389. private _performanceMonitor;
  113390. /**
  113391. * Gets the performance monitor attached to this engine
  113392. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  113393. */
  113394. get performanceMonitor(): PerformanceMonitor;
  113395. private _onFocus;
  113396. private _onBlur;
  113397. private _onCanvasPointerOut;
  113398. private _onCanvasBlur;
  113399. private _onCanvasFocus;
  113400. private _onFullscreenChange;
  113401. private _onPointerLockChange;
  113402. /**
  113403. * Gets the HTML element used to attach event listeners
  113404. * @returns a HTML element
  113405. */
  113406. getInputElement(): Nullable<HTMLElement>;
  113407. /**
  113408. * Creates a new engine
  113409. * @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
  113410. * @param antialias defines enable antialiasing (default: false)
  113411. * @param options defines further options to be sent to the getContext() function
  113412. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  113413. */
  113414. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  113415. /**
  113416. * Gets current aspect ratio
  113417. * @param viewportOwner defines the camera to use to get the aspect ratio
  113418. * @param useScreen defines if screen size must be used (or the current render target if any)
  113419. * @returns a number defining the aspect ratio
  113420. */
  113421. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  113422. /**
  113423. * Gets current screen aspect ratio
  113424. * @returns a number defining the aspect ratio
  113425. */
  113426. getScreenAspectRatio(): number;
  113427. /**
  113428. * Gets the client rect of the HTML canvas attached with the current webGL context
  113429. * @returns a client rectanglee
  113430. */
  113431. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  113432. /**
  113433. * Gets the client rect of the HTML element used for events
  113434. * @returns a client rectanglee
  113435. */
  113436. getInputElementClientRect(): Nullable<ClientRect>;
  113437. /**
  113438. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  113439. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  113440. * @returns true if engine is in deterministic lock step mode
  113441. */
  113442. isDeterministicLockStep(): boolean;
  113443. /**
  113444. * Gets the max steps when engine is running in deterministic lock step
  113445. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  113446. * @returns the max steps
  113447. */
  113448. getLockstepMaxSteps(): number;
  113449. /**
  113450. * Returns the time in ms between steps when using deterministic lock step.
  113451. * @returns time step in (ms)
  113452. */
  113453. getTimeStep(): number;
  113454. /**
  113455. * Force the mipmap generation for the given render target texture
  113456. * @param texture defines the render target texture to use
  113457. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  113458. */
  113459. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  113460. /** States */
  113461. /**
  113462. * Set various states to the webGL context
  113463. * @param culling defines backface culling state
  113464. * @param zOffset defines the value to apply to zOffset (0 by default)
  113465. * @param force defines if states must be applied even if cache is up to date
  113466. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  113467. */
  113468. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  113469. /**
  113470. * Set the z offset to apply to current rendering
  113471. * @param value defines the offset to apply
  113472. */
  113473. setZOffset(value: number): void;
  113474. /**
  113475. * Gets the current value of the zOffset
  113476. * @returns the current zOffset state
  113477. */
  113478. getZOffset(): number;
  113479. /**
  113480. * Enable or disable depth buffering
  113481. * @param enable defines the state to set
  113482. */
  113483. setDepthBuffer(enable: boolean): void;
  113484. /**
  113485. * Gets a boolean indicating if depth writing is enabled
  113486. * @returns the current depth writing state
  113487. */
  113488. getDepthWrite(): boolean;
  113489. /**
  113490. * Enable or disable depth writing
  113491. * @param enable defines the state to set
  113492. */
  113493. setDepthWrite(enable: boolean): void;
  113494. /**
  113495. * Gets a boolean indicating if stencil buffer is enabled
  113496. * @returns the current stencil buffer state
  113497. */
  113498. getStencilBuffer(): boolean;
  113499. /**
  113500. * Enable or disable the stencil buffer
  113501. * @param enable defines if the stencil buffer must be enabled or disabled
  113502. */
  113503. setStencilBuffer(enable: boolean): void;
  113504. /**
  113505. * Gets the current stencil mask
  113506. * @returns a number defining the new stencil mask to use
  113507. */
  113508. getStencilMask(): number;
  113509. /**
  113510. * Sets the current stencil mask
  113511. * @param mask defines the new stencil mask to use
  113512. */
  113513. setStencilMask(mask: number): void;
  113514. /**
  113515. * Gets the current stencil function
  113516. * @returns a number defining the stencil function to use
  113517. */
  113518. getStencilFunction(): number;
  113519. /**
  113520. * Gets the current stencil reference value
  113521. * @returns a number defining the stencil reference value to use
  113522. */
  113523. getStencilFunctionReference(): number;
  113524. /**
  113525. * Gets the current stencil mask
  113526. * @returns a number defining the stencil mask to use
  113527. */
  113528. getStencilFunctionMask(): number;
  113529. /**
  113530. * Sets the current stencil function
  113531. * @param stencilFunc defines the new stencil function to use
  113532. */
  113533. setStencilFunction(stencilFunc: number): void;
  113534. /**
  113535. * Sets the current stencil reference
  113536. * @param reference defines the new stencil reference to use
  113537. */
  113538. setStencilFunctionReference(reference: number): void;
  113539. /**
  113540. * Sets the current stencil mask
  113541. * @param mask defines the new stencil mask to use
  113542. */
  113543. setStencilFunctionMask(mask: number): void;
  113544. /**
  113545. * Gets the current stencil operation when stencil fails
  113546. * @returns a number defining stencil operation to use when stencil fails
  113547. */
  113548. getStencilOperationFail(): number;
  113549. /**
  113550. * Gets the current stencil operation when depth fails
  113551. * @returns a number defining stencil operation to use when depth fails
  113552. */
  113553. getStencilOperationDepthFail(): number;
  113554. /**
  113555. * Gets the current stencil operation when stencil passes
  113556. * @returns a number defining stencil operation to use when stencil passes
  113557. */
  113558. getStencilOperationPass(): number;
  113559. /**
  113560. * Sets the stencil operation to use when stencil fails
  113561. * @param operation defines the stencil operation to use when stencil fails
  113562. */
  113563. setStencilOperationFail(operation: number): void;
  113564. /**
  113565. * Sets the stencil operation to use when depth fails
  113566. * @param operation defines the stencil operation to use when depth fails
  113567. */
  113568. setStencilOperationDepthFail(operation: number): void;
  113569. /**
  113570. * Sets the stencil operation to use when stencil passes
  113571. * @param operation defines the stencil operation to use when stencil passes
  113572. */
  113573. setStencilOperationPass(operation: number): void;
  113574. /**
  113575. * Sets a boolean indicating if the dithering state is enabled or disabled
  113576. * @param value defines the dithering state
  113577. */
  113578. setDitheringState(value: boolean): void;
  113579. /**
  113580. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  113581. * @param value defines the rasterizer state
  113582. */
  113583. setRasterizerState(value: boolean): void;
  113584. /**
  113585. * Gets the current depth function
  113586. * @returns a number defining the depth function
  113587. */
  113588. getDepthFunction(): Nullable<number>;
  113589. /**
  113590. * Sets the current depth function
  113591. * @param depthFunc defines the function to use
  113592. */
  113593. setDepthFunction(depthFunc: number): void;
  113594. /**
  113595. * Sets the current depth function to GREATER
  113596. */
  113597. setDepthFunctionToGreater(): void;
  113598. /**
  113599. * Sets the current depth function to GEQUAL
  113600. */
  113601. setDepthFunctionToGreaterOrEqual(): void;
  113602. /**
  113603. * Sets the current depth function to LESS
  113604. */
  113605. setDepthFunctionToLess(): void;
  113606. /**
  113607. * Sets the current depth function to LEQUAL
  113608. */
  113609. setDepthFunctionToLessOrEqual(): void;
  113610. private _cachedStencilBuffer;
  113611. private _cachedStencilFunction;
  113612. private _cachedStencilMask;
  113613. private _cachedStencilOperationPass;
  113614. private _cachedStencilOperationFail;
  113615. private _cachedStencilOperationDepthFail;
  113616. private _cachedStencilReference;
  113617. /**
  113618. * Caches the the state of the stencil buffer
  113619. */
  113620. cacheStencilState(): void;
  113621. /**
  113622. * Restores the state of the stencil buffer
  113623. */
  113624. restoreStencilState(): void;
  113625. /**
  113626. * Directly set the WebGL Viewport
  113627. * @param x defines the x coordinate of the viewport (in screen space)
  113628. * @param y defines the y coordinate of the viewport (in screen space)
  113629. * @param width defines the width of the viewport (in screen space)
  113630. * @param height defines the height of the viewport (in screen space)
  113631. * @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
  113632. */
  113633. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  113634. /**
  113635. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  113636. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  113637. * @param y defines the y-coordinate of the corner of the clear rectangle
  113638. * @param width defines the width of the clear rectangle
  113639. * @param height defines the height of the clear rectangle
  113640. * @param clearColor defines the clear color
  113641. */
  113642. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  113643. /**
  113644. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  113645. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  113646. * @param y defines the y-coordinate of the corner of the clear rectangle
  113647. * @param width defines the width of the clear rectangle
  113648. * @param height defines the height of the clear rectangle
  113649. */
  113650. enableScissor(x: number, y: number, width: number, height: number): void;
  113651. /**
  113652. * Disable previously set scissor test rectangle
  113653. */
  113654. disableScissor(): void;
  113655. protected _reportDrawCall(): void;
  113656. /**
  113657. * Initializes a webVR display and starts listening to display change events
  113658. * The onVRDisplayChangedObservable will be notified upon these changes
  113659. * @returns The onVRDisplayChangedObservable
  113660. */
  113661. initWebVR(): Observable<IDisplayChangedEventArgs>;
  113662. /** @hidden */
  113663. _prepareVRComponent(): void;
  113664. /** @hidden */
  113665. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  113666. /** @hidden */
  113667. _submitVRFrame(): void;
  113668. /**
  113669. * Call this function to leave webVR mode
  113670. * Will do nothing if webVR is not supported or if there is no webVR device
  113671. * @see http://doc.babylonjs.com/how_to/webvr_camera
  113672. */
  113673. disableVR(): void;
  113674. /**
  113675. * Gets a boolean indicating that the system is in VR mode and is presenting
  113676. * @returns true if VR mode is engaged
  113677. */
  113678. isVRPresenting(): boolean;
  113679. /** @hidden */
  113680. _requestVRFrame(): void;
  113681. /** @hidden */
  113682. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  113683. /**
  113684. * Gets the source code of the vertex shader associated with a specific webGL program
  113685. * @param program defines the program to use
  113686. * @returns a string containing the source code of the vertex shader associated with the program
  113687. */
  113688. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  113689. /**
  113690. * Gets the source code of the fragment shader associated with a specific webGL program
  113691. * @param program defines the program to use
  113692. * @returns a string containing the source code of the fragment shader associated with the program
  113693. */
  113694. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  113695. /**
  113696. * Sets a depth stencil texture from a render target to the according uniform.
  113697. * @param channel The texture channel
  113698. * @param uniform The uniform to set
  113699. * @param texture The render target texture containing the depth stencil texture to apply
  113700. */
  113701. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  113702. /**
  113703. * Sets a texture to the webGL context from a postprocess
  113704. * @param channel defines the channel to use
  113705. * @param postProcess defines the source postprocess
  113706. */
  113707. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  113708. /**
  113709. * Binds the output of the passed in post process to the texture channel specified
  113710. * @param channel The channel the texture should be bound to
  113711. * @param postProcess The post process which's output should be bound
  113712. */
  113713. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  113714. protected _rebuildBuffers(): void;
  113715. /** @hidden */
  113716. _renderFrame(): void;
  113717. _renderLoop(): void;
  113718. /** @hidden */
  113719. _renderViews(): boolean;
  113720. /**
  113721. * Toggle full screen mode
  113722. * @param requestPointerLock defines if a pointer lock should be requested from the user
  113723. */
  113724. switchFullscreen(requestPointerLock: boolean): void;
  113725. /**
  113726. * Enters full screen mode
  113727. * @param requestPointerLock defines if a pointer lock should be requested from the user
  113728. */
  113729. enterFullscreen(requestPointerLock: boolean): void;
  113730. /**
  113731. * Exits full screen mode
  113732. */
  113733. exitFullscreen(): void;
  113734. /**
  113735. * Enters Pointerlock mode
  113736. */
  113737. enterPointerlock(): void;
  113738. /**
  113739. * Exits Pointerlock mode
  113740. */
  113741. exitPointerlock(): void;
  113742. /**
  113743. * Begin a new frame
  113744. */
  113745. beginFrame(): void;
  113746. /**
  113747. * Enf the current frame
  113748. */
  113749. endFrame(): void;
  113750. resize(): void;
  113751. /**
  113752. * Force a specific size of the canvas
  113753. * @param width defines the new canvas' width
  113754. * @param height defines the new canvas' height
  113755. */
  113756. setSize(width: number, height: number): void;
  113757. /**
  113758. * Updates a dynamic vertex buffer.
  113759. * @param vertexBuffer the vertex buffer to update
  113760. * @param data the data used to update the vertex buffer
  113761. * @param byteOffset the byte offset of the data
  113762. * @param byteLength the byte length of the data
  113763. */
  113764. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  113765. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  113766. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  113767. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  113768. _releaseTexture(texture: InternalTexture): void;
  113769. /**
  113770. * @hidden
  113771. * Rescales a texture
  113772. * @param source input texutre
  113773. * @param destination destination texture
  113774. * @param scene scene to use to render the resize
  113775. * @param internalFormat format to use when resizing
  113776. * @param onComplete callback to be called when resize has completed
  113777. */
  113778. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  113779. /**
  113780. * Gets the current framerate
  113781. * @returns a number representing the framerate
  113782. */
  113783. getFps(): number;
  113784. /**
  113785. * Gets the time spent between current and previous frame
  113786. * @returns a number representing the delta time in ms
  113787. */
  113788. getDeltaTime(): number;
  113789. private _measureFps;
  113790. /** @hidden */
  113791. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  113792. /**
  113793. * Update a dynamic index buffer
  113794. * @param indexBuffer defines the target index buffer
  113795. * @param indices defines the data to update
  113796. * @param offset defines the offset in the target index buffer where update should start
  113797. */
  113798. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  113799. /**
  113800. * Updates the sample count of a render target texture
  113801. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  113802. * @param texture defines the texture to update
  113803. * @param samples defines the sample count to set
  113804. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  113805. */
  113806. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  113807. /**
  113808. * Updates a depth texture Comparison Mode and Function.
  113809. * If the comparison Function is equal to 0, the mode will be set to none.
  113810. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  113811. * @param texture The texture to set the comparison function for
  113812. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  113813. */
  113814. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  113815. /**
  113816. * Creates a webGL buffer to use with instanciation
  113817. * @param capacity defines the size of the buffer
  113818. * @returns the webGL buffer
  113819. */
  113820. createInstancesBuffer(capacity: number): DataBuffer;
  113821. /**
  113822. * Delete a webGL buffer used with instanciation
  113823. * @param buffer defines the webGL buffer to delete
  113824. */
  113825. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  113826. private _clientWaitAsync;
  113827. /** @hidden */
  113828. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  113829. dispose(): void;
  113830. private _disableTouchAction;
  113831. /**
  113832. * Display the loading screen
  113833. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  113834. */
  113835. displayLoadingUI(): void;
  113836. /**
  113837. * Hide the loading screen
  113838. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  113839. */
  113840. hideLoadingUI(): void;
  113841. /**
  113842. * Gets the current loading screen object
  113843. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  113844. */
  113845. get loadingScreen(): ILoadingScreen;
  113846. /**
  113847. * Sets the current loading screen object
  113848. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  113849. */
  113850. set loadingScreen(loadingScreen: ILoadingScreen);
  113851. /**
  113852. * Sets the current loading screen text
  113853. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  113854. */
  113855. set loadingUIText(text: string);
  113856. /**
  113857. * Sets the current loading screen background color
  113858. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  113859. */
  113860. set loadingUIBackgroundColor(color: string);
  113861. /** Pointerlock and fullscreen */
  113862. /**
  113863. * Ask the browser to promote the current element to pointerlock mode
  113864. * @param element defines the DOM element to promote
  113865. */
  113866. static _RequestPointerlock(element: HTMLElement): void;
  113867. /**
  113868. * Asks the browser to exit pointerlock mode
  113869. */
  113870. static _ExitPointerlock(): void;
  113871. /**
  113872. * Ask the browser to promote the current element to fullscreen rendering mode
  113873. * @param element defines the DOM element to promote
  113874. */
  113875. static _RequestFullscreen(element: HTMLElement): void;
  113876. /**
  113877. * Asks the browser to exit fullscreen mode
  113878. */
  113879. static _ExitFullscreen(): void;
  113880. }
  113881. }
  113882. declare module BABYLON {
  113883. /**
  113884. * The engine store class is responsible to hold all the instances of Engine and Scene created
  113885. * during the life time of the application.
  113886. */
  113887. export class EngineStore {
  113888. /** Gets the list of created engines */
  113889. static Instances: Engine[];
  113890. /** @hidden */
  113891. static _LastCreatedScene: Nullable<Scene>;
  113892. /**
  113893. * Gets the latest created engine
  113894. */
  113895. static get LastCreatedEngine(): Nullable<Engine>;
  113896. /**
  113897. * Gets the latest created scene
  113898. */
  113899. static get LastCreatedScene(): Nullable<Scene>;
  113900. /**
  113901. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  113902. * @ignorenaming
  113903. */
  113904. static UseFallbackTexture: boolean;
  113905. /**
  113906. * Texture content used if a texture cannot loaded
  113907. * @ignorenaming
  113908. */
  113909. static FallbackTexture: string;
  113910. }
  113911. }
  113912. declare module BABYLON {
  113913. /**
  113914. * Helper class that provides a small promise polyfill
  113915. */
  113916. export class PromisePolyfill {
  113917. /**
  113918. * Static function used to check if the polyfill is required
  113919. * If this is the case then the function will inject the polyfill to window.Promise
  113920. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  113921. */
  113922. static Apply(force?: boolean): void;
  113923. }
  113924. }
  113925. declare module BABYLON {
  113926. /**
  113927. * Interface for screenshot methods with describe argument called `size` as object with options
  113928. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  113929. */
  113930. export interface IScreenshotSize {
  113931. /**
  113932. * number in pixels for canvas height
  113933. */
  113934. height?: number;
  113935. /**
  113936. * multiplier allowing render at a higher or lower resolution
  113937. * If value is defined then height and width will be ignored and taken from camera
  113938. */
  113939. precision?: number;
  113940. /**
  113941. * number in pixels for canvas width
  113942. */
  113943. width?: number;
  113944. }
  113945. }
  113946. declare module BABYLON {
  113947. interface IColor4Like {
  113948. r: float;
  113949. g: float;
  113950. b: float;
  113951. a: float;
  113952. }
  113953. /**
  113954. * Class containing a set of static utilities functions
  113955. */
  113956. export class Tools {
  113957. /**
  113958. * Gets or sets the base URL to use to load assets
  113959. */
  113960. static get BaseUrl(): string;
  113961. static set BaseUrl(value: string);
  113962. /**
  113963. * Enable/Disable Custom HTTP Request Headers globally.
  113964. * default = false
  113965. * @see CustomRequestHeaders
  113966. */
  113967. static UseCustomRequestHeaders: boolean;
  113968. /**
  113969. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  113970. * i.e. when loading files, where the server/service expects an Authorization header
  113971. */
  113972. static CustomRequestHeaders: {
  113973. [key: string]: string;
  113974. };
  113975. /**
  113976. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  113977. */
  113978. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  113979. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  113980. /**
  113981. * Default behaviour for cors in the application.
  113982. * It can be a string if the expected behavior is identical in the entire app.
  113983. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  113984. */
  113985. static get CorsBehavior(): string | ((url: string | string[]) => string);
  113986. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  113987. /**
  113988. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  113989. * @ignorenaming
  113990. */
  113991. static get UseFallbackTexture(): boolean;
  113992. static set UseFallbackTexture(value: boolean);
  113993. /**
  113994. * Use this object to register external classes like custom textures or material
  113995. * to allow the laoders to instantiate them
  113996. */
  113997. static get RegisteredExternalClasses(): {
  113998. [key: string]: Object;
  113999. };
  114000. static set RegisteredExternalClasses(classes: {
  114001. [key: string]: Object;
  114002. });
  114003. /**
  114004. * Texture content used if a texture cannot loaded
  114005. * @ignorenaming
  114006. */
  114007. static get fallbackTexture(): string;
  114008. static set fallbackTexture(value: string);
  114009. /**
  114010. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  114011. * @param u defines the coordinate on X axis
  114012. * @param v defines the coordinate on Y axis
  114013. * @param width defines the width of the source data
  114014. * @param height defines the height of the source data
  114015. * @param pixels defines the source byte array
  114016. * @param color defines the output color
  114017. */
  114018. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  114019. /**
  114020. * Interpolates between a and b via alpha
  114021. * @param a The lower value (returned when alpha = 0)
  114022. * @param b The upper value (returned when alpha = 1)
  114023. * @param alpha The interpolation-factor
  114024. * @return The mixed value
  114025. */
  114026. static Mix(a: number, b: number, alpha: number): number;
  114027. /**
  114028. * Tries to instantiate a new object from a given class name
  114029. * @param className defines the class name to instantiate
  114030. * @returns the new object or null if the system was not able to do the instantiation
  114031. */
  114032. static Instantiate(className: string): any;
  114033. /**
  114034. * Provides a slice function that will work even on IE
  114035. * @param data defines the array to slice
  114036. * @param start defines the start of the data (optional)
  114037. * @param end defines the end of the data (optional)
  114038. * @returns the new sliced array
  114039. */
  114040. static Slice<T>(data: T, start?: number, end?: number): T;
  114041. /**
  114042. * Polyfill for setImmediate
  114043. * @param action defines the action to execute after the current execution block
  114044. */
  114045. static SetImmediate(action: () => void): void;
  114046. /**
  114047. * Function indicating if a number is an exponent of 2
  114048. * @param value defines the value to test
  114049. * @returns true if the value is an exponent of 2
  114050. */
  114051. static IsExponentOfTwo(value: number): boolean;
  114052. private static _tmpFloatArray;
  114053. /**
  114054. * Returns the nearest 32-bit single precision float representation of a Number
  114055. * @param value A Number. If the parameter is of a different type, it will get converted
  114056. * to a number or to NaN if it cannot be converted
  114057. * @returns number
  114058. */
  114059. static FloatRound(value: number): number;
  114060. /**
  114061. * Extracts the filename from a path
  114062. * @param path defines the path to use
  114063. * @returns the filename
  114064. */
  114065. static GetFilename(path: string): string;
  114066. /**
  114067. * Extracts the "folder" part of a path (everything before the filename).
  114068. * @param uri The URI to extract the info from
  114069. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  114070. * @returns The "folder" part of the path
  114071. */
  114072. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  114073. /**
  114074. * Extracts text content from a DOM element hierarchy
  114075. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  114076. */
  114077. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  114078. /**
  114079. * Convert an angle in radians to degrees
  114080. * @param angle defines the angle to convert
  114081. * @returns the angle in degrees
  114082. */
  114083. static ToDegrees(angle: number): number;
  114084. /**
  114085. * Convert an angle in degrees to radians
  114086. * @param angle defines the angle to convert
  114087. * @returns the angle in radians
  114088. */
  114089. static ToRadians(angle: number): number;
  114090. /**
  114091. * Returns an array if obj is not an array
  114092. * @param obj defines the object to evaluate as an array
  114093. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  114094. * @returns either obj directly if obj is an array or a new array containing obj
  114095. */
  114096. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  114097. /**
  114098. * Gets the pointer prefix to use
  114099. * @param engine defines the engine we are finding the prefix for
  114100. * @returns "pointer" if touch is enabled. Else returns "mouse"
  114101. */
  114102. static GetPointerPrefix(engine: Engine): string;
  114103. /**
  114104. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  114105. * @param url define the url we are trying
  114106. * @param element define the dom element where to configure the cors policy
  114107. */
  114108. static SetCorsBehavior(url: string | string[], element: {
  114109. crossOrigin: string | null;
  114110. }): void;
  114111. /**
  114112. * Removes unwanted characters from an url
  114113. * @param url defines the url to clean
  114114. * @returns the cleaned url
  114115. */
  114116. static CleanUrl(url: string): string;
  114117. /**
  114118. * Gets or sets a function used to pre-process url before using them to load assets
  114119. */
  114120. static get PreprocessUrl(): (url: string) => string;
  114121. static set PreprocessUrl(processor: (url: string) => string);
  114122. /**
  114123. * Loads an image as an HTMLImageElement.
  114124. * @param input url string, ArrayBuffer, or Blob to load
  114125. * @param onLoad callback called when the image successfully loads
  114126. * @param onError callback called when the image fails to load
  114127. * @param offlineProvider offline provider for caching
  114128. * @param mimeType optional mime type
  114129. * @returns the HTMLImageElement of the loaded image
  114130. */
  114131. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  114132. /**
  114133. * Loads a file from a url
  114134. * @param url url string, ArrayBuffer, or Blob to load
  114135. * @param onSuccess callback called when the file successfully loads
  114136. * @param onProgress callback called while file is loading (if the server supports this mode)
  114137. * @param offlineProvider defines the offline provider for caching
  114138. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  114139. * @param onError callback called when the file fails to load
  114140. * @returns a file request object
  114141. */
  114142. 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;
  114143. /**
  114144. * Loads a file from a url
  114145. * @param url the file url to load
  114146. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  114147. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  114148. */
  114149. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  114150. /**
  114151. * Load a script (identified by an url). When the url returns, the
  114152. * content of this file is added into a new script element, attached to the DOM (body element)
  114153. * @param scriptUrl defines the url of the script to laod
  114154. * @param onSuccess defines the callback called when the script is loaded
  114155. * @param onError defines the callback to call if an error occurs
  114156. * @param scriptId defines the id of the script element
  114157. */
  114158. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  114159. /**
  114160. * Load an asynchronous script (identified by an url). When the url returns, the
  114161. * content of this file is added into a new script element, attached to the DOM (body element)
  114162. * @param scriptUrl defines the url of the script to laod
  114163. * @param scriptId defines the id of the script element
  114164. * @returns a promise request object
  114165. */
  114166. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  114167. /**
  114168. * Loads a file from a blob
  114169. * @param fileToLoad defines the blob to use
  114170. * @param callback defines the callback to call when data is loaded
  114171. * @param progressCallback defines the callback to call during loading process
  114172. * @returns a file request object
  114173. */
  114174. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  114175. /**
  114176. * Reads a file from a File object
  114177. * @param file defines the file to load
  114178. * @param onSuccess defines the callback to call when data is loaded
  114179. * @param onProgress defines the callback to call during loading process
  114180. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  114181. * @param onError defines the callback to call when an error occurs
  114182. * @returns a file request object
  114183. */
  114184. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  114185. /**
  114186. * Creates a data url from a given string content
  114187. * @param content defines the content to convert
  114188. * @returns the new data url link
  114189. */
  114190. static FileAsURL(content: string): string;
  114191. /**
  114192. * Format the given number to a specific decimal format
  114193. * @param value defines the number to format
  114194. * @param decimals defines the number of decimals to use
  114195. * @returns the formatted string
  114196. */
  114197. static Format(value: number, decimals?: number): string;
  114198. /**
  114199. * Tries to copy an object by duplicating every property
  114200. * @param source defines the source object
  114201. * @param destination defines the target object
  114202. * @param doNotCopyList defines a list of properties to avoid
  114203. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  114204. */
  114205. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  114206. /**
  114207. * Gets a boolean indicating if the given object has no own property
  114208. * @param obj defines the object to test
  114209. * @returns true if object has no own property
  114210. */
  114211. static IsEmpty(obj: any): boolean;
  114212. /**
  114213. * Function used to register events at window level
  114214. * @param windowElement defines the Window object to use
  114215. * @param events defines the events to register
  114216. */
  114217. static RegisterTopRootEvents(windowElement: Window, events: {
  114218. name: string;
  114219. handler: Nullable<(e: FocusEvent) => any>;
  114220. }[]): void;
  114221. /**
  114222. * Function used to unregister events from window level
  114223. * @param windowElement defines the Window object to use
  114224. * @param events defines the events to unregister
  114225. */
  114226. static UnregisterTopRootEvents(windowElement: Window, events: {
  114227. name: string;
  114228. handler: Nullable<(e: FocusEvent) => any>;
  114229. }[]): void;
  114230. /**
  114231. * @ignore
  114232. */
  114233. static _ScreenshotCanvas: HTMLCanvasElement;
  114234. /**
  114235. * Dumps the current bound framebuffer
  114236. * @param width defines the rendering width
  114237. * @param height defines the rendering height
  114238. * @param engine defines the hosting engine
  114239. * @param successCallback defines the callback triggered once the data are available
  114240. * @param mimeType defines the mime type of the result
  114241. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  114242. */
  114243. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  114244. /**
  114245. * Converts the canvas data to blob.
  114246. * This acts as a polyfill for browsers not supporting the to blob function.
  114247. * @param canvas Defines the canvas to extract the data from
  114248. * @param successCallback Defines the callback triggered once the data are available
  114249. * @param mimeType Defines the mime type of the result
  114250. */
  114251. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  114252. /**
  114253. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  114254. * @param successCallback defines the callback triggered once the data are available
  114255. * @param mimeType defines the mime type of the result
  114256. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  114257. */
  114258. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  114259. /**
  114260. * Downloads a blob in the browser
  114261. * @param blob defines the blob to download
  114262. * @param fileName defines the name of the downloaded file
  114263. */
  114264. static Download(blob: Blob, fileName: string): void;
  114265. /**
  114266. * Captures a screenshot of the current rendering
  114267. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  114268. * @param engine defines the rendering engine
  114269. * @param camera defines the source camera
  114270. * @param size This parameter can be set to a single number or to an object with the
  114271. * following (optional) properties: precision, width, height. If a single number is passed,
  114272. * it will be used for both width and height. If an object is passed, the screenshot size
  114273. * will be derived from the parameters. The precision property is a multiplier allowing
  114274. * rendering at a higher or lower resolution
  114275. * @param successCallback defines the callback receives a single parameter which contains the
  114276. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  114277. * src parameter of an <img> to display it
  114278. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  114279. * Check your browser for supported MIME types
  114280. */
  114281. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  114282. /**
  114283. * Captures a screenshot of the current rendering
  114284. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  114285. * @param engine defines the rendering engine
  114286. * @param camera defines the source camera
  114287. * @param size This parameter can be set to a single number or to an object with the
  114288. * following (optional) properties: precision, width, height. If a single number is passed,
  114289. * it will be used for both width and height. If an object is passed, the screenshot size
  114290. * will be derived from the parameters. The precision property is a multiplier allowing
  114291. * rendering at a higher or lower resolution
  114292. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  114293. * Check your browser for supported MIME types
  114294. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  114295. * to the src parameter of an <img> to display it
  114296. */
  114297. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  114298. /**
  114299. * Generates an image screenshot from the specified camera.
  114300. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  114301. * @param engine The engine to use for rendering
  114302. * @param camera The camera to use for rendering
  114303. * @param size This parameter can be set to a single number or to an object with the
  114304. * following (optional) properties: precision, width, height. If a single number is passed,
  114305. * it will be used for both width and height. If an object is passed, the screenshot size
  114306. * will be derived from the parameters. The precision property is a multiplier allowing
  114307. * rendering at a higher or lower resolution
  114308. * @param successCallback The callback receives a single parameter which contains the
  114309. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  114310. * src parameter of an <img> to display it
  114311. * @param mimeType The MIME type of the screenshot image (default: image/png).
  114312. * Check your browser for supported MIME types
  114313. * @param samples Texture samples (default: 1)
  114314. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  114315. * @param fileName A name for for the downloaded file.
  114316. */
  114317. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  114318. /**
  114319. * Generates an image screenshot from the specified camera.
  114320. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  114321. * @param engine The engine to use for rendering
  114322. * @param camera The camera to use for rendering
  114323. * @param size This parameter can be set to a single number or to an object with the
  114324. * following (optional) properties: precision, width, height. If a single number is passed,
  114325. * it will be used for both width and height. If an object is passed, the screenshot size
  114326. * will be derived from the parameters. The precision property is a multiplier allowing
  114327. * rendering at a higher or lower resolution
  114328. * @param mimeType The MIME type of the screenshot image (default: image/png).
  114329. * Check your browser for supported MIME types
  114330. * @param samples Texture samples (default: 1)
  114331. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  114332. * @param fileName A name for for the downloaded file.
  114333. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  114334. * to the src parameter of an <img> to display it
  114335. */
  114336. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  114337. /**
  114338. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  114339. * Be aware Math.random() could cause collisions, but:
  114340. * "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"
  114341. * @returns a pseudo random id
  114342. */
  114343. static RandomId(): string;
  114344. /**
  114345. * Test if the given uri is a base64 string
  114346. * @param uri The uri to test
  114347. * @return True if the uri is a base64 string or false otherwise
  114348. */
  114349. static IsBase64(uri: string): boolean;
  114350. /**
  114351. * Decode the given base64 uri.
  114352. * @param uri The uri to decode
  114353. * @return The decoded base64 data.
  114354. */
  114355. static DecodeBase64(uri: string): ArrayBuffer;
  114356. /**
  114357. * Gets the absolute url.
  114358. * @param url the input url
  114359. * @return the absolute url
  114360. */
  114361. static GetAbsoluteUrl(url: string): string;
  114362. /**
  114363. * No log
  114364. */
  114365. static readonly NoneLogLevel: number;
  114366. /**
  114367. * Only message logs
  114368. */
  114369. static readonly MessageLogLevel: number;
  114370. /**
  114371. * Only warning logs
  114372. */
  114373. static readonly WarningLogLevel: number;
  114374. /**
  114375. * Only error logs
  114376. */
  114377. static readonly ErrorLogLevel: number;
  114378. /**
  114379. * All logs
  114380. */
  114381. static readonly AllLogLevel: number;
  114382. /**
  114383. * Gets a value indicating the number of loading errors
  114384. * @ignorenaming
  114385. */
  114386. static get errorsCount(): number;
  114387. /**
  114388. * Callback called when a new log is added
  114389. */
  114390. static OnNewCacheEntry: (entry: string) => void;
  114391. /**
  114392. * Log a message to the console
  114393. * @param message defines the message to log
  114394. */
  114395. static Log(message: string): void;
  114396. /**
  114397. * Write a warning message to the console
  114398. * @param message defines the message to log
  114399. */
  114400. static Warn(message: string): void;
  114401. /**
  114402. * Write an error message to the console
  114403. * @param message defines the message to log
  114404. */
  114405. static Error(message: string): void;
  114406. /**
  114407. * Gets current log cache (list of logs)
  114408. */
  114409. static get LogCache(): string;
  114410. /**
  114411. * Clears the log cache
  114412. */
  114413. static ClearLogCache(): void;
  114414. /**
  114415. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  114416. */
  114417. static set LogLevels(level: number);
  114418. /**
  114419. * Checks if the window object exists
  114420. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  114421. */
  114422. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  114423. /**
  114424. * No performance log
  114425. */
  114426. static readonly PerformanceNoneLogLevel: number;
  114427. /**
  114428. * Use user marks to log performance
  114429. */
  114430. static readonly PerformanceUserMarkLogLevel: number;
  114431. /**
  114432. * Log performance to the console
  114433. */
  114434. static readonly PerformanceConsoleLogLevel: number;
  114435. private static _performance;
  114436. /**
  114437. * Sets the current performance log level
  114438. */
  114439. static set PerformanceLogLevel(level: number);
  114440. private static _StartPerformanceCounterDisabled;
  114441. private static _EndPerformanceCounterDisabled;
  114442. private static _StartUserMark;
  114443. private static _EndUserMark;
  114444. private static _StartPerformanceConsole;
  114445. private static _EndPerformanceConsole;
  114446. /**
  114447. * Starts a performance counter
  114448. */
  114449. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  114450. /**
  114451. * Ends a specific performance coutner
  114452. */
  114453. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  114454. /**
  114455. * Gets either window.performance.now() if supported or Date.now() else
  114456. */
  114457. static get Now(): number;
  114458. /**
  114459. * This method will return the name of the class used to create the instance of the given object.
  114460. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  114461. * @param object the object to get the class name from
  114462. * @param isType defines if the object is actually a type
  114463. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  114464. */
  114465. static GetClassName(object: any, isType?: boolean): string;
  114466. /**
  114467. * Gets the first element of an array satisfying a given predicate
  114468. * @param array defines the array to browse
  114469. * @param predicate defines the predicate to use
  114470. * @returns null if not found or the element
  114471. */
  114472. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  114473. /**
  114474. * This method will return the name of the full name of the class, including its owning module (if any).
  114475. * 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).
  114476. * @param object the object to get the class name from
  114477. * @param isType defines if the object is actually a type
  114478. * @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.
  114479. * @ignorenaming
  114480. */
  114481. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  114482. /**
  114483. * Returns a promise that resolves after the given amount of time.
  114484. * @param delay Number of milliseconds to delay
  114485. * @returns Promise that resolves after the given amount of time
  114486. */
  114487. static DelayAsync(delay: number): Promise<void>;
  114488. /**
  114489. * Utility function to detect if the current user agent is Safari
  114490. * @returns whether or not the current user agent is safari
  114491. */
  114492. static IsSafari(): boolean;
  114493. }
  114494. /**
  114495. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  114496. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  114497. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  114498. * @param name The name of the class, case should be preserved
  114499. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  114500. */
  114501. export function className(name: string, module?: string): (target: Object) => void;
  114502. /**
  114503. * An implementation of a loop for asynchronous functions.
  114504. */
  114505. export class AsyncLoop {
  114506. /**
  114507. * Defines the number of iterations for the loop
  114508. */
  114509. iterations: number;
  114510. /**
  114511. * Defines the current index of the loop.
  114512. */
  114513. index: number;
  114514. private _done;
  114515. private _fn;
  114516. private _successCallback;
  114517. /**
  114518. * Constructor.
  114519. * @param iterations the number of iterations.
  114520. * @param func the function to run each iteration
  114521. * @param successCallback the callback that will be called upon succesful execution
  114522. * @param offset starting offset.
  114523. */
  114524. constructor(
  114525. /**
  114526. * Defines the number of iterations for the loop
  114527. */
  114528. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  114529. /**
  114530. * Execute the next iteration. Must be called after the last iteration was finished.
  114531. */
  114532. executeNext(): void;
  114533. /**
  114534. * Break the loop and run the success callback.
  114535. */
  114536. breakLoop(): void;
  114537. /**
  114538. * Create and run an async loop.
  114539. * @param iterations the number of iterations.
  114540. * @param fn the function to run each iteration
  114541. * @param successCallback the callback that will be called upon succesful execution
  114542. * @param offset starting offset.
  114543. * @returns the created async loop object
  114544. */
  114545. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  114546. /**
  114547. * A for-loop that will run a given number of iterations synchronous and the rest async.
  114548. * @param iterations total number of iterations
  114549. * @param syncedIterations number of synchronous iterations in each async iteration.
  114550. * @param fn the function to call each iteration.
  114551. * @param callback a success call back that will be called when iterating stops.
  114552. * @param breakFunction a break condition (optional)
  114553. * @param timeout timeout settings for the setTimeout function. default - 0.
  114554. * @returns the created async loop object
  114555. */
  114556. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  114557. }
  114558. }
  114559. declare module BABYLON {
  114560. /**
  114561. * This class implement a typical dictionary using a string as key and the generic type T as value.
  114562. * The underlying implementation relies on an associative array to ensure the best performances.
  114563. * The value can be anything including 'null' but except 'undefined'
  114564. */
  114565. export class StringDictionary<T> {
  114566. /**
  114567. * This will clear this dictionary and copy the content from the 'source' one.
  114568. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  114569. * @param source the dictionary to take the content from and copy to this dictionary
  114570. */
  114571. copyFrom(source: StringDictionary<T>): void;
  114572. /**
  114573. * Get a value based from its key
  114574. * @param key the given key to get the matching value from
  114575. * @return the value if found, otherwise undefined is returned
  114576. */
  114577. get(key: string): T | undefined;
  114578. /**
  114579. * Get a value from its key or add it if it doesn't exist.
  114580. * This method will ensure you that a given key/data will be present in the dictionary.
  114581. * @param key the given key to get the matching value from
  114582. * @param factory the factory that will create the value if the key is not present in the dictionary.
  114583. * The factory will only be invoked if there's no data for the given key.
  114584. * @return the value corresponding to the key.
  114585. */
  114586. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  114587. /**
  114588. * Get a value from its key if present in the dictionary otherwise add it
  114589. * @param key the key to get the value from
  114590. * @param val if there's no such key/value pair in the dictionary add it with this value
  114591. * @return the value corresponding to the key
  114592. */
  114593. getOrAdd(key: string, val: T): T;
  114594. /**
  114595. * Check if there's a given key in the dictionary
  114596. * @param key the key to check for
  114597. * @return true if the key is present, false otherwise
  114598. */
  114599. contains(key: string): boolean;
  114600. /**
  114601. * Add a new key and its corresponding value
  114602. * @param key the key to add
  114603. * @param value the value corresponding to the key
  114604. * @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
  114605. */
  114606. add(key: string, value: T): boolean;
  114607. /**
  114608. * Update a specific value associated to a key
  114609. * @param key defines the key to use
  114610. * @param value defines the value to store
  114611. * @returns true if the value was updated (or false if the key was not found)
  114612. */
  114613. set(key: string, value: T): boolean;
  114614. /**
  114615. * Get the element of the given key and remove it from the dictionary
  114616. * @param key defines the key to search
  114617. * @returns the value associated with the key or null if not found
  114618. */
  114619. getAndRemove(key: string): Nullable<T>;
  114620. /**
  114621. * Remove a key/value from the dictionary.
  114622. * @param key the key to remove
  114623. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  114624. */
  114625. remove(key: string): boolean;
  114626. /**
  114627. * Clear the whole content of the dictionary
  114628. */
  114629. clear(): void;
  114630. /**
  114631. * Gets the current count
  114632. */
  114633. get count(): number;
  114634. /**
  114635. * Execute a callback on each key/val of the dictionary.
  114636. * Note that you can remove any element in this dictionary in the callback implementation
  114637. * @param callback the callback to execute on a given key/value pair
  114638. */
  114639. forEach(callback: (key: string, val: T) => void): void;
  114640. /**
  114641. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  114642. * If the callback returns null or undefined the method will iterate to the next key/value pair
  114643. * Note that you can remove any element in this dictionary in the callback implementation
  114644. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  114645. * @returns the first item
  114646. */
  114647. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  114648. private _count;
  114649. private _data;
  114650. }
  114651. }
  114652. declare module BABYLON {
  114653. /** @hidden */
  114654. export interface ICollisionCoordinator {
  114655. createCollider(): Collider;
  114656. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  114657. init(scene: Scene): void;
  114658. }
  114659. /** @hidden */
  114660. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  114661. private _scene;
  114662. private _scaledPosition;
  114663. private _scaledVelocity;
  114664. private _finalPosition;
  114665. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  114666. createCollider(): Collider;
  114667. init(scene: Scene): void;
  114668. private _collideWithWorld;
  114669. }
  114670. }
  114671. declare module BABYLON {
  114672. /**
  114673. * Class used to manage all inputs for the scene.
  114674. */
  114675. export class InputManager {
  114676. /** The distance in pixel that you have to move to prevent some events */
  114677. static DragMovementThreshold: number;
  114678. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  114679. static LongPressDelay: number;
  114680. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  114681. static DoubleClickDelay: number;
  114682. /** If you need to check double click without raising a single click at first click, enable this flag */
  114683. static ExclusiveDoubleClickMode: boolean;
  114684. private _wheelEventName;
  114685. private _onPointerMove;
  114686. private _onPointerDown;
  114687. private _onPointerUp;
  114688. private _initClickEvent;
  114689. private _initActionManager;
  114690. private _delayedSimpleClick;
  114691. private _delayedSimpleClickTimeout;
  114692. private _previousDelayedSimpleClickTimeout;
  114693. private _meshPickProceed;
  114694. private _previousButtonPressed;
  114695. private _currentPickResult;
  114696. private _previousPickResult;
  114697. private _totalPointersPressed;
  114698. private _doubleClickOccured;
  114699. private _pointerOverMesh;
  114700. private _pickedDownMesh;
  114701. private _pickedUpMesh;
  114702. private _pointerX;
  114703. private _pointerY;
  114704. private _unTranslatedPointerX;
  114705. private _unTranslatedPointerY;
  114706. private _startingPointerPosition;
  114707. private _previousStartingPointerPosition;
  114708. private _startingPointerTime;
  114709. private _previousStartingPointerTime;
  114710. private _pointerCaptures;
  114711. private _onKeyDown;
  114712. private _onKeyUp;
  114713. private _onCanvasFocusObserver;
  114714. private _onCanvasBlurObserver;
  114715. private _scene;
  114716. /**
  114717. * Creates a new InputManager
  114718. * @param scene defines the hosting scene
  114719. */
  114720. constructor(scene: Scene);
  114721. /**
  114722. * Gets the mesh that is currently under the pointer
  114723. */
  114724. get meshUnderPointer(): Nullable<AbstractMesh>;
  114725. /**
  114726. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  114727. */
  114728. get unTranslatedPointer(): Vector2;
  114729. /**
  114730. * Gets or sets the current on-screen X position of the pointer
  114731. */
  114732. get pointerX(): number;
  114733. set pointerX(value: number);
  114734. /**
  114735. * Gets or sets the current on-screen Y position of the pointer
  114736. */
  114737. get pointerY(): number;
  114738. set pointerY(value: number);
  114739. private _updatePointerPosition;
  114740. private _processPointerMove;
  114741. private _setRayOnPointerInfo;
  114742. private _checkPrePointerObservable;
  114743. /**
  114744. * Use this method to simulate a pointer move on a mesh
  114745. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  114746. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  114747. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  114748. */
  114749. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  114750. /**
  114751. * Use this method to simulate a pointer down on a mesh
  114752. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  114753. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  114754. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  114755. */
  114756. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  114757. private _processPointerDown;
  114758. /** @hidden */
  114759. _isPointerSwiping(): boolean;
  114760. /**
  114761. * Use this method to simulate a pointer up on a mesh
  114762. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  114763. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  114764. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  114765. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  114766. */
  114767. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  114768. private _processPointerUp;
  114769. /**
  114770. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  114771. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  114772. * @returns true if the pointer was captured
  114773. */
  114774. isPointerCaptured(pointerId?: number): boolean;
  114775. /**
  114776. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  114777. * @param attachUp defines if you want to attach events to pointerup
  114778. * @param attachDown defines if you want to attach events to pointerdown
  114779. * @param attachMove defines if you want to attach events to pointermove
  114780. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  114781. */
  114782. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  114783. /**
  114784. * Detaches all event handlers
  114785. */
  114786. detachControl(): void;
  114787. /**
  114788. * Force the value of meshUnderPointer
  114789. * @param mesh defines the mesh to use
  114790. */
  114791. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  114792. /**
  114793. * Gets the mesh under the pointer
  114794. * @returns a Mesh or null if no mesh is under the pointer
  114795. */
  114796. getPointerOverMesh(): Nullable<AbstractMesh>;
  114797. }
  114798. }
  114799. declare module BABYLON {
  114800. /**
  114801. * This class defines the direct association between an animation and a target
  114802. */
  114803. export class TargetedAnimation {
  114804. /**
  114805. * Animation to perform
  114806. */
  114807. animation: Animation;
  114808. /**
  114809. * Target to animate
  114810. */
  114811. target: any;
  114812. /**
  114813. * Serialize the object
  114814. * @returns the JSON object representing the current entity
  114815. */
  114816. serialize(): any;
  114817. }
  114818. /**
  114819. * Use this class to create coordinated animations on multiple targets
  114820. */
  114821. export class AnimationGroup implements IDisposable {
  114822. /** The name of the animation group */
  114823. name: string;
  114824. private _scene;
  114825. private _targetedAnimations;
  114826. private _animatables;
  114827. private _from;
  114828. private _to;
  114829. private _isStarted;
  114830. private _isPaused;
  114831. private _speedRatio;
  114832. private _loopAnimation;
  114833. private _isAdditive;
  114834. /**
  114835. * Gets or sets the unique id of the node
  114836. */
  114837. uniqueId: number;
  114838. /**
  114839. * This observable will notify when one animation have ended
  114840. */
  114841. onAnimationEndObservable: Observable<TargetedAnimation>;
  114842. /**
  114843. * Observer raised when one animation loops
  114844. */
  114845. onAnimationLoopObservable: Observable<TargetedAnimation>;
  114846. /**
  114847. * Observer raised when all animations have looped
  114848. */
  114849. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  114850. /**
  114851. * This observable will notify when all animations have ended.
  114852. */
  114853. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  114854. /**
  114855. * This observable will notify when all animations have paused.
  114856. */
  114857. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  114858. /**
  114859. * This observable will notify when all animations are playing.
  114860. */
  114861. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  114862. /**
  114863. * Gets the first frame
  114864. */
  114865. get from(): number;
  114866. /**
  114867. * Gets the last frame
  114868. */
  114869. get to(): number;
  114870. /**
  114871. * Define if the animations are started
  114872. */
  114873. get isStarted(): boolean;
  114874. /**
  114875. * Gets a value indicating that the current group is playing
  114876. */
  114877. get isPlaying(): boolean;
  114878. /**
  114879. * Gets or sets the speed ratio to use for all animations
  114880. */
  114881. get speedRatio(): number;
  114882. /**
  114883. * Gets or sets the speed ratio to use for all animations
  114884. */
  114885. set speedRatio(value: number);
  114886. /**
  114887. * Gets or sets if all animations should loop or not
  114888. */
  114889. get loopAnimation(): boolean;
  114890. set loopAnimation(value: boolean);
  114891. /**
  114892. * Gets or sets if all animations should be evaluated additively
  114893. */
  114894. get isAdditive(): boolean;
  114895. set isAdditive(value: boolean);
  114896. /**
  114897. * Gets the targeted animations for this animation group
  114898. */
  114899. get targetedAnimations(): Array<TargetedAnimation>;
  114900. /**
  114901. * returning the list of animatables controlled by this animation group.
  114902. */
  114903. get animatables(): Array<Animatable>;
  114904. /**
  114905. * Instantiates a new Animation Group.
  114906. * This helps managing several animations at once.
  114907. * @see http://doc.babylonjs.com/how_to/group
  114908. * @param name Defines the name of the group
  114909. * @param scene Defines the scene the group belongs to
  114910. */
  114911. constructor(
  114912. /** The name of the animation group */
  114913. name: string, scene?: Nullable<Scene>);
  114914. /**
  114915. * Add an animation (with its target) in the group
  114916. * @param animation defines the animation we want to add
  114917. * @param target defines the target of the animation
  114918. * @returns the TargetedAnimation object
  114919. */
  114920. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  114921. /**
  114922. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  114923. * It can add constant keys at begin or end
  114924. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  114925. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  114926. * @returns the animation group
  114927. */
  114928. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  114929. private _animationLoopCount;
  114930. private _animationLoopFlags;
  114931. private _processLoop;
  114932. /**
  114933. * Start all animations on given targets
  114934. * @param loop defines if animations must loop
  114935. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  114936. * @param from defines the from key (optional)
  114937. * @param to defines the to key (optional)
  114938. * @param isAdditive defines the additive state for the resulting animatables (optional)
  114939. * @returns the current animation group
  114940. */
  114941. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  114942. /**
  114943. * Pause all animations
  114944. * @returns the animation group
  114945. */
  114946. pause(): AnimationGroup;
  114947. /**
  114948. * Play all animations to initial state
  114949. * This function will start() the animations if they were not started or will restart() them if they were paused
  114950. * @param loop defines if animations must loop
  114951. * @returns the animation group
  114952. */
  114953. play(loop?: boolean): AnimationGroup;
  114954. /**
  114955. * Reset all animations to initial state
  114956. * @returns the animation group
  114957. */
  114958. reset(): AnimationGroup;
  114959. /**
  114960. * Restart animations from key 0
  114961. * @returns the animation group
  114962. */
  114963. restart(): AnimationGroup;
  114964. /**
  114965. * Stop all animations
  114966. * @returns the animation group
  114967. */
  114968. stop(): AnimationGroup;
  114969. /**
  114970. * Set animation weight for all animatables
  114971. * @param weight defines the weight to use
  114972. * @return the animationGroup
  114973. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  114974. */
  114975. setWeightForAllAnimatables(weight: number): AnimationGroup;
  114976. /**
  114977. * Synchronize and normalize all animatables with a source animatable
  114978. * @param root defines the root animatable to synchronize with
  114979. * @return the animationGroup
  114980. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  114981. */
  114982. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  114983. /**
  114984. * Goes to a specific frame in this animation group
  114985. * @param frame the frame number to go to
  114986. * @return the animationGroup
  114987. */
  114988. goToFrame(frame: number): AnimationGroup;
  114989. /**
  114990. * Dispose all associated resources
  114991. */
  114992. dispose(): void;
  114993. private _checkAnimationGroupEnded;
  114994. /**
  114995. * Clone the current animation group and returns a copy
  114996. * @param newName defines the name of the new group
  114997. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  114998. * @returns the new aniamtion group
  114999. */
  115000. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  115001. /**
  115002. * Serializes the animationGroup to an object
  115003. * @returns Serialized object
  115004. */
  115005. serialize(): any;
  115006. /**
  115007. * Returns a new AnimationGroup object parsed from the source provided.
  115008. * @param parsedAnimationGroup defines the source
  115009. * @param scene defines the scene that will receive the animationGroup
  115010. * @returns a new AnimationGroup
  115011. */
  115012. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  115013. /**
  115014. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  115015. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  115016. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  115017. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  115018. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  115019. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  115020. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  115021. */
  115022. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  115023. /**
  115024. * Returns the string "AnimationGroup"
  115025. * @returns "AnimationGroup"
  115026. */
  115027. getClassName(): string;
  115028. /**
  115029. * Creates a detailled string about the object
  115030. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  115031. * @returns a string representing the object
  115032. */
  115033. toString(fullDetails?: boolean): string;
  115034. }
  115035. }
  115036. declare module BABYLON {
  115037. /**
  115038. * Define an interface for all classes that will hold resources
  115039. */
  115040. export interface IDisposable {
  115041. /**
  115042. * Releases all held resources
  115043. */
  115044. dispose(): void;
  115045. }
  115046. /** Interface defining initialization parameters for Scene class */
  115047. export interface SceneOptions {
  115048. /**
  115049. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  115050. * It will improve performance when the number of geometries becomes important.
  115051. */
  115052. useGeometryUniqueIdsMap?: boolean;
  115053. /**
  115054. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  115055. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  115056. */
  115057. useMaterialMeshMap?: boolean;
  115058. /**
  115059. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  115060. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  115061. */
  115062. useClonedMeshMap?: boolean;
  115063. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  115064. virtual?: boolean;
  115065. }
  115066. /**
  115067. * Represents a scene to be rendered by the engine.
  115068. * @see http://doc.babylonjs.com/features/scene
  115069. */
  115070. export class Scene extends AbstractScene implements IAnimatable {
  115071. /** The fog is deactivated */
  115072. static readonly FOGMODE_NONE: number;
  115073. /** The fog density is following an exponential function */
  115074. static readonly FOGMODE_EXP: number;
  115075. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  115076. static readonly FOGMODE_EXP2: number;
  115077. /** The fog density is following a linear function. */
  115078. static readonly FOGMODE_LINEAR: number;
  115079. /**
  115080. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  115081. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  115082. */
  115083. static MinDeltaTime: number;
  115084. /**
  115085. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  115086. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  115087. */
  115088. static MaxDeltaTime: number;
  115089. /**
  115090. * Factory used to create the default material.
  115091. * @param name The name of the material to create
  115092. * @param scene The scene to create the material for
  115093. * @returns The default material
  115094. */
  115095. static DefaultMaterialFactory(scene: Scene): Material;
  115096. /**
  115097. * Factory used to create the a collision coordinator.
  115098. * @returns The collision coordinator
  115099. */
  115100. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  115101. /** @hidden */
  115102. _inputManager: InputManager;
  115103. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  115104. cameraToUseForPointers: Nullable<Camera>;
  115105. /** @hidden */
  115106. readonly _isScene: boolean;
  115107. /** @hidden */
  115108. _blockEntityCollection: boolean;
  115109. /**
  115110. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  115111. */
  115112. autoClear: boolean;
  115113. /**
  115114. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  115115. */
  115116. autoClearDepthAndStencil: boolean;
  115117. /**
  115118. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  115119. */
  115120. clearColor: Color4;
  115121. /**
  115122. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  115123. */
  115124. ambientColor: Color3;
  115125. /**
  115126. * This is use to store the default BRDF lookup for PBR materials in your scene.
  115127. * It should only be one of the following (if not the default embedded one):
  115128. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  115129. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  115130. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  115131. * The material properties need to be setup according to the type of texture in use.
  115132. */
  115133. environmentBRDFTexture: BaseTexture;
  115134. /** @hidden */
  115135. protected _environmentTexture: Nullable<BaseTexture>;
  115136. /**
  115137. * Texture used in all pbr material as the reflection texture.
  115138. * As in the majority of the scene they are the same (exception for multi room and so on),
  115139. * this is easier to reference from here than from all the materials.
  115140. */
  115141. get environmentTexture(): Nullable<BaseTexture>;
  115142. /**
  115143. * Texture used in all pbr material as the reflection texture.
  115144. * As in the majority of the scene they are the same (exception for multi room and so on),
  115145. * this is easier to set here than in all the materials.
  115146. */
  115147. set environmentTexture(value: Nullable<BaseTexture>);
  115148. /** @hidden */
  115149. protected _environmentIntensity: number;
  115150. /**
  115151. * Intensity of the environment in all pbr material.
  115152. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  115153. * As in the majority of the scene they are the same (exception for multi room and so on),
  115154. * this is easier to reference from here than from all the materials.
  115155. */
  115156. get environmentIntensity(): number;
  115157. /**
  115158. * Intensity of the environment in all pbr material.
  115159. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  115160. * As in the majority of the scene they are the same (exception for multi room and so on),
  115161. * this is easier to set here than in all the materials.
  115162. */
  115163. set environmentIntensity(value: number);
  115164. /** @hidden */
  115165. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  115166. /**
  115167. * Default image processing configuration used either in the rendering
  115168. * Forward main pass or through the imageProcessingPostProcess if present.
  115169. * As in the majority of the scene they are the same (exception for multi camera),
  115170. * this is easier to reference from here than from all the materials and post process.
  115171. *
  115172. * No setter as we it is a shared configuration, you can set the values instead.
  115173. */
  115174. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  115175. private _forceWireframe;
  115176. /**
  115177. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  115178. */
  115179. set forceWireframe(value: boolean);
  115180. get forceWireframe(): boolean;
  115181. private _skipFrustumClipping;
  115182. /**
  115183. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  115184. */
  115185. set skipFrustumClipping(value: boolean);
  115186. get skipFrustumClipping(): boolean;
  115187. private _forcePointsCloud;
  115188. /**
  115189. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  115190. */
  115191. set forcePointsCloud(value: boolean);
  115192. get forcePointsCloud(): boolean;
  115193. /**
  115194. * Gets or sets the active clipplane 1
  115195. */
  115196. clipPlane: Nullable<Plane>;
  115197. /**
  115198. * Gets or sets the active clipplane 2
  115199. */
  115200. clipPlane2: Nullable<Plane>;
  115201. /**
  115202. * Gets or sets the active clipplane 3
  115203. */
  115204. clipPlane3: Nullable<Plane>;
  115205. /**
  115206. * Gets or sets the active clipplane 4
  115207. */
  115208. clipPlane4: Nullable<Plane>;
  115209. /**
  115210. * Gets or sets the active clipplane 5
  115211. */
  115212. clipPlane5: Nullable<Plane>;
  115213. /**
  115214. * Gets or sets the active clipplane 6
  115215. */
  115216. clipPlane6: Nullable<Plane>;
  115217. /**
  115218. * Gets or sets a boolean indicating if animations are enabled
  115219. */
  115220. animationsEnabled: boolean;
  115221. private _animationPropertiesOverride;
  115222. /**
  115223. * Gets or sets the animation properties override
  115224. */
  115225. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  115226. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  115227. /**
  115228. * Gets or sets a boolean indicating if a constant deltatime has to be used
  115229. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  115230. */
  115231. useConstantAnimationDeltaTime: boolean;
  115232. /**
  115233. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  115234. * Please note that it requires to run a ray cast through the scene on every frame
  115235. */
  115236. constantlyUpdateMeshUnderPointer: boolean;
  115237. /**
  115238. * Defines the HTML cursor to use when hovering over interactive elements
  115239. */
  115240. hoverCursor: string;
  115241. /**
  115242. * Defines the HTML default cursor to use (empty by default)
  115243. */
  115244. defaultCursor: string;
  115245. /**
  115246. * Defines whether cursors are handled by the scene.
  115247. */
  115248. doNotHandleCursors: boolean;
  115249. /**
  115250. * This is used to call preventDefault() on pointer down
  115251. * in order to block unwanted artifacts like system double clicks
  115252. */
  115253. preventDefaultOnPointerDown: boolean;
  115254. /**
  115255. * This is used to call preventDefault() on pointer up
  115256. * in order to block unwanted artifacts like system double clicks
  115257. */
  115258. preventDefaultOnPointerUp: boolean;
  115259. /**
  115260. * Gets or sets user defined metadata
  115261. */
  115262. metadata: any;
  115263. /**
  115264. * For internal use only. Please do not use.
  115265. */
  115266. reservedDataStore: any;
  115267. /**
  115268. * Gets the name of the plugin used to load this scene (null by default)
  115269. */
  115270. loadingPluginName: string;
  115271. /**
  115272. * Use this array to add regular expressions used to disable offline support for specific urls
  115273. */
  115274. disableOfflineSupportExceptionRules: RegExp[];
  115275. /**
  115276. * An event triggered when the scene is disposed.
  115277. */
  115278. onDisposeObservable: Observable<Scene>;
  115279. private _onDisposeObserver;
  115280. /** Sets a function to be executed when this scene is disposed. */
  115281. set onDispose(callback: () => void);
  115282. /**
  115283. * An event triggered before rendering the scene (right after animations and physics)
  115284. */
  115285. onBeforeRenderObservable: Observable<Scene>;
  115286. private _onBeforeRenderObserver;
  115287. /** Sets a function to be executed before rendering this scene */
  115288. set beforeRender(callback: Nullable<() => void>);
  115289. /**
  115290. * An event triggered after rendering the scene
  115291. */
  115292. onAfterRenderObservable: Observable<Scene>;
  115293. /**
  115294. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  115295. */
  115296. onAfterRenderCameraObservable: Observable<Camera>;
  115297. private _onAfterRenderObserver;
  115298. /** Sets a function to be executed after rendering this scene */
  115299. set afterRender(callback: Nullable<() => void>);
  115300. /**
  115301. * An event triggered before animating the scene
  115302. */
  115303. onBeforeAnimationsObservable: Observable<Scene>;
  115304. /**
  115305. * An event triggered after animations processing
  115306. */
  115307. onAfterAnimationsObservable: Observable<Scene>;
  115308. /**
  115309. * An event triggered before draw calls are ready to be sent
  115310. */
  115311. onBeforeDrawPhaseObservable: Observable<Scene>;
  115312. /**
  115313. * An event triggered after draw calls have been sent
  115314. */
  115315. onAfterDrawPhaseObservable: Observable<Scene>;
  115316. /**
  115317. * An event triggered when the scene is ready
  115318. */
  115319. onReadyObservable: Observable<Scene>;
  115320. /**
  115321. * An event triggered before rendering a camera
  115322. */
  115323. onBeforeCameraRenderObservable: Observable<Camera>;
  115324. private _onBeforeCameraRenderObserver;
  115325. /** Sets a function to be executed before rendering a camera*/
  115326. set beforeCameraRender(callback: () => void);
  115327. /**
  115328. * An event triggered after rendering a camera
  115329. */
  115330. onAfterCameraRenderObservable: Observable<Camera>;
  115331. private _onAfterCameraRenderObserver;
  115332. /** Sets a function to be executed after rendering a camera*/
  115333. set afterCameraRender(callback: () => void);
  115334. /**
  115335. * An event triggered when active meshes evaluation is about to start
  115336. */
  115337. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  115338. /**
  115339. * An event triggered when active meshes evaluation is done
  115340. */
  115341. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  115342. /**
  115343. * An event triggered when particles rendering is about to start
  115344. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  115345. */
  115346. onBeforeParticlesRenderingObservable: Observable<Scene>;
  115347. /**
  115348. * An event triggered when particles rendering is done
  115349. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  115350. */
  115351. onAfterParticlesRenderingObservable: Observable<Scene>;
  115352. /**
  115353. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  115354. */
  115355. onDataLoadedObservable: Observable<Scene>;
  115356. /**
  115357. * An event triggered when a camera is created
  115358. */
  115359. onNewCameraAddedObservable: Observable<Camera>;
  115360. /**
  115361. * An event triggered when a camera is removed
  115362. */
  115363. onCameraRemovedObservable: Observable<Camera>;
  115364. /**
  115365. * An event triggered when a light is created
  115366. */
  115367. onNewLightAddedObservable: Observable<Light>;
  115368. /**
  115369. * An event triggered when a light is removed
  115370. */
  115371. onLightRemovedObservable: Observable<Light>;
  115372. /**
  115373. * An event triggered when a geometry is created
  115374. */
  115375. onNewGeometryAddedObservable: Observable<Geometry>;
  115376. /**
  115377. * An event triggered when a geometry is removed
  115378. */
  115379. onGeometryRemovedObservable: Observable<Geometry>;
  115380. /**
  115381. * An event triggered when a transform node is created
  115382. */
  115383. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  115384. /**
  115385. * An event triggered when a transform node is removed
  115386. */
  115387. onTransformNodeRemovedObservable: Observable<TransformNode>;
  115388. /**
  115389. * An event triggered when a mesh is created
  115390. */
  115391. onNewMeshAddedObservable: Observable<AbstractMesh>;
  115392. /**
  115393. * An event triggered when a mesh is removed
  115394. */
  115395. onMeshRemovedObservable: Observable<AbstractMesh>;
  115396. /**
  115397. * An event triggered when a skeleton is created
  115398. */
  115399. onNewSkeletonAddedObservable: Observable<Skeleton>;
  115400. /**
  115401. * An event triggered when a skeleton is removed
  115402. */
  115403. onSkeletonRemovedObservable: Observable<Skeleton>;
  115404. /**
  115405. * An event triggered when a material is created
  115406. */
  115407. onNewMaterialAddedObservable: Observable<Material>;
  115408. /**
  115409. * An event triggered when a material is removed
  115410. */
  115411. onMaterialRemovedObservable: Observable<Material>;
  115412. /**
  115413. * An event triggered when a texture is created
  115414. */
  115415. onNewTextureAddedObservable: Observable<BaseTexture>;
  115416. /**
  115417. * An event triggered when a texture is removed
  115418. */
  115419. onTextureRemovedObservable: Observable<BaseTexture>;
  115420. /**
  115421. * An event triggered when render targets are about to be rendered
  115422. * Can happen multiple times per frame.
  115423. */
  115424. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  115425. /**
  115426. * An event triggered when render targets were rendered.
  115427. * Can happen multiple times per frame.
  115428. */
  115429. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  115430. /**
  115431. * An event triggered before calculating deterministic simulation step
  115432. */
  115433. onBeforeStepObservable: Observable<Scene>;
  115434. /**
  115435. * An event triggered after calculating deterministic simulation step
  115436. */
  115437. onAfterStepObservable: Observable<Scene>;
  115438. /**
  115439. * An event triggered when the activeCamera property is updated
  115440. */
  115441. onActiveCameraChanged: Observable<Scene>;
  115442. /**
  115443. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  115444. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  115445. * 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)
  115446. */
  115447. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  115448. /**
  115449. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  115450. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  115451. * 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)
  115452. */
  115453. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  115454. /**
  115455. * This Observable will when a mesh has been imported into the scene.
  115456. */
  115457. onMeshImportedObservable: Observable<AbstractMesh>;
  115458. /**
  115459. * This Observable will when an animation file has been imported into the scene.
  115460. */
  115461. onAnimationFileImportedObservable: Observable<Scene>;
  115462. /**
  115463. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  115464. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  115465. */
  115466. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  115467. /** @hidden */
  115468. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  115469. /**
  115470. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  115471. */
  115472. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  115473. /**
  115474. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  115475. */
  115476. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  115477. /**
  115478. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  115479. */
  115480. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  115481. /** Callback called when a pointer move is detected */
  115482. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  115483. /** Callback called when a pointer down is detected */
  115484. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  115485. /** Callback called when a pointer up is detected */
  115486. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  115487. /** Callback called when a pointer pick is detected */
  115488. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  115489. /**
  115490. * 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).
  115491. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  115492. */
  115493. onPrePointerObservable: Observable<PointerInfoPre>;
  115494. /**
  115495. * Observable event triggered each time an input event is received from the rendering canvas
  115496. */
  115497. onPointerObservable: Observable<PointerInfo>;
  115498. /**
  115499. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  115500. */
  115501. get unTranslatedPointer(): Vector2;
  115502. /**
  115503. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  115504. */
  115505. static get DragMovementThreshold(): number;
  115506. static set DragMovementThreshold(value: number);
  115507. /**
  115508. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  115509. */
  115510. static get LongPressDelay(): number;
  115511. static set LongPressDelay(value: number);
  115512. /**
  115513. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  115514. */
  115515. static get DoubleClickDelay(): number;
  115516. static set DoubleClickDelay(value: number);
  115517. /** If you need to check double click without raising a single click at first click, enable this flag */
  115518. static get ExclusiveDoubleClickMode(): boolean;
  115519. static set ExclusiveDoubleClickMode(value: boolean);
  115520. /** @hidden */
  115521. _mirroredCameraPosition: Nullable<Vector3>;
  115522. /**
  115523. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  115524. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  115525. */
  115526. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  115527. /**
  115528. * Observable event triggered each time an keyboard event is received from the hosting window
  115529. */
  115530. onKeyboardObservable: Observable<KeyboardInfo>;
  115531. private _useRightHandedSystem;
  115532. /**
  115533. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  115534. */
  115535. set useRightHandedSystem(value: boolean);
  115536. get useRightHandedSystem(): boolean;
  115537. private _timeAccumulator;
  115538. private _currentStepId;
  115539. private _currentInternalStep;
  115540. /**
  115541. * Sets the step Id used by deterministic lock step
  115542. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  115543. * @param newStepId defines the step Id
  115544. */
  115545. setStepId(newStepId: number): void;
  115546. /**
  115547. * Gets the step Id used by deterministic lock step
  115548. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  115549. * @returns the step Id
  115550. */
  115551. getStepId(): number;
  115552. /**
  115553. * Gets the internal step used by deterministic lock step
  115554. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  115555. * @returns the internal step
  115556. */
  115557. getInternalStep(): number;
  115558. private _fogEnabled;
  115559. /**
  115560. * Gets or sets a boolean indicating if fog is enabled on this scene
  115561. * @see http://doc.babylonjs.com/babylon101/environment#fog
  115562. * (Default is true)
  115563. */
  115564. set fogEnabled(value: boolean);
  115565. get fogEnabled(): boolean;
  115566. private _fogMode;
  115567. /**
  115568. * Gets or sets the fog mode to use
  115569. * @see http://doc.babylonjs.com/babylon101/environment#fog
  115570. * | mode | value |
  115571. * | --- | --- |
  115572. * | FOGMODE_NONE | 0 |
  115573. * | FOGMODE_EXP | 1 |
  115574. * | FOGMODE_EXP2 | 2 |
  115575. * | FOGMODE_LINEAR | 3 |
  115576. */
  115577. set fogMode(value: number);
  115578. get fogMode(): number;
  115579. /**
  115580. * Gets or sets the fog color to use
  115581. * @see http://doc.babylonjs.com/babylon101/environment#fog
  115582. * (Default is Color3(0.2, 0.2, 0.3))
  115583. */
  115584. fogColor: Color3;
  115585. /**
  115586. * Gets or sets the fog density to use
  115587. * @see http://doc.babylonjs.com/babylon101/environment#fog
  115588. * (Default is 0.1)
  115589. */
  115590. fogDensity: number;
  115591. /**
  115592. * Gets or sets the fog start distance to use
  115593. * @see http://doc.babylonjs.com/babylon101/environment#fog
  115594. * (Default is 0)
  115595. */
  115596. fogStart: number;
  115597. /**
  115598. * Gets or sets the fog end distance to use
  115599. * @see http://doc.babylonjs.com/babylon101/environment#fog
  115600. * (Default is 1000)
  115601. */
  115602. fogEnd: number;
  115603. private _shadowsEnabled;
  115604. /**
  115605. * Gets or sets a boolean indicating if shadows are enabled on this scene
  115606. */
  115607. set shadowsEnabled(value: boolean);
  115608. get shadowsEnabled(): boolean;
  115609. private _lightsEnabled;
  115610. /**
  115611. * Gets or sets a boolean indicating if lights are enabled on this scene
  115612. */
  115613. set lightsEnabled(value: boolean);
  115614. get lightsEnabled(): boolean;
  115615. /** All of the active cameras added to this scene. */
  115616. activeCameras: Camera[];
  115617. /** @hidden */
  115618. _activeCamera: Nullable<Camera>;
  115619. /** Gets or sets the current active camera */
  115620. get activeCamera(): Nullable<Camera>;
  115621. set activeCamera(value: Nullable<Camera>);
  115622. private _defaultMaterial;
  115623. /** The default material used on meshes when no material is affected */
  115624. get defaultMaterial(): Material;
  115625. /** The default material used on meshes when no material is affected */
  115626. set defaultMaterial(value: Material);
  115627. private _texturesEnabled;
  115628. /**
  115629. * Gets or sets a boolean indicating if textures are enabled on this scene
  115630. */
  115631. set texturesEnabled(value: boolean);
  115632. get texturesEnabled(): boolean;
  115633. /**
  115634. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  115635. */
  115636. physicsEnabled: boolean;
  115637. /**
  115638. * Gets or sets a boolean indicating if particles are enabled on this scene
  115639. */
  115640. particlesEnabled: boolean;
  115641. /**
  115642. * Gets or sets a boolean indicating if sprites are enabled on this scene
  115643. */
  115644. spritesEnabled: boolean;
  115645. private _skeletonsEnabled;
  115646. /**
  115647. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  115648. */
  115649. set skeletonsEnabled(value: boolean);
  115650. get skeletonsEnabled(): boolean;
  115651. /**
  115652. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  115653. */
  115654. lensFlaresEnabled: boolean;
  115655. /**
  115656. * Gets or sets a boolean indicating if collisions are enabled on this scene
  115657. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  115658. */
  115659. collisionsEnabled: boolean;
  115660. private _collisionCoordinator;
  115661. /** @hidden */
  115662. get collisionCoordinator(): ICollisionCoordinator;
  115663. /**
  115664. * Defines the gravity applied to this scene (used only for collisions)
  115665. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  115666. */
  115667. gravity: Vector3;
  115668. /**
  115669. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  115670. */
  115671. postProcessesEnabled: boolean;
  115672. /**
  115673. * The list of postprocesses added to the scene
  115674. */
  115675. postProcesses: PostProcess[];
  115676. /**
  115677. * Gets the current postprocess manager
  115678. */
  115679. postProcessManager: PostProcessManager;
  115680. /**
  115681. * Gets or sets a boolean indicating if render targets are enabled on this scene
  115682. */
  115683. renderTargetsEnabled: boolean;
  115684. /**
  115685. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  115686. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  115687. */
  115688. dumpNextRenderTargets: boolean;
  115689. /**
  115690. * The list of user defined render targets added to the scene
  115691. */
  115692. customRenderTargets: RenderTargetTexture[];
  115693. /**
  115694. * Defines if texture loading must be delayed
  115695. * If true, textures will only be loaded when they need to be rendered
  115696. */
  115697. useDelayedTextureLoading: boolean;
  115698. /**
  115699. * Gets the list of meshes imported to the scene through SceneLoader
  115700. */
  115701. importedMeshesFiles: String[];
  115702. /**
  115703. * Gets or sets a boolean indicating if probes are enabled on this scene
  115704. */
  115705. probesEnabled: boolean;
  115706. /**
  115707. * Gets or sets the current offline provider to use to store scene data
  115708. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  115709. */
  115710. offlineProvider: IOfflineProvider;
  115711. /**
  115712. * Gets or sets the action manager associated with the scene
  115713. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  115714. */
  115715. actionManager: AbstractActionManager;
  115716. private _meshesForIntersections;
  115717. /**
  115718. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  115719. */
  115720. proceduralTexturesEnabled: boolean;
  115721. private _engine;
  115722. private _totalVertices;
  115723. /** @hidden */
  115724. _activeIndices: PerfCounter;
  115725. /** @hidden */
  115726. _activeParticles: PerfCounter;
  115727. /** @hidden */
  115728. _activeBones: PerfCounter;
  115729. private _animationRatio;
  115730. /** @hidden */
  115731. _animationTimeLast: number;
  115732. /** @hidden */
  115733. _animationTime: number;
  115734. /**
  115735. * Gets or sets a general scale for animation speed
  115736. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  115737. */
  115738. animationTimeScale: number;
  115739. /** @hidden */
  115740. _cachedMaterial: Nullable<Material>;
  115741. /** @hidden */
  115742. _cachedEffect: Nullable<Effect>;
  115743. /** @hidden */
  115744. _cachedVisibility: Nullable<number>;
  115745. private _renderId;
  115746. private _frameId;
  115747. private _executeWhenReadyTimeoutId;
  115748. private _intermediateRendering;
  115749. private _viewUpdateFlag;
  115750. private _projectionUpdateFlag;
  115751. /** @hidden */
  115752. _toBeDisposed: Nullable<IDisposable>[];
  115753. private _activeRequests;
  115754. /** @hidden */
  115755. _pendingData: any[];
  115756. private _isDisposed;
  115757. /**
  115758. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  115759. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  115760. */
  115761. dispatchAllSubMeshesOfActiveMeshes: boolean;
  115762. private _activeMeshes;
  115763. private _processedMaterials;
  115764. private _renderTargets;
  115765. /** @hidden */
  115766. _activeParticleSystems: SmartArray<IParticleSystem>;
  115767. private _activeSkeletons;
  115768. private _softwareSkinnedMeshes;
  115769. private _renderingManager;
  115770. /** @hidden */
  115771. _activeAnimatables: Animatable[];
  115772. private _transformMatrix;
  115773. private _sceneUbo;
  115774. /** @hidden */
  115775. _viewMatrix: Matrix;
  115776. private _projectionMatrix;
  115777. /** @hidden */
  115778. _forcedViewPosition: Nullable<Vector3>;
  115779. /** @hidden */
  115780. _frustumPlanes: Plane[];
  115781. /**
  115782. * Gets the list of frustum planes (built from the active camera)
  115783. */
  115784. get frustumPlanes(): Plane[];
  115785. /**
  115786. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  115787. * This is useful if there are more lights that the maximum simulteanous authorized
  115788. */
  115789. requireLightSorting: boolean;
  115790. /** @hidden */
  115791. readonly useMaterialMeshMap: boolean;
  115792. /** @hidden */
  115793. readonly useClonedMeshMap: boolean;
  115794. private _externalData;
  115795. private _uid;
  115796. /**
  115797. * @hidden
  115798. * Backing store of defined scene components.
  115799. */
  115800. _components: ISceneComponent[];
  115801. /**
  115802. * @hidden
  115803. * Backing store of defined scene components.
  115804. */
  115805. _serializableComponents: ISceneSerializableComponent[];
  115806. /**
  115807. * List of components to register on the next registration step.
  115808. */
  115809. private _transientComponents;
  115810. /**
  115811. * Registers the transient components if needed.
  115812. */
  115813. private _registerTransientComponents;
  115814. /**
  115815. * @hidden
  115816. * Add a component to the scene.
  115817. * Note that the ccomponent could be registered on th next frame if this is called after
  115818. * the register component stage.
  115819. * @param component Defines the component to add to the scene
  115820. */
  115821. _addComponent(component: ISceneComponent): void;
  115822. /**
  115823. * @hidden
  115824. * Gets a component from the scene.
  115825. * @param name defines the name of the component to retrieve
  115826. * @returns the component or null if not present
  115827. */
  115828. _getComponent(name: string): Nullable<ISceneComponent>;
  115829. /**
  115830. * @hidden
  115831. * Defines the actions happening before camera updates.
  115832. */
  115833. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  115834. /**
  115835. * @hidden
  115836. * Defines the actions happening before clear the canvas.
  115837. */
  115838. _beforeClearStage: Stage<SimpleStageAction>;
  115839. /**
  115840. * @hidden
  115841. * Defines the actions when collecting render targets for the frame.
  115842. */
  115843. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  115844. /**
  115845. * @hidden
  115846. * Defines the actions happening for one camera in the frame.
  115847. */
  115848. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  115849. /**
  115850. * @hidden
  115851. * Defines the actions happening during the per mesh ready checks.
  115852. */
  115853. _isReadyForMeshStage: Stage<MeshStageAction>;
  115854. /**
  115855. * @hidden
  115856. * Defines the actions happening before evaluate active mesh checks.
  115857. */
  115858. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  115859. /**
  115860. * @hidden
  115861. * Defines the actions happening during the evaluate sub mesh checks.
  115862. */
  115863. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  115864. /**
  115865. * @hidden
  115866. * Defines the actions happening during the active mesh stage.
  115867. */
  115868. _activeMeshStage: Stage<ActiveMeshStageAction>;
  115869. /**
  115870. * @hidden
  115871. * Defines the actions happening during the per camera render target step.
  115872. */
  115873. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  115874. /**
  115875. * @hidden
  115876. * Defines the actions happening just before the active camera is drawing.
  115877. */
  115878. _beforeCameraDrawStage: Stage<CameraStageAction>;
  115879. /**
  115880. * @hidden
  115881. * Defines the actions happening just before a render target is drawing.
  115882. */
  115883. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  115884. /**
  115885. * @hidden
  115886. * Defines the actions happening just before a rendering group is drawing.
  115887. */
  115888. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  115889. /**
  115890. * @hidden
  115891. * Defines the actions happening just before a mesh is drawing.
  115892. */
  115893. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  115894. /**
  115895. * @hidden
  115896. * Defines the actions happening just after a mesh has been drawn.
  115897. */
  115898. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  115899. /**
  115900. * @hidden
  115901. * Defines the actions happening just after a rendering group has been drawn.
  115902. */
  115903. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  115904. /**
  115905. * @hidden
  115906. * Defines the actions happening just after the active camera has been drawn.
  115907. */
  115908. _afterCameraDrawStage: Stage<CameraStageAction>;
  115909. /**
  115910. * @hidden
  115911. * Defines the actions happening just after a render target has been drawn.
  115912. */
  115913. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  115914. /**
  115915. * @hidden
  115916. * Defines the actions happening just after rendering all cameras and computing intersections.
  115917. */
  115918. _afterRenderStage: Stage<SimpleStageAction>;
  115919. /**
  115920. * @hidden
  115921. * Defines the actions happening when a pointer move event happens.
  115922. */
  115923. _pointerMoveStage: Stage<PointerMoveStageAction>;
  115924. /**
  115925. * @hidden
  115926. * Defines the actions happening when a pointer down event happens.
  115927. */
  115928. _pointerDownStage: Stage<PointerUpDownStageAction>;
  115929. /**
  115930. * @hidden
  115931. * Defines the actions happening when a pointer up event happens.
  115932. */
  115933. _pointerUpStage: Stage<PointerUpDownStageAction>;
  115934. /**
  115935. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  115936. */
  115937. private geometriesByUniqueId;
  115938. /**
  115939. * Creates a new Scene
  115940. * @param engine defines the engine to use to render this scene
  115941. * @param options defines the scene options
  115942. */
  115943. constructor(engine: Engine, options?: SceneOptions);
  115944. /**
  115945. * Gets a string idenfifying the name of the class
  115946. * @returns "Scene" string
  115947. */
  115948. getClassName(): string;
  115949. private _defaultMeshCandidates;
  115950. /**
  115951. * @hidden
  115952. */
  115953. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  115954. private _defaultSubMeshCandidates;
  115955. /**
  115956. * @hidden
  115957. */
  115958. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  115959. /**
  115960. * Sets the default candidate providers for the scene.
  115961. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  115962. * and getCollidingSubMeshCandidates to their default function
  115963. */
  115964. setDefaultCandidateProviders(): void;
  115965. /**
  115966. * Gets the mesh that is currently under the pointer
  115967. */
  115968. get meshUnderPointer(): Nullable<AbstractMesh>;
  115969. /**
  115970. * Gets or sets the current on-screen X position of the pointer
  115971. */
  115972. get pointerX(): number;
  115973. set pointerX(value: number);
  115974. /**
  115975. * Gets or sets the current on-screen Y position of the pointer
  115976. */
  115977. get pointerY(): number;
  115978. set pointerY(value: number);
  115979. /**
  115980. * Gets the cached material (ie. the latest rendered one)
  115981. * @returns the cached material
  115982. */
  115983. getCachedMaterial(): Nullable<Material>;
  115984. /**
  115985. * Gets the cached effect (ie. the latest rendered one)
  115986. * @returns the cached effect
  115987. */
  115988. getCachedEffect(): Nullable<Effect>;
  115989. /**
  115990. * Gets the cached visibility state (ie. the latest rendered one)
  115991. * @returns the cached visibility state
  115992. */
  115993. getCachedVisibility(): Nullable<number>;
  115994. /**
  115995. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  115996. * @param material defines the current material
  115997. * @param effect defines the current effect
  115998. * @param visibility defines the current visibility state
  115999. * @returns true if one parameter is not cached
  116000. */
  116001. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  116002. /**
  116003. * Gets the engine associated with the scene
  116004. * @returns an Engine
  116005. */
  116006. getEngine(): Engine;
  116007. /**
  116008. * Gets the total number of vertices rendered per frame
  116009. * @returns the total number of vertices rendered per frame
  116010. */
  116011. getTotalVertices(): number;
  116012. /**
  116013. * Gets the performance counter for total vertices
  116014. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  116015. */
  116016. get totalVerticesPerfCounter(): PerfCounter;
  116017. /**
  116018. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  116019. * @returns the total number of active indices rendered per frame
  116020. */
  116021. getActiveIndices(): number;
  116022. /**
  116023. * Gets the performance counter for active indices
  116024. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  116025. */
  116026. get totalActiveIndicesPerfCounter(): PerfCounter;
  116027. /**
  116028. * Gets the total number of active particles rendered per frame
  116029. * @returns the total number of active particles rendered per frame
  116030. */
  116031. getActiveParticles(): number;
  116032. /**
  116033. * Gets the performance counter for active particles
  116034. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  116035. */
  116036. get activeParticlesPerfCounter(): PerfCounter;
  116037. /**
  116038. * Gets the total number of active bones rendered per frame
  116039. * @returns the total number of active bones rendered per frame
  116040. */
  116041. getActiveBones(): number;
  116042. /**
  116043. * Gets the performance counter for active bones
  116044. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  116045. */
  116046. get activeBonesPerfCounter(): PerfCounter;
  116047. /**
  116048. * Gets the array of active meshes
  116049. * @returns an array of AbstractMesh
  116050. */
  116051. getActiveMeshes(): SmartArray<AbstractMesh>;
  116052. /**
  116053. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  116054. * @returns a number
  116055. */
  116056. getAnimationRatio(): number;
  116057. /**
  116058. * Gets an unique Id for the current render phase
  116059. * @returns a number
  116060. */
  116061. getRenderId(): number;
  116062. /**
  116063. * Gets an unique Id for the current frame
  116064. * @returns a number
  116065. */
  116066. getFrameId(): number;
  116067. /** Call this function if you want to manually increment the render Id*/
  116068. incrementRenderId(): void;
  116069. private _createUbo;
  116070. /**
  116071. * Use this method to simulate a pointer move on a mesh
  116072. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  116073. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  116074. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  116075. * @returns the current scene
  116076. */
  116077. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  116078. /**
  116079. * Use this method to simulate a pointer down on a mesh
  116080. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  116081. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  116082. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  116083. * @returns the current scene
  116084. */
  116085. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  116086. /**
  116087. * Use this method to simulate a pointer up on a mesh
  116088. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  116089. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  116090. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  116091. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  116092. * @returns the current scene
  116093. */
  116094. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  116095. /**
  116096. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  116097. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  116098. * @returns true if the pointer was captured
  116099. */
  116100. isPointerCaptured(pointerId?: number): boolean;
  116101. /**
  116102. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  116103. * @param attachUp defines if you want to attach events to pointerup
  116104. * @param attachDown defines if you want to attach events to pointerdown
  116105. * @param attachMove defines if you want to attach events to pointermove
  116106. */
  116107. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  116108. /** Detaches all event handlers*/
  116109. detachControl(): void;
  116110. /**
  116111. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  116112. * Delay loaded resources are not taking in account
  116113. * @return true if all required resources are ready
  116114. */
  116115. isReady(): boolean;
  116116. /** Resets all cached information relative to material (including effect and visibility) */
  116117. resetCachedMaterial(): void;
  116118. /**
  116119. * Registers a function to be called before every frame render
  116120. * @param func defines the function to register
  116121. */
  116122. registerBeforeRender(func: () => void): void;
  116123. /**
  116124. * Unregisters a function called before every frame render
  116125. * @param func defines the function to unregister
  116126. */
  116127. unregisterBeforeRender(func: () => void): void;
  116128. /**
  116129. * Registers a function to be called after every frame render
  116130. * @param func defines the function to register
  116131. */
  116132. registerAfterRender(func: () => void): void;
  116133. /**
  116134. * Unregisters a function called after every frame render
  116135. * @param func defines the function to unregister
  116136. */
  116137. unregisterAfterRender(func: () => void): void;
  116138. private _executeOnceBeforeRender;
  116139. /**
  116140. * The provided function will run before render once and will be disposed afterwards.
  116141. * A timeout delay can be provided so that the function will be executed in N ms.
  116142. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  116143. * @param func The function to be executed.
  116144. * @param timeout optional delay in ms
  116145. */
  116146. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  116147. /** @hidden */
  116148. _addPendingData(data: any): void;
  116149. /** @hidden */
  116150. _removePendingData(data: any): void;
  116151. /**
  116152. * Returns the number of items waiting to be loaded
  116153. * @returns the number of items waiting to be loaded
  116154. */
  116155. getWaitingItemsCount(): number;
  116156. /**
  116157. * Returns a boolean indicating if the scene is still loading data
  116158. */
  116159. get isLoading(): boolean;
  116160. /**
  116161. * Registers a function to be executed when the scene is ready
  116162. * @param {Function} func - the function to be executed
  116163. */
  116164. executeWhenReady(func: () => void): void;
  116165. /**
  116166. * Returns a promise that resolves when the scene is ready
  116167. * @returns A promise that resolves when the scene is ready
  116168. */
  116169. whenReadyAsync(): Promise<void>;
  116170. /** @hidden */
  116171. _checkIsReady(): void;
  116172. /**
  116173. * Gets all animatable attached to the scene
  116174. */
  116175. get animatables(): Animatable[];
  116176. /**
  116177. * Resets the last animation time frame.
  116178. * Useful to override when animations start running when loading a scene for the first time.
  116179. */
  116180. resetLastAnimationTimeFrame(): void;
  116181. /**
  116182. * Gets the current view matrix
  116183. * @returns a Matrix
  116184. */
  116185. getViewMatrix(): Matrix;
  116186. /**
  116187. * Gets the current projection matrix
  116188. * @returns a Matrix
  116189. */
  116190. getProjectionMatrix(): Matrix;
  116191. /**
  116192. * Gets the current transform matrix
  116193. * @returns a Matrix made of View * Projection
  116194. */
  116195. getTransformMatrix(): Matrix;
  116196. /**
  116197. * Sets the current transform matrix
  116198. * @param viewL defines the View matrix to use
  116199. * @param projectionL defines the Projection matrix to use
  116200. * @param viewR defines the right View matrix to use (if provided)
  116201. * @param projectionR defines the right Projection matrix to use (if provided)
  116202. */
  116203. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  116204. /**
  116205. * Gets the uniform buffer used to store scene data
  116206. * @returns a UniformBuffer
  116207. */
  116208. getSceneUniformBuffer(): UniformBuffer;
  116209. /**
  116210. * Gets an unique (relatively to the current scene) Id
  116211. * @returns an unique number for the scene
  116212. */
  116213. getUniqueId(): number;
  116214. /**
  116215. * Add a mesh to the list of scene's meshes
  116216. * @param newMesh defines the mesh to add
  116217. * @param recursive if all child meshes should also be added to the scene
  116218. */
  116219. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  116220. /**
  116221. * Remove a mesh for the list of scene's meshes
  116222. * @param toRemove defines the mesh to remove
  116223. * @param recursive if all child meshes should also be removed from the scene
  116224. * @returns the index where the mesh was in the mesh list
  116225. */
  116226. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  116227. /**
  116228. * Add a transform node to the list of scene's transform nodes
  116229. * @param newTransformNode defines the transform node to add
  116230. */
  116231. addTransformNode(newTransformNode: TransformNode): void;
  116232. /**
  116233. * Remove a transform node for the list of scene's transform nodes
  116234. * @param toRemove defines the transform node to remove
  116235. * @returns the index where the transform node was in the transform node list
  116236. */
  116237. removeTransformNode(toRemove: TransformNode): number;
  116238. /**
  116239. * Remove a skeleton for the list of scene's skeletons
  116240. * @param toRemove defines the skeleton to remove
  116241. * @returns the index where the skeleton was in the skeleton list
  116242. */
  116243. removeSkeleton(toRemove: Skeleton): number;
  116244. /**
  116245. * Remove a morph target for the list of scene's morph targets
  116246. * @param toRemove defines the morph target to remove
  116247. * @returns the index where the morph target was in the morph target list
  116248. */
  116249. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  116250. /**
  116251. * Remove a light for the list of scene's lights
  116252. * @param toRemove defines the light to remove
  116253. * @returns the index where the light was in the light list
  116254. */
  116255. removeLight(toRemove: Light): number;
  116256. /**
  116257. * Remove a camera for the list of scene's cameras
  116258. * @param toRemove defines the camera to remove
  116259. * @returns the index where the camera was in the camera list
  116260. */
  116261. removeCamera(toRemove: Camera): number;
  116262. /**
  116263. * Remove a particle system for the list of scene's particle systems
  116264. * @param toRemove defines the particle system to remove
  116265. * @returns the index where the particle system was in the particle system list
  116266. */
  116267. removeParticleSystem(toRemove: IParticleSystem): number;
  116268. /**
  116269. * Remove a animation for the list of scene's animations
  116270. * @param toRemove defines the animation to remove
  116271. * @returns the index where the animation was in the animation list
  116272. */
  116273. removeAnimation(toRemove: Animation): number;
  116274. /**
  116275. * Will stop the animation of the given target
  116276. * @param target - the target
  116277. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  116278. * @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)
  116279. */
  116280. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  116281. /**
  116282. * Removes the given animation group from this scene.
  116283. * @param toRemove The animation group to remove
  116284. * @returns The index of the removed animation group
  116285. */
  116286. removeAnimationGroup(toRemove: AnimationGroup): number;
  116287. /**
  116288. * Removes the given multi-material from this scene.
  116289. * @param toRemove The multi-material to remove
  116290. * @returns The index of the removed multi-material
  116291. */
  116292. removeMultiMaterial(toRemove: MultiMaterial): number;
  116293. /**
  116294. * Removes the given material from this scene.
  116295. * @param toRemove The material to remove
  116296. * @returns The index of the removed material
  116297. */
  116298. removeMaterial(toRemove: Material): number;
  116299. /**
  116300. * Removes the given action manager from this scene.
  116301. * @param toRemove The action manager to remove
  116302. * @returns The index of the removed action manager
  116303. */
  116304. removeActionManager(toRemove: AbstractActionManager): number;
  116305. /**
  116306. * Removes the given texture from this scene.
  116307. * @param toRemove The texture to remove
  116308. * @returns The index of the removed texture
  116309. */
  116310. removeTexture(toRemove: BaseTexture): number;
  116311. /**
  116312. * Adds the given light to this scene
  116313. * @param newLight The light to add
  116314. */
  116315. addLight(newLight: Light): void;
  116316. /**
  116317. * Sorts the list list based on light priorities
  116318. */
  116319. sortLightsByPriority(): void;
  116320. /**
  116321. * Adds the given camera to this scene
  116322. * @param newCamera The camera to add
  116323. */
  116324. addCamera(newCamera: Camera): void;
  116325. /**
  116326. * Adds the given skeleton to this scene
  116327. * @param newSkeleton The skeleton to add
  116328. */
  116329. addSkeleton(newSkeleton: Skeleton): void;
  116330. /**
  116331. * Adds the given particle system to this scene
  116332. * @param newParticleSystem The particle system to add
  116333. */
  116334. addParticleSystem(newParticleSystem: IParticleSystem): void;
  116335. /**
  116336. * Adds the given animation to this scene
  116337. * @param newAnimation The animation to add
  116338. */
  116339. addAnimation(newAnimation: Animation): void;
  116340. /**
  116341. * Adds the given animation group to this scene.
  116342. * @param newAnimationGroup The animation group to add
  116343. */
  116344. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  116345. /**
  116346. * Adds the given multi-material to this scene
  116347. * @param newMultiMaterial The multi-material to add
  116348. */
  116349. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  116350. /**
  116351. * Adds the given material to this scene
  116352. * @param newMaterial The material to add
  116353. */
  116354. addMaterial(newMaterial: Material): void;
  116355. /**
  116356. * Adds the given morph target to this scene
  116357. * @param newMorphTargetManager The morph target to add
  116358. */
  116359. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  116360. /**
  116361. * Adds the given geometry to this scene
  116362. * @param newGeometry The geometry to add
  116363. */
  116364. addGeometry(newGeometry: Geometry): void;
  116365. /**
  116366. * Adds the given action manager to this scene
  116367. * @param newActionManager The action manager to add
  116368. */
  116369. addActionManager(newActionManager: AbstractActionManager): void;
  116370. /**
  116371. * Adds the given texture to this scene.
  116372. * @param newTexture The texture to add
  116373. */
  116374. addTexture(newTexture: BaseTexture): void;
  116375. /**
  116376. * Switch active camera
  116377. * @param newCamera defines the new active camera
  116378. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  116379. */
  116380. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  116381. /**
  116382. * sets the active camera of the scene using its ID
  116383. * @param id defines the camera's ID
  116384. * @return the new active camera or null if none found.
  116385. */
  116386. setActiveCameraByID(id: string): Nullable<Camera>;
  116387. /**
  116388. * sets the active camera of the scene using its name
  116389. * @param name defines the camera's name
  116390. * @returns the new active camera or null if none found.
  116391. */
  116392. setActiveCameraByName(name: string): Nullable<Camera>;
  116393. /**
  116394. * get an animation group using its name
  116395. * @param name defines the material's name
  116396. * @return the animation group or null if none found.
  116397. */
  116398. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  116399. /**
  116400. * Get a material using its unique id
  116401. * @param uniqueId defines the material's unique id
  116402. * @return the material or null if none found.
  116403. */
  116404. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  116405. /**
  116406. * get a material using its id
  116407. * @param id defines the material's ID
  116408. * @return the material or null if none found.
  116409. */
  116410. getMaterialByID(id: string): Nullable<Material>;
  116411. /**
  116412. * Gets a the last added material using a given id
  116413. * @param id defines the material's ID
  116414. * @return the last material with the given id or null if none found.
  116415. */
  116416. getLastMaterialByID(id: string): Nullable<Material>;
  116417. /**
  116418. * Gets a material using its name
  116419. * @param name defines the material's name
  116420. * @return the material or null if none found.
  116421. */
  116422. getMaterialByName(name: string): Nullable<Material>;
  116423. /**
  116424. * Get a texture using its unique id
  116425. * @param uniqueId defines the texture's unique id
  116426. * @return the texture or null if none found.
  116427. */
  116428. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  116429. /**
  116430. * Gets a camera using its id
  116431. * @param id defines the id to look for
  116432. * @returns the camera or null if not found
  116433. */
  116434. getCameraByID(id: string): Nullable<Camera>;
  116435. /**
  116436. * Gets a camera using its unique id
  116437. * @param uniqueId defines the unique id to look for
  116438. * @returns the camera or null if not found
  116439. */
  116440. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  116441. /**
  116442. * Gets a camera using its name
  116443. * @param name defines the camera's name
  116444. * @return the camera or null if none found.
  116445. */
  116446. getCameraByName(name: string): Nullable<Camera>;
  116447. /**
  116448. * Gets a bone using its id
  116449. * @param id defines the bone's id
  116450. * @return the bone or null if not found
  116451. */
  116452. getBoneByID(id: string): Nullable<Bone>;
  116453. /**
  116454. * Gets a bone using its id
  116455. * @param name defines the bone's name
  116456. * @return the bone or null if not found
  116457. */
  116458. getBoneByName(name: string): Nullable<Bone>;
  116459. /**
  116460. * Gets a light node using its name
  116461. * @param name defines the the light's name
  116462. * @return the light or null if none found.
  116463. */
  116464. getLightByName(name: string): Nullable<Light>;
  116465. /**
  116466. * Gets a light node using its id
  116467. * @param id defines the light's id
  116468. * @return the light or null if none found.
  116469. */
  116470. getLightByID(id: string): Nullable<Light>;
  116471. /**
  116472. * Gets a light node using its scene-generated unique ID
  116473. * @param uniqueId defines the light's unique id
  116474. * @return the light or null if none found.
  116475. */
  116476. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  116477. /**
  116478. * Gets a particle system by id
  116479. * @param id defines the particle system id
  116480. * @return the corresponding system or null if none found
  116481. */
  116482. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  116483. /**
  116484. * Gets a geometry using its ID
  116485. * @param id defines the geometry's id
  116486. * @return the geometry or null if none found.
  116487. */
  116488. getGeometryByID(id: string): Nullable<Geometry>;
  116489. private _getGeometryByUniqueID;
  116490. /**
  116491. * Add a new geometry to this scene
  116492. * @param geometry defines the geometry to be added to the scene.
  116493. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  116494. * @return a boolean defining if the geometry was added or not
  116495. */
  116496. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  116497. /**
  116498. * Removes an existing geometry
  116499. * @param geometry defines the geometry to be removed from the scene
  116500. * @return a boolean defining if the geometry was removed or not
  116501. */
  116502. removeGeometry(geometry: Geometry): boolean;
  116503. /**
  116504. * Gets the list of geometries attached to the scene
  116505. * @returns an array of Geometry
  116506. */
  116507. getGeometries(): Geometry[];
  116508. /**
  116509. * Gets the first added mesh found of a given ID
  116510. * @param id defines the id to search for
  116511. * @return the mesh found or null if not found at all
  116512. */
  116513. getMeshByID(id: string): Nullable<AbstractMesh>;
  116514. /**
  116515. * Gets a list of meshes using their id
  116516. * @param id defines the id to search for
  116517. * @returns a list of meshes
  116518. */
  116519. getMeshesByID(id: string): Array<AbstractMesh>;
  116520. /**
  116521. * Gets the first added transform node found of a given ID
  116522. * @param id defines the id to search for
  116523. * @return the found transform node or null if not found at all.
  116524. */
  116525. getTransformNodeByID(id: string): Nullable<TransformNode>;
  116526. /**
  116527. * Gets a transform node with its auto-generated unique id
  116528. * @param uniqueId efines the unique id to search for
  116529. * @return the found transform node or null if not found at all.
  116530. */
  116531. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  116532. /**
  116533. * Gets a list of transform nodes using their id
  116534. * @param id defines the id to search for
  116535. * @returns a list of transform nodes
  116536. */
  116537. getTransformNodesByID(id: string): Array<TransformNode>;
  116538. /**
  116539. * Gets a mesh with its auto-generated unique id
  116540. * @param uniqueId defines the unique id to search for
  116541. * @return the found mesh or null if not found at all.
  116542. */
  116543. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  116544. /**
  116545. * Gets a the last added mesh using a given id
  116546. * @param id defines the id to search for
  116547. * @return the found mesh or null if not found at all.
  116548. */
  116549. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  116550. /**
  116551. * Gets a the last added node (Mesh, Camera, Light) using a given id
  116552. * @param id defines the id to search for
  116553. * @return the found node or null if not found at all
  116554. */
  116555. getLastEntryByID(id: string): Nullable<Node>;
  116556. /**
  116557. * Gets a node (Mesh, Camera, Light) using a given id
  116558. * @param id defines the id to search for
  116559. * @return the found node or null if not found at all
  116560. */
  116561. getNodeByID(id: string): Nullable<Node>;
  116562. /**
  116563. * Gets a node (Mesh, Camera, Light) using a given name
  116564. * @param name defines the name to search for
  116565. * @return the found node or null if not found at all.
  116566. */
  116567. getNodeByName(name: string): Nullable<Node>;
  116568. /**
  116569. * Gets a mesh using a given name
  116570. * @param name defines the name to search for
  116571. * @return the found mesh or null if not found at all.
  116572. */
  116573. getMeshByName(name: string): Nullable<AbstractMesh>;
  116574. /**
  116575. * Gets a transform node using a given name
  116576. * @param name defines the name to search for
  116577. * @return the found transform node or null if not found at all.
  116578. */
  116579. getTransformNodeByName(name: string): Nullable<TransformNode>;
  116580. /**
  116581. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  116582. * @param id defines the id to search for
  116583. * @return the found skeleton or null if not found at all.
  116584. */
  116585. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  116586. /**
  116587. * Gets a skeleton using a given auto generated unique id
  116588. * @param uniqueId defines the unique id to search for
  116589. * @return the found skeleton or null if not found at all.
  116590. */
  116591. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  116592. /**
  116593. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  116594. * @param id defines the id to search for
  116595. * @return the found skeleton or null if not found at all.
  116596. */
  116597. getSkeletonById(id: string): Nullable<Skeleton>;
  116598. /**
  116599. * Gets a skeleton using a given name
  116600. * @param name defines the name to search for
  116601. * @return the found skeleton or null if not found at all.
  116602. */
  116603. getSkeletonByName(name: string): Nullable<Skeleton>;
  116604. /**
  116605. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  116606. * @param id defines the id to search for
  116607. * @return the found morph target manager or null if not found at all.
  116608. */
  116609. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  116610. /**
  116611. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  116612. * @param id defines the id to search for
  116613. * @return the found morph target or null if not found at all.
  116614. */
  116615. getMorphTargetById(id: string): Nullable<MorphTarget>;
  116616. /**
  116617. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  116618. * @param name defines the name to search for
  116619. * @return the found morph target or null if not found at all.
  116620. */
  116621. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  116622. /**
  116623. * Gets a boolean indicating if the given mesh is active
  116624. * @param mesh defines the mesh to look for
  116625. * @returns true if the mesh is in the active list
  116626. */
  116627. isActiveMesh(mesh: AbstractMesh): boolean;
  116628. /**
  116629. * Return a unique id as a string which can serve as an identifier for the scene
  116630. */
  116631. get uid(): string;
  116632. /**
  116633. * Add an externaly attached data from its key.
  116634. * This method call will fail and return false, if such key already exists.
  116635. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  116636. * @param key the unique key that identifies the data
  116637. * @param data the data object to associate to the key for this Engine instance
  116638. * @return true if no such key were already present and the data was added successfully, false otherwise
  116639. */
  116640. addExternalData<T>(key: string, data: T): boolean;
  116641. /**
  116642. * Get an externaly attached data from its key
  116643. * @param key the unique key that identifies the data
  116644. * @return the associated data, if present (can be null), or undefined if not present
  116645. */
  116646. getExternalData<T>(key: string): Nullable<T>;
  116647. /**
  116648. * Get an externaly attached data from its key, create it using a factory if it's not already present
  116649. * @param key the unique key that identifies the data
  116650. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  116651. * @return the associated data, can be null if the factory returned null.
  116652. */
  116653. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  116654. /**
  116655. * Remove an externaly attached data from the Engine instance
  116656. * @param key the unique key that identifies the data
  116657. * @return true if the data was successfully removed, false if it doesn't exist
  116658. */
  116659. removeExternalData(key: string): boolean;
  116660. private _evaluateSubMesh;
  116661. /**
  116662. * Clear the processed materials smart array preventing retention point in material dispose.
  116663. */
  116664. freeProcessedMaterials(): void;
  116665. private _preventFreeActiveMeshesAndRenderingGroups;
  116666. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  116667. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  116668. * when disposing several meshes in a row or a hierarchy of meshes.
  116669. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  116670. */
  116671. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  116672. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  116673. /**
  116674. * Clear the active meshes smart array preventing retention point in mesh dispose.
  116675. */
  116676. freeActiveMeshes(): void;
  116677. /**
  116678. * Clear the info related to rendering groups preventing retention points during dispose.
  116679. */
  116680. freeRenderingGroups(): void;
  116681. /** @hidden */
  116682. _isInIntermediateRendering(): boolean;
  116683. /**
  116684. * Lambda returning the list of potentially active meshes.
  116685. */
  116686. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  116687. /**
  116688. * Lambda returning the list of potentially active sub meshes.
  116689. */
  116690. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  116691. /**
  116692. * Lambda returning the list of potentially intersecting sub meshes.
  116693. */
  116694. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  116695. /**
  116696. * Lambda returning the list of potentially colliding sub meshes.
  116697. */
  116698. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  116699. private _activeMeshesFrozen;
  116700. private _skipEvaluateActiveMeshesCompletely;
  116701. /**
  116702. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  116703. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  116704. * @returns the current scene
  116705. */
  116706. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  116707. /**
  116708. * Use this function to restart evaluating active meshes on every frame
  116709. * @returns the current scene
  116710. */
  116711. unfreezeActiveMeshes(): Scene;
  116712. private _evaluateActiveMeshes;
  116713. private _activeMesh;
  116714. /**
  116715. * Update the transform matrix to update from the current active camera
  116716. * @param force defines a boolean used to force the update even if cache is up to date
  116717. */
  116718. updateTransformMatrix(force?: boolean): void;
  116719. private _bindFrameBuffer;
  116720. /** @hidden */
  116721. _allowPostProcessClearColor: boolean;
  116722. /** @hidden */
  116723. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  116724. private _processSubCameras;
  116725. private _checkIntersections;
  116726. /** @hidden */
  116727. _advancePhysicsEngineStep(step: number): void;
  116728. /**
  116729. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  116730. */
  116731. getDeterministicFrameTime: () => number;
  116732. /** @hidden */
  116733. _animate(): void;
  116734. /** Execute all animations (for a frame) */
  116735. animate(): void;
  116736. /**
  116737. * Render the scene
  116738. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  116739. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  116740. */
  116741. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  116742. /**
  116743. * Freeze all materials
  116744. * A frozen material will not be updatable but should be faster to render
  116745. */
  116746. freezeMaterials(): void;
  116747. /**
  116748. * Unfreeze all materials
  116749. * A frozen material will not be updatable but should be faster to render
  116750. */
  116751. unfreezeMaterials(): void;
  116752. /**
  116753. * Releases all held ressources
  116754. */
  116755. dispose(): void;
  116756. /**
  116757. * Gets if the scene is already disposed
  116758. */
  116759. get isDisposed(): boolean;
  116760. /**
  116761. * Call this function to reduce memory footprint of the scene.
  116762. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  116763. */
  116764. clearCachedVertexData(): void;
  116765. /**
  116766. * This function will remove the local cached buffer data from texture.
  116767. * It will save memory but will prevent the texture from being rebuilt
  116768. */
  116769. cleanCachedTextureBuffer(): void;
  116770. /**
  116771. * Get the world extend vectors with an optional filter
  116772. *
  116773. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  116774. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  116775. */
  116776. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  116777. min: Vector3;
  116778. max: Vector3;
  116779. };
  116780. /**
  116781. * Creates a ray that can be used to pick in the scene
  116782. * @param x defines the x coordinate of the origin (on-screen)
  116783. * @param y defines the y coordinate of the origin (on-screen)
  116784. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  116785. * @param camera defines the camera to use for the picking
  116786. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  116787. * @returns a Ray
  116788. */
  116789. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  116790. /**
  116791. * Creates a ray that can be used to pick in the scene
  116792. * @param x defines the x coordinate of the origin (on-screen)
  116793. * @param y defines the y coordinate of the origin (on-screen)
  116794. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  116795. * @param result defines the ray where to store the picking ray
  116796. * @param camera defines the camera to use for the picking
  116797. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  116798. * @returns the current scene
  116799. */
  116800. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  116801. /**
  116802. * Creates a ray that can be used to pick in the scene
  116803. * @param x defines the x coordinate of the origin (on-screen)
  116804. * @param y defines the y coordinate of the origin (on-screen)
  116805. * @param camera defines the camera to use for the picking
  116806. * @returns a Ray
  116807. */
  116808. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  116809. /**
  116810. * Creates a ray that can be used to pick in the scene
  116811. * @param x defines the x coordinate of the origin (on-screen)
  116812. * @param y defines the y coordinate of the origin (on-screen)
  116813. * @param result defines the ray where to store the picking ray
  116814. * @param camera defines the camera to use for the picking
  116815. * @returns the current scene
  116816. */
  116817. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  116818. /** Launch a ray to try to pick a mesh in the scene
  116819. * @param x position on screen
  116820. * @param y position on screen
  116821. * @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
  116822. * @param fastCheck defines if the first intersection will be used (and not the closest)
  116823. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  116824. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  116825. * @returns a PickingInfo
  116826. */
  116827. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  116828. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  116829. * @param x position on screen
  116830. * @param y position on screen
  116831. * @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
  116832. * @param fastCheck defines if the first intersection will be used (and not the closest)
  116833. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  116834. * @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)
  116835. */
  116836. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  116837. /** Use the given ray to pick a mesh in the scene
  116838. * @param ray The ray to use to pick meshes
  116839. * @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
  116840. * @param fastCheck defines if the first intersection will be used (and not the closest)
  116841. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  116842. * @returns a PickingInfo
  116843. */
  116844. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  116845. /**
  116846. * Launch a ray to try to pick a mesh in the scene
  116847. * @param x X position on screen
  116848. * @param y Y position on screen
  116849. * @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
  116850. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  116851. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  116852. * @returns an array of PickingInfo
  116853. */
  116854. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  116855. /**
  116856. * Launch a ray to try to pick a mesh in the scene
  116857. * @param ray Ray to use
  116858. * @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
  116859. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  116860. * @returns an array of PickingInfo
  116861. */
  116862. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  116863. /**
  116864. * Force the value of meshUnderPointer
  116865. * @param mesh defines the mesh to use
  116866. */
  116867. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  116868. /**
  116869. * Gets the mesh under the pointer
  116870. * @returns a Mesh or null if no mesh is under the pointer
  116871. */
  116872. getPointerOverMesh(): Nullable<AbstractMesh>;
  116873. /** @hidden */
  116874. _rebuildGeometries(): void;
  116875. /** @hidden */
  116876. _rebuildTextures(): void;
  116877. private _getByTags;
  116878. /**
  116879. * Get a list of meshes by tags
  116880. * @param tagsQuery defines the tags query to use
  116881. * @param forEach defines a predicate used to filter results
  116882. * @returns an array of Mesh
  116883. */
  116884. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  116885. /**
  116886. * Get a list of cameras by tags
  116887. * @param tagsQuery defines the tags query to use
  116888. * @param forEach defines a predicate used to filter results
  116889. * @returns an array of Camera
  116890. */
  116891. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  116892. /**
  116893. * Get a list of lights by tags
  116894. * @param tagsQuery defines the tags query to use
  116895. * @param forEach defines a predicate used to filter results
  116896. * @returns an array of Light
  116897. */
  116898. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  116899. /**
  116900. * Get a list of materials by tags
  116901. * @param tagsQuery defines the tags query to use
  116902. * @param forEach defines a predicate used to filter results
  116903. * @returns an array of Material
  116904. */
  116905. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  116906. /**
  116907. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  116908. * This allowed control for front to back rendering or reversly depending of the special needs.
  116909. *
  116910. * @param renderingGroupId The rendering group id corresponding to its index
  116911. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  116912. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  116913. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  116914. */
  116915. 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;
  116916. /**
  116917. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  116918. *
  116919. * @param renderingGroupId The rendering group id corresponding to its index
  116920. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  116921. * @param depth Automatically clears depth between groups if true and autoClear is true.
  116922. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  116923. */
  116924. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  116925. /**
  116926. * Gets the current auto clear configuration for one rendering group of the rendering
  116927. * manager.
  116928. * @param index the rendering group index to get the information for
  116929. * @returns The auto clear setup for the requested rendering group
  116930. */
  116931. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  116932. private _blockMaterialDirtyMechanism;
  116933. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  116934. get blockMaterialDirtyMechanism(): boolean;
  116935. set blockMaterialDirtyMechanism(value: boolean);
  116936. /**
  116937. * Will flag all materials as dirty to trigger new shader compilation
  116938. * @param flag defines the flag used to specify which material part must be marked as dirty
  116939. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  116940. */
  116941. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  116942. /** @hidden */
  116943. _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;
  116944. /** @hidden */
  116945. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  116946. /** @hidden */
  116947. _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;
  116948. /** @hidden */
  116949. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  116950. /** @hidden */
  116951. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  116952. /** @hidden */
  116953. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  116954. }
  116955. }
  116956. declare module BABYLON {
  116957. /**
  116958. * Set of assets to keep when moving a scene into an asset container.
  116959. */
  116960. export class KeepAssets extends AbstractScene {
  116961. }
  116962. /**
  116963. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  116964. */
  116965. export class InstantiatedEntries {
  116966. /**
  116967. * List of new root nodes (eg. nodes with no parent)
  116968. */
  116969. rootNodes: TransformNode[];
  116970. /**
  116971. * List of new skeletons
  116972. */
  116973. skeletons: Skeleton[];
  116974. /**
  116975. * List of new animation groups
  116976. */
  116977. animationGroups: AnimationGroup[];
  116978. }
  116979. /**
  116980. * Container with a set of assets that can be added or removed from a scene.
  116981. */
  116982. export class AssetContainer extends AbstractScene {
  116983. private _wasAddedToScene;
  116984. /**
  116985. * The scene the AssetContainer belongs to.
  116986. */
  116987. scene: Scene;
  116988. /**
  116989. * Instantiates an AssetContainer.
  116990. * @param scene The scene the AssetContainer belongs to.
  116991. */
  116992. constructor(scene: Scene);
  116993. /**
  116994. * Instantiate or clone all meshes and add the new ones to the scene.
  116995. * Skeletons and animation groups will all be cloned
  116996. * @param nameFunction defines an optional function used to get new names for clones
  116997. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  116998. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  116999. */
  117000. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  117001. /**
  117002. * Adds all the assets from the container to the scene.
  117003. */
  117004. addAllToScene(): void;
  117005. /**
  117006. * Removes all the assets in the container from the scene
  117007. */
  117008. removeAllFromScene(): void;
  117009. /**
  117010. * Disposes all the assets in the container
  117011. */
  117012. dispose(): void;
  117013. private _moveAssets;
  117014. /**
  117015. * Removes all the assets contained in the scene and adds them to the container.
  117016. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  117017. */
  117018. moveAllFromScene(keepAssets?: KeepAssets): void;
  117019. /**
  117020. * 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.
  117021. * @returns the root mesh
  117022. */
  117023. createRootMesh(): Mesh;
  117024. /**
  117025. * Merge animations (direct and animation groups) from this asset container into a scene
  117026. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  117027. * @param animatables set of animatables to retarget to a node from the scene
  117028. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  117029. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  117030. */
  117031. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  117032. }
  117033. }
  117034. declare module BABYLON {
  117035. /**
  117036. * Defines how the parser contract is defined.
  117037. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  117038. */
  117039. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  117040. /**
  117041. * Defines how the individual parser contract is defined.
  117042. * These parser can parse an individual asset
  117043. */
  117044. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  117045. /**
  117046. * Base class of the scene acting as a container for the different elements composing a scene.
  117047. * This class is dynamically extended by the different components of the scene increasing
  117048. * flexibility and reducing coupling
  117049. */
  117050. export abstract class AbstractScene {
  117051. /**
  117052. * Stores the list of available parsers in the application.
  117053. */
  117054. private static _BabylonFileParsers;
  117055. /**
  117056. * Stores the list of available individual parsers in the application.
  117057. */
  117058. private static _IndividualBabylonFileParsers;
  117059. /**
  117060. * Adds a parser in the list of available ones
  117061. * @param name Defines the name of the parser
  117062. * @param parser Defines the parser to add
  117063. */
  117064. static AddParser(name: string, parser: BabylonFileParser): void;
  117065. /**
  117066. * Gets a general parser from the list of avaialble ones
  117067. * @param name Defines the name of the parser
  117068. * @returns the requested parser or null
  117069. */
  117070. static GetParser(name: string): Nullable<BabylonFileParser>;
  117071. /**
  117072. * Adds n individual parser in the list of available ones
  117073. * @param name Defines the name of the parser
  117074. * @param parser Defines the parser to add
  117075. */
  117076. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  117077. /**
  117078. * Gets an individual parser from the list of avaialble ones
  117079. * @param name Defines the name of the parser
  117080. * @returns the requested parser or null
  117081. */
  117082. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  117083. /**
  117084. * Parser json data and populate both a scene and its associated container object
  117085. * @param jsonData Defines the data to parse
  117086. * @param scene Defines the scene to parse the data for
  117087. * @param container Defines the container attached to the parsing sequence
  117088. * @param rootUrl Defines the root url of the data
  117089. */
  117090. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  117091. /**
  117092. * Gets the list of root nodes (ie. nodes with no parent)
  117093. */
  117094. rootNodes: Node[];
  117095. /** All of the cameras added to this scene
  117096. * @see http://doc.babylonjs.com/babylon101/cameras
  117097. */
  117098. cameras: Camera[];
  117099. /**
  117100. * All of the lights added to this scene
  117101. * @see http://doc.babylonjs.com/babylon101/lights
  117102. */
  117103. lights: Light[];
  117104. /**
  117105. * All of the (abstract) meshes added to this scene
  117106. */
  117107. meshes: AbstractMesh[];
  117108. /**
  117109. * The list of skeletons added to the scene
  117110. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  117111. */
  117112. skeletons: Skeleton[];
  117113. /**
  117114. * All of the particle systems added to this scene
  117115. * @see http://doc.babylonjs.com/babylon101/particles
  117116. */
  117117. particleSystems: IParticleSystem[];
  117118. /**
  117119. * Gets a list of Animations associated with the scene
  117120. */
  117121. animations: Animation[];
  117122. /**
  117123. * All of the animation groups added to this scene
  117124. * @see http://doc.babylonjs.com/how_to/group
  117125. */
  117126. animationGroups: AnimationGroup[];
  117127. /**
  117128. * All of the multi-materials added to this scene
  117129. * @see http://doc.babylonjs.com/how_to/multi_materials
  117130. */
  117131. multiMaterials: MultiMaterial[];
  117132. /**
  117133. * All of the materials added to this scene
  117134. * In the context of a Scene, it is not supposed to be modified manually.
  117135. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  117136. * Note also that the order of the Material within the array is not significant and might change.
  117137. * @see http://doc.babylonjs.com/babylon101/materials
  117138. */
  117139. materials: Material[];
  117140. /**
  117141. * The list of morph target managers added to the scene
  117142. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  117143. */
  117144. morphTargetManagers: MorphTargetManager[];
  117145. /**
  117146. * The list of geometries used in the scene.
  117147. */
  117148. geometries: Geometry[];
  117149. /**
  117150. * All of the tranform nodes added to this scene
  117151. * In the context of a Scene, it is not supposed to be modified manually.
  117152. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  117153. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  117154. * @see http://doc.babylonjs.com/how_to/transformnode
  117155. */
  117156. transformNodes: TransformNode[];
  117157. /**
  117158. * ActionManagers available on the scene.
  117159. */
  117160. actionManagers: AbstractActionManager[];
  117161. /**
  117162. * Textures to keep.
  117163. */
  117164. textures: BaseTexture[];
  117165. /**
  117166. * Environment texture for the scene
  117167. */
  117168. environmentTexture: Nullable<BaseTexture>;
  117169. /**
  117170. * @returns all meshes, lights, cameras, transformNodes and bones
  117171. */
  117172. getNodes(): Array<Node>;
  117173. }
  117174. }
  117175. declare module BABYLON {
  117176. /**
  117177. * Interface used to define options for Sound class
  117178. */
  117179. export interface ISoundOptions {
  117180. /**
  117181. * Does the sound autoplay once loaded.
  117182. */
  117183. autoplay?: boolean;
  117184. /**
  117185. * Does the sound loop after it finishes playing once.
  117186. */
  117187. loop?: boolean;
  117188. /**
  117189. * Sound's volume
  117190. */
  117191. volume?: number;
  117192. /**
  117193. * Is it a spatial sound?
  117194. */
  117195. spatialSound?: boolean;
  117196. /**
  117197. * Maximum distance to hear that sound
  117198. */
  117199. maxDistance?: number;
  117200. /**
  117201. * Uses user defined attenuation function
  117202. */
  117203. useCustomAttenuation?: boolean;
  117204. /**
  117205. * Define the roll off factor of spatial sounds.
  117206. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  117207. */
  117208. rolloffFactor?: number;
  117209. /**
  117210. * Define the reference distance the sound should be heard perfectly.
  117211. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  117212. */
  117213. refDistance?: number;
  117214. /**
  117215. * Define the distance attenuation model the sound will follow.
  117216. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  117217. */
  117218. distanceModel?: string;
  117219. /**
  117220. * Defines the playback speed (1 by default)
  117221. */
  117222. playbackRate?: number;
  117223. /**
  117224. * Defines if the sound is from a streaming source
  117225. */
  117226. streaming?: boolean;
  117227. /**
  117228. * Defines an optional length (in seconds) inside the sound file
  117229. */
  117230. length?: number;
  117231. /**
  117232. * Defines an optional offset (in seconds) inside the sound file
  117233. */
  117234. offset?: number;
  117235. /**
  117236. * If true, URLs will not be required to state the audio file codec to use.
  117237. */
  117238. skipCodecCheck?: boolean;
  117239. }
  117240. /**
  117241. * Defines a sound that can be played in the application.
  117242. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  117243. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  117244. */
  117245. export class Sound {
  117246. /**
  117247. * The name of the sound in the scene.
  117248. */
  117249. name: string;
  117250. /**
  117251. * Does the sound autoplay once loaded.
  117252. */
  117253. autoplay: boolean;
  117254. /**
  117255. * Does the sound loop after it finishes playing once.
  117256. */
  117257. loop: boolean;
  117258. /**
  117259. * Does the sound use a custom attenuation curve to simulate the falloff
  117260. * happening when the source gets further away from the camera.
  117261. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  117262. */
  117263. useCustomAttenuation: boolean;
  117264. /**
  117265. * The sound track id this sound belongs to.
  117266. */
  117267. soundTrackId: number;
  117268. /**
  117269. * Is this sound currently played.
  117270. */
  117271. isPlaying: boolean;
  117272. /**
  117273. * Is this sound currently paused.
  117274. */
  117275. isPaused: boolean;
  117276. /**
  117277. * Does this sound enables spatial sound.
  117278. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  117279. */
  117280. spatialSound: boolean;
  117281. /**
  117282. * Define the reference distance the sound should be heard perfectly.
  117283. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  117284. */
  117285. refDistance: number;
  117286. /**
  117287. * Define the roll off factor of spatial sounds.
  117288. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  117289. */
  117290. rolloffFactor: number;
  117291. /**
  117292. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  117293. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  117294. */
  117295. maxDistance: number;
  117296. /**
  117297. * Define the distance attenuation model the sound will follow.
  117298. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  117299. */
  117300. distanceModel: string;
  117301. /**
  117302. * @hidden
  117303. * Back Compat
  117304. **/
  117305. onended: () => any;
  117306. /**
  117307. * Gets or sets an object used to store user defined information for the sound.
  117308. */
  117309. metadata: any;
  117310. /**
  117311. * Observable event when the current playing sound finishes.
  117312. */
  117313. onEndedObservable: Observable<Sound>;
  117314. private _panningModel;
  117315. private _playbackRate;
  117316. private _streaming;
  117317. private _startTime;
  117318. private _startOffset;
  117319. private _position;
  117320. /** @hidden */
  117321. _positionInEmitterSpace: boolean;
  117322. private _localDirection;
  117323. private _volume;
  117324. private _isReadyToPlay;
  117325. private _isDirectional;
  117326. private _readyToPlayCallback;
  117327. private _audioBuffer;
  117328. private _soundSource;
  117329. private _streamingSource;
  117330. private _soundPanner;
  117331. private _soundGain;
  117332. private _inputAudioNode;
  117333. private _outputAudioNode;
  117334. private _coneInnerAngle;
  117335. private _coneOuterAngle;
  117336. private _coneOuterGain;
  117337. private _scene;
  117338. private _connectedTransformNode;
  117339. private _customAttenuationFunction;
  117340. private _registerFunc;
  117341. private _isOutputConnected;
  117342. private _htmlAudioElement;
  117343. private _urlType;
  117344. private _length?;
  117345. private _offset?;
  117346. /** @hidden */
  117347. static _SceneComponentInitialization: (scene: Scene) => void;
  117348. /**
  117349. * Create a sound and attach it to a scene
  117350. * @param name Name of your sound
  117351. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  117352. * @param scene defines the scene the sound belongs to
  117353. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  117354. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  117355. */
  117356. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  117357. /**
  117358. * Release the sound and its associated resources
  117359. */
  117360. dispose(): void;
  117361. /**
  117362. * Gets if the sounds is ready to be played or not.
  117363. * @returns true if ready, otherwise false
  117364. */
  117365. isReady(): boolean;
  117366. private _soundLoaded;
  117367. /**
  117368. * Sets the data of the sound from an audiobuffer
  117369. * @param audioBuffer The audioBuffer containing the data
  117370. */
  117371. setAudioBuffer(audioBuffer: AudioBuffer): void;
  117372. /**
  117373. * Updates the current sounds options such as maxdistance, loop...
  117374. * @param options A JSON object containing values named as the object properties
  117375. */
  117376. updateOptions(options: ISoundOptions): void;
  117377. private _createSpatialParameters;
  117378. private _updateSpatialParameters;
  117379. /**
  117380. * Switch the panning model to HRTF:
  117381. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  117382. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  117383. */
  117384. switchPanningModelToHRTF(): void;
  117385. /**
  117386. * Switch the panning model to Equal Power:
  117387. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  117388. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  117389. */
  117390. switchPanningModelToEqualPower(): void;
  117391. private _switchPanningModel;
  117392. /**
  117393. * Connect this sound to a sound track audio node like gain...
  117394. * @param soundTrackAudioNode the sound track audio node to connect to
  117395. */
  117396. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  117397. /**
  117398. * Transform this sound into a directional source
  117399. * @param coneInnerAngle Size of the inner cone in degree
  117400. * @param coneOuterAngle Size of the outer cone in degree
  117401. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  117402. */
  117403. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  117404. /**
  117405. * Gets or sets the inner angle for the directional cone.
  117406. */
  117407. get directionalConeInnerAngle(): number;
  117408. /**
  117409. * Gets or sets the inner angle for the directional cone.
  117410. */
  117411. set directionalConeInnerAngle(value: number);
  117412. /**
  117413. * Gets or sets the outer angle for the directional cone.
  117414. */
  117415. get directionalConeOuterAngle(): number;
  117416. /**
  117417. * Gets or sets the outer angle for the directional cone.
  117418. */
  117419. set directionalConeOuterAngle(value: number);
  117420. /**
  117421. * Sets the position of the emitter if spatial sound is enabled
  117422. * @param newPosition Defines the new posisiton
  117423. */
  117424. setPosition(newPosition: Vector3): void;
  117425. /**
  117426. * Sets the local direction of the emitter if spatial sound is enabled
  117427. * @param newLocalDirection Defines the new local direction
  117428. */
  117429. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  117430. private _updateDirection;
  117431. /** @hidden */
  117432. updateDistanceFromListener(): void;
  117433. /**
  117434. * Sets a new custom attenuation function for the sound.
  117435. * @param callback Defines the function used for the attenuation
  117436. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  117437. */
  117438. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  117439. /**
  117440. * Play the sound
  117441. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  117442. * @param offset (optional) Start the sound at a specific time in seconds
  117443. * @param length (optional) Sound duration (in seconds)
  117444. */
  117445. play(time?: number, offset?: number, length?: number): void;
  117446. private _onended;
  117447. /**
  117448. * Stop the sound
  117449. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  117450. */
  117451. stop(time?: number): void;
  117452. /**
  117453. * Put the sound in pause
  117454. */
  117455. pause(): void;
  117456. /**
  117457. * Sets a dedicated volume for this sounds
  117458. * @param newVolume Define the new volume of the sound
  117459. * @param time Define time for gradual change to new volume
  117460. */
  117461. setVolume(newVolume: number, time?: number): void;
  117462. /**
  117463. * Set the sound play back rate
  117464. * @param newPlaybackRate Define the playback rate the sound should be played at
  117465. */
  117466. setPlaybackRate(newPlaybackRate: number): void;
  117467. /**
  117468. * Gets the volume of the sound.
  117469. * @returns the volume of the sound
  117470. */
  117471. getVolume(): number;
  117472. /**
  117473. * Attach the sound to a dedicated mesh
  117474. * @param transformNode The transform node to connect the sound with
  117475. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  117476. */
  117477. attachToMesh(transformNode: TransformNode): void;
  117478. /**
  117479. * Detach the sound from the previously attached mesh
  117480. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  117481. */
  117482. detachFromMesh(): void;
  117483. private _onRegisterAfterWorldMatrixUpdate;
  117484. /**
  117485. * Clone the current sound in the scene.
  117486. * @returns the new sound clone
  117487. */
  117488. clone(): Nullable<Sound>;
  117489. /**
  117490. * Gets the current underlying audio buffer containing the data
  117491. * @returns the audio buffer
  117492. */
  117493. getAudioBuffer(): Nullable<AudioBuffer>;
  117494. /**
  117495. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  117496. * @returns the source node
  117497. */
  117498. getSoundSource(): Nullable<AudioBufferSourceNode>;
  117499. /**
  117500. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  117501. * @returns the gain node
  117502. */
  117503. getSoundGain(): Nullable<GainNode>;
  117504. /**
  117505. * Serializes the Sound in a JSON representation
  117506. * @returns the JSON representation of the sound
  117507. */
  117508. serialize(): any;
  117509. /**
  117510. * Parse a JSON representation of a sound to innstantiate in a given scene
  117511. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  117512. * @param scene Define the scene the new parsed sound should be created in
  117513. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  117514. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  117515. * @returns the newly parsed sound
  117516. */
  117517. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  117518. }
  117519. }
  117520. declare module BABYLON {
  117521. /**
  117522. * This defines an action helpful to play a defined sound on a triggered action.
  117523. */
  117524. export class PlaySoundAction extends Action {
  117525. private _sound;
  117526. /**
  117527. * Instantiate the action
  117528. * @param triggerOptions defines the trigger options
  117529. * @param sound defines the sound to play
  117530. * @param condition defines the trigger related conditions
  117531. */
  117532. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  117533. /** @hidden */
  117534. _prepare(): void;
  117535. /**
  117536. * Execute the action and play the sound.
  117537. */
  117538. execute(): void;
  117539. /**
  117540. * Serializes the actions and its related information.
  117541. * @param parent defines the object to serialize in
  117542. * @returns the serialized object
  117543. */
  117544. serialize(parent: any): any;
  117545. }
  117546. /**
  117547. * This defines an action helpful to stop a defined sound on a triggered action.
  117548. */
  117549. export class StopSoundAction extends Action {
  117550. private _sound;
  117551. /**
  117552. * Instantiate the action
  117553. * @param triggerOptions defines the trigger options
  117554. * @param sound defines the sound to stop
  117555. * @param condition defines the trigger related conditions
  117556. */
  117557. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  117558. /** @hidden */
  117559. _prepare(): void;
  117560. /**
  117561. * Execute the action and stop the sound.
  117562. */
  117563. execute(): void;
  117564. /**
  117565. * Serializes the actions and its related information.
  117566. * @param parent defines the object to serialize in
  117567. * @returns the serialized object
  117568. */
  117569. serialize(parent: any): any;
  117570. }
  117571. }
  117572. declare module BABYLON {
  117573. /**
  117574. * This defines an action responsible to change the value of a property
  117575. * by interpolating between its current value and the newly set one once triggered.
  117576. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  117577. */
  117578. export class InterpolateValueAction extends Action {
  117579. /**
  117580. * Defines the path of the property where the value should be interpolated
  117581. */
  117582. propertyPath: string;
  117583. /**
  117584. * Defines the target value at the end of the interpolation.
  117585. */
  117586. value: any;
  117587. /**
  117588. * Defines the time it will take for the property to interpolate to the value.
  117589. */
  117590. duration: number;
  117591. /**
  117592. * Defines if the other scene animations should be stopped when the action has been triggered
  117593. */
  117594. stopOtherAnimations?: boolean;
  117595. /**
  117596. * Defines a callback raised once the interpolation animation has been done.
  117597. */
  117598. onInterpolationDone?: () => void;
  117599. /**
  117600. * Observable triggered once the interpolation animation has been done.
  117601. */
  117602. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  117603. private _target;
  117604. private _effectiveTarget;
  117605. private _property;
  117606. /**
  117607. * Instantiate the action
  117608. * @param triggerOptions defines the trigger options
  117609. * @param target defines the object containing the value to interpolate
  117610. * @param propertyPath defines the path to the property in the target object
  117611. * @param value defines the target value at the end of the interpolation
  117612. * @param duration deines the time it will take for the property to interpolate to the value.
  117613. * @param condition defines the trigger related conditions
  117614. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  117615. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  117616. */
  117617. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  117618. /** @hidden */
  117619. _prepare(): void;
  117620. /**
  117621. * Execute the action starts the value interpolation.
  117622. */
  117623. execute(): void;
  117624. /**
  117625. * Serializes the actions and its related information.
  117626. * @param parent defines the object to serialize in
  117627. * @returns the serialized object
  117628. */
  117629. serialize(parent: any): any;
  117630. }
  117631. }
  117632. declare module BABYLON {
  117633. /**
  117634. * Options allowed during the creation of a sound track.
  117635. */
  117636. export interface ISoundTrackOptions {
  117637. /**
  117638. * The volume the sound track should take during creation
  117639. */
  117640. volume?: number;
  117641. /**
  117642. * Define if the sound track is the main sound track of the scene
  117643. */
  117644. mainTrack?: boolean;
  117645. }
  117646. /**
  117647. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  117648. * It will be also used in a future release to apply effects on a specific track.
  117649. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  117650. */
  117651. export class SoundTrack {
  117652. /**
  117653. * The unique identifier of the sound track in the scene.
  117654. */
  117655. id: number;
  117656. /**
  117657. * The list of sounds included in the sound track.
  117658. */
  117659. soundCollection: Array<Sound>;
  117660. private _outputAudioNode;
  117661. private _scene;
  117662. private _connectedAnalyser;
  117663. private _options;
  117664. private _isInitialized;
  117665. /**
  117666. * Creates a new sound track.
  117667. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  117668. * @param scene Define the scene the sound track belongs to
  117669. * @param options
  117670. */
  117671. constructor(scene: Scene, options?: ISoundTrackOptions);
  117672. private _initializeSoundTrackAudioGraph;
  117673. /**
  117674. * Release the sound track and its associated resources
  117675. */
  117676. dispose(): void;
  117677. /**
  117678. * Adds a sound to this sound track
  117679. * @param sound define the cound to add
  117680. * @ignoreNaming
  117681. */
  117682. AddSound(sound: Sound): void;
  117683. /**
  117684. * Removes a sound to this sound track
  117685. * @param sound define the cound to remove
  117686. * @ignoreNaming
  117687. */
  117688. RemoveSound(sound: Sound): void;
  117689. /**
  117690. * Set a global volume for the full sound track.
  117691. * @param newVolume Define the new volume of the sound track
  117692. */
  117693. setVolume(newVolume: number): void;
  117694. /**
  117695. * Switch the panning model to HRTF:
  117696. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  117697. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  117698. */
  117699. switchPanningModelToHRTF(): void;
  117700. /**
  117701. * Switch the panning model to Equal Power:
  117702. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  117703. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  117704. */
  117705. switchPanningModelToEqualPower(): void;
  117706. /**
  117707. * Connect the sound track to an audio analyser allowing some amazing
  117708. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  117709. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  117710. * @param analyser The analyser to connect to the engine
  117711. */
  117712. connectToAnalyser(analyser: Analyser): void;
  117713. }
  117714. }
  117715. declare module BABYLON {
  117716. interface AbstractScene {
  117717. /**
  117718. * The list of sounds used in the scene.
  117719. */
  117720. sounds: Nullable<Array<Sound>>;
  117721. }
  117722. interface Scene {
  117723. /**
  117724. * @hidden
  117725. * Backing field
  117726. */
  117727. _mainSoundTrack: SoundTrack;
  117728. /**
  117729. * The main sound track played by the scene.
  117730. * It cotains your primary collection of sounds.
  117731. */
  117732. mainSoundTrack: SoundTrack;
  117733. /**
  117734. * The list of sound tracks added to the scene
  117735. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  117736. */
  117737. soundTracks: Nullable<Array<SoundTrack>>;
  117738. /**
  117739. * Gets a sound using a given name
  117740. * @param name defines the name to search for
  117741. * @return the found sound or null if not found at all.
  117742. */
  117743. getSoundByName(name: string): Nullable<Sound>;
  117744. /**
  117745. * Gets or sets if audio support is enabled
  117746. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  117747. */
  117748. audioEnabled: boolean;
  117749. /**
  117750. * Gets or sets if audio will be output to headphones
  117751. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  117752. */
  117753. headphone: boolean;
  117754. /**
  117755. * Gets or sets custom audio listener position provider
  117756. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  117757. */
  117758. audioListenerPositionProvider: Nullable<() => Vector3>;
  117759. /**
  117760. * Gets or sets a refresh rate when using 3D audio positioning
  117761. */
  117762. audioPositioningRefreshRate: number;
  117763. }
  117764. /**
  117765. * Defines the sound scene component responsible to manage any sounds
  117766. * in a given scene.
  117767. */
  117768. export class AudioSceneComponent implements ISceneSerializableComponent {
  117769. /**
  117770. * The component name helpfull to identify the component in the list of scene components.
  117771. */
  117772. readonly name: string;
  117773. /**
  117774. * The scene the component belongs to.
  117775. */
  117776. scene: Scene;
  117777. private _audioEnabled;
  117778. /**
  117779. * Gets whether audio is enabled or not.
  117780. * Please use related enable/disable method to switch state.
  117781. */
  117782. get audioEnabled(): boolean;
  117783. private _headphone;
  117784. /**
  117785. * Gets whether audio is outputing to headphone or not.
  117786. * Please use the according Switch methods to change output.
  117787. */
  117788. get headphone(): boolean;
  117789. /**
  117790. * Gets or sets a refresh rate when using 3D audio positioning
  117791. */
  117792. audioPositioningRefreshRate: number;
  117793. private _audioListenerPositionProvider;
  117794. /**
  117795. * Gets the current audio listener position provider
  117796. */
  117797. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  117798. /**
  117799. * Sets a custom listener position for all sounds in the scene
  117800. * By default, this is the position of the first active camera
  117801. */
  117802. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  117803. /**
  117804. * Creates a new instance of the component for the given scene
  117805. * @param scene Defines the scene to register the component in
  117806. */
  117807. constructor(scene: Scene);
  117808. /**
  117809. * Registers the component in a given scene
  117810. */
  117811. register(): void;
  117812. /**
  117813. * Rebuilds the elements related to this component in case of
  117814. * context lost for instance.
  117815. */
  117816. rebuild(): void;
  117817. /**
  117818. * Serializes the component data to the specified json object
  117819. * @param serializationObject The object to serialize to
  117820. */
  117821. serialize(serializationObject: any): void;
  117822. /**
  117823. * Adds all the elements from the container to the scene
  117824. * @param container the container holding the elements
  117825. */
  117826. addFromContainer(container: AbstractScene): void;
  117827. /**
  117828. * Removes all the elements in the container from the scene
  117829. * @param container contains the elements to remove
  117830. * @param dispose if the removed element should be disposed (default: false)
  117831. */
  117832. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  117833. /**
  117834. * Disposes the component and the associated ressources.
  117835. */
  117836. dispose(): void;
  117837. /**
  117838. * Disables audio in the associated scene.
  117839. */
  117840. disableAudio(): void;
  117841. /**
  117842. * Enables audio in the associated scene.
  117843. */
  117844. enableAudio(): void;
  117845. /**
  117846. * Switch audio to headphone output.
  117847. */
  117848. switchAudioModeForHeadphones(): void;
  117849. /**
  117850. * Switch audio to normal speakers.
  117851. */
  117852. switchAudioModeForNormalSpeakers(): void;
  117853. private _cachedCameraDirection;
  117854. private _cachedCameraPosition;
  117855. private _lastCheck;
  117856. private _afterRender;
  117857. }
  117858. }
  117859. declare module BABYLON {
  117860. /**
  117861. * Wraps one or more Sound objects and selects one with random weight for playback.
  117862. */
  117863. export class WeightedSound {
  117864. /** When true a Sound will be selected and played when the current playing Sound completes. */
  117865. loop: boolean;
  117866. private _coneInnerAngle;
  117867. private _coneOuterAngle;
  117868. private _volume;
  117869. /** A Sound is currently playing. */
  117870. isPlaying: boolean;
  117871. /** A Sound is currently paused. */
  117872. isPaused: boolean;
  117873. private _sounds;
  117874. private _weights;
  117875. private _currentIndex?;
  117876. /**
  117877. * Creates a new WeightedSound from the list of sounds given.
  117878. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  117879. * @param sounds Array of Sounds that will be selected from.
  117880. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  117881. */
  117882. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  117883. /**
  117884. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  117885. */
  117886. get directionalConeInnerAngle(): number;
  117887. /**
  117888. * The size of cone in degress for a directional sound in which there will be no attenuation.
  117889. */
  117890. set directionalConeInnerAngle(value: number);
  117891. /**
  117892. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  117893. * Listener angles between innerAngle and outerAngle will falloff linearly.
  117894. */
  117895. get directionalConeOuterAngle(): number;
  117896. /**
  117897. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  117898. * Listener angles between innerAngle and outerAngle will falloff linearly.
  117899. */
  117900. set directionalConeOuterAngle(value: number);
  117901. /**
  117902. * Playback volume.
  117903. */
  117904. get volume(): number;
  117905. /**
  117906. * Playback volume.
  117907. */
  117908. set volume(value: number);
  117909. private _onended;
  117910. /**
  117911. * Suspend playback
  117912. */
  117913. pause(): void;
  117914. /**
  117915. * Stop playback
  117916. */
  117917. stop(): void;
  117918. /**
  117919. * Start playback.
  117920. * @param startOffset Position the clip head at a specific time in seconds.
  117921. */
  117922. play(startOffset?: number): void;
  117923. }
  117924. }
  117925. declare module BABYLON {
  117926. /**
  117927. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  117928. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  117929. */
  117930. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  117931. /**
  117932. * Gets the name of the behavior.
  117933. */
  117934. get name(): string;
  117935. /**
  117936. * The easing function used by animations
  117937. */
  117938. static EasingFunction: BackEase;
  117939. /**
  117940. * The easing mode used by animations
  117941. */
  117942. static EasingMode: number;
  117943. /**
  117944. * The duration of the animation, in milliseconds
  117945. */
  117946. transitionDuration: number;
  117947. /**
  117948. * Length of the distance animated by the transition when lower radius is reached
  117949. */
  117950. lowerRadiusTransitionRange: number;
  117951. /**
  117952. * Length of the distance animated by the transition when upper radius is reached
  117953. */
  117954. upperRadiusTransitionRange: number;
  117955. private _autoTransitionRange;
  117956. /**
  117957. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  117958. */
  117959. get autoTransitionRange(): boolean;
  117960. /**
  117961. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  117962. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  117963. */
  117964. set autoTransitionRange(value: boolean);
  117965. private _attachedCamera;
  117966. private _onAfterCheckInputsObserver;
  117967. private _onMeshTargetChangedObserver;
  117968. /**
  117969. * Initializes the behavior.
  117970. */
  117971. init(): void;
  117972. /**
  117973. * Attaches the behavior to its arc rotate camera.
  117974. * @param camera Defines the camera to attach the behavior to
  117975. */
  117976. attach(camera: ArcRotateCamera): void;
  117977. /**
  117978. * Detaches the behavior from its current arc rotate camera.
  117979. */
  117980. detach(): void;
  117981. private _radiusIsAnimating;
  117982. private _radiusBounceTransition;
  117983. private _animatables;
  117984. private _cachedWheelPrecision;
  117985. /**
  117986. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  117987. * @param radiusLimit The limit to check against.
  117988. * @return Bool to indicate if at limit.
  117989. */
  117990. private _isRadiusAtLimit;
  117991. /**
  117992. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  117993. * @param radiusDelta The delta by which to animate to. Can be negative.
  117994. */
  117995. private _applyBoundRadiusAnimation;
  117996. /**
  117997. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  117998. */
  117999. protected _clearAnimationLocks(): void;
  118000. /**
  118001. * Stops and removes all animations that have been applied to the camera
  118002. */
  118003. stopAllAnimations(): void;
  118004. }
  118005. }
  118006. declare module BABYLON {
  118007. /**
  118008. * 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.
  118009. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  118010. */
  118011. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  118012. /**
  118013. * Gets the name of the behavior.
  118014. */
  118015. get name(): string;
  118016. private _mode;
  118017. private _radiusScale;
  118018. private _positionScale;
  118019. private _defaultElevation;
  118020. private _elevationReturnTime;
  118021. private _elevationReturnWaitTime;
  118022. private _zoomStopsAnimation;
  118023. private _framingTime;
  118024. /**
  118025. * The easing function used by animations
  118026. */
  118027. static EasingFunction: ExponentialEase;
  118028. /**
  118029. * The easing mode used by animations
  118030. */
  118031. static EasingMode: number;
  118032. /**
  118033. * Sets the current mode used by the behavior
  118034. */
  118035. set mode(mode: number);
  118036. /**
  118037. * Gets current mode used by the behavior.
  118038. */
  118039. get mode(): number;
  118040. /**
  118041. * Sets the scale applied to the radius (1 by default)
  118042. */
  118043. set radiusScale(radius: number);
  118044. /**
  118045. * Gets the scale applied to the radius
  118046. */
  118047. get radiusScale(): number;
  118048. /**
  118049. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  118050. */
  118051. set positionScale(scale: number);
  118052. /**
  118053. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  118054. */
  118055. get positionScale(): number;
  118056. /**
  118057. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  118058. * behaviour is triggered, in radians.
  118059. */
  118060. set defaultElevation(elevation: number);
  118061. /**
  118062. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  118063. * behaviour is triggered, in radians.
  118064. */
  118065. get defaultElevation(): number;
  118066. /**
  118067. * Sets the time (in milliseconds) taken to return to the default beta position.
  118068. * Negative value indicates camera should not return to default.
  118069. */
  118070. set elevationReturnTime(speed: number);
  118071. /**
  118072. * Gets the time (in milliseconds) taken to return to the default beta position.
  118073. * Negative value indicates camera should not return to default.
  118074. */
  118075. get elevationReturnTime(): number;
  118076. /**
  118077. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  118078. */
  118079. set elevationReturnWaitTime(time: number);
  118080. /**
  118081. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  118082. */
  118083. get elevationReturnWaitTime(): number;
  118084. /**
  118085. * Sets the flag that indicates if user zooming should stop animation.
  118086. */
  118087. set zoomStopsAnimation(flag: boolean);
  118088. /**
  118089. * Gets the flag that indicates if user zooming should stop animation.
  118090. */
  118091. get zoomStopsAnimation(): boolean;
  118092. /**
  118093. * Sets the transition time when framing the mesh, in milliseconds
  118094. */
  118095. set framingTime(time: number);
  118096. /**
  118097. * Gets the transition time when framing the mesh, in milliseconds
  118098. */
  118099. get framingTime(): number;
  118100. /**
  118101. * Define if the behavior should automatically change the configured
  118102. * camera limits and sensibilities.
  118103. */
  118104. autoCorrectCameraLimitsAndSensibility: boolean;
  118105. private _onPrePointerObservableObserver;
  118106. private _onAfterCheckInputsObserver;
  118107. private _onMeshTargetChangedObserver;
  118108. private _attachedCamera;
  118109. private _isPointerDown;
  118110. private _lastInteractionTime;
  118111. /**
  118112. * Initializes the behavior.
  118113. */
  118114. init(): void;
  118115. /**
  118116. * Attaches the behavior to its arc rotate camera.
  118117. * @param camera Defines the camera to attach the behavior to
  118118. */
  118119. attach(camera: ArcRotateCamera): void;
  118120. /**
  118121. * Detaches the behavior from its current arc rotate camera.
  118122. */
  118123. detach(): void;
  118124. private _animatables;
  118125. private _betaIsAnimating;
  118126. private _betaTransition;
  118127. private _radiusTransition;
  118128. private _vectorTransition;
  118129. /**
  118130. * Targets the given mesh and updates zoom level accordingly.
  118131. * @param mesh The mesh to target.
  118132. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  118133. * @param onAnimationEnd Callback triggered at the end of the framing animation
  118134. */
  118135. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  118136. /**
  118137. * Targets the given mesh with its children and updates zoom level accordingly.
  118138. * @param mesh The mesh to target.
  118139. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  118140. * @param onAnimationEnd Callback triggered at the end of the framing animation
  118141. */
  118142. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  118143. /**
  118144. * Targets the given meshes with their children and updates zoom level accordingly.
  118145. * @param meshes The mesh to target.
  118146. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  118147. * @param onAnimationEnd Callback triggered at the end of the framing animation
  118148. */
  118149. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  118150. /**
  118151. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  118152. * @param minimumWorld Determines the smaller position of the bounding box extend
  118153. * @param maximumWorld Determines the bigger position of the bounding box extend
  118154. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  118155. * @param onAnimationEnd Callback triggered at the end of the framing animation
  118156. */
  118157. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  118158. /**
  118159. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  118160. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  118161. * frustum width.
  118162. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  118163. * to fully enclose the mesh in the viewing frustum.
  118164. */
  118165. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  118166. /**
  118167. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  118168. * is automatically returned to its default position (expected to be above ground plane).
  118169. */
  118170. private _maintainCameraAboveGround;
  118171. /**
  118172. * Returns the frustum slope based on the canvas ratio and camera FOV
  118173. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  118174. */
  118175. private _getFrustumSlope;
  118176. /**
  118177. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  118178. */
  118179. private _clearAnimationLocks;
  118180. /**
  118181. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  118182. */
  118183. private _applyUserInteraction;
  118184. /**
  118185. * Stops and removes all animations that have been applied to the camera
  118186. */
  118187. stopAllAnimations(): void;
  118188. /**
  118189. * Gets a value indicating if the user is moving the camera
  118190. */
  118191. get isUserIsMoving(): boolean;
  118192. /**
  118193. * The camera can move all the way towards the mesh.
  118194. */
  118195. static IgnoreBoundsSizeMode: number;
  118196. /**
  118197. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  118198. */
  118199. static FitFrustumSidesMode: number;
  118200. }
  118201. }
  118202. declare module BABYLON {
  118203. /**
  118204. * Base class for Camera Pointer Inputs.
  118205. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  118206. * for example usage.
  118207. */
  118208. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  118209. /**
  118210. * Defines the camera the input is attached to.
  118211. */
  118212. abstract camera: Camera;
  118213. /**
  118214. * Whether keyboard modifier keys are pressed at time of last mouse event.
  118215. */
  118216. protected _altKey: boolean;
  118217. protected _ctrlKey: boolean;
  118218. protected _metaKey: boolean;
  118219. protected _shiftKey: boolean;
  118220. /**
  118221. * Which mouse buttons were pressed at time of last mouse event.
  118222. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  118223. */
  118224. protected _buttonsPressed: number;
  118225. /**
  118226. * Defines the buttons associated with the input to handle camera move.
  118227. */
  118228. buttons: number[];
  118229. /**
  118230. * Attach the input controls to a specific dom element to get the input from.
  118231. * @param element Defines the element the controls should be listened from
  118232. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  118233. */
  118234. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  118235. /**
  118236. * Detach the current controls from the specified dom element.
  118237. * @param element Defines the element to stop listening the inputs from
  118238. */
  118239. detachControl(element: Nullable<HTMLElement>): void;
  118240. /**
  118241. * Gets the class name of the current input.
  118242. * @returns the class name
  118243. */
  118244. getClassName(): string;
  118245. /**
  118246. * Get the friendly name associated with the input class.
  118247. * @returns the input friendly name
  118248. */
  118249. getSimpleName(): string;
  118250. /**
  118251. * Called on pointer POINTERDOUBLETAP event.
  118252. * Override this method to provide functionality on POINTERDOUBLETAP event.
  118253. */
  118254. protected onDoubleTap(type: string): void;
  118255. /**
  118256. * Called on pointer POINTERMOVE event if only a single touch is active.
  118257. * Override this method to provide functionality.
  118258. */
  118259. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  118260. /**
  118261. * Called on pointer POINTERMOVE event if multiple touches are active.
  118262. * Override this method to provide functionality.
  118263. */
  118264. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  118265. /**
  118266. * Called on JS contextmenu event.
  118267. * Override this method to provide functionality.
  118268. */
  118269. protected onContextMenu(evt: PointerEvent): void;
  118270. /**
  118271. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  118272. * press.
  118273. * Override this method to provide functionality.
  118274. */
  118275. protected onButtonDown(evt: PointerEvent): void;
  118276. /**
  118277. * Called each time a new POINTERUP event occurs. Ie, for each button
  118278. * release.
  118279. * Override this method to provide functionality.
  118280. */
  118281. protected onButtonUp(evt: PointerEvent): void;
  118282. /**
  118283. * Called when window becomes inactive.
  118284. * Override this method to provide functionality.
  118285. */
  118286. protected onLostFocus(): void;
  118287. private _pointerInput;
  118288. private _observer;
  118289. private _onLostFocus;
  118290. private pointA;
  118291. private pointB;
  118292. }
  118293. }
  118294. declare module BABYLON {
  118295. /**
  118296. * Manage the pointers inputs to control an arc rotate camera.
  118297. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  118298. */
  118299. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  118300. /**
  118301. * Defines the camera the input is attached to.
  118302. */
  118303. camera: ArcRotateCamera;
  118304. /**
  118305. * Gets the class name of the current input.
  118306. * @returns the class name
  118307. */
  118308. getClassName(): string;
  118309. /**
  118310. * Defines the buttons associated with the input to handle camera move.
  118311. */
  118312. buttons: number[];
  118313. /**
  118314. * Defines the pointer angular sensibility along the X axis or how fast is
  118315. * the camera rotating.
  118316. */
  118317. angularSensibilityX: number;
  118318. /**
  118319. * Defines the pointer angular sensibility along the Y axis or how fast is
  118320. * the camera rotating.
  118321. */
  118322. angularSensibilityY: number;
  118323. /**
  118324. * Defines the pointer pinch precision or how fast is the camera zooming.
  118325. */
  118326. pinchPrecision: number;
  118327. /**
  118328. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  118329. * from 0.
  118330. * It defines the percentage of current camera.radius to use as delta when
  118331. * pinch zoom is used.
  118332. */
  118333. pinchDeltaPercentage: number;
  118334. /**
  118335. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  118336. * that any object in the plane at the camera's target point will scale
  118337. * perfectly with finger motion.
  118338. * Overrides pinchDeltaPercentage and pinchPrecision.
  118339. */
  118340. useNaturalPinchZoom: boolean;
  118341. /**
  118342. * Defines the pointer panning sensibility or how fast is the camera moving.
  118343. */
  118344. panningSensibility: number;
  118345. /**
  118346. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  118347. */
  118348. multiTouchPanning: boolean;
  118349. /**
  118350. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  118351. * zoom (pinch) through multitouch.
  118352. */
  118353. multiTouchPanAndZoom: boolean;
  118354. /**
  118355. * Revers pinch action direction.
  118356. */
  118357. pinchInwards: boolean;
  118358. private _isPanClick;
  118359. private _twoFingerActivityCount;
  118360. private _isPinching;
  118361. /**
  118362. * Called on pointer POINTERMOVE event if only a single touch is active.
  118363. */
  118364. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  118365. /**
  118366. * Called on pointer POINTERDOUBLETAP event.
  118367. */
  118368. protected onDoubleTap(type: string): void;
  118369. /**
  118370. * Called on pointer POINTERMOVE event if multiple touches are active.
  118371. */
  118372. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  118373. /**
  118374. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  118375. * press.
  118376. */
  118377. protected onButtonDown(evt: PointerEvent): void;
  118378. /**
  118379. * Called each time a new POINTERUP event occurs. Ie, for each button
  118380. * release.
  118381. */
  118382. protected onButtonUp(evt: PointerEvent): void;
  118383. /**
  118384. * Called when window becomes inactive.
  118385. */
  118386. protected onLostFocus(): void;
  118387. }
  118388. }
  118389. declare module BABYLON {
  118390. /**
  118391. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  118392. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  118393. */
  118394. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  118395. /**
  118396. * Defines the camera the input is attached to.
  118397. */
  118398. camera: ArcRotateCamera;
  118399. /**
  118400. * Defines the list of key codes associated with the up action (increase alpha)
  118401. */
  118402. keysUp: number[];
  118403. /**
  118404. * Defines the list of key codes associated with the down action (decrease alpha)
  118405. */
  118406. keysDown: number[];
  118407. /**
  118408. * Defines the list of key codes associated with the left action (increase beta)
  118409. */
  118410. keysLeft: number[];
  118411. /**
  118412. * Defines the list of key codes associated with the right action (decrease beta)
  118413. */
  118414. keysRight: number[];
  118415. /**
  118416. * Defines the list of key codes associated with the reset action.
  118417. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  118418. */
  118419. keysReset: number[];
  118420. /**
  118421. * Defines the panning sensibility of the inputs.
  118422. * (How fast is the camera panning)
  118423. */
  118424. panningSensibility: number;
  118425. /**
  118426. * Defines the zooming sensibility of the inputs.
  118427. * (How fast is the camera zooming)
  118428. */
  118429. zoomingSensibility: number;
  118430. /**
  118431. * Defines whether maintaining the alt key down switch the movement mode from
  118432. * orientation to zoom.
  118433. */
  118434. useAltToZoom: boolean;
  118435. /**
  118436. * Rotation speed of the camera
  118437. */
  118438. angularSpeed: number;
  118439. private _keys;
  118440. private _ctrlPressed;
  118441. private _altPressed;
  118442. private _onCanvasBlurObserver;
  118443. private _onKeyboardObserver;
  118444. private _engine;
  118445. private _scene;
  118446. /**
  118447. * Attach the input controls to a specific dom element to get the input from.
  118448. * @param element Defines the element the controls should be listened from
  118449. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  118450. */
  118451. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  118452. /**
  118453. * Detach the current controls from the specified dom element.
  118454. * @param element Defines the element to stop listening the inputs from
  118455. */
  118456. detachControl(element: Nullable<HTMLElement>): void;
  118457. /**
  118458. * Update the current camera state depending on the inputs that have been used this frame.
  118459. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  118460. */
  118461. checkInputs(): void;
  118462. /**
  118463. * Gets the class name of the current intput.
  118464. * @returns the class name
  118465. */
  118466. getClassName(): string;
  118467. /**
  118468. * Get the friendly name associated with the input class.
  118469. * @returns the input friendly name
  118470. */
  118471. getSimpleName(): string;
  118472. }
  118473. }
  118474. declare module BABYLON {
  118475. /**
  118476. * Manage the mouse wheel inputs to control an arc rotate camera.
  118477. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  118478. */
  118479. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  118480. /**
  118481. * Defines the camera the input is attached to.
  118482. */
  118483. camera: ArcRotateCamera;
  118484. /**
  118485. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  118486. */
  118487. wheelPrecision: number;
  118488. /**
  118489. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  118490. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  118491. */
  118492. wheelDeltaPercentage: number;
  118493. private _wheel;
  118494. private _observer;
  118495. private computeDeltaFromMouseWheelLegacyEvent;
  118496. /**
  118497. * Attach the input controls to a specific dom element to get the input from.
  118498. * @param element Defines the element the controls should be listened from
  118499. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  118500. */
  118501. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  118502. /**
  118503. * Detach the current controls from the specified dom element.
  118504. * @param element Defines the element to stop listening the inputs from
  118505. */
  118506. detachControl(element: Nullable<HTMLElement>): void;
  118507. /**
  118508. * Gets the class name of the current intput.
  118509. * @returns the class name
  118510. */
  118511. getClassName(): string;
  118512. /**
  118513. * Get the friendly name associated with the input class.
  118514. * @returns the input friendly name
  118515. */
  118516. getSimpleName(): string;
  118517. }
  118518. }
  118519. declare module BABYLON {
  118520. /**
  118521. * Default Inputs manager for the ArcRotateCamera.
  118522. * It groups all the default supported inputs for ease of use.
  118523. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  118524. */
  118525. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  118526. /**
  118527. * Instantiates a new ArcRotateCameraInputsManager.
  118528. * @param camera Defines the camera the inputs belong to
  118529. */
  118530. constructor(camera: ArcRotateCamera);
  118531. /**
  118532. * Add mouse wheel input support to the input manager.
  118533. * @returns the current input manager
  118534. */
  118535. addMouseWheel(): ArcRotateCameraInputsManager;
  118536. /**
  118537. * Add pointers input support to the input manager.
  118538. * @returns the current input manager
  118539. */
  118540. addPointers(): ArcRotateCameraInputsManager;
  118541. /**
  118542. * Add keyboard input support to the input manager.
  118543. * @returns the current input manager
  118544. */
  118545. addKeyboard(): ArcRotateCameraInputsManager;
  118546. }
  118547. }
  118548. declare module BABYLON {
  118549. /**
  118550. * This represents an orbital type of camera.
  118551. *
  118552. * 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.
  118553. * 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.
  118554. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  118555. */
  118556. export class ArcRotateCamera extends TargetCamera {
  118557. /**
  118558. * Defines the rotation angle of the camera along the longitudinal axis.
  118559. */
  118560. alpha: number;
  118561. /**
  118562. * Defines the rotation angle of the camera along the latitudinal axis.
  118563. */
  118564. beta: number;
  118565. /**
  118566. * Defines the radius of the camera from it s target point.
  118567. */
  118568. radius: number;
  118569. protected _target: Vector3;
  118570. protected _targetHost: Nullable<AbstractMesh>;
  118571. /**
  118572. * Defines the target point of the camera.
  118573. * The camera looks towards it form the radius distance.
  118574. */
  118575. get target(): Vector3;
  118576. set target(value: Vector3);
  118577. /**
  118578. * Define the current local position of the camera in the scene
  118579. */
  118580. get position(): Vector3;
  118581. set position(newPosition: Vector3);
  118582. protected _upVector: Vector3;
  118583. protected _upToYMatrix: Matrix;
  118584. protected _YToUpMatrix: Matrix;
  118585. /**
  118586. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  118587. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  118588. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  118589. */
  118590. set upVector(vec: Vector3);
  118591. get upVector(): Vector3;
  118592. /**
  118593. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  118594. */
  118595. setMatUp(): void;
  118596. /**
  118597. * Current inertia value on the longitudinal axis.
  118598. * The bigger this number the longer it will take for the camera to stop.
  118599. */
  118600. inertialAlphaOffset: number;
  118601. /**
  118602. * Current inertia value on the latitudinal axis.
  118603. * The bigger this number the longer it will take for the camera to stop.
  118604. */
  118605. inertialBetaOffset: number;
  118606. /**
  118607. * Current inertia value on the radius axis.
  118608. * The bigger this number the longer it will take for the camera to stop.
  118609. */
  118610. inertialRadiusOffset: number;
  118611. /**
  118612. * Minimum allowed angle on the longitudinal axis.
  118613. * This can help limiting how the Camera is able to move in the scene.
  118614. */
  118615. lowerAlphaLimit: Nullable<number>;
  118616. /**
  118617. * Maximum allowed angle on the longitudinal axis.
  118618. * This can help limiting how the Camera is able to move in the scene.
  118619. */
  118620. upperAlphaLimit: Nullable<number>;
  118621. /**
  118622. * Minimum allowed angle on the latitudinal axis.
  118623. * This can help limiting how the Camera is able to move in the scene.
  118624. */
  118625. lowerBetaLimit: number;
  118626. /**
  118627. * Maximum allowed angle on the latitudinal axis.
  118628. * This can help limiting how the Camera is able to move in the scene.
  118629. */
  118630. upperBetaLimit: number;
  118631. /**
  118632. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  118633. * This can help limiting how the Camera is able to move in the scene.
  118634. */
  118635. lowerRadiusLimit: Nullable<number>;
  118636. /**
  118637. * Maximum allowed distance of the camera to the target (The camera can not get further).
  118638. * This can help limiting how the Camera is able to move in the scene.
  118639. */
  118640. upperRadiusLimit: Nullable<number>;
  118641. /**
  118642. * Defines the current inertia value used during panning of the camera along the X axis.
  118643. */
  118644. inertialPanningX: number;
  118645. /**
  118646. * Defines the current inertia value used during panning of the camera along the Y axis.
  118647. */
  118648. inertialPanningY: number;
  118649. /**
  118650. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  118651. * Basically if your fingers moves away from more than this distance you will be considered
  118652. * in pinch mode.
  118653. */
  118654. pinchToPanMaxDistance: number;
  118655. /**
  118656. * Defines the maximum distance the camera can pan.
  118657. * This could help keeping the cammera always in your scene.
  118658. */
  118659. panningDistanceLimit: Nullable<number>;
  118660. /**
  118661. * Defines the target of the camera before paning.
  118662. */
  118663. panningOriginTarget: Vector3;
  118664. /**
  118665. * Defines the value of the inertia used during panning.
  118666. * 0 would mean stop inertia and one would mean no decelleration at all.
  118667. */
  118668. panningInertia: number;
  118669. /**
  118670. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  118671. */
  118672. get angularSensibilityX(): number;
  118673. set angularSensibilityX(value: number);
  118674. /**
  118675. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  118676. */
  118677. get angularSensibilityY(): number;
  118678. set angularSensibilityY(value: number);
  118679. /**
  118680. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  118681. */
  118682. get pinchPrecision(): number;
  118683. set pinchPrecision(value: number);
  118684. /**
  118685. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  118686. * It will be used instead of pinchDeltaPrecision if different from 0.
  118687. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  118688. */
  118689. get pinchDeltaPercentage(): number;
  118690. set pinchDeltaPercentage(value: number);
  118691. /**
  118692. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  118693. * and pinch delta percentage.
  118694. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  118695. * that any object in the plane at the camera's target point will scale
  118696. * perfectly with finger motion.
  118697. */
  118698. get useNaturalPinchZoom(): boolean;
  118699. set useNaturalPinchZoom(value: boolean);
  118700. /**
  118701. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  118702. */
  118703. get panningSensibility(): number;
  118704. set panningSensibility(value: number);
  118705. /**
  118706. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  118707. */
  118708. get keysUp(): number[];
  118709. set keysUp(value: number[]);
  118710. /**
  118711. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  118712. */
  118713. get keysDown(): number[];
  118714. set keysDown(value: number[]);
  118715. /**
  118716. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  118717. */
  118718. get keysLeft(): number[];
  118719. set keysLeft(value: number[]);
  118720. /**
  118721. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  118722. */
  118723. get keysRight(): number[];
  118724. set keysRight(value: number[]);
  118725. /**
  118726. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  118727. */
  118728. get wheelPrecision(): number;
  118729. set wheelPrecision(value: number);
  118730. /**
  118731. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  118732. * It will be used instead of pinchDeltaPrecision if different from 0.
  118733. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  118734. */
  118735. get wheelDeltaPercentage(): number;
  118736. set wheelDeltaPercentage(value: number);
  118737. /**
  118738. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  118739. */
  118740. zoomOnFactor: number;
  118741. /**
  118742. * Defines a screen offset for the camera position.
  118743. */
  118744. targetScreenOffset: Vector2;
  118745. /**
  118746. * Allows the camera to be completely reversed.
  118747. * If false the camera can not arrive upside down.
  118748. */
  118749. allowUpsideDown: boolean;
  118750. /**
  118751. * Define if double tap/click is used to restore the previously saved state of the camera.
  118752. */
  118753. useInputToRestoreState: boolean;
  118754. /** @hidden */
  118755. _viewMatrix: Matrix;
  118756. /** @hidden */
  118757. _useCtrlForPanning: boolean;
  118758. /** @hidden */
  118759. _panningMouseButton: number;
  118760. /**
  118761. * Defines the input associated to the camera.
  118762. */
  118763. inputs: ArcRotateCameraInputsManager;
  118764. /** @hidden */
  118765. _reset: () => void;
  118766. /**
  118767. * Defines the allowed panning axis.
  118768. */
  118769. panningAxis: Vector3;
  118770. protected _localDirection: Vector3;
  118771. protected _transformedDirection: Vector3;
  118772. private _bouncingBehavior;
  118773. /**
  118774. * Gets the bouncing behavior of the camera if it has been enabled.
  118775. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  118776. */
  118777. get bouncingBehavior(): Nullable<BouncingBehavior>;
  118778. /**
  118779. * Defines if the bouncing behavior of the camera is enabled on the camera.
  118780. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  118781. */
  118782. get useBouncingBehavior(): boolean;
  118783. set useBouncingBehavior(value: boolean);
  118784. private _framingBehavior;
  118785. /**
  118786. * Gets the framing behavior of the camera if it has been enabled.
  118787. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  118788. */
  118789. get framingBehavior(): Nullable<FramingBehavior>;
  118790. /**
  118791. * Defines if the framing behavior of the camera is enabled on the camera.
  118792. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  118793. */
  118794. get useFramingBehavior(): boolean;
  118795. set useFramingBehavior(value: boolean);
  118796. private _autoRotationBehavior;
  118797. /**
  118798. * Gets the auto rotation behavior of the camera if it has been enabled.
  118799. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  118800. */
  118801. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  118802. /**
  118803. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  118804. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  118805. */
  118806. get useAutoRotationBehavior(): boolean;
  118807. set useAutoRotationBehavior(value: boolean);
  118808. /**
  118809. * Observable triggered when the mesh target has been changed on the camera.
  118810. */
  118811. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  118812. /**
  118813. * Event raised when the camera is colliding with a mesh.
  118814. */
  118815. onCollide: (collidedMesh: AbstractMesh) => void;
  118816. /**
  118817. * Defines whether the camera should check collision with the objects oh the scene.
  118818. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  118819. */
  118820. checkCollisions: boolean;
  118821. /**
  118822. * Defines the collision radius of the camera.
  118823. * This simulates a sphere around the camera.
  118824. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  118825. */
  118826. collisionRadius: Vector3;
  118827. protected _collider: Collider;
  118828. protected _previousPosition: Vector3;
  118829. protected _collisionVelocity: Vector3;
  118830. protected _newPosition: Vector3;
  118831. protected _previousAlpha: number;
  118832. protected _previousBeta: number;
  118833. protected _previousRadius: number;
  118834. protected _collisionTriggered: boolean;
  118835. protected _targetBoundingCenter: Nullable<Vector3>;
  118836. private _computationVector;
  118837. /**
  118838. * Instantiates a new ArcRotateCamera in a given scene
  118839. * @param name Defines the name of the camera
  118840. * @param alpha Defines the camera rotation along the logitudinal axis
  118841. * @param beta Defines the camera rotation along the latitudinal axis
  118842. * @param radius Defines the camera distance from its target
  118843. * @param target Defines the camera target
  118844. * @param scene Defines the scene the camera belongs to
  118845. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  118846. */
  118847. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  118848. /** @hidden */
  118849. _initCache(): void;
  118850. /** @hidden */
  118851. _updateCache(ignoreParentClass?: boolean): void;
  118852. protected _getTargetPosition(): Vector3;
  118853. private _storedAlpha;
  118854. private _storedBeta;
  118855. private _storedRadius;
  118856. private _storedTarget;
  118857. private _storedTargetScreenOffset;
  118858. /**
  118859. * Stores the current state of the camera (alpha, beta, radius and target)
  118860. * @returns the camera itself
  118861. */
  118862. storeState(): Camera;
  118863. /**
  118864. * @hidden
  118865. * Restored camera state. You must call storeState() first
  118866. */
  118867. _restoreStateValues(): boolean;
  118868. /** @hidden */
  118869. _isSynchronizedViewMatrix(): boolean;
  118870. /**
  118871. * Attached controls to the current camera.
  118872. * @param element Defines the element the controls should be listened from
  118873. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  118874. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  118875. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  118876. */
  118877. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  118878. /**
  118879. * Detach the current controls from the camera.
  118880. * The camera will stop reacting to inputs.
  118881. * @param element Defines the element to stop listening the inputs from
  118882. */
  118883. detachControl(element: HTMLElement): void;
  118884. /** @hidden */
  118885. _checkInputs(): void;
  118886. protected _checkLimits(): void;
  118887. /**
  118888. * Rebuilds angles (alpha, beta) and radius from the give position and target
  118889. */
  118890. rebuildAnglesAndRadius(): void;
  118891. /**
  118892. * Use a position to define the current camera related information like alpha, beta and radius
  118893. * @param position Defines the position to set the camera at
  118894. */
  118895. setPosition(position: Vector3): void;
  118896. /**
  118897. * Defines the target the camera should look at.
  118898. * This will automatically adapt alpha beta and radius to fit within the new target.
  118899. * @param target Defines the new target as a Vector or a mesh
  118900. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  118901. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  118902. */
  118903. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  118904. /** @hidden */
  118905. _getViewMatrix(): Matrix;
  118906. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  118907. /**
  118908. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  118909. * @param meshes Defines the mesh to zoom on
  118910. * @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)
  118911. */
  118912. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  118913. /**
  118914. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  118915. * The target will be changed but the radius
  118916. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  118917. * @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)
  118918. */
  118919. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  118920. min: Vector3;
  118921. max: Vector3;
  118922. distance: number;
  118923. }, doNotUpdateMaxZ?: boolean): void;
  118924. /**
  118925. * @override
  118926. * Override Camera.createRigCamera
  118927. */
  118928. createRigCamera(name: string, cameraIndex: number): Camera;
  118929. /**
  118930. * @hidden
  118931. * @override
  118932. * Override Camera._updateRigCameras
  118933. */
  118934. _updateRigCameras(): void;
  118935. /**
  118936. * Destroy the camera and release the current resources hold by it.
  118937. */
  118938. dispose(): void;
  118939. /**
  118940. * Gets the current object class name.
  118941. * @return the class name
  118942. */
  118943. getClassName(): string;
  118944. }
  118945. }
  118946. declare module BABYLON {
  118947. /**
  118948. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  118949. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  118950. */
  118951. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  118952. /**
  118953. * Gets the name of the behavior.
  118954. */
  118955. get name(): string;
  118956. private _zoomStopsAnimation;
  118957. private _idleRotationSpeed;
  118958. private _idleRotationWaitTime;
  118959. private _idleRotationSpinupTime;
  118960. /**
  118961. * Sets the flag that indicates if user zooming should stop animation.
  118962. */
  118963. set zoomStopsAnimation(flag: boolean);
  118964. /**
  118965. * Gets the flag that indicates if user zooming should stop animation.
  118966. */
  118967. get zoomStopsAnimation(): boolean;
  118968. /**
  118969. * Sets the default speed at which the camera rotates around the model.
  118970. */
  118971. set idleRotationSpeed(speed: number);
  118972. /**
  118973. * Gets the default speed at which the camera rotates around the model.
  118974. */
  118975. get idleRotationSpeed(): number;
  118976. /**
  118977. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  118978. */
  118979. set idleRotationWaitTime(time: number);
  118980. /**
  118981. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  118982. */
  118983. get idleRotationWaitTime(): number;
  118984. /**
  118985. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  118986. */
  118987. set idleRotationSpinupTime(time: number);
  118988. /**
  118989. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  118990. */
  118991. get idleRotationSpinupTime(): number;
  118992. /**
  118993. * Gets a value indicating if the camera is currently rotating because of this behavior
  118994. */
  118995. get rotationInProgress(): boolean;
  118996. private _onPrePointerObservableObserver;
  118997. private _onAfterCheckInputsObserver;
  118998. private _attachedCamera;
  118999. private _isPointerDown;
  119000. private _lastFrameTime;
  119001. private _lastInteractionTime;
  119002. private _cameraRotationSpeed;
  119003. /**
  119004. * Initializes the behavior.
  119005. */
  119006. init(): void;
  119007. /**
  119008. * Attaches the behavior to its arc rotate camera.
  119009. * @param camera Defines the camera to attach the behavior to
  119010. */
  119011. attach(camera: ArcRotateCamera): void;
  119012. /**
  119013. * Detaches the behavior from its current arc rotate camera.
  119014. */
  119015. detach(): void;
  119016. /**
  119017. * Returns true if user is scrolling.
  119018. * @return true if user is scrolling.
  119019. */
  119020. private _userIsZooming;
  119021. private _lastFrameRadius;
  119022. private _shouldAnimationStopForInteraction;
  119023. /**
  119024. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  119025. */
  119026. private _applyUserInteraction;
  119027. private _userIsMoving;
  119028. }
  119029. }
  119030. declare module BABYLON {
  119031. /**
  119032. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  119033. */
  119034. export class AttachToBoxBehavior implements Behavior<Mesh> {
  119035. private ui;
  119036. /**
  119037. * The name of the behavior
  119038. */
  119039. name: string;
  119040. /**
  119041. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  119042. */
  119043. distanceAwayFromFace: number;
  119044. /**
  119045. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  119046. */
  119047. distanceAwayFromBottomOfFace: number;
  119048. private _faceVectors;
  119049. private _target;
  119050. private _scene;
  119051. private _onRenderObserver;
  119052. private _tmpMatrix;
  119053. private _tmpVector;
  119054. /**
  119055. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  119056. * @param ui The transform node that should be attched to the mesh
  119057. */
  119058. constructor(ui: TransformNode);
  119059. /**
  119060. * Initializes the behavior
  119061. */
  119062. init(): void;
  119063. private _closestFace;
  119064. private _zeroVector;
  119065. private _lookAtTmpMatrix;
  119066. private _lookAtToRef;
  119067. /**
  119068. * Attaches the AttachToBoxBehavior to the passed in mesh
  119069. * @param target The mesh that the specified node will be attached to
  119070. */
  119071. attach(target: Mesh): void;
  119072. /**
  119073. * Detaches the behavior from the mesh
  119074. */
  119075. detach(): void;
  119076. }
  119077. }
  119078. declare module BABYLON {
  119079. /**
  119080. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  119081. */
  119082. export class FadeInOutBehavior implements Behavior<Mesh> {
  119083. /**
  119084. * Time in milliseconds to delay before fading in (Default: 0)
  119085. */
  119086. delay: number;
  119087. /**
  119088. * Time in milliseconds for the mesh to fade in (Default: 300)
  119089. */
  119090. fadeInTime: number;
  119091. private _millisecondsPerFrame;
  119092. private _hovered;
  119093. private _hoverValue;
  119094. private _ownerNode;
  119095. /**
  119096. * Instatiates the FadeInOutBehavior
  119097. */
  119098. constructor();
  119099. /**
  119100. * The name of the behavior
  119101. */
  119102. get name(): string;
  119103. /**
  119104. * Initializes the behavior
  119105. */
  119106. init(): void;
  119107. /**
  119108. * Attaches the fade behavior on the passed in mesh
  119109. * @param ownerNode The mesh that will be faded in/out once attached
  119110. */
  119111. attach(ownerNode: Mesh): void;
  119112. /**
  119113. * Detaches the behavior from the mesh
  119114. */
  119115. detach(): void;
  119116. /**
  119117. * Triggers the mesh to begin fading in or out
  119118. * @param value if the object should fade in or out (true to fade in)
  119119. */
  119120. fadeIn(value: boolean): void;
  119121. private _update;
  119122. private _setAllVisibility;
  119123. }
  119124. }
  119125. declare module BABYLON {
  119126. /**
  119127. * Class containing a set of static utilities functions for managing Pivots
  119128. * @hidden
  119129. */
  119130. export class PivotTools {
  119131. private static _PivotCached;
  119132. private static _OldPivotPoint;
  119133. private static _PivotTranslation;
  119134. private static _PivotTmpVector;
  119135. /** @hidden */
  119136. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  119137. /** @hidden */
  119138. static _RestorePivotPoint(mesh: AbstractMesh): void;
  119139. }
  119140. }
  119141. declare module BABYLON {
  119142. /**
  119143. * Class containing static functions to help procedurally build meshes
  119144. */
  119145. export class PlaneBuilder {
  119146. /**
  119147. * Creates a plane mesh
  119148. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  119149. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  119150. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  119151. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119152. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119153. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119154. * @param name defines the name of the mesh
  119155. * @param options defines the options used to create the mesh
  119156. * @param scene defines the hosting scene
  119157. * @returns the plane mesh
  119158. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  119159. */
  119160. static CreatePlane(name: string, options: {
  119161. size?: number;
  119162. width?: number;
  119163. height?: number;
  119164. sideOrientation?: number;
  119165. frontUVs?: Vector4;
  119166. backUVs?: Vector4;
  119167. updatable?: boolean;
  119168. sourcePlane?: Plane;
  119169. }, scene?: Nullable<Scene>): Mesh;
  119170. }
  119171. }
  119172. declare module BABYLON {
  119173. /**
  119174. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  119175. */
  119176. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  119177. private static _AnyMouseID;
  119178. /**
  119179. * Abstract mesh the behavior is set on
  119180. */
  119181. attachedNode: AbstractMesh;
  119182. private _dragPlane;
  119183. private _scene;
  119184. private _pointerObserver;
  119185. private _beforeRenderObserver;
  119186. private static _planeScene;
  119187. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  119188. /**
  119189. * 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)
  119190. */
  119191. maxDragAngle: number;
  119192. /**
  119193. * @hidden
  119194. */
  119195. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  119196. /**
  119197. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  119198. */
  119199. currentDraggingPointerID: number;
  119200. /**
  119201. * The last position where the pointer hit the drag plane in world space
  119202. */
  119203. lastDragPosition: Vector3;
  119204. /**
  119205. * If the behavior is currently in a dragging state
  119206. */
  119207. dragging: boolean;
  119208. /**
  119209. * 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)
  119210. */
  119211. dragDeltaRatio: number;
  119212. /**
  119213. * If the drag plane orientation should be updated during the dragging (Default: true)
  119214. */
  119215. updateDragPlane: boolean;
  119216. private _debugMode;
  119217. private _moving;
  119218. /**
  119219. * Fires each time the attached mesh is dragged with the pointer
  119220. * * delta between last drag position and current drag position in world space
  119221. * * dragDistance along the drag axis
  119222. * * dragPlaneNormal normal of the current drag plane used during the drag
  119223. * * dragPlanePoint in world space where the drag intersects the drag plane
  119224. */
  119225. onDragObservable: Observable<{
  119226. delta: Vector3;
  119227. dragPlanePoint: Vector3;
  119228. dragPlaneNormal: Vector3;
  119229. dragDistance: number;
  119230. pointerId: number;
  119231. }>;
  119232. /**
  119233. * Fires each time a drag begins (eg. mouse down on mesh)
  119234. */
  119235. onDragStartObservable: Observable<{
  119236. dragPlanePoint: Vector3;
  119237. pointerId: number;
  119238. }>;
  119239. /**
  119240. * Fires each time a drag ends (eg. mouse release after drag)
  119241. */
  119242. onDragEndObservable: Observable<{
  119243. dragPlanePoint: Vector3;
  119244. pointerId: number;
  119245. }>;
  119246. /**
  119247. * If the attached mesh should be moved when dragged
  119248. */
  119249. moveAttached: boolean;
  119250. /**
  119251. * If the drag behavior will react to drag events (Default: true)
  119252. */
  119253. enabled: boolean;
  119254. /**
  119255. * If pointer events should start and release the drag (Default: true)
  119256. */
  119257. startAndReleaseDragOnPointerEvents: boolean;
  119258. /**
  119259. * If camera controls should be detached during the drag
  119260. */
  119261. detachCameraControls: boolean;
  119262. /**
  119263. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  119264. */
  119265. useObjectOrientationForDragging: boolean;
  119266. private _options;
  119267. /**
  119268. * Gets the options used by the behavior
  119269. */
  119270. get options(): {
  119271. dragAxis?: Vector3;
  119272. dragPlaneNormal?: Vector3;
  119273. };
  119274. /**
  119275. * Sets the options used by the behavior
  119276. */
  119277. set options(options: {
  119278. dragAxis?: Vector3;
  119279. dragPlaneNormal?: Vector3;
  119280. });
  119281. /**
  119282. * Creates a pointer drag behavior that can be attached to a mesh
  119283. * @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)
  119284. */
  119285. constructor(options?: {
  119286. dragAxis?: Vector3;
  119287. dragPlaneNormal?: Vector3;
  119288. });
  119289. /**
  119290. * Predicate to determine if it is valid to move the object to a new position when it is moved
  119291. */
  119292. validateDrag: (targetPosition: Vector3) => boolean;
  119293. /**
  119294. * The name of the behavior
  119295. */
  119296. get name(): string;
  119297. /**
  119298. * Initializes the behavior
  119299. */
  119300. init(): void;
  119301. private _tmpVector;
  119302. private _alternatePickedPoint;
  119303. private _worldDragAxis;
  119304. private _targetPosition;
  119305. private _attachedElement;
  119306. /**
  119307. * Attaches the drag behavior the passed in mesh
  119308. * @param ownerNode The mesh that will be dragged around once attached
  119309. * @param predicate Predicate to use for pick filtering
  119310. */
  119311. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  119312. /**
  119313. * Force relase the drag action by code.
  119314. */
  119315. releaseDrag(): void;
  119316. private _startDragRay;
  119317. private _lastPointerRay;
  119318. /**
  119319. * Simulates the start of a pointer drag event on the behavior
  119320. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  119321. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  119322. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  119323. */
  119324. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  119325. private _startDrag;
  119326. private _dragDelta;
  119327. private _moveDrag;
  119328. private _pickWithRayOnDragPlane;
  119329. private _pointA;
  119330. private _pointB;
  119331. private _pointC;
  119332. private _lineA;
  119333. private _lineB;
  119334. private _localAxis;
  119335. private _lookAt;
  119336. private _updateDragPlanePosition;
  119337. /**
  119338. * Detaches the behavior from the mesh
  119339. */
  119340. detach(): void;
  119341. }
  119342. }
  119343. declare module BABYLON {
  119344. /**
  119345. * A behavior that when attached to a mesh will allow the mesh to be scaled
  119346. */
  119347. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  119348. private _dragBehaviorA;
  119349. private _dragBehaviorB;
  119350. private _startDistance;
  119351. private _initialScale;
  119352. private _targetScale;
  119353. private _ownerNode;
  119354. private _sceneRenderObserver;
  119355. /**
  119356. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  119357. */
  119358. constructor();
  119359. /**
  119360. * The name of the behavior
  119361. */
  119362. get name(): string;
  119363. /**
  119364. * Initializes the behavior
  119365. */
  119366. init(): void;
  119367. private _getCurrentDistance;
  119368. /**
  119369. * Attaches the scale behavior the passed in mesh
  119370. * @param ownerNode The mesh that will be scaled around once attached
  119371. */
  119372. attach(ownerNode: Mesh): void;
  119373. /**
  119374. * Detaches the behavior from the mesh
  119375. */
  119376. detach(): void;
  119377. }
  119378. }
  119379. declare module BABYLON {
  119380. /**
  119381. * 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
  119382. */
  119383. export class SixDofDragBehavior implements Behavior<Mesh> {
  119384. private static _virtualScene;
  119385. private _ownerNode;
  119386. private _sceneRenderObserver;
  119387. private _scene;
  119388. private _targetPosition;
  119389. private _virtualOriginMesh;
  119390. private _virtualDragMesh;
  119391. private _pointerObserver;
  119392. private _moving;
  119393. private _startingOrientation;
  119394. private _attachedElement;
  119395. /**
  119396. * 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)
  119397. */
  119398. private zDragFactor;
  119399. /**
  119400. * If the object should rotate to face the drag origin
  119401. */
  119402. rotateDraggedObject: boolean;
  119403. /**
  119404. * If the behavior is currently in a dragging state
  119405. */
  119406. dragging: boolean;
  119407. /**
  119408. * 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)
  119409. */
  119410. dragDeltaRatio: number;
  119411. /**
  119412. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  119413. */
  119414. currentDraggingPointerID: number;
  119415. /**
  119416. * If camera controls should be detached during the drag
  119417. */
  119418. detachCameraControls: boolean;
  119419. /**
  119420. * Fires each time a drag starts
  119421. */
  119422. onDragStartObservable: Observable<{}>;
  119423. /**
  119424. * Fires each time a drag ends (eg. mouse release after drag)
  119425. */
  119426. onDragEndObservable: Observable<{}>;
  119427. /**
  119428. * 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
  119429. */
  119430. constructor();
  119431. /**
  119432. * The name of the behavior
  119433. */
  119434. get name(): string;
  119435. /**
  119436. * Initializes the behavior
  119437. */
  119438. init(): void;
  119439. /**
  119440. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  119441. */
  119442. private get _pointerCamera();
  119443. /**
  119444. * Attaches the scale behavior the passed in mesh
  119445. * @param ownerNode The mesh that will be scaled around once attached
  119446. */
  119447. attach(ownerNode: Mesh): void;
  119448. /**
  119449. * Detaches the behavior from the mesh
  119450. */
  119451. detach(): void;
  119452. }
  119453. }
  119454. declare module BABYLON {
  119455. /**
  119456. * Class used to apply inverse kinematics to bones
  119457. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  119458. */
  119459. export class BoneIKController {
  119460. private static _tmpVecs;
  119461. private static _tmpQuat;
  119462. private static _tmpMats;
  119463. /**
  119464. * Gets or sets the target mesh
  119465. */
  119466. targetMesh: AbstractMesh;
  119467. /** Gets or sets the mesh used as pole */
  119468. poleTargetMesh: AbstractMesh;
  119469. /**
  119470. * Gets or sets the bone used as pole
  119471. */
  119472. poleTargetBone: Nullable<Bone>;
  119473. /**
  119474. * Gets or sets the target position
  119475. */
  119476. targetPosition: Vector3;
  119477. /**
  119478. * Gets or sets the pole target position
  119479. */
  119480. poleTargetPosition: Vector3;
  119481. /**
  119482. * Gets or sets the pole target local offset
  119483. */
  119484. poleTargetLocalOffset: Vector3;
  119485. /**
  119486. * Gets or sets the pole angle
  119487. */
  119488. poleAngle: number;
  119489. /**
  119490. * Gets or sets the mesh associated with the controller
  119491. */
  119492. mesh: AbstractMesh;
  119493. /**
  119494. * The amount to slerp (spherical linear interpolation) to the target. Set this to a value between 0 and 1 (a value of 1 disables slerp)
  119495. */
  119496. slerpAmount: number;
  119497. private _bone1Quat;
  119498. private _bone1Mat;
  119499. private _bone2Ang;
  119500. private _bone1;
  119501. private _bone2;
  119502. private _bone1Length;
  119503. private _bone2Length;
  119504. private _maxAngle;
  119505. private _maxReach;
  119506. private _rightHandedSystem;
  119507. private _bendAxis;
  119508. private _slerping;
  119509. private _adjustRoll;
  119510. /**
  119511. * Gets or sets maximum allowed angle
  119512. */
  119513. get maxAngle(): number;
  119514. set maxAngle(value: number);
  119515. /**
  119516. * Creates a new BoneIKController
  119517. * @param mesh defines the mesh to control
  119518. * @param bone defines the bone to control
  119519. * @param options defines options to set up the controller
  119520. */
  119521. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  119522. targetMesh?: AbstractMesh;
  119523. poleTargetMesh?: AbstractMesh;
  119524. poleTargetBone?: Bone;
  119525. poleTargetLocalOffset?: Vector3;
  119526. poleAngle?: number;
  119527. bendAxis?: Vector3;
  119528. maxAngle?: number;
  119529. slerpAmount?: number;
  119530. });
  119531. private _setMaxAngle;
  119532. /**
  119533. * Force the controller to update the bones
  119534. */
  119535. update(): void;
  119536. }
  119537. }
  119538. declare module BABYLON {
  119539. /**
  119540. * Class used to make a bone look toward a point in space
  119541. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  119542. */
  119543. export class BoneLookController {
  119544. private static _tmpVecs;
  119545. private static _tmpQuat;
  119546. private static _tmpMats;
  119547. /**
  119548. * The target Vector3 that the bone will look at
  119549. */
  119550. target: Vector3;
  119551. /**
  119552. * The mesh that the bone is attached to
  119553. */
  119554. mesh: AbstractMesh;
  119555. /**
  119556. * The bone that will be looking to the target
  119557. */
  119558. bone: Bone;
  119559. /**
  119560. * The up axis of the coordinate system that is used when the bone is rotated
  119561. */
  119562. upAxis: Vector3;
  119563. /**
  119564. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  119565. */
  119566. upAxisSpace: Space;
  119567. /**
  119568. * Used to make an adjustment to the yaw of the bone
  119569. */
  119570. adjustYaw: number;
  119571. /**
  119572. * Used to make an adjustment to the pitch of the bone
  119573. */
  119574. adjustPitch: number;
  119575. /**
  119576. * Used to make an adjustment to the roll of the bone
  119577. */
  119578. adjustRoll: number;
  119579. /**
  119580. * 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)
  119581. */
  119582. slerpAmount: number;
  119583. private _minYaw;
  119584. private _maxYaw;
  119585. private _minPitch;
  119586. private _maxPitch;
  119587. private _minYawSin;
  119588. private _minYawCos;
  119589. private _maxYawSin;
  119590. private _maxYawCos;
  119591. private _midYawConstraint;
  119592. private _minPitchTan;
  119593. private _maxPitchTan;
  119594. private _boneQuat;
  119595. private _slerping;
  119596. private _transformYawPitch;
  119597. private _transformYawPitchInv;
  119598. private _firstFrameSkipped;
  119599. private _yawRange;
  119600. private _fowardAxis;
  119601. /**
  119602. * Gets or sets the minimum yaw angle that the bone can look to
  119603. */
  119604. get minYaw(): number;
  119605. set minYaw(value: number);
  119606. /**
  119607. * Gets or sets the maximum yaw angle that the bone can look to
  119608. */
  119609. get maxYaw(): number;
  119610. set maxYaw(value: number);
  119611. /**
  119612. * Gets or sets the minimum pitch angle that the bone can look to
  119613. */
  119614. get minPitch(): number;
  119615. set minPitch(value: number);
  119616. /**
  119617. * Gets or sets the maximum pitch angle that the bone can look to
  119618. */
  119619. get maxPitch(): number;
  119620. set maxPitch(value: number);
  119621. /**
  119622. * Create a BoneLookController
  119623. * @param mesh the mesh that the bone belongs to
  119624. * @param bone the bone that will be looking to the target
  119625. * @param target the target Vector3 to look at
  119626. * @param options optional settings:
  119627. * * maxYaw: the maximum angle the bone will yaw to
  119628. * * minYaw: the minimum angle the bone will yaw to
  119629. * * maxPitch: the maximum angle the bone will pitch to
  119630. * * minPitch: the minimum angle the bone will yaw to
  119631. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  119632. * * upAxis: the up axis of the coordinate system
  119633. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  119634. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  119635. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  119636. * * adjustYaw: used to make an adjustment to the yaw of the bone
  119637. * * adjustPitch: used to make an adjustment to the pitch of the bone
  119638. * * adjustRoll: used to make an adjustment to the roll of the bone
  119639. **/
  119640. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  119641. maxYaw?: number;
  119642. minYaw?: number;
  119643. maxPitch?: number;
  119644. minPitch?: number;
  119645. slerpAmount?: number;
  119646. upAxis?: Vector3;
  119647. upAxisSpace?: Space;
  119648. yawAxis?: Vector3;
  119649. pitchAxis?: Vector3;
  119650. adjustYaw?: number;
  119651. adjustPitch?: number;
  119652. adjustRoll?: number;
  119653. });
  119654. /**
  119655. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  119656. */
  119657. update(): void;
  119658. private _getAngleDiff;
  119659. private _getAngleBetween;
  119660. private _isAngleBetween;
  119661. }
  119662. }
  119663. declare module BABYLON {
  119664. /**
  119665. * Manage the gamepad inputs to control an arc rotate camera.
  119666. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  119667. */
  119668. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  119669. /**
  119670. * Defines the camera the input is attached to.
  119671. */
  119672. camera: ArcRotateCamera;
  119673. /**
  119674. * Defines the gamepad the input is gathering event from.
  119675. */
  119676. gamepad: Nullable<Gamepad>;
  119677. /**
  119678. * Defines the gamepad rotation sensiblity.
  119679. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  119680. */
  119681. gamepadRotationSensibility: number;
  119682. /**
  119683. * Defines the gamepad move sensiblity.
  119684. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  119685. */
  119686. gamepadMoveSensibility: number;
  119687. private _yAxisScale;
  119688. /**
  119689. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  119690. */
  119691. get invertYAxis(): boolean;
  119692. set invertYAxis(value: boolean);
  119693. private _onGamepadConnectedObserver;
  119694. private _onGamepadDisconnectedObserver;
  119695. /**
  119696. * Attach the input controls to a specific dom element to get the input from.
  119697. * @param element Defines the element the controls should be listened from
  119698. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  119699. */
  119700. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  119701. /**
  119702. * Detach the current controls from the specified dom element.
  119703. * @param element Defines the element to stop listening the inputs from
  119704. */
  119705. detachControl(element: Nullable<HTMLElement>): void;
  119706. /**
  119707. * Update the current camera state depending on the inputs that have been used this frame.
  119708. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  119709. */
  119710. checkInputs(): void;
  119711. /**
  119712. * Gets the class name of the current intput.
  119713. * @returns the class name
  119714. */
  119715. getClassName(): string;
  119716. /**
  119717. * Get the friendly name associated with the input class.
  119718. * @returns the input friendly name
  119719. */
  119720. getSimpleName(): string;
  119721. }
  119722. }
  119723. declare module BABYLON {
  119724. interface ArcRotateCameraInputsManager {
  119725. /**
  119726. * Add orientation input support to the input manager.
  119727. * @returns the current input manager
  119728. */
  119729. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  119730. }
  119731. /**
  119732. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  119733. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  119734. */
  119735. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  119736. /**
  119737. * Defines the camera the input is attached to.
  119738. */
  119739. camera: ArcRotateCamera;
  119740. /**
  119741. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  119742. */
  119743. alphaCorrection: number;
  119744. /**
  119745. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  119746. */
  119747. gammaCorrection: number;
  119748. private _alpha;
  119749. private _gamma;
  119750. private _dirty;
  119751. private _deviceOrientationHandler;
  119752. /**
  119753. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  119754. */
  119755. constructor();
  119756. /**
  119757. * Attach the input controls to a specific dom element to get the input from.
  119758. * @param element Defines the element the controls should be listened from
  119759. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  119760. */
  119761. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  119762. /** @hidden */
  119763. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  119764. /**
  119765. * Update the current camera state depending on the inputs that have been used this frame.
  119766. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  119767. */
  119768. checkInputs(): void;
  119769. /**
  119770. * Detach the current controls from the specified dom element.
  119771. * @param element Defines the element to stop listening the inputs from
  119772. */
  119773. detachControl(element: Nullable<HTMLElement>): void;
  119774. /**
  119775. * Gets the class name of the current intput.
  119776. * @returns the class name
  119777. */
  119778. getClassName(): string;
  119779. /**
  119780. * Get the friendly name associated with the input class.
  119781. * @returns the input friendly name
  119782. */
  119783. getSimpleName(): string;
  119784. }
  119785. }
  119786. declare module BABYLON {
  119787. /**
  119788. * Listen to mouse events to control the camera.
  119789. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  119790. */
  119791. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  119792. /**
  119793. * Defines the camera the input is attached to.
  119794. */
  119795. camera: FlyCamera;
  119796. /**
  119797. * Defines if touch is enabled. (Default is true.)
  119798. */
  119799. touchEnabled: boolean;
  119800. /**
  119801. * Defines the buttons associated with the input to handle camera rotation.
  119802. */
  119803. buttons: number[];
  119804. /**
  119805. * Assign buttons for Yaw control.
  119806. */
  119807. buttonsYaw: number[];
  119808. /**
  119809. * Assign buttons for Pitch control.
  119810. */
  119811. buttonsPitch: number[];
  119812. /**
  119813. * Assign buttons for Roll control.
  119814. */
  119815. buttonsRoll: number[];
  119816. /**
  119817. * Detect if any button is being pressed while mouse is moved.
  119818. * -1 = Mouse locked.
  119819. * 0 = Left button.
  119820. * 1 = Middle Button.
  119821. * 2 = Right Button.
  119822. */
  119823. activeButton: number;
  119824. /**
  119825. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  119826. * Higher values reduce its sensitivity.
  119827. */
  119828. angularSensibility: number;
  119829. private _mousemoveCallback;
  119830. private _observer;
  119831. private _rollObserver;
  119832. private previousPosition;
  119833. private noPreventDefault;
  119834. private element;
  119835. /**
  119836. * Listen to mouse events to control the camera.
  119837. * @param touchEnabled Define if touch is enabled. (Default is true.)
  119838. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  119839. */
  119840. constructor(touchEnabled?: boolean);
  119841. /**
  119842. * Attach the mouse control to the HTML DOM element.
  119843. * @param element Defines the element that listens to the input events.
  119844. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  119845. */
  119846. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  119847. /**
  119848. * Detach the current controls from the specified dom element.
  119849. * @param element Defines the element to stop listening the inputs from
  119850. */
  119851. detachControl(element: Nullable<HTMLElement>): void;
  119852. /**
  119853. * Gets the class name of the current input.
  119854. * @returns the class name.
  119855. */
  119856. getClassName(): string;
  119857. /**
  119858. * Get the friendly name associated with the input class.
  119859. * @returns the input's friendly name.
  119860. */
  119861. getSimpleName(): string;
  119862. private _pointerInput;
  119863. private _onMouseMove;
  119864. /**
  119865. * Rotate camera by mouse offset.
  119866. */
  119867. private rotateCamera;
  119868. }
  119869. }
  119870. declare module BABYLON {
  119871. /**
  119872. * Default Inputs manager for the FlyCamera.
  119873. * It groups all the default supported inputs for ease of use.
  119874. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  119875. */
  119876. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  119877. /**
  119878. * Instantiates a new FlyCameraInputsManager.
  119879. * @param camera Defines the camera the inputs belong to.
  119880. */
  119881. constructor(camera: FlyCamera);
  119882. /**
  119883. * Add keyboard input support to the input manager.
  119884. * @returns the new FlyCameraKeyboardMoveInput().
  119885. */
  119886. addKeyboard(): FlyCameraInputsManager;
  119887. /**
  119888. * Add mouse input support to the input manager.
  119889. * @param touchEnabled Enable touch screen support.
  119890. * @returns the new FlyCameraMouseInput().
  119891. */
  119892. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  119893. }
  119894. }
  119895. declare module BABYLON {
  119896. /**
  119897. * This is a flying camera, designed for 3D movement and rotation in all directions,
  119898. * such as in a 3D Space Shooter or a Flight Simulator.
  119899. */
  119900. export class FlyCamera extends TargetCamera {
  119901. /**
  119902. * Define the collision ellipsoid of the camera.
  119903. * This is helpful for simulating a camera body, like a player's body.
  119904. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  119905. */
  119906. ellipsoid: Vector3;
  119907. /**
  119908. * Define an offset for the position of the ellipsoid around the camera.
  119909. * This can be helpful if the camera is attached away from the player's body center,
  119910. * such as at its head.
  119911. */
  119912. ellipsoidOffset: Vector3;
  119913. /**
  119914. * Enable or disable collisions of the camera with the rest of the scene objects.
  119915. */
  119916. checkCollisions: boolean;
  119917. /**
  119918. * Enable or disable gravity on the camera.
  119919. */
  119920. applyGravity: boolean;
  119921. /**
  119922. * Define the current direction the camera is moving to.
  119923. */
  119924. cameraDirection: Vector3;
  119925. /**
  119926. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  119927. * This overrides and empties cameraRotation.
  119928. */
  119929. rotationQuaternion: Quaternion;
  119930. /**
  119931. * Track Roll to maintain the wanted Rolling when looking around.
  119932. */
  119933. _trackRoll: number;
  119934. /**
  119935. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  119936. */
  119937. rollCorrect: number;
  119938. /**
  119939. * Mimic a banked turn, Rolling the camera when Yawing.
  119940. * It's recommended to use rollCorrect = 10 for faster banking correction.
  119941. */
  119942. bankedTurn: boolean;
  119943. /**
  119944. * Limit in radians for how much Roll banking will add. (Default: 90°)
  119945. */
  119946. bankedTurnLimit: number;
  119947. /**
  119948. * Value of 0 disables the banked Roll.
  119949. * Value of 1 is equal to the Yaw angle in radians.
  119950. */
  119951. bankedTurnMultiplier: number;
  119952. /**
  119953. * The inputs manager loads all the input sources, such as keyboard and mouse.
  119954. */
  119955. inputs: FlyCameraInputsManager;
  119956. /**
  119957. * Gets the input sensibility for mouse input.
  119958. * Higher values reduce sensitivity.
  119959. */
  119960. get angularSensibility(): number;
  119961. /**
  119962. * Sets the input sensibility for a mouse input.
  119963. * Higher values reduce sensitivity.
  119964. */
  119965. set angularSensibility(value: number);
  119966. /**
  119967. * Get the keys for camera movement forward.
  119968. */
  119969. get keysForward(): number[];
  119970. /**
  119971. * Set the keys for camera movement forward.
  119972. */
  119973. set keysForward(value: number[]);
  119974. /**
  119975. * Get the keys for camera movement backward.
  119976. */
  119977. get keysBackward(): number[];
  119978. set keysBackward(value: number[]);
  119979. /**
  119980. * Get the keys for camera movement up.
  119981. */
  119982. get keysUp(): number[];
  119983. /**
  119984. * Set the keys for camera movement up.
  119985. */
  119986. set keysUp(value: number[]);
  119987. /**
  119988. * Get the keys for camera movement down.
  119989. */
  119990. get keysDown(): number[];
  119991. /**
  119992. * Set the keys for camera movement down.
  119993. */
  119994. set keysDown(value: number[]);
  119995. /**
  119996. * Get the keys for camera movement left.
  119997. */
  119998. get keysLeft(): number[];
  119999. /**
  120000. * Set the keys for camera movement left.
  120001. */
  120002. set keysLeft(value: number[]);
  120003. /**
  120004. * Set the keys for camera movement right.
  120005. */
  120006. get keysRight(): number[];
  120007. /**
  120008. * Set the keys for camera movement right.
  120009. */
  120010. set keysRight(value: number[]);
  120011. /**
  120012. * Event raised when the camera collides with a mesh in the scene.
  120013. */
  120014. onCollide: (collidedMesh: AbstractMesh) => void;
  120015. private _collider;
  120016. private _needMoveForGravity;
  120017. private _oldPosition;
  120018. private _diffPosition;
  120019. private _newPosition;
  120020. /** @hidden */
  120021. _localDirection: Vector3;
  120022. /** @hidden */
  120023. _transformedDirection: Vector3;
  120024. /**
  120025. * Instantiates a FlyCamera.
  120026. * This is a flying camera, designed for 3D movement and rotation in all directions,
  120027. * such as in a 3D Space Shooter or a Flight Simulator.
  120028. * @param name Define the name of the camera in the scene.
  120029. * @param position Define the starting position of the camera in the scene.
  120030. * @param scene Define the scene the camera belongs to.
  120031. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  120032. */
  120033. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  120034. /**
  120035. * Attach a control to the HTML DOM element.
  120036. * @param element Defines the element that listens to the input events.
  120037. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  120038. */
  120039. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  120040. /**
  120041. * Detach a control from the HTML DOM element.
  120042. * The camera will stop reacting to that input.
  120043. * @param element Defines the element that listens to the input events.
  120044. */
  120045. detachControl(element: HTMLElement): void;
  120046. private _collisionMask;
  120047. /**
  120048. * Get the mask that the camera ignores in collision events.
  120049. */
  120050. get collisionMask(): number;
  120051. /**
  120052. * Set the mask that the camera ignores in collision events.
  120053. */
  120054. set collisionMask(mask: number);
  120055. /** @hidden */
  120056. _collideWithWorld(displacement: Vector3): void;
  120057. /** @hidden */
  120058. private _onCollisionPositionChange;
  120059. /** @hidden */
  120060. _checkInputs(): void;
  120061. /** @hidden */
  120062. _decideIfNeedsToMove(): boolean;
  120063. /** @hidden */
  120064. _updatePosition(): void;
  120065. /**
  120066. * Restore the Roll to its target value at the rate specified.
  120067. * @param rate - Higher means slower restoring.
  120068. * @hidden
  120069. */
  120070. restoreRoll(rate: number): void;
  120071. /**
  120072. * Destroy the camera and release the current resources held by it.
  120073. */
  120074. dispose(): void;
  120075. /**
  120076. * Get the current object class name.
  120077. * @returns the class name.
  120078. */
  120079. getClassName(): string;
  120080. }
  120081. }
  120082. declare module BABYLON {
  120083. /**
  120084. * Listen to keyboard events to control the camera.
  120085. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  120086. */
  120087. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  120088. /**
  120089. * Defines the camera the input is attached to.
  120090. */
  120091. camera: FlyCamera;
  120092. /**
  120093. * The list of keyboard keys used to control the forward move of the camera.
  120094. */
  120095. keysForward: number[];
  120096. /**
  120097. * The list of keyboard keys used to control the backward move of the camera.
  120098. */
  120099. keysBackward: number[];
  120100. /**
  120101. * The list of keyboard keys used to control the forward move of the camera.
  120102. */
  120103. keysUp: number[];
  120104. /**
  120105. * The list of keyboard keys used to control the backward move of the camera.
  120106. */
  120107. keysDown: number[];
  120108. /**
  120109. * The list of keyboard keys used to control the right strafe move of the camera.
  120110. */
  120111. keysRight: number[];
  120112. /**
  120113. * The list of keyboard keys used to control the left strafe move of the camera.
  120114. */
  120115. keysLeft: number[];
  120116. private _keys;
  120117. private _onCanvasBlurObserver;
  120118. private _onKeyboardObserver;
  120119. private _engine;
  120120. private _scene;
  120121. /**
  120122. * Attach the input controls to a specific dom element to get the input from.
  120123. * @param element Defines the element the controls should be listened from
  120124. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  120125. */
  120126. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  120127. /**
  120128. * Detach the current controls from the specified dom element.
  120129. * @param element Defines the element to stop listening the inputs from
  120130. */
  120131. detachControl(element: Nullable<HTMLElement>): void;
  120132. /**
  120133. * Gets the class name of the current intput.
  120134. * @returns the class name
  120135. */
  120136. getClassName(): string;
  120137. /** @hidden */
  120138. _onLostFocus(e: FocusEvent): void;
  120139. /**
  120140. * Get the friendly name associated with the input class.
  120141. * @returns the input friendly name
  120142. */
  120143. getSimpleName(): string;
  120144. /**
  120145. * Update the current camera state depending on the inputs that have been used this frame.
  120146. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  120147. */
  120148. checkInputs(): void;
  120149. }
  120150. }
  120151. declare module BABYLON {
  120152. /**
  120153. * Manage the mouse wheel inputs to control a follow camera.
  120154. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  120155. */
  120156. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  120157. /**
  120158. * Defines the camera the input is attached to.
  120159. */
  120160. camera: FollowCamera;
  120161. /**
  120162. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  120163. */
  120164. axisControlRadius: boolean;
  120165. /**
  120166. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  120167. */
  120168. axisControlHeight: boolean;
  120169. /**
  120170. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  120171. */
  120172. axisControlRotation: boolean;
  120173. /**
  120174. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  120175. * relation to mouseWheel events.
  120176. */
  120177. wheelPrecision: number;
  120178. /**
  120179. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  120180. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  120181. */
  120182. wheelDeltaPercentage: number;
  120183. private _wheel;
  120184. private _observer;
  120185. /**
  120186. * Attach the input controls to a specific dom element to get the input from.
  120187. * @param element Defines the element the controls should be listened from
  120188. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  120189. */
  120190. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  120191. /**
  120192. * Detach the current controls from the specified dom element.
  120193. * @param element Defines the element to stop listening the inputs from
  120194. */
  120195. detachControl(element: Nullable<HTMLElement>): void;
  120196. /**
  120197. * Gets the class name of the current intput.
  120198. * @returns the class name
  120199. */
  120200. getClassName(): string;
  120201. /**
  120202. * Get the friendly name associated with the input class.
  120203. * @returns the input friendly name
  120204. */
  120205. getSimpleName(): string;
  120206. }
  120207. }
  120208. declare module BABYLON {
  120209. /**
  120210. * Manage the pointers inputs to control an follow camera.
  120211. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  120212. */
  120213. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  120214. /**
  120215. * Defines the camera the input is attached to.
  120216. */
  120217. camera: FollowCamera;
  120218. /**
  120219. * Gets the class name of the current input.
  120220. * @returns the class name
  120221. */
  120222. getClassName(): string;
  120223. /**
  120224. * Defines the pointer angular sensibility along the X axis or how fast is
  120225. * the camera rotating.
  120226. * A negative number will reverse the axis direction.
  120227. */
  120228. angularSensibilityX: number;
  120229. /**
  120230. * Defines the pointer angular sensibility along the Y axis or how fast is
  120231. * the camera rotating.
  120232. * A negative number will reverse the axis direction.
  120233. */
  120234. angularSensibilityY: number;
  120235. /**
  120236. * Defines the pointer pinch precision or how fast is the camera zooming.
  120237. * A negative number will reverse the axis direction.
  120238. */
  120239. pinchPrecision: number;
  120240. /**
  120241. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  120242. * from 0.
  120243. * It defines the percentage of current camera.radius to use as delta when
  120244. * pinch zoom is used.
  120245. */
  120246. pinchDeltaPercentage: number;
  120247. /**
  120248. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  120249. */
  120250. axisXControlRadius: boolean;
  120251. /**
  120252. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  120253. */
  120254. axisXControlHeight: boolean;
  120255. /**
  120256. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  120257. */
  120258. axisXControlRotation: boolean;
  120259. /**
  120260. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  120261. */
  120262. axisYControlRadius: boolean;
  120263. /**
  120264. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  120265. */
  120266. axisYControlHeight: boolean;
  120267. /**
  120268. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  120269. */
  120270. axisYControlRotation: boolean;
  120271. /**
  120272. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  120273. */
  120274. axisPinchControlRadius: boolean;
  120275. /**
  120276. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  120277. */
  120278. axisPinchControlHeight: boolean;
  120279. /**
  120280. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  120281. */
  120282. axisPinchControlRotation: boolean;
  120283. /**
  120284. * Log error messages if basic misconfiguration has occurred.
  120285. */
  120286. warningEnable: boolean;
  120287. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  120288. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  120289. private _warningCounter;
  120290. private _warning;
  120291. }
  120292. }
  120293. declare module BABYLON {
  120294. /**
  120295. * Default Inputs manager for the FollowCamera.
  120296. * It groups all the default supported inputs for ease of use.
  120297. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  120298. */
  120299. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  120300. /**
  120301. * Instantiates a new FollowCameraInputsManager.
  120302. * @param camera Defines the camera the inputs belong to
  120303. */
  120304. constructor(camera: FollowCamera);
  120305. /**
  120306. * Add keyboard input support to the input manager.
  120307. * @returns the current input manager
  120308. */
  120309. addKeyboard(): FollowCameraInputsManager;
  120310. /**
  120311. * Add mouse wheel input support to the input manager.
  120312. * @returns the current input manager
  120313. */
  120314. addMouseWheel(): FollowCameraInputsManager;
  120315. /**
  120316. * Add pointers input support to the input manager.
  120317. * @returns the current input manager
  120318. */
  120319. addPointers(): FollowCameraInputsManager;
  120320. /**
  120321. * Add orientation input support to the input manager.
  120322. * @returns the current input manager
  120323. */
  120324. addVRDeviceOrientation(): FollowCameraInputsManager;
  120325. }
  120326. }
  120327. declare module BABYLON {
  120328. /**
  120329. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  120330. * an arc rotate version arcFollowCamera are available.
  120331. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  120332. */
  120333. export class FollowCamera extends TargetCamera {
  120334. /**
  120335. * Distance the follow camera should follow an object at
  120336. */
  120337. radius: number;
  120338. /**
  120339. * Minimum allowed distance of the camera to the axis of rotation
  120340. * (The camera can not get closer).
  120341. * This can help limiting how the Camera is able to move in the scene.
  120342. */
  120343. lowerRadiusLimit: Nullable<number>;
  120344. /**
  120345. * Maximum allowed distance of the camera to the axis of rotation
  120346. * (The camera can not get further).
  120347. * This can help limiting how the Camera is able to move in the scene.
  120348. */
  120349. upperRadiusLimit: Nullable<number>;
  120350. /**
  120351. * Define a rotation offset between the camera and the object it follows
  120352. */
  120353. rotationOffset: number;
  120354. /**
  120355. * Minimum allowed angle to camera position relative to target object.
  120356. * This can help limiting how the Camera is able to move in the scene.
  120357. */
  120358. lowerRotationOffsetLimit: Nullable<number>;
  120359. /**
  120360. * Maximum allowed angle to camera position relative to target object.
  120361. * This can help limiting how the Camera is able to move in the scene.
  120362. */
  120363. upperRotationOffsetLimit: Nullable<number>;
  120364. /**
  120365. * Define a height offset between the camera and the object it follows.
  120366. * It can help following an object from the top (like a car chaing a plane)
  120367. */
  120368. heightOffset: number;
  120369. /**
  120370. * Minimum allowed height of camera position relative to target object.
  120371. * This can help limiting how the Camera is able to move in the scene.
  120372. */
  120373. lowerHeightOffsetLimit: Nullable<number>;
  120374. /**
  120375. * Maximum allowed height of camera position relative to target object.
  120376. * This can help limiting how the Camera is able to move in the scene.
  120377. */
  120378. upperHeightOffsetLimit: Nullable<number>;
  120379. /**
  120380. * Define how fast the camera can accelerate to follow it s target.
  120381. */
  120382. cameraAcceleration: number;
  120383. /**
  120384. * Define the speed limit of the camera following an object.
  120385. */
  120386. maxCameraSpeed: number;
  120387. /**
  120388. * Define the target of the camera.
  120389. */
  120390. lockedTarget: Nullable<AbstractMesh>;
  120391. /**
  120392. * Defines the input associated with the camera.
  120393. */
  120394. inputs: FollowCameraInputsManager;
  120395. /**
  120396. * Instantiates the follow camera.
  120397. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  120398. * @param name Define the name of the camera in the scene
  120399. * @param position Define the position of the camera
  120400. * @param scene Define the scene the camera belong to
  120401. * @param lockedTarget Define the target of the camera
  120402. */
  120403. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  120404. private _follow;
  120405. /**
  120406. * Attached controls to the current camera.
  120407. * @param element Defines the element the controls should be listened from
  120408. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  120409. */
  120410. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  120411. /**
  120412. * Detach the current controls from the camera.
  120413. * The camera will stop reacting to inputs.
  120414. * @param element Defines the element to stop listening the inputs from
  120415. */
  120416. detachControl(element: HTMLElement): void;
  120417. /** @hidden */
  120418. _checkInputs(): void;
  120419. private _checkLimits;
  120420. /**
  120421. * Gets the camera class name.
  120422. * @returns the class name
  120423. */
  120424. getClassName(): string;
  120425. }
  120426. /**
  120427. * Arc Rotate version of the follow camera.
  120428. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  120429. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  120430. */
  120431. export class ArcFollowCamera extends TargetCamera {
  120432. /** The longitudinal angle of the camera */
  120433. alpha: number;
  120434. /** The latitudinal angle of the camera */
  120435. beta: number;
  120436. /** The radius of the camera from its target */
  120437. radius: number;
  120438. /** Define the camera target (the messh it should follow) */
  120439. target: Nullable<AbstractMesh>;
  120440. private _cartesianCoordinates;
  120441. /**
  120442. * Instantiates a new ArcFollowCamera
  120443. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  120444. * @param name Define the name of the camera
  120445. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  120446. * @param beta Define the rotation angle of the camera around the elevation axis
  120447. * @param radius Define the radius of the camera from its target point
  120448. * @param target Define the target of the camera
  120449. * @param scene Define the scene the camera belongs to
  120450. */
  120451. constructor(name: string,
  120452. /** The longitudinal angle of the camera */
  120453. alpha: number,
  120454. /** The latitudinal angle of the camera */
  120455. beta: number,
  120456. /** The radius of the camera from its target */
  120457. radius: number,
  120458. /** Define the camera target (the messh it should follow) */
  120459. target: Nullable<AbstractMesh>, scene: Scene);
  120460. private _follow;
  120461. /** @hidden */
  120462. _checkInputs(): void;
  120463. /**
  120464. * Returns the class name of the object.
  120465. * It is mostly used internally for serialization purposes.
  120466. */
  120467. getClassName(): string;
  120468. }
  120469. }
  120470. declare module BABYLON {
  120471. /**
  120472. * Manage the keyboard inputs to control the movement of a follow camera.
  120473. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  120474. */
  120475. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  120476. /**
  120477. * Defines the camera the input is attached to.
  120478. */
  120479. camera: FollowCamera;
  120480. /**
  120481. * Defines the list of key codes associated with the up action (increase heightOffset)
  120482. */
  120483. keysHeightOffsetIncr: number[];
  120484. /**
  120485. * Defines the list of key codes associated with the down action (decrease heightOffset)
  120486. */
  120487. keysHeightOffsetDecr: number[];
  120488. /**
  120489. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  120490. */
  120491. keysHeightOffsetModifierAlt: boolean;
  120492. /**
  120493. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  120494. */
  120495. keysHeightOffsetModifierCtrl: boolean;
  120496. /**
  120497. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  120498. */
  120499. keysHeightOffsetModifierShift: boolean;
  120500. /**
  120501. * Defines the list of key codes associated with the left action (increase rotationOffset)
  120502. */
  120503. keysRotationOffsetIncr: number[];
  120504. /**
  120505. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  120506. */
  120507. keysRotationOffsetDecr: number[];
  120508. /**
  120509. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  120510. */
  120511. keysRotationOffsetModifierAlt: boolean;
  120512. /**
  120513. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  120514. */
  120515. keysRotationOffsetModifierCtrl: boolean;
  120516. /**
  120517. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  120518. */
  120519. keysRotationOffsetModifierShift: boolean;
  120520. /**
  120521. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  120522. */
  120523. keysRadiusIncr: number[];
  120524. /**
  120525. * Defines the list of key codes associated with the zoom-out action (increase radius)
  120526. */
  120527. keysRadiusDecr: number[];
  120528. /**
  120529. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  120530. */
  120531. keysRadiusModifierAlt: boolean;
  120532. /**
  120533. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  120534. */
  120535. keysRadiusModifierCtrl: boolean;
  120536. /**
  120537. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  120538. */
  120539. keysRadiusModifierShift: boolean;
  120540. /**
  120541. * Defines the rate of change of heightOffset.
  120542. */
  120543. heightSensibility: number;
  120544. /**
  120545. * Defines the rate of change of rotationOffset.
  120546. */
  120547. rotationSensibility: number;
  120548. /**
  120549. * Defines the rate of change of radius.
  120550. */
  120551. radiusSensibility: number;
  120552. private _keys;
  120553. private _ctrlPressed;
  120554. private _altPressed;
  120555. private _shiftPressed;
  120556. private _onCanvasBlurObserver;
  120557. private _onKeyboardObserver;
  120558. private _engine;
  120559. private _scene;
  120560. /**
  120561. * Attach the input controls to a specific dom element to get the input from.
  120562. * @param element Defines the element the controls should be listened from
  120563. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  120564. */
  120565. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  120566. /**
  120567. * Detach the current controls from the specified dom element.
  120568. * @param element Defines the element to stop listening the inputs from
  120569. */
  120570. detachControl(element: Nullable<HTMLElement>): void;
  120571. /**
  120572. * Update the current camera state depending on the inputs that have been used this frame.
  120573. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  120574. */
  120575. checkInputs(): void;
  120576. /**
  120577. * Gets the class name of the current input.
  120578. * @returns the class name
  120579. */
  120580. getClassName(): string;
  120581. /**
  120582. * Get the friendly name associated with the input class.
  120583. * @returns the input friendly name
  120584. */
  120585. getSimpleName(): string;
  120586. /**
  120587. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  120588. * allow modification of the heightOffset value.
  120589. */
  120590. private _modifierHeightOffset;
  120591. /**
  120592. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  120593. * allow modification of the rotationOffset value.
  120594. */
  120595. private _modifierRotationOffset;
  120596. /**
  120597. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  120598. * allow modification of the radius value.
  120599. */
  120600. private _modifierRadius;
  120601. }
  120602. }
  120603. declare module BABYLON {
  120604. interface FreeCameraInputsManager {
  120605. /**
  120606. * @hidden
  120607. */
  120608. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  120609. /**
  120610. * Add orientation input support to the input manager.
  120611. * @returns the current input manager
  120612. */
  120613. addDeviceOrientation(): FreeCameraInputsManager;
  120614. }
  120615. /**
  120616. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  120617. * Screen rotation is taken into account.
  120618. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  120619. */
  120620. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  120621. private _camera;
  120622. private _screenOrientationAngle;
  120623. private _constantTranform;
  120624. private _screenQuaternion;
  120625. private _alpha;
  120626. private _beta;
  120627. private _gamma;
  120628. /**
  120629. * Can be used to detect if a device orientation sensor is available on a device
  120630. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  120631. * @returns a promise that will resolve on orientation change
  120632. */
  120633. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  120634. /**
  120635. * @hidden
  120636. */
  120637. _onDeviceOrientationChangedObservable: Observable<void>;
  120638. /**
  120639. * Instantiates a new input
  120640. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  120641. */
  120642. constructor();
  120643. /**
  120644. * Define the camera controlled by the input.
  120645. */
  120646. get camera(): FreeCamera;
  120647. set camera(camera: FreeCamera);
  120648. /**
  120649. * Attach the input controls to a specific dom element to get the input from.
  120650. * @param element Defines the element the controls should be listened from
  120651. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  120652. */
  120653. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  120654. private _orientationChanged;
  120655. private _deviceOrientation;
  120656. /**
  120657. * Detach the current controls from the specified dom element.
  120658. * @param element Defines the element to stop listening the inputs from
  120659. */
  120660. detachControl(element: Nullable<HTMLElement>): void;
  120661. /**
  120662. * Update the current camera state depending on the inputs that have been used this frame.
  120663. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  120664. */
  120665. checkInputs(): void;
  120666. /**
  120667. * Gets the class name of the current intput.
  120668. * @returns the class name
  120669. */
  120670. getClassName(): string;
  120671. /**
  120672. * Get the friendly name associated with the input class.
  120673. * @returns the input friendly name
  120674. */
  120675. getSimpleName(): string;
  120676. }
  120677. }
  120678. declare module BABYLON {
  120679. /**
  120680. * Manage the gamepad inputs to control a free camera.
  120681. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  120682. */
  120683. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  120684. /**
  120685. * Define the camera the input is attached to.
  120686. */
  120687. camera: FreeCamera;
  120688. /**
  120689. * Define the Gamepad controlling the input
  120690. */
  120691. gamepad: Nullable<Gamepad>;
  120692. /**
  120693. * Defines the gamepad rotation sensiblity.
  120694. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  120695. */
  120696. gamepadAngularSensibility: number;
  120697. /**
  120698. * Defines the gamepad move sensiblity.
  120699. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  120700. */
  120701. gamepadMoveSensibility: number;
  120702. private _yAxisScale;
  120703. /**
  120704. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  120705. */
  120706. get invertYAxis(): boolean;
  120707. set invertYAxis(value: boolean);
  120708. private _onGamepadConnectedObserver;
  120709. private _onGamepadDisconnectedObserver;
  120710. private _cameraTransform;
  120711. private _deltaTransform;
  120712. private _vector3;
  120713. private _vector2;
  120714. /**
  120715. * Attach the input controls to a specific dom element to get the input from.
  120716. * @param element Defines the element the controls should be listened from
  120717. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  120718. */
  120719. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  120720. /**
  120721. * Detach the current controls from the specified dom element.
  120722. * @param element Defines the element to stop listening the inputs from
  120723. */
  120724. detachControl(element: Nullable<HTMLElement>): void;
  120725. /**
  120726. * Update the current camera state depending on the inputs that have been used this frame.
  120727. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  120728. */
  120729. checkInputs(): void;
  120730. /**
  120731. * Gets the class name of the current intput.
  120732. * @returns the class name
  120733. */
  120734. getClassName(): string;
  120735. /**
  120736. * Get the friendly name associated with the input class.
  120737. * @returns the input friendly name
  120738. */
  120739. getSimpleName(): string;
  120740. }
  120741. }
  120742. declare module BABYLON {
  120743. /**
  120744. * Defines the potential axis of a Joystick
  120745. */
  120746. export enum JoystickAxis {
  120747. /** X axis */
  120748. X = 0,
  120749. /** Y axis */
  120750. Y = 1,
  120751. /** Z axis */
  120752. Z = 2
  120753. }
  120754. /**
  120755. * Class used to define virtual joystick (used in touch mode)
  120756. */
  120757. export class VirtualJoystick {
  120758. /**
  120759. * Gets or sets a boolean indicating that left and right values must be inverted
  120760. */
  120761. reverseLeftRight: boolean;
  120762. /**
  120763. * Gets or sets a boolean indicating that up and down values must be inverted
  120764. */
  120765. reverseUpDown: boolean;
  120766. /**
  120767. * Gets the offset value for the position (ie. the change of the position value)
  120768. */
  120769. deltaPosition: Vector3;
  120770. /**
  120771. * Gets a boolean indicating if the virtual joystick was pressed
  120772. */
  120773. pressed: boolean;
  120774. /**
  120775. * Canvas the virtual joystick will render onto, default z-index of this is 5
  120776. */
  120777. static Canvas: Nullable<HTMLCanvasElement>;
  120778. private static _globalJoystickIndex;
  120779. private static vjCanvasContext;
  120780. private static vjCanvasWidth;
  120781. private static vjCanvasHeight;
  120782. private static halfWidth;
  120783. private _action;
  120784. private _axisTargetedByLeftAndRight;
  120785. private _axisTargetedByUpAndDown;
  120786. private _joystickSensibility;
  120787. private _inversedSensibility;
  120788. private _joystickPointerID;
  120789. private _joystickColor;
  120790. private _joystickPointerPos;
  120791. private _joystickPreviousPointerPos;
  120792. private _joystickPointerStartPos;
  120793. private _deltaJoystickVector;
  120794. private _leftJoystick;
  120795. private _touches;
  120796. private _onPointerDownHandlerRef;
  120797. private _onPointerMoveHandlerRef;
  120798. private _onPointerUpHandlerRef;
  120799. private _onResize;
  120800. /**
  120801. * Creates a new virtual joystick
  120802. * @param leftJoystick defines that the joystick is for left hand (false by default)
  120803. */
  120804. constructor(leftJoystick?: boolean);
  120805. /**
  120806. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  120807. * @param newJoystickSensibility defines the new sensibility
  120808. */
  120809. setJoystickSensibility(newJoystickSensibility: number): void;
  120810. private _onPointerDown;
  120811. private _onPointerMove;
  120812. private _onPointerUp;
  120813. /**
  120814. * Change the color of the virtual joystick
  120815. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  120816. */
  120817. setJoystickColor(newColor: string): void;
  120818. /**
  120819. * Defines a callback to call when the joystick is touched
  120820. * @param action defines the callback
  120821. */
  120822. setActionOnTouch(action: () => any): void;
  120823. /**
  120824. * Defines which axis you'd like to control for left & right
  120825. * @param axis defines the axis to use
  120826. */
  120827. setAxisForLeftRight(axis: JoystickAxis): void;
  120828. /**
  120829. * Defines which axis you'd like to control for up & down
  120830. * @param axis defines the axis to use
  120831. */
  120832. setAxisForUpDown(axis: JoystickAxis): void;
  120833. private _drawVirtualJoystick;
  120834. /**
  120835. * Release internal HTML canvas
  120836. */
  120837. releaseCanvas(): void;
  120838. }
  120839. }
  120840. declare module BABYLON {
  120841. interface FreeCameraInputsManager {
  120842. /**
  120843. * Add virtual joystick input support to the input manager.
  120844. * @returns the current input manager
  120845. */
  120846. addVirtualJoystick(): FreeCameraInputsManager;
  120847. }
  120848. /**
  120849. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  120850. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  120851. */
  120852. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  120853. /**
  120854. * Defines the camera the input is attached to.
  120855. */
  120856. camera: FreeCamera;
  120857. private _leftjoystick;
  120858. private _rightjoystick;
  120859. /**
  120860. * Gets the left stick of the virtual joystick.
  120861. * @returns The virtual Joystick
  120862. */
  120863. getLeftJoystick(): VirtualJoystick;
  120864. /**
  120865. * Gets the right stick of the virtual joystick.
  120866. * @returns The virtual Joystick
  120867. */
  120868. getRightJoystick(): VirtualJoystick;
  120869. /**
  120870. * Update the current camera state depending on the inputs that have been used this frame.
  120871. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  120872. */
  120873. checkInputs(): void;
  120874. /**
  120875. * Attach the input controls to a specific dom element to get the input from.
  120876. * @param element Defines the element the controls should be listened from
  120877. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  120878. */
  120879. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  120880. /**
  120881. * Detach the current controls from the specified dom element.
  120882. * @param element Defines the element to stop listening the inputs from
  120883. */
  120884. detachControl(element: Nullable<HTMLElement>): void;
  120885. /**
  120886. * Gets the class name of the current intput.
  120887. * @returns the class name
  120888. */
  120889. getClassName(): string;
  120890. /**
  120891. * Get the friendly name associated with the input class.
  120892. * @returns the input friendly name
  120893. */
  120894. getSimpleName(): string;
  120895. }
  120896. }
  120897. declare module BABYLON {
  120898. /**
  120899. * This represents a FPS type of camera controlled by touch.
  120900. * This is like a universal camera minus the Gamepad controls.
  120901. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  120902. */
  120903. export class TouchCamera extends FreeCamera {
  120904. /**
  120905. * Defines the touch sensibility for rotation.
  120906. * The higher the faster.
  120907. */
  120908. get touchAngularSensibility(): number;
  120909. set touchAngularSensibility(value: number);
  120910. /**
  120911. * Defines the touch sensibility for move.
  120912. * The higher the faster.
  120913. */
  120914. get touchMoveSensibility(): number;
  120915. set touchMoveSensibility(value: number);
  120916. /**
  120917. * Instantiates a new touch camera.
  120918. * This represents a FPS type of camera controlled by touch.
  120919. * This is like a universal camera minus the Gamepad controls.
  120920. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  120921. * @param name Define the name of the camera in the scene
  120922. * @param position Define the start position of the camera in the scene
  120923. * @param scene Define the scene the camera belongs to
  120924. */
  120925. constructor(name: string, position: Vector3, scene: Scene);
  120926. /**
  120927. * Gets the current object class name.
  120928. * @return the class name
  120929. */
  120930. getClassName(): string;
  120931. /** @hidden */
  120932. _setupInputs(): void;
  120933. }
  120934. }
  120935. declare module BABYLON {
  120936. /**
  120937. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  120938. * being tilted forward or back and left or right.
  120939. */
  120940. export class DeviceOrientationCamera extends FreeCamera {
  120941. private _initialQuaternion;
  120942. private _quaternionCache;
  120943. private _tmpDragQuaternion;
  120944. private _disablePointerInputWhenUsingDeviceOrientation;
  120945. /**
  120946. * Creates a new device orientation camera
  120947. * @param name The name of the camera
  120948. * @param position The start position camera
  120949. * @param scene The scene the camera belongs to
  120950. */
  120951. constructor(name: string, position: Vector3, scene: Scene);
  120952. /**
  120953. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  120954. */
  120955. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  120956. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  120957. private _dragFactor;
  120958. /**
  120959. * Enabled turning on the y axis when the orientation sensor is active
  120960. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  120961. */
  120962. enableHorizontalDragging(dragFactor?: number): void;
  120963. /**
  120964. * Gets the current instance class name ("DeviceOrientationCamera").
  120965. * This helps avoiding instanceof at run time.
  120966. * @returns the class name
  120967. */
  120968. getClassName(): string;
  120969. /**
  120970. * @hidden
  120971. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  120972. */
  120973. _checkInputs(): void;
  120974. /**
  120975. * Reset the camera to its default orientation on the specified axis only.
  120976. * @param axis The axis to reset
  120977. */
  120978. resetToCurrentRotation(axis?: Axis): void;
  120979. }
  120980. }
  120981. declare module BABYLON {
  120982. /**
  120983. * Defines supported buttons for XBox360 compatible gamepads
  120984. */
  120985. export enum Xbox360Button {
  120986. /** A */
  120987. A = 0,
  120988. /** B */
  120989. B = 1,
  120990. /** X */
  120991. X = 2,
  120992. /** Y */
  120993. Y = 3,
  120994. /** Left button */
  120995. LB = 4,
  120996. /** Right button */
  120997. RB = 5,
  120998. /** Back */
  120999. Back = 8,
  121000. /** Start */
  121001. Start = 9,
  121002. /** Left stick */
  121003. LeftStick = 10,
  121004. /** Right stick */
  121005. RightStick = 11
  121006. }
  121007. /** Defines values for XBox360 DPad */
  121008. export enum Xbox360Dpad {
  121009. /** Up */
  121010. Up = 12,
  121011. /** Down */
  121012. Down = 13,
  121013. /** Left */
  121014. Left = 14,
  121015. /** Right */
  121016. Right = 15
  121017. }
  121018. /**
  121019. * Defines a XBox360 gamepad
  121020. */
  121021. export class Xbox360Pad extends Gamepad {
  121022. private _leftTrigger;
  121023. private _rightTrigger;
  121024. private _onlefttriggerchanged;
  121025. private _onrighttriggerchanged;
  121026. private _onbuttondown;
  121027. private _onbuttonup;
  121028. private _ondpaddown;
  121029. private _ondpadup;
  121030. /** Observable raised when a button is pressed */
  121031. onButtonDownObservable: Observable<Xbox360Button>;
  121032. /** Observable raised when a button is released */
  121033. onButtonUpObservable: Observable<Xbox360Button>;
  121034. /** Observable raised when a pad is pressed */
  121035. onPadDownObservable: Observable<Xbox360Dpad>;
  121036. /** Observable raised when a pad is released */
  121037. onPadUpObservable: Observable<Xbox360Dpad>;
  121038. private _buttonA;
  121039. private _buttonB;
  121040. private _buttonX;
  121041. private _buttonY;
  121042. private _buttonBack;
  121043. private _buttonStart;
  121044. private _buttonLB;
  121045. private _buttonRB;
  121046. private _buttonLeftStick;
  121047. private _buttonRightStick;
  121048. private _dPadUp;
  121049. private _dPadDown;
  121050. private _dPadLeft;
  121051. private _dPadRight;
  121052. private _isXboxOnePad;
  121053. /**
  121054. * Creates a new XBox360 gamepad object
  121055. * @param id defines the id of this gamepad
  121056. * @param index defines its index
  121057. * @param gamepad defines the internal HTML gamepad object
  121058. * @param xboxOne defines if it is a XBox One gamepad
  121059. */
  121060. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  121061. /**
  121062. * Defines the callback to call when left trigger is pressed
  121063. * @param callback defines the callback to use
  121064. */
  121065. onlefttriggerchanged(callback: (value: number) => void): void;
  121066. /**
  121067. * Defines the callback to call when right trigger is pressed
  121068. * @param callback defines the callback to use
  121069. */
  121070. onrighttriggerchanged(callback: (value: number) => void): void;
  121071. /**
  121072. * Gets the left trigger value
  121073. */
  121074. get leftTrigger(): number;
  121075. /**
  121076. * Sets the left trigger value
  121077. */
  121078. set leftTrigger(newValue: number);
  121079. /**
  121080. * Gets the right trigger value
  121081. */
  121082. get rightTrigger(): number;
  121083. /**
  121084. * Sets the right trigger value
  121085. */
  121086. set rightTrigger(newValue: number);
  121087. /**
  121088. * Defines the callback to call when a button is pressed
  121089. * @param callback defines the callback to use
  121090. */
  121091. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  121092. /**
  121093. * Defines the callback to call when a button is released
  121094. * @param callback defines the callback to use
  121095. */
  121096. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  121097. /**
  121098. * Defines the callback to call when a pad is pressed
  121099. * @param callback defines the callback to use
  121100. */
  121101. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  121102. /**
  121103. * Defines the callback to call when a pad is released
  121104. * @param callback defines the callback to use
  121105. */
  121106. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  121107. private _setButtonValue;
  121108. private _setDPadValue;
  121109. /**
  121110. * Gets the value of the `A` button
  121111. */
  121112. get buttonA(): number;
  121113. /**
  121114. * Sets the value of the `A` button
  121115. */
  121116. set buttonA(value: number);
  121117. /**
  121118. * Gets the value of the `B` button
  121119. */
  121120. get buttonB(): number;
  121121. /**
  121122. * Sets the value of the `B` button
  121123. */
  121124. set buttonB(value: number);
  121125. /**
  121126. * Gets the value of the `X` button
  121127. */
  121128. get buttonX(): number;
  121129. /**
  121130. * Sets the value of the `X` button
  121131. */
  121132. set buttonX(value: number);
  121133. /**
  121134. * Gets the value of the `Y` button
  121135. */
  121136. get buttonY(): number;
  121137. /**
  121138. * Sets the value of the `Y` button
  121139. */
  121140. set buttonY(value: number);
  121141. /**
  121142. * Gets the value of the `Start` button
  121143. */
  121144. get buttonStart(): number;
  121145. /**
  121146. * Sets the value of the `Start` button
  121147. */
  121148. set buttonStart(value: number);
  121149. /**
  121150. * Gets the value of the `Back` button
  121151. */
  121152. get buttonBack(): number;
  121153. /**
  121154. * Sets the value of the `Back` button
  121155. */
  121156. set buttonBack(value: number);
  121157. /**
  121158. * Gets the value of the `Left` button
  121159. */
  121160. get buttonLB(): number;
  121161. /**
  121162. * Sets the value of the `Left` button
  121163. */
  121164. set buttonLB(value: number);
  121165. /**
  121166. * Gets the value of the `Right` button
  121167. */
  121168. get buttonRB(): number;
  121169. /**
  121170. * Sets the value of the `Right` button
  121171. */
  121172. set buttonRB(value: number);
  121173. /**
  121174. * Gets the value of the Left joystick
  121175. */
  121176. get buttonLeftStick(): number;
  121177. /**
  121178. * Sets the value of the Left joystick
  121179. */
  121180. set buttonLeftStick(value: number);
  121181. /**
  121182. * Gets the value of the Right joystick
  121183. */
  121184. get buttonRightStick(): number;
  121185. /**
  121186. * Sets the value of the Right joystick
  121187. */
  121188. set buttonRightStick(value: number);
  121189. /**
  121190. * Gets the value of D-pad up
  121191. */
  121192. get dPadUp(): number;
  121193. /**
  121194. * Sets the value of D-pad up
  121195. */
  121196. set dPadUp(value: number);
  121197. /**
  121198. * Gets the value of D-pad down
  121199. */
  121200. get dPadDown(): number;
  121201. /**
  121202. * Sets the value of D-pad down
  121203. */
  121204. set dPadDown(value: number);
  121205. /**
  121206. * Gets the value of D-pad left
  121207. */
  121208. get dPadLeft(): number;
  121209. /**
  121210. * Sets the value of D-pad left
  121211. */
  121212. set dPadLeft(value: number);
  121213. /**
  121214. * Gets the value of D-pad right
  121215. */
  121216. get dPadRight(): number;
  121217. /**
  121218. * Sets the value of D-pad right
  121219. */
  121220. set dPadRight(value: number);
  121221. /**
  121222. * Force the gamepad to synchronize with device values
  121223. */
  121224. update(): void;
  121225. /**
  121226. * Disposes the gamepad
  121227. */
  121228. dispose(): void;
  121229. }
  121230. }
  121231. declare module BABYLON {
  121232. /**
  121233. * Defines supported buttons for DualShock compatible gamepads
  121234. */
  121235. export enum DualShockButton {
  121236. /** Cross */
  121237. Cross = 0,
  121238. /** Circle */
  121239. Circle = 1,
  121240. /** Square */
  121241. Square = 2,
  121242. /** Triangle */
  121243. Triangle = 3,
  121244. /** L1 */
  121245. L1 = 4,
  121246. /** R1 */
  121247. R1 = 5,
  121248. /** Share */
  121249. Share = 8,
  121250. /** Options */
  121251. Options = 9,
  121252. /** Left stick */
  121253. LeftStick = 10,
  121254. /** Right stick */
  121255. RightStick = 11
  121256. }
  121257. /** Defines values for DualShock DPad */
  121258. export enum DualShockDpad {
  121259. /** Up */
  121260. Up = 12,
  121261. /** Down */
  121262. Down = 13,
  121263. /** Left */
  121264. Left = 14,
  121265. /** Right */
  121266. Right = 15
  121267. }
  121268. /**
  121269. * Defines a DualShock gamepad
  121270. */
  121271. export class DualShockPad extends Gamepad {
  121272. private _leftTrigger;
  121273. private _rightTrigger;
  121274. private _onlefttriggerchanged;
  121275. private _onrighttriggerchanged;
  121276. private _onbuttondown;
  121277. private _onbuttonup;
  121278. private _ondpaddown;
  121279. private _ondpadup;
  121280. /** Observable raised when a button is pressed */
  121281. onButtonDownObservable: Observable<DualShockButton>;
  121282. /** Observable raised when a button is released */
  121283. onButtonUpObservable: Observable<DualShockButton>;
  121284. /** Observable raised when a pad is pressed */
  121285. onPadDownObservable: Observable<DualShockDpad>;
  121286. /** Observable raised when a pad is released */
  121287. onPadUpObservable: Observable<DualShockDpad>;
  121288. private _buttonCross;
  121289. private _buttonCircle;
  121290. private _buttonSquare;
  121291. private _buttonTriangle;
  121292. private _buttonShare;
  121293. private _buttonOptions;
  121294. private _buttonL1;
  121295. private _buttonR1;
  121296. private _buttonLeftStick;
  121297. private _buttonRightStick;
  121298. private _dPadUp;
  121299. private _dPadDown;
  121300. private _dPadLeft;
  121301. private _dPadRight;
  121302. /**
  121303. * Creates a new DualShock gamepad object
  121304. * @param id defines the id of this gamepad
  121305. * @param index defines its index
  121306. * @param gamepad defines the internal HTML gamepad object
  121307. */
  121308. constructor(id: string, index: number, gamepad: any);
  121309. /**
  121310. * Defines the callback to call when left trigger is pressed
  121311. * @param callback defines the callback to use
  121312. */
  121313. onlefttriggerchanged(callback: (value: number) => void): void;
  121314. /**
  121315. * Defines the callback to call when right trigger is pressed
  121316. * @param callback defines the callback to use
  121317. */
  121318. onrighttriggerchanged(callback: (value: number) => void): void;
  121319. /**
  121320. * Gets the left trigger value
  121321. */
  121322. get leftTrigger(): number;
  121323. /**
  121324. * Sets the left trigger value
  121325. */
  121326. set leftTrigger(newValue: number);
  121327. /**
  121328. * Gets the right trigger value
  121329. */
  121330. get rightTrigger(): number;
  121331. /**
  121332. * Sets the right trigger value
  121333. */
  121334. set rightTrigger(newValue: number);
  121335. /**
  121336. * Defines the callback to call when a button is pressed
  121337. * @param callback defines the callback to use
  121338. */
  121339. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  121340. /**
  121341. * Defines the callback to call when a button is released
  121342. * @param callback defines the callback to use
  121343. */
  121344. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  121345. /**
  121346. * Defines the callback to call when a pad is pressed
  121347. * @param callback defines the callback to use
  121348. */
  121349. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  121350. /**
  121351. * Defines the callback to call when a pad is released
  121352. * @param callback defines the callback to use
  121353. */
  121354. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  121355. private _setButtonValue;
  121356. private _setDPadValue;
  121357. /**
  121358. * Gets the value of the `Cross` button
  121359. */
  121360. get buttonCross(): number;
  121361. /**
  121362. * Sets the value of the `Cross` button
  121363. */
  121364. set buttonCross(value: number);
  121365. /**
  121366. * Gets the value of the `Circle` button
  121367. */
  121368. get buttonCircle(): number;
  121369. /**
  121370. * Sets the value of the `Circle` button
  121371. */
  121372. set buttonCircle(value: number);
  121373. /**
  121374. * Gets the value of the `Square` button
  121375. */
  121376. get buttonSquare(): number;
  121377. /**
  121378. * Sets the value of the `Square` button
  121379. */
  121380. set buttonSquare(value: number);
  121381. /**
  121382. * Gets the value of the `Triangle` button
  121383. */
  121384. get buttonTriangle(): number;
  121385. /**
  121386. * Sets the value of the `Triangle` button
  121387. */
  121388. set buttonTriangle(value: number);
  121389. /**
  121390. * Gets the value of the `Options` button
  121391. */
  121392. get buttonOptions(): number;
  121393. /**
  121394. * Sets the value of the `Options` button
  121395. */
  121396. set buttonOptions(value: number);
  121397. /**
  121398. * Gets the value of the `Share` button
  121399. */
  121400. get buttonShare(): number;
  121401. /**
  121402. * Sets the value of the `Share` button
  121403. */
  121404. set buttonShare(value: number);
  121405. /**
  121406. * Gets the value of the `L1` button
  121407. */
  121408. get buttonL1(): number;
  121409. /**
  121410. * Sets the value of the `L1` button
  121411. */
  121412. set buttonL1(value: number);
  121413. /**
  121414. * Gets the value of the `R1` button
  121415. */
  121416. get buttonR1(): number;
  121417. /**
  121418. * Sets the value of the `R1` button
  121419. */
  121420. set buttonR1(value: number);
  121421. /**
  121422. * Gets the value of the Left joystick
  121423. */
  121424. get buttonLeftStick(): number;
  121425. /**
  121426. * Sets the value of the Left joystick
  121427. */
  121428. set buttonLeftStick(value: number);
  121429. /**
  121430. * Gets the value of the Right joystick
  121431. */
  121432. get buttonRightStick(): number;
  121433. /**
  121434. * Sets the value of the Right joystick
  121435. */
  121436. set buttonRightStick(value: number);
  121437. /**
  121438. * Gets the value of D-pad up
  121439. */
  121440. get dPadUp(): number;
  121441. /**
  121442. * Sets the value of D-pad up
  121443. */
  121444. set dPadUp(value: number);
  121445. /**
  121446. * Gets the value of D-pad down
  121447. */
  121448. get dPadDown(): number;
  121449. /**
  121450. * Sets the value of D-pad down
  121451. */
  121452. set dPadDown(value: number);
  121453. /**
  121454. * Gets the value of D-pad left
  121455. */
  121456. get dPadLeft(): number;
  121457. /**
  121458. * Sets the value of D-pad left
  121459. */
  121460. set dPadLeft(value: number);
  121461. /**
  121462. * Gets the value of D-pad right
  121463. */
  121464. get dPadRight(): number;
  121465. /**
  121466. * Sets the value of D-pad right
  121467. */
  121468. set dPadRight(value: number);
  121469. /**
  121470. * Force the gamepad to synchronize with device values
  121471. */
  121472. update(): void;
  121473. /**
  121474. * Disposes the gamepad
  121475. */
  121476. dispose(): void;
  121477. }
  121478. }
  121479. declare module BABYLON {
  121480. /**
  121481. * Manager for handling gamepads
  121482. */
  121483. export class GamepadManager {
  121484. private _scene?;
  121485. private _babylonGamepads;
  121486. private _oneGamepadConnected;
  121487. /** @hidden */
  121488. _isMonitoring: boolean;
  121489. private _gamepadEventSupported;
  121490. private _gamepadSupport?;
  121491. /**
  121492. * observable to be triggered when the gamepad controller has been connected
  121493. */
  121494. onGamepadConnectedObservable: Observable<Gamepad>;
  121495. /**
  121496. * observable to be triggered when the gamepad controller has been disconnected
  121497. */
  121498. onGamepadDisconnectedObservable: Observable<Gamepad>;
  121499. private _onGamepadConnectedEvent;
  121500. private _onGamepadDisconnectedEvent;
  121501. /**
  121502. * Initializes the gamepad manager
  121503. * @param _scene BabylonJS scene
  121504. */
  121505. constructor(_scene?: Scene | undefined);
  121506. /**
  121507. * The gamepads in the game pad manager
  121508. */
  121509. get gamepads(): Gamepad[];
  121510. /**
  121511. * Get the gamepad controllers based on type
  121512. * @param type The type of gamepad controller
  121513. * @returns Nullable gamepad
  121514. */
  121515. getGamepadByType(type?: number): Nullable<Gamepad>;
  121516. /**
  121517. * Disposes the gamepad manager
  121518. */
  121519. dispose(): void;
  121520. private _addNewGamepad;
  121521. private _startMonitoringGamepads;
  121522. private _stopMonitoringGamepads;
  121523. /** @hidden */
  121524. _checkGamepadsStatus(): void;
  121525. private _updateGamepadObjects;
  121526. }
  121527. }
  121528. declare module BABYLON {
  121529. interface Scene {
  121530. /** @hidden */
  121531. _gamepadManager: Nullable<GamepadManager>;
  121532. /**
  121533. * Gets the gamepad manager associated with the scene
  121534. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  121535. */
  121536. gamepadManager: GamepadManager;
  121537. }
  121538. /**
  121539. * Interface representing a free camera inputs manager
  121540. */
  121541. interface FreeCameraInputsManager {
  121542. /**
  121543. * Adds gamepad input support to the FreeCameraInputsManager.
  121544. * @returns the FreeCameraInputsManager
  121545. */
  121546. addGamepad(): FreeCameraInputsManager;
  121547. }
  121548. /**
  121549. * Interface representing an arc rotate camera inputs manager
  121550. */
  121551. interface ArcRotateCameraInputsManager {
  121552. /**
  121553. * Adds gamepad input support to the ArcRotateCamera InputManager.
  121554. * @returns the camera inputs manager
  121555. */
  121556. addGamepad(): ArcRotateCameraInputsManager;
  121557. }
  121558. /**
  121559. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  121560. */
  121561. export class GamepadSystemSceneComponent implements ISceneComponent {
  121562. /**
  121563. * The component name helpfull to identify the component in the list of scene components.
  121564. */
  121565. readonly name: string;
  121566. /**
  121567. * The scene the component belongs to.
  121568. */
  121569. scene: Scene;
  121570. /**
  121571. * Creates a new instance of the component for the given scene
  121572. * @param scene Defines the scene to register the component in
  121573. */
  121574. constructor(scene: Scene);
  121575. /**
  121576. * Registers the component in a given scene
  121577. */
  121578. register(): void;
  121579. /**
  121580. * Rebuilds the elements related to this component in case of
  121581. * context lost for instance.
  121582. */
  121583. rebuild(): void;
  121584. /**
  121585. * Disposes the component and the associated ressources
  121586. */
  121587. dispose(): void;
  121588. private _beforeCameraUpdate;
  121589. }
  121590. }
  121591. declare module BABYLON {
  121592. /**
  121593. * 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,
  121594. * which still works and will still be found in many Playgrounds.
  121595. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  121596. */
  121597. export class UniversalCamera extends TouchCamera {
  121598. /**
  121599. * Defines the gamepad rotation sensiblity.
  121600. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  121601. */
  121602. get gamepadAngularSensibility(): number;
  121603. set gamepadAngularSensibility(value: number);
  121604. /**
  121605. * Defines the gamepad move sensiblity.
  121606. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  121607. */
  121608. get gamepadMoveSensibility(): number;
  121609. set gamepadMoveSensibility(value: number);
  121610. /**
  121611. * 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,
  121612. * which still works and will still be found in many Playgrounds.
  121613. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  121614. * @param name Define the name of the camera in the scene
  121615. * @param position Define the start position of the camera in the scene
  121616. * @param scene Define the scene the camera belongs to
  121617. */
  121618. constructor(name: string, position: Vector3, scene: Scene);
  121619. /**
  121620. * Gets the current object class name.
  121621. * @return the class name
  121622. */
  121623. getClassName(): string;
  121624. }
  121625. }
  121626. declare module BABYLON {
  121627. /**
  121628. * This represents a FPS type of camera. This is only here for back compat purpose.
  121629. * Please use the UniversalCamera instead as both are identical.
  121630. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  121631. */
  121632. export class GamepadCamera extends UniversalCamera {
  121633. /**
  121634. * Instantiates a new Gamepad Camera
  121635. * This represents a FPS type of camera. This is only here for back compat purpose.
  121636. * Please use the UniversalCamera instead as both are identical.
  121637. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  121638. * @param name Define the name of the camera in the scene
  121639. * @param position Define the start position of the camera in the scene
  121640. * @param scene Define the scene the camera belongs to
  121641. */
  121642. constructor(name: string, position: Vector3, scene: Scene);
  121643. /**
  121644. * Gets the current object class name.
  121645. * @return the class name
  121646. */
  121647. getClassName(): string;
  121648. }
  121649. }
  121650. declare module BABYLON {
  121651. /** @hidden */
  121652. export var passPixelShader: {
  121653. name: string;
  121654. shader: string;
  121655. };
  121656. }
  121657. declare module BABYLON {
  121658. /** @hidden */
  121659. export var passCubePixelShader: {
  121660. name: string;
  121661. shader: string;
  121662. };
  121663. }
  121664. declare module BABYLON {
  121665. /**
  121666. * PassPostProcess which produces an output the same as it's input
  121667. */
  121668. export class PassPostProcess extends PostProcess {
  121669. /**
  121670. * Creates the PassPostProcess
  121671. * @param name The name of the effect.
  121672. * @param options The required width/height ratio to downsize to before computing the render pass.
  121673. * @param camera The camera to apply the render pass to.
  121674. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  121675. * @param engine The engine which the post process will be applied. (default: current engine)
  121676. * @param reusable If the post process can be reused on the same frame. (default: false)
  121677. * @param textureType The type of texture to be used when performing the post processing.
  121678. * @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)
  121679. */
  121680. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  121681. }
  121682. /**
  121683. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  121684. */
  121685. export class PassCubePostProcess extends PostProcess {
  121686. private _face;
  121687. /**
  121688. * Gets or sets the cube face to display.
  121689. * * 0 is +X
  121690. * * 1 is -X
  121691. * * 2 is +Y
  121692. * * 3 is -Y
  121693. * * 4 is +Z
  121694. * * 5 is -Z
  121695. */
  121696. get face(): number;
  121697. set face(value: number);
  121698. /**
  121699. * Creates the PassCubePostProcess
  121700. * @param name The name of the effect.
  121701. * @param options The required width/height ratio to downsize to before computing the render pass.
  121702. * @param camera The camera to apply the render pass to.
  121703. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  121704. * @param engine The engine which the post process will be applied. (default: current engine)
  121705. * @param reusable If the post process can be reused on the same frame. (default: false)
  121706. * @param textureType The type of texture to be used when performing the post processing.
  121707. * @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)
  121708. */
  121709. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  121710. }
  121711. }
  121712. declare module BABYLON {
  121713. /** @hidden */
  121714. export var anaglyphPixelShader: {
  121715. name: string;
  121716. shader: string;
  121717. };
  121718. }
  121719. declare module BABYLON {
  121720. /**
  121721. * Postprocess used to generate anaglyphic rendering
  121722. */
  121723. export class AnaglyphPostProcess extends PostProcess {
  121724. private _passedProcess;
  121725. /**
  121726. * Creates a new AnaglyphPostProcess
  121727. * @param name defines postprocess name
  121728. * @param options defines creation options or target ratio scale
  121729. * @param rigCameras defines cameras using this postprocess
  121730. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  121731. * @param engine defines hosting engine
  121732. * @param reusable defines if the postprocess will be reused multiple times per frame
  121733. */
  121734. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  121735. }
  121736. }
  121737. declare module BABYLON {
  121738. /**
  121739. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  121740. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  121741. */
  121742. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  121743. /**
  121744. * Creates a new AnaglyphArcRotateCamera
  121745. * @param name defines camera name
  121746. * @param alpha defines alpha angle (in radians)
  121747. * @param beta defines beta angle (in radians)
  121748. * @param radius defines radius
  121749. * @param target defines camera target
  121750. * @param interaxialDistance defines distance between each color axis
  121751. * @param scene defines the hosting scene
  121752. */
  121753. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  121754. /**
  121755. * Gets camera class name
  121756. * @returns AnaglyphArcRotateCamera
  121757. */
  121758. getClassName(): string;
  121759. }
  121760. }
  121761. declare module BABYLON {
  121762. /**
  121763. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  121764. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  121765. */
  121766. export class AnaglyphFreeCamera extends FreeCamera {
  121767. /**
  121768. * Creates a new AnaglyphFreeCamera
  121769. * @param name defines camera name
  121770. * @param position defines initial position
  121771. * @param interaxialDistance defines distance between each color axis
  121772. * @param scene defines the hosting scene
  121773. */
  121774. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  121775. /**
  121776. * Gets camera class name
  121777. * @returns AnaglyphFreeCamera
  121778. */
  121779. getClassName(): string;
  121780. }
  121781. }
  121782. declare module BABYLON {
  121783. /**
  121784. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  121785. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  121786. */
  121787. export class AnaglyphGamepadCamera extends GamepadCamera {
  121788. /**
  121789. * Creates a new AnaglyphGamepadCamera
  121790. * @param name defines camera name
  121791. * @param position defines initial position
  121792. * @param interaxialDistance defines distance between each color axis
  121793. * @param scene defines the hosting scene
  121794. */
  121795. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  121796. /**
  121797. * Gets camera class name
  121798. * @returns AnaglyphGamepadCamera
  121799. */
  121800. getClassName(): string;
  121801. }
  121802. }
  121803. declare module BABYLON {
  121804. /**
  121805. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  121806. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  121807. */
  121808. export class AnaglyphUniversalCamera extends UniversalCamera {
  121809. /**
  121810. * Creates a new AnaglyphUniversalCamera
  121811. * @param name defines camera name
  121812. * @param position defines initial position
  121813. * @param interaxialDistance defines distance between each color axis
  121814. * @param scene defines the hosting scene
  121815. */
  121816. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  121817. /**
  121818. * Gets camera class name
  121819. * @returns AnaglyphUniversalCamera
  121820. */
  121821. getClassName(): string;
  121822. }
  121823. }
  121824. declare module BABYLON {
  121825. /**
  121826. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  121827. * @see http://doc.babylonjs.com/features/cameras
  121828. */
  121829. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  121830. /**
  121831. * Creates a new StereoscopicArcRotateCamera
  121832. * @param name defines camera name
  121833. * @param alpha defines alpha angle (in radians)
  121834. * @param beta defines beta angle (in radians)
  121835. * @param radius defines radius
  121836. * @param target defines camera target
  121837. * @param interaxialDistance defines distance between each color axis
  121838. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  121839. * @param scene defines the hosting scene
  121840. */
  121841. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  121842. /**
  121843. * Gets camera class name
  121844. * @returns StereoscopicArcRotateCamera
  121845. */
  121846. getClassName(): string;
  121847. }
  121848. }
  121849. declare module BABYLON {
  121850. /**
  121851. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  121852. * @see http://doc.babylonjs.com/features/cameras
  121853. */
  121854. export class StereoscopicFreeCamera extends FreeCamera {
  121855. /**
  121856. * Creates a new StereoscopicFreeCamera
  121857. * @param name defines camera name
  121858. * @param position defines initial position
  121859. * @param interaxialDistance defines distance between each color axis
  121860. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  121861. * @param scene defines the hosting scene
  121862. */
  121863. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  121864. /**
  121865. * Gets camera class name
  121866. * @returns StereoscopicFreeCamera
  121867. */
  121868. getClassName(): string;
  121869. }
  121870. }
  121871. declare module BABYLON {
  121872. /**
  121873. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  121874. * @see http://doc.babylonjs.com/features/cameras
  121875. */
  121876. export class StereoscopicGamepadCamera extends GamepadCamera {
  121877. /**
  121878. * Creates a new StereoscopicGamepadCamera
  121879. * @param name defines camera name
  121880. * @param position defines initial position
  121881. * @param interaxialDistance defines distance between each color axis
  121882. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  121883. * @param scene defines the hosting scene
  121884. */
  121885. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  121886. /**
  121887. * Gets camera class name
  121888. * @returns StereoscopicGamepadCamera
  121889. */
  121890. getClassName(): string;
  121891. }
  121892. }
  121893. declare module BABYLON {
  121894. /**
  121895. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  121896. * @see http://doc.babylonjs.com/features/cameras
  121897. */
  121898. export class StereoscopicUniversalCamera extends UniversalCamera {
  121899. /**
  121900. * Creates a new StereoscopicUniversalCamera
  121901. * @param name defines camera name
  121902. * @param position defines initial position
  121903. * @param interaxialDistance defines distance between each color axis
  121904. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  121905. * @param scene defines the hosting scene
  121906. */
  121907. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  121908. /**
  121909. * Gets camera class name
  121910. * @returns StereoscopicUniversalCamera
  121911. */
  121912. getClassName(): string;
  121913. }
  121914. }
  121915. declare module BABYLON {
  121916. /**
  121917. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  121918. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  121919. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  121920. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  121921. */
  121922. export class VirtualJoysticksCamera extends FreeCamera {
  121923. /**
  121924. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  121925. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  121926. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  121927. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  121928. * @param name Define the name of the camera in the scene
  121929. * @param position Define the start position of the camera in the scene
  121930. * @param scene Define the scene the camera belongs to
  121931. */
  121932. constructor(name: string, position: Vector3, scene: Scene);
  121933. /**
  121934. * Gets the current object class name.
  121935. * @return the class name
  121936. */
  121937. getClassName(): string;
  121938. }
  121939. }
  121940. declare module BABYLON {
  121941. /**
  121942. * This represents all the required metrics to create a VR camera.
  121943. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  121944. */
  121945. export class VRCameraMetrics {
  121946. /**
  121947. * Define the horizontal resolution off the screen.
  121948. */
  121949. hResolution: number;
  121950. /**
  121951. * Define the vertical resolution off the screen.
  121952. */
  121953. vResolution: number;
  121954. /**
  121955. * Define the horizontal screen size.
  121956. */
  121957. hScreenSize: number;
  121958. /**
  121959. * Define the vertical screen size.
  121960. */
  121961. vScreenSize: number;
  121962. /**
  121963. * Define the vertical screen center position.
  121964. */
  121965. vScreenCenter: number;
  121966. /**
  121967. * Define the distance of the eyes to the screen.
  121968. */
  121969. eyeToScreenDistance: number;
  121970. /**
  121971. * Define the distance between both lenses
  121972. */
  121973. lensSeparationDistance: number;
  121974. /**
  121975. * Define the distance between both viewer's eyes.
  121976. */
  121977. interpupillaryDistance: number;
  121978. /**
  121979. * Define the distortion factor of the VR postprocess.
  121980. * Please, touch with care.
  121981. */
  121982. distortionK: number[];
  121983. /**
  121984. * Define the chromatic aberration correction factors for the VR post process.
  121985. */
  121986. chromaAbCorrection: number[];
  121987. /**
  121988. * Define the scale factor of the post process.
  121989. * The smaller the better but the slower.
  121990. */
  121991. postProcessScaleFactor: number;
  121992. /**
  121993. * Define an offset for the lens center.
  121994. */
  121995. lensCenterOffset: number;
  121996. /**
  121997. * Define if the current vr camera should compensate the distortion of the lense or not.
  121998. */
  121999. compensateDistortion: boolean;
  122000. /**
  122001. * Defines if multiview should be enabled when rendering (Default: false)
  122002. */
  122003. multiviewEnabled: boolean;
  122004. /**
  122005. * Gets the rendering aspect ratio based on the provided resolutions.
  122006. */
  122007. get aspectRatio(): number;
  122008. /**
  122009. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  122010. */
  122011. get aspectRatioFov(): number;
  122012. /**
  122013. * @hidden
  122014. */
  122015. get leftHMatrix(): Matrix;
  122016. /**
  122017. * @hidden
  122018. */
  122019. get rightHMatrix(): Matrix;
  122020. /**
  122021. * @hidden
  122022. */
  122023. get leftPreViewMatrix(): Matrix;
  122024. /**
  122025. * @hidden
  122026. */
  122027. get rightPreViewMatrix(): Matrix;
  122028. /**
  122029. * Get the default VRMetrics based on the most generic setup.
  122030. * @returns the default vr metrics
  122031. */
  122032. static GetDefault(): VRCameraMetrics;
  122033. }
  122034. }
  122035. declare module BABYLON {
  122036. /** @hidden */
  122037. export var vrDistortionCorrectionPixelShader: {
  122038. name: string;
  122039. shader: string;
  122040. };
  122041. }
  122042. declare module BABYLON {
  122043. /**
  122044. * VRDistortionCorrectionPostProcess used for mobile VR
  122045. */
  122046. export class VRDistortionCorrectionPostProcess extends PostProcess {
  122047. private _isRightEye;
  122048. private _distortionFactors;
  122049. private _postProcessScaleFactor;
  122050. private _lensCenterOffset;
  122051. private _scaleIn;
  122052. private _scaleFactor;
  122053. private _lensCenter;
  122054. /**
  122055. * Initializes the VRDistortionCorrectionPostProcess
  122056. * @param name The name of the effect.
  122057. * @param camera The camera to apply the render pass to.
  122058. * @param isRightEye If this is for the right eye distortion
  122059. * @param vrMetrics All the required metrics for the VR camera
  122060. */
  122061. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  122062. }
  122063. }
  122064. declare module BABYLON {
  122065. /**
  122066. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  122067. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  122068. */
  122069. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  122070. /**
  122071. * Creates a new VRDeviceOrientationArcRotateCamera
  122072. * @param name defines camera name
  122073. * @param alpha defines the camera rotation along the logitudinal axis
  122074. * @param beta defines the camera rotation along the latitudinal axis
  122075. * @param radius defines the camera distance from its target
  122076. * @param target defines the camera target
  122077. * @param scene defines the scene the camera belongs to
  122078. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  122079. * @param vrCameraMetrics defines the vr metrics associated to the camera
  122080. */
  122081. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  122082. /**
  122083. * Gets camera class name
  122084. * @returns VRDeviceOrientationArcRotateCamera
  122085. */
  122086. getClassName(): string;
  122087. }
  122088. }
  122089. declare module BABYLON {
  122090. /**
  122091. * Camera used to simulate VR rendering (based on FreeCamera)
  122092. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  122093. */
  122094. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  122095. /**
  122096. * Creates a new VRDeviceOrientationFreeCamera
  122097. * @param name defines camera name
  122098. * @param position defines the start position of the camera
  122099. * @param scene defines the scene the camera belongs to
  122100. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  122101. * @param vrCameraMetrics defines the vr metrics associated to the camera
  122102. */
  122103. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  122104. /**
  122105. * Gets camera class name
  122106. * @returns VRDeviceOrientationFreeCamera
  122107. */
  122108. getClassName(): string;
  122109. }
  122110. }
  122111. declare module BABYLON {
  122112. /**
  122113. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  122114. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  122115. */
  122116. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  122117. /**
  122118. * Creates a new VRDeviceOrientationGamepadCamera
  122119. * @param name defines camera name
  122120. * @param position defines the start position of the camera
  122121. * @param scene defines the scene the camera belongs to
  122122. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  122123. * @param vrCameraMetrics defines the vr metrics associated to the camera
  122124. */
  122125. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  122126. /**
  122127. * Gets camera class name
  122128. * @returns VRDeviceOrientationGamepadCamera
  122129. */
  122130. getClassName(): string;
  122131. }
  122132. }
  122133. declare module BABYLON {
  122134. /** @hidden */
  122135. export var imageProcessingPixelShader: {
  122136. name: string;
  122137. shader: string;
  122138. };
  122139. }
  122140. declare module BABYLON {
  122141. /**
  122142. * ImageProcessingPostProcess
  122143. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  122144. */
  122145. export class ImageProcessingPostProcess extends PostProcess {
  122146. /**
  122147. * Default configuration related to image processing available in the PBR Material.
  122148. */
  122149. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  122150. /**
  122151. * Gets the image processing configuration used either in this material.
  122152. */
  122153. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  122154. /**
  122155. * Sets the Default image processing configuration used either in the this material.
  122156. *
  122157. * If sets to null, the scene one is in use.
  122158. */
  122159. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  122160. /**
  122161. * Keep track of the image processing observer to allow dispose and replace.
  122162. */
  122163. private _imageProcessingObserver;
  122164. /**
  122165. * Attaches a new image processing configuration to the PBR Material.
  122166. * @param configuration
  122167. */
  122168. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  122169. /**
  122170. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  122171. */
  122172. get colorCurves(): Nullable<ColorCurves>;
  122173. /**
  122174. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  122175. */
  122176. set colorCurves(value: Nullable<ColorCurves>);
  122177. /**
  122178. * Gets wether the color curves effect is enabled.
  122179. */
  122180. get colorCurvesEnabled(): boolean;
  122181. /**
  122182. * Sets wether the color curves effect is enabled.
  122183. */
  122184. set colorCurvesEnabled(value: boolean);
  122185. /**
  122186. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  122187. */
  122188. get colorGradingTexture(): Nullable<BaseTexture>;
  122189. /**
  122190. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  122191. */
  122192. set colorGradingTexture(value: Nullable<BaseTexture>);
  122193. /**
  122194. * Gets wether the color grading effect is enabled.
  122195. */
  122196. get colorGradingEnabled(): boolean;
  122197. /**
  122198. * Gets wether the color grading effect is enabled.
  122199. */
  122200. set colorGradingEnabled(value: boolean);
  122201. /**
  122202. * Gets exposure used in the effect.
  122203. */
  122204. get exposure(): number;
  122205. /**
  122206. * Sets exposure used in the effect.
  122207. */
  122208. set exposure(value: number);
  122209. /**
  122210. * Gets wether tonemapping is enabled or not.
  122211. */
  122212. get toneMappingEnabled(): boolean;
  122213. /**
  122214. * Sets wether tonemapping is enabled or not
  122215. */
  122216. set toneMappingEnabled(value: boolean);
  122217. /**
  122218. * Gets the type of tone mapping effect.
  122219. */
  122220. get toneMappingType(): number;
  122221. /**
  122222. * Sets the type of tone mapping effect.
  122223. */
  122224. set toneMappingType(value: number);
  122225. /**
  122226. * Gets contrast used in the effect.
  122227. */
  122228. get contrast(): number;
  122229. /**
  122230. * Sets contrast used in the effect.
  122231. */
  122232. set contrast(value: number);
  122233. /**
  122234. * Gets Vignette stretch size.
  122235. */
  122236. get vignetteStretch(): number;
  122237. /**
  122238. * Sets Vignette stretch size.
  122239. */
  122240. set vignetteStretch(value: number);
  122241. /**
  122242. * Gets Vignette centre X Offset.
  122243. */
  122244. get vignetteCentreX(): number;
  122245. /**
  122246. * Sets Vignette centre X Offset.
  122247. */
  122248. set vignetteCentreX(value: number);
  122249. /**
  122250. * Gets Vignette centre Y Offset.
  122251. */
  122252. get vignetteCentreY(): number;
  122253. /**
  122254. * Sets Vignette centre Y Offset.
  122255. */
  122256. set vignetteCentreY(value: number);
  122257. /**
  122258. * Gets Vignette weight or intensity of the vignette effect.
  122259. */
  122260. get vignetteWeight(): number;
  122261. /**
  122262. * Sets Vignette weight or intensity of the vignette effect.
  122263. */
  122264. set vignetteWeight(value: number);
  122265. /**
  122266. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  122267. * if vignetteEnabled is set to true.
  122268. */
  122269. get vignetteColor(): Color4;
  122270. /**
  122271. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  122272. * if vignetteEnabled is set to true.
  122273. */
  122274. set vignetteColor(value: Color4);
  122275. /**
  122276. * Gets Camera field of view used by the Vignette effect.
  122277. */
  122278. get vignetteCameraFov(): number;
  122279. /**
  122280. * Sets Camera field of view used by the Vignette effect.
  122281. */
  122282. set vignetteCameraFov(value: number);
  122283. /**
  122284. * Gets the vignette blend mode allowing different kind of effect.
  122285. */
  122286. get vignetteBlendMode(): number;
  122287. /**
  122288. * Sets the vignette blend mode allowing different kind of effect.
  122289. */
  122290. set vignetteBlendMode(value: number);
  122291. /**
  122292. * Gets wether the vignette effect is enabled.
  122293. */
  122294. get vignetteEnabled(): boolean;
  122295. /**
  122296. * Sets wether the vignette effect is enabled.
  122297. */
  122298. set vignetteEnabled(value: boolean);
  122299. private _fromLinearSpace;
  122300. /**
  122301. * Gets wether the input of the processing is in Gamma or Linear Space.
  122302. */
  122303. get fromLinearSpace(): boolean;
  122304. /**
  122305. * Sets wether the input of the processing is in Gamma or Linear Space.
  122306. */
  122307. set fromLinearSpace(value: boolean);
  122308. /**
  122309. * Defines cache preventing GC.
  122310. */
  122311. private _defines;
  122312. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  122313. /**
  122314. * "ImageProcessingPostProcess"
  122315. * @returns "ImageProcessingPostProcess"
  122316. */
  122317. getClassName(): string;
  122318. protected _updateParameters(): void;
  122319. dispose(camera?: Camera): void;
  122320. }
  122321. }
  122322. declare module BABYLON {
  122323. /**
  122324. * Class containing static functions to help procedurally build meshes
  122325. */
  122326. export class GroundBuilder {
  122327. /**
  122328. * Creates a ground mesh
  122329. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  122330. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  122331. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122332. * @param name defines the name of the mesh
  122333. * @param options defines the options used to create the mesh
  122334. * @param scene defines the hosting scene
  122335. * @returns the ground mesh
  122336. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  122337. */
  122338. static CreateGround(name: string, options: {
  122339. width?: number;
  122340. height?: number;
  122341. subdivisions?: number;
  122342. subdivisionsX?: number;
  122343. subdivisionsY?: number;
  122344. updatable?: boolean;
  122345. }, scene: any): Mesh;
  122346. /**
  122347. * Creates a tiled ground mesh
  122348. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  122349. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  122350. * * 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
  122351. * * 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
  122352. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  122353. * @param name defines the name of the mesh
  122354. * @param options defines the options used to create the mesh
  122355. * @param scene defines the hosting scene
  122356. * @returns the tiled ground mesh
  122357. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  122358. */
  122359. static CreateTiledGround(name: string, options: {
  122360. xmin: number;
  122361. zmin: number;
  122362. xmax: number;
  122363. zmax: number;
  122364. subdivisions?: {
  122365. w: number;
  122366. h: number;
  122367. };
  122368. precision?: {
  122369. w: number;
  122370. h: number;
  122371. };
  122372. updatable?: boolean;
  122373. }, scene?: Nullable<Scene>): Mesh;
  122374. /**
  122375. * Creates a ground mesh from a height map
  122376. * * The parameter `url` sets the URL of the height map image resource.
  122377. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  122378. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  122379. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  122380. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  122381. * * 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.
  122382. * * 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).
  122383. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  122384. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  122385. * @param name defines the name of the mesh
  122386. * @param url defines the url to the height map
  122387. * @param options defines the options used to create the mesh
  122388. * @param scene defines the hosting scene
  122389. * @returns the ground mesh
  122390. * @see https://doc.babylonjs.com/babylon101/height_map
  122391. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  122392. */
  122393. static CreateGroundFromHeightMap(name: string, url: string, options: {
  122394. width?: number;
  122395. height?: number;
  122396. subdivisions?: number;
  122397. minHeight?: number;
  122398. maxHeight?: number;
  122399. colorFilter?: Color3;
  122400. alphaFilter?: number;
  122401. updatable?: boolean;
  122402. onReady?: (mesh: GroundMesh) => void;
  122403. }, scene?: Nullable<Scene>): GroundMesh;
  122404. }
  122405. }
  122406. declare module BABYLON {
  122407. /**
  122408. * Class containing static functions to help procedurally build meshes
  122409. */
  122410. export class TorusBuilder {
  122411. /**
  122412. * Creates a torus mesh
  122413. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  122414. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  122415. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  122416. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  122417. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122418. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  122419. * @param name defines the name of the mesh
  122420. * @param options defines the options used to create the mesh
  122421. * @param scene defines the hosting scene
  122422. * @returns the torus mesh
  122423. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  122424. */
  122425. static CreateTorus(name: string, options: {
  122426. diameter?: number;
  122427. thickness?: number;
  122428. tessellation?: number;
  122429. updatable?: boolean;
  122430. sideOrientation?: number;
  122431. frontUVs?: Vector4;
  122432. backUVs?: Vector4;
  122433. }, scene: any): Mesh;
  122434. }
  122435. }
  122436. declare module BABYLON {
  122437. /**
  122438. * Class containing static functions to help procedurally build meshes
  122439. */
  122440. export class CylinderBuilder {
  122441. /**
  122442. * Creates a cylinder or a cone mesh
  122443. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  122444. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  122445. * * 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.
  122446. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  122447. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  122448. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  122449. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  122450. * * 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).
  122451. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  122452. * * 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).
  122453. * * 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
  122454. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  122455. * * 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
  122456. * * 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.
  122457. * * If `enclose` is false, a ring surface is one element.
  122458. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  122459. * * 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
  122460. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  122461. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122462. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  122463. * @param name defines the name of the mesh
  122464. * @param options defines the options used to create the mesh
  122465. * @param scene defines the hosting scene
  122466. * @returns the cylinder mesh
  122467. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  122468. */
  122469. static CreateCylinder(name: string, options: {
  122470. height?: number;
  122471. diameterTop?: number;
  122472. diameterBottom?: number;
  122473. diameter?: number;
  122474. tessellation?: number;
  122475. subdivisions?: number;
  122476. arc?: number;
  122477. faceColors?: Color4[];
  122478. faceUV?: Vector4[];
  122479. updatable?: boolean;
  122480. hasRings?: boolean;
  122481. enclose?: boolean;
  122482. cap?: number;
  122483. sideOrientation?: number;
  122484. frontUVs?: Vector4;
  122485. backUVs?: Vector4;
  122486. }, scene: any): Mesh;
  122487. }
  122488. }
  122489. declare module BABYLON {
  122490. /**
  122491. * States of the webXR experience
  122492. */
  122493. export enum WebXRState {
  122494. /**
  122495. * Transitioning to being in XR mode
  122496. */
  122497. ENTERING_XR = 0,
  122498. /**
  122499. * Transitioning to non XR mode
  122500. */
  122501. EXITING_XR = 1,
  122502. /**
  122503. * In XR mode and presenting
  122504. */
  122505. IN_XR = 2,
  122506. /**
  122507. * Not entered XR mode
  122508. */
  122509. NOT_IN_XR = 3
  122510. }
  122511. /**
  122512. * Abstraction of the XR render target
  122513. */
  122514. export interface WebXRRenderTarget extends IDisposable {
  122515. /**
  122516. * xrpresent context of the canvas which can be used to display/mirror xr content
  122517. */
  122518. canvasContext: WebGLRenderingContext;
  122519. /**
  122520. * xr layer for the canvas
  122521. */
  122522. xrLayer: Nullable<XRWebGLLayer>;
  122523. /**
  122524. * Initializes the xr layer for the session
  122525. * @param xrSession xr session
  122526. * @returns a promise that will resolve once the XR Layer has been created
  122527. */
  122528. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  122529. }
  122530. }
  122531. declare module BABYLON {
  122532. /**
  122533. * COnfiguration object for WebXR output canvas
  122534. */
  122535. export class WebXRManagedOutputCanvasOptions {
  122536. /**
  122537. * An optional canvas in case you wish to create it yourself and provide it here.
  122538. * If not provided, a new canvas will be created
  122539. */
  122540. canvasElement?: HTMLCanvasElement;
  122541. /**
  122542. * Options for this XR Layer output
  122543. */
  122544. canvasOptions?: XRWebGLLayerOptions;
  122545. /**
  122546. * CSS styling for a newly created canvas (if not provided)
  122547. */
  122548. newCanvasCssStyle?: string;
  122549. /**
  122550. * Get the default values of the configuration object
  122551. * @returns default values of this configuration object
  122552. */
  122553. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  122554. }
  122555. /**
  122556. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  122557. */
  122558. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  122559. private _options;
  122560. private _canvas;
  122561. private _engine;
  122562. /**
  122563. * Rendering context of the canvas which can be used to display/mirror xr content
  122564. */
  122565. canvasContext: WebGLRenderingContext;
  122566. /**
  122567. * xr layer for the canvas
  122568. */
  122569. xrLayer: Nullable<XRWebGLLayer>;
  122570. /**
  122571. * Initializes the canvas to be added/removed upon entering/exiting xr
  122572. * @param _xrSessionManager The XR Session manager
  122573. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  122574. */
  122575. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  122576. /**
  122577. * Disposes of the object
  122578. */
  122579. dispose(): void;
  122580. /**
  122581. * Initializes the xr layer for the session
  122582. * @param xrSession xr session
  122583. * @returns a promise that will resolve once the XR Layer has been created
  122584. */
  122585. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  122586. private _addCanvas;
  122587. private _removeCanvas;
  122588. private _setManagedOutputCanvas;
  122589. }
  122590. }
  122591. declare module BABYLON {
  122592. /**
  122593. * Manages an XRSession to work with Babylon's engine
  122594. * @see https://doc.babylonjs.com/how_to/webxr
  122595. */
  122596. export class WebXRSessionManager implements IDisposable {
  122597. /** The scene which the session should be created for */
  122598. scene: Scene;
  122599. private _referenceSpace;
  122600. private _rttProvider;
  122601. private _sessionEnded;
  122602. private _xrNavigator;
  122603. private baseLayer;
  122604. /**
  122605. * The base reference space from which the session started. good if you want to reset your
  122606. * reference space
  122607. */
  122608. baseReferenceSpace: XRReferenceSpace;
  122609. /**
  122610. * Current XR frame
  122611. */
  122612. currentFrame: Nullable<XRFrame>;
  122613. /** WebXR timestamp updated every frame */
  122614. currentTimestamp: number;
  122615. /**
  122616. * Used just in case of a failure to initialize an immersive session.
  122617. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  122618. */
  122619. defaultHeightCompensation: number;
  122620. /**
  122621. * Fires every time a new xrFrame arrives which can be used to update the camera
  122622. */
  122623. onXRFrameObservable: Observable<XRFrame>;
  122624. /**
  122625. * Fires when the reference space changed
  122626. */
  122627. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  122628. /**
  122629. * Fires when the xr session is ended either by the device or manually done
  122630. */
  122631. onXRSessionEnded: Observable<any>;
  122632. /**
  122633. * Fires when the xr session is ended either by the device or manually done
  122634. */
  122635. onXRSessionInit: Observable<XRSession>;
  122636. /**
  122637. * Underlying xr session
  122638. */
  122639. session: XRSession;
  122640. /**
  122641. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  122642. * or get the offset the player is currently at.
  122643. */
  122644. viewerReferenceSpace: XRReferenceSpace;
  122645. /**
  122646. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  122647. * @param scene The scene which the session should be created for
  122648. */
  122649. constructor(
  122650. /** The scene which the session should be created for */
  122651. scene: Scene);
  122652. /**
  122653. * The current reference space used in this session. This reference space can constantly change!
  122654. * It is mainly used to offset the camera's position.
  122655. */
  122656. get referenceSpace(): XRReferenceSpace;
  122657. /**
  122658. * Set a new reference space and triggers the observable
  122659. */
  122660. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  122661. /**
  122662. * Disposes of the session manager
  122663. */
  122664. dispose(): void;
  122665. /**
  122666. * Stops the xrSession and restores the render loop
  122667. * @returns Promise which resolves after it exits XR
  122668. */
  122669. exitXRAsync(): Promise<void>;
  122670. /**
  122671. * Gets the correct render target texture to be rendered this frame for this eye
  122672. * @param eye the eye for which to get the render target
  122673. * @returns the render target for the specified eye
  122674. */
  122675. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  122676. /**
  122677. * Creates a WebXRRenderTarget object for the XR session
  122678. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  122679. * @param options optional options to provide when creating a new render target
  122680. * @returns a WebXR render target to which the session can render
  122681. */
  122682. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  122683. /**
  122684. * Initializes the manager
  122685. * After initialization enterXR can be called to start an XR session
  122686. * @returns Promise which resolves after it is initialized
  122687. */
  122688. initializeAsync(): Promise<void>;
  122689. /**
  122690. * Initializes an xr session
  122691. * @param xrSessionMode mode to initialize
  122692. * @param xrSessionInit defines optional and required values to pass to the session builder
  122693. * @returns a promise which will resolve once the session has been initialized
  122694. */
  122695. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  122696. /**
  122697. * Checks if a session would be supported for the creation options specified
  122698. * @param sessionMode session mode to check if supported eg. immersive-vr
  122699. * @returns A Promise that resolves to true if supported and false if not
  122700. */
  122701. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  122702. /**
  122703. * Resets the reference space to the one started the session
  122704. */
  122705. resetReferenceSpace(): void;
  122706. /**
  122707. * Starts rendering to the xr layer
  122708. */
  122709. runXRRenderLoop(): void;
  122710. /**
  122711. * Sets the reference space on the xr session
  122712. * @param referenceSpaceType space to set
  122713. * @returns a promise that will resolve once the reference space has been set
  122714. */
  122715. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  122716. /**
  122717. * Updates the render state of the session
  122718. * @param state state to set
  122719. * @returns a promise that resolves once the render state has been updated
  122720. */
  122721. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  122722. /**
  122723. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  122724. * @param sessionMode defines the session to test
  122725. * @returns a promise with boolean as final value
  122726. */
  122727. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  122728. private _createRenderTargetTexture;
  122729. }
  122730. }
  122731. declare module BABYLON {
  122732. /**
  122733. * WebXR Camera which holds the views for the xrSession
  122734. * @see https://doc.babylonjs.com/how_to/webxr_camera
  122735. */
  122736. export class WebXRCamera extends FreeCamera {
  122737. private _xrSessionManager;
  122738. private _firstFrame;
  122739. private _referenceQuaternion;
  122740. private _referencedPosition;
  122741. private _xrInvPositionCache;
  122742. private _xrInvQuaternionCache;
  122743. /**
  122744. * Should position compensation execute on first frame.
  122745. * This is used when copying the position from a native (non XR) camera
  122746. */
  122747. compensateOnFirstFrame: boolean;
  122748. /**
  122749. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  122750. * @param name the name of the camera
  122751. * @param scene the scene to add the camera to
  122752. * @param _xrSessionManager a constructed xr session manager
  122753. */
  122754. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  122755. /**
  122756. * Return the user's height, unrelated to the current ground.
  122757. * This will be the y position of this camera, when ground level is 0.
  122758. */
  122759. get realWorldHeight(): number;
  122760. /** @hidden */
  122761. _updateForDualEyeDebugging(): void;
  122762. /**
  122763. * Sets this camera's transformation based on a non-vr camera
  122764. * @param otherCamera the non-vr camera to copy the transformation from
  122765. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  122766. */
  122767. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  122768. /**
  122769. * Gets the current instance class name ("WebXRCamera").
  122770. * @returns the class name
  122771. */
  122772. getClassName(): string;
  122773. /**
  122774. * Overriding the _getViewMatrix function, as it is computed by WebXR
  122775. */
  122776. _getViewMatrix(): Matrix;
  122777. private _updateFromXRSession;
  122778. private _updateNumberOfRigCameras;
  122779. private _updateReferenceSpace;
  122780. private _updateReferenceSpaceOffset;
  122781. }
  122782. }
  122783. declare module BABYLON {
  122784. /**
  122785. * Defining the interface required for a (webxr) feature
  122786. */
  122787. export interface IWebXRFeature extends IDisposable {
  122788. /**
  122789. * Is this feature attached
  122790. */
  122791. attached: boolean;
  122792. /**
  122793. * Should auto-attach be disabled?
  122794. */
  122795. disableAutoAttach: boolean;
  122796. /**
  122797. * Attach the feature to the session
  122798. * Will usually be called by the features manager
  122799. *
  122800. * @param force should attachment be forced (even when already attached)
  122801. * @returns true if successful.
  122802. */
  122803. attach(force?: boolean): boolean;
  122804. /**
  122805. * Detach the feature from the session
  122806. * Will usually be called by the features manager
  122807. *
  122808. * @returns true if successful.
  122809. */
  122810. detach(): boolean;
  122811. }
  122812. /**
  122813. * A list of the currently available features without referencing them
  122814. */
  122815. export class WebXRFeatureName {
  122816. /**
  122817. * The name of the anchor system feature
  122818. */
  122819. static ANCHOR_SYSTEM: string;
  122820. /**
  122821. * The name of the background remover feature
  122822. */
  122823. static BACKGROUND_REMOVER: string;
  122824. /**
  122825. * The name of the hit test feature
  122826. */
  122827. static HIT_TEST: string;
  122828. /**
  122829. * physics impostors for xr controllers feature
  122830. */
  122831. static PHYSICS_CONTROLLERS: string;
  122832. /**
  122833. * The name of the plane detection feature
  122834. */
  122835. static PLANE_DETECTION: string;
  122836. /**
  122837. * The name of the pointer selection feature
  122838. */
  122839. static POINTER_SELECTION: string;
  122840. /**
  122841. * The name of the teleportation feature
  122842. */
  122843. static TELEPORTATION: string;
  122844. }
  122845. /**
  122846. * Defining the constructor of a feature. Used to register the modules.
  122847. */
  122848. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  122849. /**
  122850. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  122851. * It is mainly used in AR sessions.
  122852. *
  122853. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  122854. */
  122855. export class WebXRFeaturesManager implements IDisposable {
  122856. private _xrSessionManager;
  122857. private static readonly _AvailableFeatures;
  122858. private _features;
  122859. /**
  122860. * constructs a new features manages.
  122861. *
  122862. * @param _xrSessionManager an instance of WebXRSessionManager
  122863. */
  122864. constructor(_xrSessionManager: WebXRSessionManager);
  122865. /**
  122866. * Used to register a module. After calling this function a developer can use this feature in the scene.
  122867. * Mainly used internally.
  122868. *
  122869. * @param featureName the name of the feature to register
  122870. * @param constructorFunction the function used to construct the module
  122871. * @param version the (babylon) version of the module
  122872. * @param stable is that a stable version of this module
  122873. */
  122874. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  122875. /**
  122876. * Returns a constructor of a specific feature.
  122877. *
  122878. * @param featureName the name of the feature to construct
  122879. * @param version the version of the feature to load
  122880. * @param xrSessionManager the xrSessionManager. Used to construct the module
  122881. * @param options optional options provided to the module.
  122882. * @returns a function that, when called, will return a new instance of this feature
  122883. */
  122884. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  122885. /**
  122886. * Can be used to return the list of features currently registered
  122887. *
  122888. * @returns an Array of available features
  122889. */
  122890. static GetAvailableFeatures(): string[];
  122891. /**
  122892. * Gets the versions available for a specific feature
  122893. * @param featureName the name of the feature
  122894. * @returns an array with the available versions
  122895. */
  122896. static GetAvailableVersions(featureName: string): string[];
  122897. /**
  122898. * Return the latest unstable version of this feature
  122899. * @param featureName the name of the feature to search
  122900. * @returns the version number. if not found will return -1
  122901. */
  122902. static GetLatestVersionOfFeature(featureName: string): number;
  122903. /**
  122904. * Return the latest stable version of this feature
  122905. * @param featureName the name of the feature to search
  122906. * @returns the version number. if not found will return -1
  122907. */
  122908. static GetStableVersionOfFeature(featureName: string): number;
  122909. /**
  122910. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  122911. * Can be used during a session to start a feature
  122912. * @param featureName the name of feature to attach
  122913. */
  122914. attachFeature(featureName: string): void;
  122915. /**
  122916. * Can be used inside a session or when the session ends to detach a specific feature
  122917. * @param featureName the name of the feature to detach
  122918. */
  122919. detachFeature(featureName: string): void;
  122920. /**
  122921. * Used to disable an already-enabled feature
  122922. * The feature will be disposed and will be recreated once enabled.
  122923. * @param featureName the feature to disable
  122924. * @returns true if disable was successful
  122925. */
  122926. disableFeature(featureName: string | {
  122927. Name: string;
  122928. }): boolean;
  122929. /**
  122930. * dispose this features manager
  122931. */
  122932. dispose(): void;
  122933. /**
  122934. * 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.
  122935. * 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.
  122936. *
  122937. * @param featureName the name of the feature to load or the class of the feature
  122938. * @param version optional version to load. if not provided the latest version will be enabled
  122939. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  122940. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  122941. * @returns a new constructed feature or throws an error if feature not found.
  122942. */
  122943. enableFeature(featureName: string | {
  122944. Name: string;
  122945. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  122946. /**
  122947. * get the implementation of an enabled feature.
  122948. * @param featureName the name of the feature to load
  122949. * @returns the feature class, if found
  122950. */
  122951. getEnabledFeature(featureName: string): IWebXRFeature;
  122952. /**
  122953. * Get the list of enabled features
  122954. * @returns an array of enabled features
  122955. */
  122956. getEnabledFeatures(): string[];
  122957. }
  122958. }
  122959. declare module BABYLON {
  122960. /**
  122961. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  122962. * @see https://doc.babylonjs.com/how_to/webxr
  122963. */
  122964. export class WebXRExperienceHelper implements IDisposable {
  122965. private scene;
  122966. private _nonVRCamera;
  122967. private _originalSceneAutoClear;
  122968. private _supported;
  122969. /**
  122970. * Camera used to render xr content
  122971. */
  122972. camera: WebXRCamera;
  122973. /** A features manager for this xr session */
  122974. featuresManager: WebXRFeaturesManager;
  122975. /**
  122976. * Observers registered here will be triggered after the camera's initial transformation is set
  122977. * This can be used to set a different ground level or an extra rotation.
  122978. *
  122979. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  122980. * to the position set after this observable is done executing.
  122981. */
  122982. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  122983. /**
  122984. * Fires when the state of the experience helper has changed
  122985. */
  122986. onStateChangedObservable: Observable<WebXRState>;
  122987. /** Session manager used to keep track of xr session */
  122988. sessionManager: WebXRSessionManager;
  122989. /**
  122990. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  122991. */
  122992. state: WebXRState;
  122993. /**
  122994. * Creates a WebXRExperienceHelper
  122995. * @param scene The scene the helper should be created in
  122996. */
  122997. private constructor();
  122998. /**
  122999. * Creates the experience helper
  123000. * @param scene the scene to attach the experience helper to
  123001. * @returns a promise for the experience helper
  123002. */
  123003. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  123004. /**
  123005. * Disposes of the experience helper
  123006. */
  123007. dispose(): void;
  123008. /**
  123009. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  123010. * @param sessionMode options for the XR session
  123011. * @param referenceSpaceType frame of reference of the XR session
  123012. * @param renderTarget the output canvas that will be used to enter XR mode
  123013. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  123014. * @returns promise that resolves after xr mode has entered
  123015. */
  123016. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  123017. /**
  123018. * Exits XR mode and returns the scene to its original state
  123019. * @returns promise that resolves after xr mode has exited
  123020. */
  123021. exitXRAsync(): Promise<void>;
  123022. private _nonXRToXRCamera;
  123023. private _setState;
  123024. }
  123025. }
  123026. declare module BABYLON {
  123027. /**
  123028. * X-Y values for axes in WebXR
  123029. */
  123030. export interface IWebXRMotionControllerAxesValue {
  123031. /**
  123032. * The value of the x axis
  123033. */
  123034. x: number;
  123035. /**
  123036. * The value of the y-axis
  123037. */
  123038. y: number;
  123039. }
  123040. /**
  123041. * changed / previous values for the values of this component
  123042. */
  123043. export interface IWebXRMotionControllerComponentChangesValues<T> {
  123044. /**
  123045. * current (this frame) value
  123046. */
  123047. current: T;
  123048. /**
  123049. * previous (last change) value
  123050. */
  123051. previous: T;
  123052. }
  123053. /**
  123054. * Represents changes in the component between current frame and last values recorded
  123055. */
  123056. export interface IWebXRMotionControllerComponentChanges {
  123057. /**
  123058. * will be populated with previous and current values if axes changed
  123059. */
  123060. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  123061. /**
  123062. * will be populated with previous and current values if pressed changed
  123063. */
  123064. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  123065. /**
  123066. * will be populated with previous and current values if touched changed
  123067. */
  123068. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  123069. /**
  123070. * will be populated with previous and current values if value changed
  123071. */
  123072. value?: IWebXRMotionControllerComponentChangesValues<number>;
  123073. }
  123074. /**
  123075. * This class represents a single component (for example button or thumbstick) of a motion controller
  123076. */
  123077. export class WebXRControllerComponent implements IDisposable {
  123078. /**
  123079. * the id of this component
  123080. */
  123081. id: string;
  123082. /**
  123083. * the type of the component
  123084. */
  123085. type: MotionControllerComponentType;
  123086. private _buttonIndex;
  123087. private _axesIndices;
  123088. private _axes;
  123089. private _changes;
  123090. private _currentValue;
  123091. private _hasChanges;
  123092. private _pressed;
  123093. private _touched;
  123094. /**
  123095. * button component type
  123096. */
  123097. static BUTTON_TYPE: MotionControllerComponentType;
  123098. /**
  123099. * squeeze component type
  123100. */
  123101. static SQUEEZE_TYPE: MotionControllerComponentType;
  123102. /**
  123103. * Thumbstick component type
  123104. */
  123105. static THUMBSTICK_TYPE: MotionControllerComponentType;
  123106. /**
  123107. * Touchpad component type
  123108. */
  123109. static TOUCHPAD_TYPE: MotionControllerComponentType;
  123110. /**
  123111. * trigger component type
  123112. */
  123113. static TRIGGER_TYPE: MotionControllerComponentType;
  123114. /**
  123115. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  123116. * the axes data changes
  123117. */
  123118. onAxisValueChangedObservable: Observable<{
  123119. x: number;
  123120. y: number;
  123121. }>;
  123122. /**
  123123. * Observers registered here will be triggered when the state of a button changes
  123124. * State change is either pressed / touched / value
  123125. */
  123126. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  123127. /**
  123128. * Creates a new component for a motion controller.
  123129. * It is created by the motion controller itself
  123130. *
  123131. * @param id the id of this component
  123132. * @param type the type of the component
  123133. * @param _buttonIndex index in the buttons array of the gamepad
  123134. * @param _axesIndices indices of the values in the axes array of the gamepad
  123135. */
  123136. constructor(
  123137. /**
  123138. * the id of this component
  123139. */
  123140. id: string,
  123141. /**
  123142. * the type of the component
  123143. */
  123144. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  123145. /**
  123146. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  123147. */
  123148. get axes(): IWebXRMotionControllerAxesValue;
  123149. /**
  123150. * Get the changes. Elements will be populated only if they changed with their previous and current value
  123151. */
  123152. get changes(): IWebXRMotionControllerComponentChanges;
  123153. /**
  123154. * Return whether or not the component changed the last frame
  123155. */
  123156. get hasChanges(): boolean;
  123157. /**
  123158. * is the button currently pressed
  123159. */
  123160. get pressed(): boolean;
  123161. /**
  123162. * is the button currently touched
  123163. */
  123164. get touched(): boolean;
  123165. /**
  123166. * Get the current value of this component
  123167. */
  123168. get value(): number;
  123169. /**
  123170. * Dispose this component
  123171. */
  123172. dispose(): void;
  123173. /**
  123174. * Are there axes correlating to this component
  123175. * @return true is axes data is available
  123176. */
  123177. isAxes(): boolean;
  123178. /**
  123179. * Is this component a button (hence - pressable)
  123180. * @returns true if can be pressed
  123181. */
  123182. isButton(): boolean;
  123183. /**
  123184. * update this component using the gamepad object it is in. Called on every frame
  123185. * @param nativeController the native gamepad controller object
  123186. */
  123187. update(nativeController: IMinimalMotionControllerObject): void;
  123188. }
  123189. }
  123190. declare module BABYLON {
  123191. /**
  123192. * Class used to represent data loading progression
  123193. */
  123194. export class SceneLoaderProgressEvent {
  123195. /** defines if data length to load can be evaluated */
  123196. readonly lengthComputable: boolean;
  123197. /** defines the loaded data length */
  123198. readonly loaded: number;
  123199. /** defines the data length to load */
  123200. readonly total: number;
  123201. /**
  123202. * Create a new progress event
  123203. * @param lengthComputable defines if data length to load can be evaluated
  123204. * @param loaded defines the loaded data length
  123205. * @param total defines the data length to load
  123206. */
  123207. constructor(
  123208. /** defines if data length to load can be evaluated */
  123209. lengthComputable: boolean,
  123210. /** defines the loaded data length */
  123211. loaded: number,
  123212. /** defines the data length to load */
  123213. total: number);
  123214. /**
  123215. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  123216. * @param event defines the source event
  123217. * @returns a new SceneLoaderProgressEvent
  123218. */
  123219. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  123220. }
  123221. /**
  123222. * Interface used by SceneLoader plugins to define supported file extensions
  123223. */
  123224. export interface ISceneLoaderPluginExtensions {
  123225. /**
  123226. * Defines the list of supported extensions
  123227. */
  123228. [extension: string]: {
  123229. isBinary: boolean;
  123230. };
  123231. }
  123232. /**
  123233. * Interface used by SceneLoader plugin factory
  123234. */
  123235. export interface ISceneLoaderPluginFactory {
  123236. /**
  123237. * Defines the name of the factory
  123238. */
  123239. name: string;
  123240. /**
  123241. * Function called to create a new plugin
  123242. * @return the new plugin
  123243. */
  123244. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  123245. /**
  123246. * The callback that returns true if the data can be directly loaded.
  123247. * @param data string containing the file data
  123248. * @returns if the data can be loaded directly
  123249. */
  123250. canDirectLoad?(data: string): boolean;
  123251. }
  123252. /**
  123253. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  123254. */
  123255. export interface ISceneLoaderPluginBase {
  123256. /**
  123257. * The friendly name of this plugin.
  123258. */
  123259. name: string;
  123260. /**
  123261. * The file extensions supported by this plugin.
  123262. */
  123263. extensions: string | ISceneLoaderPluginExtensions;
  123264. /**
  123265. * The callback called when loading from a url.
  123266. * @param scene scene loading this url
  123267. * @param url url to load
  123268. * @param onSuccess callback called when the file successfully loads
  123269. * @param onProgress callback called while file is loading (if the server supports this mode)
  123270. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  123271. * @param onError callback called when the file fails to load
  123272. * @returns a file request object
  123273. */
  123274. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  123275. /**
  123276. * The callback called when loading from a file object.
  123277. * @param scene scene loading this file
  123278. * @param file defines the file to load
  123279. * @param onSuccess defines the callback to call when data is loaded
  123280. * @param onProgress defines the callback to call during loading process
  123281. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  123282. * @param onError defines the callback to call when an error occurs
  123283. * @returns a file request object
  123284. */
  123285. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  123286. /**
  123287. * The callback that returns true if the data can be directly loaded.
  123288. * @param data string containing the file data
  123289. * @returns if the data can be loaded directly
  123290. */
  123291. canDirectLoad?(data: string): boolean;
  123292. /**
  123293. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  123294. * @param scene scene loading this data
  123295. * @param data string containing the data
  123296. * @returns data to pass to the plugin
  123297. */
  123298. directLoad?(scene: Scene, data: string): any;
  123299. /**
  123300. * The callback that allows custom handling of the root url based on the response url.
  123301. * @param rootUrl the original root url
  123302. * @param responseURL the response url if available
  123303. * @returns the new root url
  123304. */
  123305. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  123306. }
  123307. /**
  123308. * Interface used to define a SceneLoader plugin
  123309. */
  123310. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  123311. /**
  123312. * Import meshes into a scene.
  123313. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  123314. * @param scene The scene to import into
  123315. * @param data The data to import
  123316. * @param rootUrl The root url for scene and resources
  123317. * @param meshes The meshes array to import into
  123318. * @param particleSystems The particle systems array to import into
  123319. * @param skeletons The skeletons array to import into
  123320. * @param onError The callback when import fails
  123321. * @returns True if successful or false otherwise
  123322. */
  123323. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  123324. /**
  123325. * Load into a scene.
  123326. * @param scene The scene to load into
  123327. * @param data The data to import
  123328. * @param rootUrl The root url for scene and resources
  123329. * @param onError The callback when import fails
  123330. * @returns True if successful or false otherwise
  123331. */
  123332. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  123333. /**
  123334. * Load into an asset container.
  123335. * @param scene The scene to load into
  123336. * @param data The data to import
  123337. * @param rootUrl The root url for scene and resources
  123338. * @param onError The callback when import fails
  123339. * @returns The loaded asset container
  123340. */
  123341. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  123342. }
  123343. /**
  123344. * Interface used to define an async SceneLoader plugin
  123345. */
  123346. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  123347. /**
  123348. * Import meshes into a scene.
  123349. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  123350. * @param scene The scene to import into
  123351. * @param data The data to import
  123352. * @param rootUrl The root url for scene and resources
  123353. * @param onProgress The callback when the load progresses
  123354. * @param fileName Defines the name of the file to load
  123355. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  123356. */
  123357. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  123358. meshes: AbstractMesh[];
  123359. particleSystems: IParticleSystem[];
  123360. skeletons: Skeleton[];
  123361. animationGroups: AnimationGroup[];
  123362. }>;
  123363. /**
  123364. * Load into a scene.
  123365. * @param scene The scene to load into
  123366. * @param data The data to import
  123367. * @param rootUrl The root url for scene and resources
  123368. * @param onProgress The callback when the load progresses
  123369. * @param fileName Defines the name of the file to load
  123370. * @returns Nothing
  123371. */
  123372. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  123373. /**
  123374. * Load into an asset container.
  123375. * @param scene The scene to load into
  123376. * @param data The data to import
  123377. * @param rootUrl The root url for scene and resources
  123378. * @param onProgress The callback when the load progresses
  123379. * @param fileName Defines the name of the file to load
  123380. * @returns The loaded asset container
  123381. */
  123382. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  123383. }
  123384. /**
  123385. * Mode that determines how to handle old animation groups before loading new ones.
  123386. */
  123387. export enum SceneLoaderAnimationGroupLoadingMode {
  123388. /**
  123389. * Reset all old animations to initial state then dispose them.
  123390. */
  123391. Clean = 0,
  123392. /**
  123393. * Stop all old animations.
  123394. */
  123395. Stop = 1,
  123396. /**
  123397. * Restart old animations from first frame.
  123398. */
  123399. Sync = 2,
  123400. /**
  123401. * Old animations remains untouched.
  123402. */
  123403. NoSync = 3
  123404. }
  123405. /**
  123406. * Class used to load scene from various file formats using registered plugins
  123407. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  123408. */
  123409. export class SceneLoader {
  123410. /**
  123411. * No logging while loading
  123412. */
  123413. static readonly NO_LOGGING: number;
  123414. /**
  123415. * Minimal logging while loading
  123416. */
  123417. static readonly MINIMAL_LOGGING: number;
  123418. /**
  123419. * Summary logging while loading
  123420. */
  123421. static readonly SUMMARY_LOGGING: number;
  123422. /**
  123423. * Detailled logging while loading
  123424. */
  123425. static readonly DETAILED_LOGGING: number;
  123426. /**
  123427. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  123428. */
  123429. static get ForceFullSceneLoadingForIncremental(): boolean;
  123430. static set ForceFullSceneLoadingForIncremental(value: boolean);
  123431. /**
  123432. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  123433. */
  123434. static get ShowLoadingScreen(): boolean;
  123435. static set ShowLoadingScreen(value: boolean);
  123436. /**
  123437. * Defines the current logging level (while loading the scene)
  123438. * @ignorenaming
  123439. */
  123440. static get loggingLevel(): number;
  123441. static set loggingLevel(value: number);
  123442. /**
  123443. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  123444. */
  123445. static get CleanBoneMatrixWeights(): boolean;
  123446. static set CleanBoneMatrixWeights(value: boolean);
  123447. /**
  123448. * Event raised when a plugin is used to load a scene
  123449. */
  123450. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  123451. private static _registeredPlugins;
  123452. private static _getDefaultPlugin;
  123453. private static _getPluginForExtension;
  123454. private static _getPluginForDirectLoad;
  123455. private static _getPluginForFilename;
  123456. private static _getDirectLoad;
  123457. private static _loadData;
  123458. private static _getFileInfo;
  123459. /**
  123460. * Gets a plugin that can load the given extension
  123461. * @param extension defines the extension to load
  123462. * @returns a plugin or null if none works
  123463. */
  123464. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  123465. /**
  123466. * Gets a boolean indicating that the given extension can be loaded
  123467. * @param extension defines the extension to load
  123468. * @returns true if the extension is supported
  123469. */
  123470. static IsPluginForExtensionAvailable(extension: string): boolean;
  123471. /**
  123472. * Adds a new plugin to the list of registered plugins
  123473. * @param plugin defines the plugin to add
  123474. */
  123475. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  123476. /**
  123477. * Import meshes into a scene
  123478. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  123479. * @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)
  123480. * @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)
  123481. * @param scene the instance of BABYLON.Scene to append to
  123482. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  123483. * @param onProgress a callback with a progress event for each file being loaded
  123484. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  123485. * @param pluginExtension the extension used to determine the plugin
  123486. * @returns The loaded plugin
  123487. */
  123488. 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>;
  123489. /**
  123490. * Import meshes into a scene
  123491. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  123492. * @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)
  123493. * @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)
  123494. * @param scene the instance of BABYLON.Scene to append to
  123495. * @param onProgress a callback with a progress event for each file being loaded
  123496. * @param pluginExtension the extension used to determine the plugin
  123497. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  123498. */
  123499. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  123500. meshes: AbstractMesh[];
  123501. particleSystems: IParticleSystem[];
  123502. skeletons: Skeleton[];
  123503. animationGroups: AnimationGroup[];
  123504. }>;
  123505. /**
  123506. * Load a scene
  123507. * @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)
  123508. * @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)
  123509. * @param engine is the instance of BABYLON.Engine to use to create the scene
  123510. * @param onSuccess a callback with the scene when import succeeds
  123511. * @param onProgress a callback with a progress event for each file being loaded
  123512. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  123513. * @param pluginExtension the extension used to determine the plugin
  123514. * @returns The loaded plugin
  123515. */
  123516. 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>;
  123517. /**
  123518. * Load a scene
  123519. * @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)
  123520. * @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)
  123521. * @param engine is the instance of BABYLON.Engine to use to create the scene
  123522. * @param onProgress a callback with a progress event for each file being loaded
  123523. * @param pluginExtension the extension used to determine the plugin
  123524. * @returns The loaded scene
  123525. */
  123526. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  123527. /**
  123528. * Append a scene
  123529. * @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)
  123530. * @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)
  123531. * @param scene is the instance of BABYLON.Scene to append to
  123532. * @param onSuccess a callback with the scene when import succeeds
  123533. * @param onProgress a callback with a progress event for each file being loaded
  123534. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  123535. * @param pluginExtension the extension used to determine the plugin
  123536. * @returns The loaded plugin
  123537. */
  123538. 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>;
  123539. /**
  123540. * Append a scene
  123541. * @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)
  123542. * @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)
  123543. * @param scene is the instance of BABYLON.Scene to append to
  123544. * @param onProgress a callback with a progress event for each file being loaded
  123545. * @param pluginExtension the extension used to determine the plugin
  123546. * @returns The given scene
  123547. */
  123548. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  123549. /**
  123550. * Load a scene into an asset container
  123551. * @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)
  123552. * @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)
  123553. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  123554. * @param onSuccess a callback with the scene when import succeeds
  123555. * @param onProgress a callback with a progress event for each file being loaded
  123556. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  123557. * @param pluginExtension the extension used to determine the plugin
  123558. * @returns The loaded plugin
  123559. */
  123560. 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>;
  123561. /**
  123562. * Load a scene into an asset container
  123563. * @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)
  123564. * @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)
  123565. * @param scene is the instance of Scene to append to
  123566. * @param onProgress a callback with a progress event for each file being loaded
  123567. * @param pluginExtension the extension used to determine the plugin
  123568. * @returns The loaded asset container
  123569. */
  123570. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  123571. /**
  123572. * Import animations from a file into a scene
  123573. * @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)
  123574. * @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)
  123575. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  123576. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  123577. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  123578. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  123579. * @param onSuccess a callback with the scene when import succeeds
  123580. * @param onProgress a callback with a progress event for each file being loaded
  123581. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  123582. */
  123583. 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;
  123584. /**
  123585. * Import animations from a file into a scene
  123586. * @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)
  123587. * @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)
  123588. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  123589. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  123590. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  123591. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  123592. * @param onSuccess a callback with the scene when import succeeds
  123593. * @param onProgress a callback with a progress event for each file being loaded
  123594. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  123595. * @returns the updated scene with imported animations
  123596. */
  123597. 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>;
  123598. }
  123599. }
  123600. declare module BABYLON {
  123601. /**
  123602. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  123603. */
  123604. export type MotionControllerHandedness = "none" | "left" | "right";
  123605. /**
  123606. * The type of components available in motion controllers.
  123607. * This is not the name of the component.
  123608. */
  123609. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  123610. /**
  123611. * The state of a controller component
  123612. */
  123613. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  123614. /**
  123615. * The schema of motion controller layout.
  123616. * No object will be initialized using this interface
  123617. * This is used just to define the profile.
  123618. */
  123619. export interface IMotionControllerLayout {
  123620. /**
  123621. * Path to load the assets. Usually relative to the base path
  123622. */
  123623. assetPath: string;
  123624. /**
  123625. * Available components (unsorted)
  123626. */
  123627. components: {
  123628. /**
  123629. * A map of component Ids
  123630. */
  123631. [componentId: string]: {
  123632. /**
  123633. * The type of input the component outputs
  123634. */
  123635. type: MotionControllerComponentType;
  123636. /**
  123637. * The indices of this component in the gamepad object
  123638. */
  123639. gamepadIndices: {
  123640. /**
  123641. * Index of button
  123642. */
  123643. button?: number;
  123644. /**
  123645. * If available, index of x-axis
  123646. */
  123647. xAxis?: number;
  123648. /**
  123649. * If available, index of y-axis
  123650. */
  123651. yAxis?: number;
  123652. };
  123653. /**
  123654. * The mesh's root node name
  123655. */
  123656. rootNodeName: string;
  123657. /**
  123658. * Animation definitions for this model
  123659. */
  123660. visualResponses: {
  123661. [stateKey: string]: {
  123662. /**
  123663. * What property will be animated
  123664. */
  123665. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  123666. /**
  123667. * What states influence this visual response
  123668. */
  123669. states: MotionControllerComponentStateType[];
  123670. /**
  123671. * Type of animation - movement or visibility
  123672. */
  123673. valueNodeProperty: "transform" | "visibility";
  123674. /**
  123675. * Base node name to move. Its position will be calculated according to the min and max nodes
  123676. */
  123677. valueNodeName?: string;
  123678. /**
  123679. * Minimum movement node
  123680. */
  123681. minNodeName?: string;
  123682. /**
  123683. * Max movement node
  123684. */
  123685. maxNodeName?: string;
  123686. };
  123687. };
  123688. /**
  123689. * If touch enabled, what is the name of node to display user feedback
  123690. */
  123691. touchPointNodeName?: string;
  123692. };
  123693. };
  123694. /**
  123695. * Is it xr standard mapping or not
  123696. */
  123697. gamepadMapping: "" | "xr-standard";
  123698. /**
  123699. * Base root node of this entire model
  123700. */
  123701. rootNodeName: string;
  123702. /**
  123703. * Defines the main button component id
  123704. */
  123705. selectComponentId: string;
  123706. }
  123707. /**
  123708. * A definition for the layout map in the input profile
  123709. */
  123710. export interface IMotionControllerLayoutMap {
  123711. /**
  123712. * Layouts with handedness type as a key
  123713. */
  123714. [handedness: string]: IMotionControllerLayout;
  123715. }
  123716. /**
  123717. * The XR Input profile schema
  123718. * Profiles can be found here:
  123719. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  123720. */
  123721. export interface IMotionControllerProfile {
  123722. /**
  123723. * fallback profiles for this profileId
  123724. */
  123725. fallbackProfileIds: string[];
  123726. /**
  123727. * The layout map, with handedness as key
  123728. */
  123729. layouts: IMotionControllerLayoutMap;
  123730. /**
  123731. * The id of this profile
  123732. * correlates to the profile(s) in the xrInput.profiles array
  123733. */
  123734. profileId: string;
  123735. }
  123736. /**
  123737. * A helper-interface for the 3 meshes needed for controller button animation
  123738. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  123739. */
  123740. export interface IMotionControllerButtonMeshMap {
  123741. /**
  123742. * the mesh that defines the pressed value mesh position.
  123743. * This is used to find the max-position of this button
  123744. */
  123745. pressedMesh: AbstractMesh;
  123746. /**
  123747. * the mesh that defines the unpressed value mesh position.
  123748. * This is used to find the min (or initial) position of this button
  123749. */
  123750. unpressedMesh: AbstractMesh;
  123751. /**
  123752. * The mesh that will be changed when value changes
  123753. */
  123754. valueMesh: AbstractMesh;
  123755. }
  123756. /**
  123757. * A helper-interface for the 3 meshes needed for controller axis animation.
  123758. * This will be expanded when touchpad animations are fully supported
  123759. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  123760. */
  123761. export interface IMotionControllerMeshMap {
  123762. /**
  123763. * the mesh that defines the maximum value mesh position.
  123764. */
  123765. maxMesh?: AbstractMesh;
  123766. /**
  123767. * the mesh that defines the minimum value mesh position.
  123768. */
  123769. minMesh?: AbstractMesh;
  123770. /**
  123771. * The mesh that will be changed when axis value changes
  123772. */
  123773. valueMesh: AbstractMesh;
  123774. }
  123775. /**
  123776. * The elements needed for change-detection of the gamepad objects in motion controllers
  123777. */
  123778. export interface IMinimalMotionControllerObject {
  123779. /**
  123780. * Available axes of this controller
  123781. */
  123782. axes: number[];
  123783. /**
  123784. * An array of available buttons
  123785. */
  123786. buttons: Array<{
  123787. /**
  123788. * Value of the button/trigger
  123789. */
  123790. value: number;
  123791. /**
  123792. * If the button/trigger is currently touched
  123793. */
  123794. touched: boolean;
  123795. /**
  123796. * If the button/trigger is currently pressed
  123797. */
  123798. pressed: boolean;
  123799. }>;
  123800. /**
  123801. * EXPERIMENTAL haptic support.
  123802. */
  123803. hapticActuators?: Array<{
  123804. pulse: (value: number, duration: number) => Promise<boolean>;
  123805. }>;
  123806. }
  123807. /**
  123808. * An Abstract Motion controller
  123809. * This class receives an xrInput and a profile layout and uses those to initialize the components
  123810. * Each component has an observable to check for changes in value and state
  123811. */
  123812. export abstract class WebXRAbstractMotionController implements IDisposable {
  123813. protected scene: Scene;
  123814. protected layout: IMotionControllerLayout;
  123815. /**
  123816. * The gamepad object correlating to this controller
  123817. */
  123818. gamepadObject: IMinimalMotionControllerObject;
  123819. /**
  123820. * handedness (left/right/none) of this controller
  123821. */
  123822. handedness: MotionControllerHandedness;
  123823. private _initComponent;
  123824. private _modelReady;
  123825. /**
  123826. * A map of components (WebXRControllerComponent) in this motion controller
  123827. * Components have a ComponentType and can also have both button and axis definitions
  123828. */
  123829. readonly components: {
  123830. [id: string]: WebXRControllerComponent;
  123831. };
  123832. /**
  123833. * Disable the model's animation. Can be set at any time.
  123834. */
  123835. disableAnimation: boolean;
  123836. /**
  123837. * Observers registered here will be triggered when the model of this controller is done loading
  123838. */
  123839. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  123840. /**
  123841. * The profile id of this motion controller
  123842. */
  123843. abstract profileId: string;
  123844. /**
  123845. * The root mesh of the model. It is null if the model was not yet initialized
  123846. */
  123847. rootMesh: Nullable<AbstractMesh>;
  123848. /**
  123849. * constructs a new abstract motion controller
  123850. * @param scene the scene to which the model of the controller will be added
  123851. * @param layout The profile layout to load
  123852. * @param gamepadObject The gamepad object correlating to this controller
  123853. * @param handedness handedness (left/right/none) of this controller
  123854. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  123855. */
  123856. constructor(scene: Scene, layout: IMotionControllerLayout,
  123857. /**
  123858. * The gamepad object correlating to this controller
  123859. */
  123860. gamepadObject: IMinimalMotionControllerObject,
  123861. /**
  123862. * handedness (left/right/none) of this controller
  123863. */
  123864. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  123865. /**
  123866. * Dispose this controller, the model mesh and all its components
  123867. */
  123868. dispose(): void;
  123869. /**
  123870. * Returns all components of specific type
  123871. * @param type the type to search for
  123872. * @return an array of components with this type
  123873. */
  123874. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  123875. /**
  123876. * get a component based an its component id as defined in layout.components
  123877. * @param id the id of the component
  123878. * @returns the component correlates to the id or undefined if not found
  123879. */
  123880. getComponent(id: string): WebXRControllerComponent;
  123881. /**
  123882. * Get the list of components available in this motion controller
  123883. * @returns an array of strings correlating to available components
  123884. */
  123885. getComponentIds(): string[];
  123886. /**
  123887. * Get the first component of specific type
  123888. * @param type type of component to find
  123889. * @return a controller component or null if not found
  123890. */
  123891. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  123892. /**
  123893. * Get the main (Select) component of this controller as defined in the layout
  123894. * @returns the main component of this controller
  123895. */
  123896. getMainComponent(): WebXRControllerComponent;
  123897. /**
  123898. * Loads the model correlating to this controller
  123899. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  123900. * @returns A promise fulfilled with the result of the model loading
  123901. */
  123902. loadModel(): Promise<boolean>;
  123903. /**
  123904. * Update this model using the current XRFrame
  123905. * @param xrFrame the current xr frame to use and update the model
  123906. */
  123907. updateFromXRFrame(xrFrame: XRFrame): void;
  123908. /**
  123909. * Backwards compatibility due to a deeply-integrated typo
  123910. */
  123911. get handness(): XREye;
  123912. /**
  123913. * Pulse (vibrate) this controller
  123914. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  123915. * Consecutive calls to this function will cancel the last pulse call
  123916. *
  123917. * @param value the strength of the pulse in 0.0...1.0 range
  123918. * @param duration Duration of the pulse in milliseconds
  123919. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  123920. * @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
  123921. */
  123922. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  123923. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  123924. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  123925. /**
  123926. * Moves the axis on the controller mesh based on its current state
  123927. * @param axis the index of the axis
  123928. * @param axisValue the value of the axis which determines the meshes new position
  123929. * @hidden
  123930. */
  123931. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  123932. /**
  123933. * Update the model itself with the current frame data
  123934. * @param xrFrame the frame to use for updating the model mesh
  123935. */
  123936. protected updateModel(xrFrame: XRFrame): void;
  123937. /**
  123938. * Get the filename and path for this controller's model
  123939. * @returns a map of filename and path
  123940. */
  123941. protected abstract _getFilenameAndPath(): {
  123942. filename: string;
  123943. path: string;
  123944. };
  123945. /**
  123946. * This function is called before the mesh is loaded. It checks for loading constraints.
  123947. * For example, this function can check if the GLB loader is available
  123948. * If this function returns false, the generic controller will be loaded instead
  123949. * @returns Is the client ready to load the mesh
  123950. */
  123951. protected abstract _getModelLoadingConstraints(): boolean;
  123952. /**
  123953. * This function will be called after the model was successfully loaded and can be used
  123954. * for mesh transformations before it is available for the user
  123955. * @param meshes the loaded meshes
  123956. */
  123957. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  123958. /**
  123959. * Set the root mesh for this controller. Important for the WebXR controller class
  123960. * @param meshes the loaded meshes
  123961. */
  123962. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  123963. /**
  123964. * A function executed each frame that updates the mesh (if needed)
  123965. * @param xrFrame the current xrFrame
  123966. */
  123967. protected abstract _updateModel(xrFrame: XRFrame): void;
  123968. private _getGenericFilenameAndPath;
  123969. private _getGenericParentMesh;
  123970. }
  123971. }
  123972. declare module BABYLON {
  123973. /**
  123974. * A generic trigger-only motion controller for WebXR
  123975. */
  123976. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  123977. /**
  123978. * Static version of the profile id of this controller
  123979. */
  123980. static ProfileId: string;
  123981. profileId: string;
  123982. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  123983. protected _getFilenameAndPath(): {
  123984. filename: string;
  123985. path: string;
  123986. };
  123987. protected _getModelLoadingConstraints(): boolean;
  123988. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  123989. protected _setRootMesh(meshes: AbstractMesh[]): void;
  123990. protected _updateModel(): void;
  123991. }
  123992. }
  123993. declare module BABYLON {
  123994. /**
  123995. * Class containing static functions to help procedurally build meshes
  123996. */
  123997. export class SphereBuilder {
  123998. /**
  123999. * Creates a sphere mesh
  124000. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  124001. * * 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`)
  124002. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  124003. * * 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
  124004. * * 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)
  124005. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124006. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124007. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124008. * @param name defines the name of the mesh
  124009. * @param options defines the options used to create the mesh
  124010. * @param scene defines the hosting scene
  124011. * @returns the sphere mesh
  124012. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  124013. */
  124014. static CreateSphere(name: string, options: {
  124015. segments?: number;
  124016. diameter?: number;
  124017. diameterX?: number;
  124018. diameterY?: number;
  124019. diameterZ?: number;
  124020. arc?: number;
  124021. slice?: number;
  124022. sideOrientation?: number;
  124023. frontUVs?: Vector4;
  124024. backUVs?: Vector4;
  124025. updatable?: boolean;
  124026. }, scene?: Nullable<Scene>): Mesh;
  124027. }
  124028. }
  124029. declare module BABYLON {
  124030. /**
  124031. * A profiled motion controller has its profile loaded from an online repository.
  124032. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  124033. */
  124034. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  124035. private _repositoryUrl;
  124036. private _buttonMeshMapping;
  124037. private _touchDots;
  124038. /**
  124039. * The profile ID of this controller. Will be populated when the controller initializes.
  124040. */
  124041. profileId: string;
  124042. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  124043. dispose(): void;
  124044. protected _getFilenameAndPath(): {
  124045. filename: string;
  124046. path: string;
  124047. };
  124048. protected _getModelLoadingConstraints(): boolean;
  124049. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  124050. protected _setRootMesh(meshes: AbstractMesh[]): void;
  124051. protected _updateModel(_xrFrame: XRFrame): void;
  124052. }
  124053. }
  124054. declare module BABYLON {
  124055. /**
  124056. * A construction function type to create a new controller based on an xrInput object
  124057. */
  124058. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  124059. /**
  124060. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  124061. *
  124062. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  124063. * it should be replaced with auto-loaded controllers.
  124064. *
  124065. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  124066. */
  124067. export class WebXRMotionControllerManager {
  124068. private static _AvailableControllers;
  124069. private static _Fallbacks;
  124070. private static _ProfileLoadingPromises;
  124071. private static _ProfilesList;
  124072. /**
  124073. * The base URL of the online controller repository. Can be changed at any time.
  124074. */
  124075. static BaseRepositoryUrl: string;
  124076. /**
  124077. * Which repository gets priority - local or online
  124078. */
  124079. static PrioritizeOnlineRepository: boolean;
  124080. /**
  124081. * Use the online repository, or use only locally-defined controllers
  124082. */
  124083. static UseOnlineRepository: boolean;
  124084. /**
  124085. * Clear the cache used for profile loading and reload when requested again
  124086. */
  124087. static ClearProfilesCache(): void;
  124088. /**
  124089. * Register the default fallbacks.
  124090. * This function is called automatically when this file is imported.
  124091. */
  124092. static DefaultFallbacks(): void;
  124093. /**
  124094. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  124095. * @param profileId the profile to which a fallback needs to be found
  124096. * @return an array with corresponding fallback profiles
  124097. */
  124098. static FindFallbackWithProfileId(profileId: string): string[];
  124099. /**
  124100. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  124101. * The order of search:
  124102. *
  124103. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  124104. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  124105. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  124106. * 4) return the generic trigger controller if none were found
  124107. *
  124108. * @param xrInput the xrInput to which a new controller is initialized
  124109. * @param scene the scene to which the model will be added
  124110. * @param forceProfile force a certain profile for this controller
  124111. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  124112. */
  124113. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  124114. /**
  124115. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  124116. *
  124117. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  124118. *
  124119. * @param type the profile type to register
  124120. * @param constructFunction the function to be called when loading this profile
  124121. */
  124122. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  124123. /**
  124124. * Register a fallback to a specific profile.
  124125. * @param profileId the profileId that will receive the fallbacks
  124126. * @param fallbacks A list of fallback profiles
  124127. */
  124128. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  124129. /**
  124130. * Will update the list of profiles available in the repository
  124131. * @return a promise that resolves to a map of profiles available online
  124132. */
  124133. static UpdateProfilesList(): Promise<{
  124134. [profile: string]: string;
  124135. }>;
  124136. private static _LoadProfileFromRepository;
  124137. private static _LoadProfilesFromAvailableControllers;
  124138. }
  124139. }
  124140. declare module BABYLON {
  124141. /**
  124142. * Configuration options for the WebXR controller creation
  124143. */
  124144. export interface IWebXRControllerOptions {
  124145. /**
  124146. * Should the controller mesh be animated when a user interacts with it
  124147. * The pressed buttons / thumbstick and touchpad animations will be disabled
  124148. */
  124149. disableMotionControllerAnimation?: boolean;
  124150. /**
  124151. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  124152. */
  124153. doNotLoadControllerMesh?: boolean;
  124154. /**
  124155. * Force a specific controller type for this controller.
  124156. * This can be used when creating your own profile or when testing different controllers
  124157. */
  124158. forceControllerProfile?: string;
  124159. /**
  124160. * Defines a rendering group ID for meshes that will be loaded.
  124161. * This is for the default controllers only.
  124162. */
  124163. renderingGroupId?: number;
  124164. }
  124165. /**
  124166. * Represents an XR controller
  124167. */
  124168. export class WebXRInputSource {
  124169. private _scene;
  124170. /** The underlying input source for the controller */
  124171. inputSource: XRInputSource;
  124172. private _options;
  124173. private _tmpVector;
  124174. private _uniqueId;
  124175. /**
  124176. * 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
  124177. */
  124178. grip?: AbstractMesh;
  124179. /**
  124180. * If available, this is the gamepad object related to this controller.
  124181. * Using this object it is possible to get click events and trackpad changes of the
  124182. * webxr controller that is currently being used.
  124183. */
  124184. motionController?: WebXRAbstractMotionController;
  124185. /**
  124186. * Event that fires when the controller is removed/disposed.
  124187. * The object provided as event data is this controller, after associated assets were disposed.
  124188. * uniqueId is still available.
  124189. */
  124190. onDisposeObservable: Observable<WebXRInputSource>;
  124191. /**
  124192. * Will be triggered when the mesh associated with the motion controller is done loading.
  124193. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  124194. * A shortened version of controller -> motion controller -> on mesh loaded.
  124195. */
  124196. onMeshLoadedObservable: Observable<AbstractMesh>;
  124197. /**
  124198. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  124199. */
  124200. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  124201. /**
  124202. * Pointer which can be used to select objects or attach a visible laser to
  124203. */
  124204. pointer: AbstractMesh;
  124205. /**
  124206. * Creates the controller
  124207. * @see https://doc.babylonjs.com/how_to/webxr
  124208. * @param _scene the scene which the controller should be associated to
  124209. * @param inputSource the underlying input source for the controller
  124210. * @param _options options for this controller creation
  124211. */
  124212. constructor(_scene: Scene,
  124213. /** The underlying input source for the controller */
  124214. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  124215. /**
  124216. * Get this controllers unique id
  124217. */
  124218. get uniqueId(): string;
  124219. /**
  124220. * Disposes of the object
  124221. */
  124222. dispose(): void;
  124223. /**
  124224. * Gets a world space ray coming from the pointer or grip
  124225. * @param result the resulting ray
  124226. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  124227. */
  124228. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  124229. /**
  124230. * Updates the controller pose based on the given XRFrame
  124231. * @param xrFrame xr frame to update the pose with
  124232. * @param referenceSpace reference space to use
  124233. */
  124234. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  124235. }
  124236. }
  124237. declare module BABYLON {
  124238. /**
  124239. * The schema for initialization options of the XR Input class
  124240. */
  124241. export interface IWebXRInputOptions {
  124242. /**
  124243. * If set to true no model will be automatically loaded
  124244. */
  124245. doNotLoadControllerMeshes?: boolean;
  124246. /**
  124247. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  124248. * If not found, the xr input profile data will be used.
  124249. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  124250. */
  124251. forceInputProfile?: string;
  124252. /**
  124253. * Do not send a request to the controller repository to load the profile.
  124254. *
  124255. * Instead, use the controllers available in babylon itself.
  124256. */
  124257. disableOnlineControllerRepository?: boolean;
  124258. /**
  124259. * A custom URL for the controllers repository
  124260. */
  124261. customControllersRepositoryURL?: string;
  124262. /**
  124263. * Should the controller model's components not move according to the user input
  124264. */
  124265. disableControllerAnimation?: boolean;
  124266. /**
  124267. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  124268. */
  124269. controllerOptions?: IWebXRControllerOptions;
  124270. }
  124271. /**
  124272. * XR input used to track XR inputs such as controllers/rays
  124273. */
  124274. export class WebXRInput implements IDisposable {
  124275. /**
  124276. * the xr session manager for this session
  124277. */
  124278. xrSessionManager: WebXRSessionManager;
  124279. /**
  124280. * the WebXR camera for this session. Mainly used for teleportation
  124281. */
  124282. xrCamera: WebXRCamera;
  124283. private readonly options;
  124284. /**
  124285. * XR controllers being tracked
  124286. */
  124287. controllers: Array<WebXRInputSource>;
  124288. private _frameObserver;
  124289. private _sessionEndedObserver;
  124290. private _sessionInitObserver;
  124291. /**
  124292. * Event when a controller has been connected/added
  124293. */
  124294. onControllerAddedObservable: Observable<WebXRInputSource>;
  124295. /**
  124296. * Event when a controller has been removed/disconnected
  124297. */
  124298. onControllerRemovedObservable: Observable<WebXRInputSource>;
  124299. /**
  124300. * Initializes the WebXRInput
  124301. * @param xrSessionManager the xr session manager for this session
  124302. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  124303. * @param options = initialization options for this xr input
  124304. */
  124305. constructor(
  124306. /**
  124307. * the xr session manager for this session
  124308. */
  124309. xrSessionManager: WebXRSessionManager,
  124310. /**
  124311. * the WebXR camera for this session. Mainly used for teleportation
  124312. */
  124313. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  124314. private _onInputSourcesChange;
  124315. private _addAndRemoveControllers;
  124316. /**
  124317. * Disposes of the object
  124318. */
  124319. dispose(): void;
  124320. }
  124321. }
  124322. declare module BABYLON {
  124323. /**
  124324. * This is the base class for all WebXR features.
  124325. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  124326. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  124327. */
  124328. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  124329. protected _xrSessionManager: WebXRSessionManager;
  124330. private _attached;
  124331. private _removeOnDetach;
  124332. /**
  124333. * Should auto-attach be disabled?
  124334. */
  124335. disableAutoAttach: boolean;
  124336. /**
  124337. * Construct a new (abstract) WebXR feature
  124338. * @param _xrSessionManager the xr session manager for this feature
  124339. */
  124340. constructor(_xrSessionManager: WebXRSessionManager);
  124341. /**
  124342. * Is this feature attached
  124343. */
  124344. get attached(): boolean;
  124345. /**
  124346. * attach this feature
  124347. *
  124348. * @param force should attachment be forced (even when already attached)
  124349. * @returns true if successful, false is failed or already attached
  124350. */
  124351. attach(force?: boolean): boolean;
  124352. /**
  124353. * detach this feature.
  124354. *
  124355. * @returns true if successful, false if failed or already detached
  124356. */
  124357. detach(): boolean;
  124358. /**
  124359. * Dispose this feature and all of the resources attached
  124360. */
  124361. dispose(): void;
  124362. /**
  124363. * This is used to register callbacks that will automatically be removed when detach is called.
  124364. * @param observable the observable to which the observer will be attached
  124365. * @param callback the callback to register
  124366. */
  124367. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  124368. /**
  124369. * Code in this function will be executed on each xrFrame received from the browser.
  124370. * This function will not execute after the feature is detached.
  124371. * @param _xrFrame the current frame
  124372. */
  124373. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  124374. }
  124375. }
  124376. declare module BABYLON {
  124377. /**
  124378. * Renders a layer on top of an existing scene
  124379. */
  124380. export class UtilityLayerRenderer implements IDisposable {
  124381. /** the original scene that will be rendered on top of */
  124382. originalScene: Scene;
  124383. private _pointerCaptures;
  124384. private _lastPointerEvents;
  124385. private static _DefaultUtilityLayer;
  124386. private static _DefaultKeepDepthUtilityLayer;
  124387. private _sharedGizmoLight;
  124388. private _renderCamera;
  124389. /**
  124390. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  124391. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  124392. * @returns the camera that is used when rendering the utility layer
  124393. */
  124394. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  124395. /**
  124396. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  124397. * @param cam the camera that should be used when rendering the utility layer
  124398. */
  124399. setRenderCamera(cam: Nullable<Camera>): void;
  124400. /**
  124401. * @hidden
  124402. * Light which used by gizmos to get light shading
  124403. */
  124404. _getSharedGizmoLight(): HemisphericLight;
  124405. /**
  124406. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  124407. */
  124408. pickUtilitySceneFirst: boolean;
  124409. /**
  124410. * 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)
  124411. */
  124412. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  124413. /**
  124414. * 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)
  124415. */
  124416. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  124417. /**
  124418. * The scene that is rendered on top of the original scene
  124419. */
  124420. utilityLayerScene: Scene;
  124421. /**
  124422. * If the utility layer should automatically be rendered on top of existing scene
  124423. */
  124424. shouldRender: boolean;
  124425. /**
  124426. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  124427. */
  124428. onlyCheckPointerDownEvents: boolean;
  124429. /**
  124430. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  124431. */
  124432. processAllEvents: boolean;
  124433. /**
  124434. * Observable raised when the pointer move from the utility layer scene to the main scene
  124435. */
  124436. onPointerOutObservable: Observable<number>;
  124437. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  124438. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  124439. private _afterRenderObserver;
  124440. private _sceneDisposeObserver;
  124441. private _originalPointerObserver;
  124442. /**
  124443. * Instantiates a UtilityLayerRenderer
  124444. * @param originalScene the original scene that will be rendered on top of
  124445. * @param handleEvents boolean indicating if the utility layer should handle events
  124446. */
  124447. constructor(
  124448. /** the original scene that will be rendered on top of */
  124449. originalScene: Scene, handleEvents?: boolean);
  124450. private _notifyObservers;
  124451. /**
  124452. * Renders the utility layers scene on top of the original scene
  124453. */
  124454. render(): void;
  124455. /**
  124456. * Disposes of the renderer
  124457. */
  124458. dispose(): void;
  124459. private _updateCamera;
  124460. }
  124461. }
  124462. declare module BABYLON {
  124463. /**
  124464. * Options interface for the pointer selection module
  124465. */
  124466. export interface IWebXRControllerPointerSelectionOptions {
  124467. /**
  124468. * if provided, this scene will be used to render meshes.
  124469. */
  124470. customUtilityLayerScene?: Scene;
  124471. /**
  124472. * 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)
  124473. * If not disabled, the last picked point will be used to execute a pointer up event
  124474. * If disabled, pointer up event will be triggered right after the pointer down event.
  124475. * Used in screen and gaze target ray mode only
  124476. */
  124477. disablePointerUpOnTouchOut: boolean;
  124478. /**
  124479. * For gaze mode (time to select instead of press)
  124480. */
  124481. forceGazeMode: boolean;
  124482. /**
  124483. * 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
  124484. * to start a new countdown to the pointer down event.
  124485. * Defaults to 1.
  124486. */
  124487. gazeModePointerMovedFactor?: number;
  124488. /**
  124489. * Different button type to use instead of the main component
  124490. */
  124491. overrideButtonId?: string;
  124492. /**
  124493. * use this rendering group id for the meshes (optional)
  124494. */
  124495. renderingGroupId?: number;
  124496. /**
  124497. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  124498. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  124499. * 3000 means 3 seconds between pointing at something and selecting it
  124500. */
  124501. timeToSelect?: number;
  124502. /**
  124503. * Should meshes created here be added to a utility layer or the main scene
  124504. */
  124505. useUtilityLayer?: boolean;
  124506. /**
  124507. * the xr input to use with this pointer selection
  124508. */
  124509. xrInput: WebXRInput;
  124510. }
  124511. /**
  124512. * A module that will enable pointer selection for motion controllers of XR Input Sources
  124513. */
  124514. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  124515. private readonly _options;
  124516. private static _idCounter;
  124517. private _attachController;
  124518. private _controllers;
  124519. private _scene;
  124520. private _tmpVectorForPickCompare;
  124521. /**
  124522. * The module's name
  124523. */
  124524. static readonly Name: string;
  124525. /**
  124526. * The (Babylon) version of this module.
  124527. * This is an integer representing the implementation version.
  124528. * This number does not correspond to the WebXR specs version
  124529. */
  124530. static readonly Version: number;
  124531. /**
  124532. * Disable lighting on the laser pointer (so it will always be visible)
  124533. */
  124534. disablePointerLighting: boolean;
  124535. /**
  124536. * Disable lighting on the selection mesh (so it will always be visible)
  124537. */
  124538. disableSelectionMeshLighting: boolean;
  124539. /**
  124540. * Should the laser pointer be displayed
  124541. */
  124542. displayLaserPointer: boolean;
  124543. /**
  124544. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  124545. */
  124546. displaySelectionMesh: boolean;
  124547. /**
  124548. * This color will be set to the laser pointer when selection is triggered
  124549. */
  124550. laserPointerPickedColor: Color3;
  124551. /**
  124552. * Default color of the laser pointer
  124553. */
  124554. lasterPointerDefaultColor: Color3;
  124555. /**
  124556. * default color of the selection ring
  124557. */
  124558. selectionMeshDefaultColor: Color3;
  124559. /**
  124560. * This color will be applied to the selection ring when selection is triggered
  124561. */
  124562. selectionMeshPickedColor: Color3;
  124563. /**
  124564. * Optional filter to be used for ray selection. This predicate shares behavior with
  124565. * scene.pointerMovePredicate which takes priority if it is also assigned.
  124566. */
  124567. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  124568. /**
  124569. * constructs a new background remover module
  124570. * @param _xrSessionManager the session manager for this module
  124571. * @param _options read-only options to be used in this module
  124572. */
  124573. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  124574. /**
  124575. * attach this feature
  124576. * Will usually be called by the features manager
  124577. *
  124578. * @returns true if successful.
  124579. */
  124580. attach(): boolean;
  124581. /**
  124582. * detach this feature.
  124583. * Will usually be called by the features manager
  124584. *
  124585. * @returns true if successful.
  124586. */
  124587. detach(): boolean;
  124588. /**
  124589. * Will get the mesh under a specific pointer.
  124590. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  124591. * @param controllerId the controllerId to check
  124592. * @returns The mesh under pointer or null if no mesh is under the pointer
  124593. */
  124594. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  124595. /**
  124596. * Get the xr controller that correlates to the pointer id in the pointer event
  124597. *
  124598. * @param id the pointer id to search for
  124599. * @returns the controller that correlates to this id or null if not found
  124600. */
  124601. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  124602. protected _onXRFrame(_xrFrame: XRFrame): void;
  124603. private _attachGazeMode;
  124604. private _attachScreenRayMode;
  124605. private _attachTrackedPointerRayMode;
  124606. private _convertNormalToDirectionOfRay;
  124607. private _detachController;
  124608. private _generateNewMeshPair;
  124609. private _pickingMoved;
  124610. private _updatePointerDistance;
  124611. }
  124612. }
  124613. declare module BABYLON {
  124614. /**
  124615. * Button which can be used to enter a different mode of XR
  124616. */
  124617. export class WebXREnterExitUIButton {
  124618. /** button element */
  124619. element: HTMLElement;
  124620. /** XR initialization options for the button */
  124621. sessionMode: XRSessionMode;
  124622. /** Reference space type */
  124623. referenceSpaceType: XRReferenceSpaceType;
  124624. /**
  124625. * Creates a WebXREnterExitUIButton
  124626. * @param element button element
  124627. * @param sessionMode XR initialization session mode
  124628. * @param referenceSpaceType the type of reference space to be used
  124629. */
  124630. constructor(
  124631. /** button element */
  124632. element: HTMLElement,
  124633. /** XR initialization options for the button */
  124634. sessionMode: XRSessionMode,
  124635. /** Reference space type */
  124636. referenceSpaceType: XRReferenceSpaceType);
  124637. /**
  124638. * Extendable function which can be used to update the button's visuals when the state changes
  124639. * @param activeButton the current active button in the UI
  124640. */
  124641. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  124642. }
  124643. /**
  124644. * Options to create the webXR UI
  124645. */
  124646. export class WebXREnterExitUIOptions {
  124647. /**
  124648. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  124649. */
  124650. customButtons?: Array<WebXREnterExitUIButton>;
  124651. /**
  124652. * A reference space type to use when creating the default button.
  124653. * Default is local-floor
  124654. */
  124655. referenceSpaceType?: XRReferenceSpaceType;
  124656. /**
  124657. * Context to enter xr with
  124658. */
  124659. renderTarget?: Nullable<WebXRRenderTarget>;
  124660. /**
  124661. * A session mode to use when creating the default button.
  124662. * Default is immersive-vr
  124663. */
  124664. sessionMode?: XRSessionMode;
  124665. /**
  124666. * A list of optional features to init the session with
  124667. */
  124668. optionalFeatures?: string[];
  124669. }
  124670. /**
  124671. * UI to allow the user to enter/exit XR mode
  124672. */
  124673. export class WebXREnterExitUI implements IDisposable {
  124674. private scene;
  124675. /** version of the options passed to this UI */
  124676. options: WebXREnterExitUIOptions;
  124677. private _activeButton;
  124678. private _buttons;
  124679. private _overlay;
  124680. /**
  124681. * Fired every time the active button is changed.
  124682. *
  124683. * When xr is entered via a button that launches xr that button will be the callback parameter
  124684. *
  124685. * When exiting xr the callback parameter will be null)
  124686. */
  124687. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  124688. /**
  124689. *
  124690. * @param scene babylon scene object to use
  124691. * @param options (read-only) version of the options passed to this UI
  124692. */
  124693. private constructor();
  124694. /**
  124695. * Creates UI to allow the user to enter/exit XR mode
  124696. * @param scene the scene to add the ui to
  124697. * @param helper the xr experience helper to enter/exit xr with
  124698. * @param options options to configure the UI
  124699. * @returns the created ui
  124700. */
  124701. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  124702. /**
  124703. * Disposes of the XR UI component
  124704. */
  124705. dispose(): void;
  124706. private _updateButtons;
  124707. }
  124708. }
  124709. declare module BABYLON {
  124710. /**
  124711. * Class containing static functions to help procedurally build meshes
  124712. */
  124713. export class LinesBuilder {
  124714. /**
  124715. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  124716. * * 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
  124717. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  124718. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  124719. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  124720. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  124721. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  124722. * * 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
  124723. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  124724. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124725. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  124726. * @param name defines the name of the new line system
  124727. * @param options defines the options used to create the line system
  124728. * @param scene defines the hosting scene
  124729. * @returns a new line system mesh
  124730. */
  124731. static CreateLineSystem(name: string, options: {
  124732. lines: Vector3[][];
  124733. updatable?: boolean;
  124734. instance?: Nullable<LinesMesh>;
  124735. colors?: Nullable<Color4[][]>;
  124736. useVertexAlpha?: boolean;
  124737. }, scene: Nullable<Scene>): LinesMesh;
  124738. /**
  124739. * Creates a line mesh
  124740. * 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
  124741. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  124742. * * The parameter `points` is an array successive Vector3
  124743. * * 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
  124744. * * The optional parameter `colors` is an array of successive Color4, one per line point
  124745. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  124746. * * When updating an instance, remember that only point positions can change, not the number of points
  124747. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124748. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  124749. * @param name defines the name of the new line system
  124750. * @param options defines the options used to create the line system
  124751. * @param scene defines the hosting scene
  124752. * @returns a new line mesh
  124753. */
  124754. static CreateLines(name: string, options: {
  124755. points: Vector3[];
  124756. updatable?: boolean;
  124757. instance?: Nullable<LinesMesh>;
  124758. colors?: Color4[];
  124759. useVertexAlpha?: boolean;
  124760. }, scene?: Nullable<Scene>): LinesMesh;
  124761. /**
  124762. * Creates a dashed line mesh
  124763. * * 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
  124764. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  124765. * * The parameter `points` is an array successive Vector3
  124766. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  124767. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  124768. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  124769. * * 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
  124770. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  124771. * * When updating an instance, remember that only point positions can change, not the number of points
  124772. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124773. * @param name defines the name of the mesh
  124774. * @param options defines the options used to create the mesh
  124775. * @param scene defines the hosting scene
  124776. * @returns the dashed line mesh
  124777. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  124778. */
  124779. static CreateDashedLines(name: string, options: {
  124780. points: Vector3[];
  124781. dashSize?: number;
  124782. gapSize?: number;
  124783. dashNb?: number;
  124784. updatable?: boolean;
  124785. instance?: LinesMesh;
  124786. useVertexAlpha?: boolean;
  124787. }, scene?: Nullable<Scene>): LinesMesh;
  124788. }
  124789. }
  124790. declare module BABYLON {
  124791. /**
  124792. * The options container for the teleportation module
  124793. */
  124794. export interface IWebXRTeleportationOptions {
  124795. /**
  124796. * if provided, this scene will be used to render meshes.
  124797. */
  124798. customUtilityLayerScene?: Scene;
  124799. /**
  124800. * Values to configure the default target mesh
  124801. */
  124802. defaultTargetMeshOptions?: {
  124803. /**
  124804. * Fill color of the teleportation area
  124805. */
  124806. teleportationFillColor?: string;
  124807. /**
  124808. * Border color for the teleportation area
  124809. */
  124810. teleportationBorderColor?: string;
  124811. /**
  124812. * Disable the mesh's animation sequence
  124813. */
  124814. disableAnimation?: boolean;
  124815. /**
  124816. * Disable lighting on the material or the ring and arrow
  124817. */
  124818. disableLighting?: boolean;
  124819. /**
  124820. * Override the default material of the torus and arrow
  124821. */
  124822. torusArrowMaterial?: Material;
  124823. };
  124824. /**
  124825. * A list of meshes to use as floor meshes.
  124826. * Meshes can be added and removed after initializing the feature using the
  124827. * addFloorMesh and removeFloorMesh functions
  124828. * If empty, rotation will still work
  124829. */
  124830. floorMeshes?: AbstractMesh[];
  124831. /**
  124832. * use this rendering group id for the meshes (optional)
  124833. */
  124834. renderingGroupId?: number;
  124835. /**
  124836. * Should teleportation move only to snap points
  124837. */
  124838. snapPointsOnly?: boolean;
  124839. /**
  124840. * An array of points to which the teleportation will snap to.
  124841. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  124842. */
  124843. snapPositions?: Vector3[];
  124844. /**
  124845. * How close should the teleportation ray be in order to snap to position.
  124846. * Default to 0.8 units (meters)
  124847. */
  124848. snapToPositionRadius?: number;
  124849. /**
  124850. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  124851. * If you want to support rotation, make sure your mesh has a direction indicator.
  124852. *
  124853. * When left untouched, the default mesh will be initialized.
  124854. */
  124855. teleportationTargetMesh?: AbstractMesh;
  124856. /**
  124857. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  124858. */
  124859. timeToTeleport?: number;
  124860. /**
  124861. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  124862. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  124863. */
  124864. useMainComponentOnly?: boolean;
  124865. /**
  124866. * Should meshes created here be added to a utility layer or the main scene
  124867. */
  124868. useUtilityLayer?: boolean;
  124869. /**
  124870. * Babylon XR Input class for controller
  124871. */
  124872. xrInput: WebXRInput;
  124873. }
  124874. /**
  124875. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  124876. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  124877. * the input of the attached controllers.
  124878. */
  124879. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  124880. private _options;
  124881. private _controllers;
  124882. private _currentTeleportationControllerId;
  124883. private _floorMeshes;
  124884. private _quadraticBezierCurve;
  124885. private _selectionFeature;
  124886. private _snapToPositions;
  124887. private _snappedToPoint;
  124888. private _teleportationRingMaterial?;
  124889. private _tmpRay;
  124890. private _tmpVector;
  124891. /**
  124892. * The module's name
  124893. */
  124894. static readonly Name: string;
  124895. /**
  124896. * The (Babylon) version of this module.
  124897. * This is an integer representing the implementation version.
  124898. * This number does not correspond to the webxr specs version
  124899. */
  124900. static readonly Version: number;
  124901. /**
  124902. * Is movement backwards enabled
  124903. */
  124904. backwardsMovementEnabled: boolean;
  124905. /**
  124906. * Distance to travel when moving backwards
  124907. */
  124908. backwardsTeleportationDistance: number;
  124909. /**
  124910. * The distance from the user to the inspection point in the direction of the controller
  124911. * A higher number will allow the user to move further
  124912. * defaults to 5 (meters, in xr units)
  124913. */
  124914. parabolicCheckRadius: number;
  124915. /**
  124916. * Should the module support parabolic ray on top of direct ray
  124917. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  124918. * Very helpful when moving between floors / different heights
  124919. */
  124920. parabolicRayEnabled: boolean;
  124921. /**
  124922. * How much rotation should be applied when rotating right and left
  124923. */
  124924. rotationAngle: number;
  124925. /**
  124926. * Is rotation enabled when moving forward?
  124927. * Disabling this feature will prevent the user from deciding the direction when teleporting
  124928. */
  124929. rotationEnabled: boolean;
  124930. /**
  124931. * constructs a new anchor system
  124932. * @param _xrSessionManager an instance of WebXRSessionManager
  124933. * @param _options configuration object for this feature
  124934. */
  124935. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  124936. /**
  124937. * Get the snapPointsOnly flag
  124938. */
  124939. get snapPointsOnly(): boolean;
  124940. /**
  124941. * Sets the snapPointsOnly flag
  124942. * @param snapToPoints should teleportation be exclusively to snap points
  124943. */
  124944. set snapPointsOnly(snapToPoints: boolean);
  124945. /**
  124946. * Add a new mesh to the floor meshes array
  124947. * @param mesh the mesh to use as floor mesh
  124948. */
  124949. addFloorMesh(mesh: AbstractMesh): void;
  124950. /**
  124951. * Add a new snap-to point to fix teleportation to this position
  124952. * @param newSnapPoint The new Snap-To point
  124953. */
  124954. addSnapPoint(newSnapPoint: Vector3): void;
  124955. attach(): boolean;
  124956. detach(): boolean;
  124957. dispose(): void;
  124958. /**
  124959. * Remove a mesh from the floor meshes array
  124960. * @param mesh the mesh to remove
  124961. */
  124962. removeFloorMesh(mesh: AbstractMesh): void;
  124963. /**
  124964. * Remove a mesh from the floor meshes array using its name
  124965. * @param name the mesh name to remove
  124966. */
  124967. removeFloorMeshByName(name: string): void;
  124968. /**
  124969. * 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
  124970. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  124971. * @returns was the point found and removed or not
  124972. */
  124973. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  124974. /**
  124975. * This function sets a selection feature that will be disabled when
  124976. * the forward ray is shown and will be reattached when hidden.
  124977. * This is used to remove the selection rays when moving.
  124978. * @param selectionFeature the feature to disable when forward movement is enabled
  124979. */
  124980. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  124981. protected _onXRFrame(_xrFrame: XRFrame): void;
  124982. private _attachController;
  124983. private _createDefaultTargetMesh;
  124984. private _detachController;
  124985. private _findClosestSnapPointWithRadius;
  124986. private _setTargetMeshPosition;
  124987. private _setTargetMeshVisibility;
  124988. private _showParabolicPath;
  124989. private _teleportForward;
  124990. }
  124991. }
  124992. declare module BABYLON {
  124993. /**
  124994. * Options for the default xr helper
  124995. */
  124996. export class WebXRDefaultExperienceOptions {
  124997. /**
  124998. * Enable or disable default UI to enter XR
  124999. */
  125000. disableDefaultUI?: boolean;
  125001. /**
  125002. * Should teleportation not initialize. defaults to false.
  125003. */
  125004. disableTeleportation?: boolean;
  125005. /**
  125006. * Floor meshes that will be used for teleport
  125007. */
  125008. floorMeshes?: Array<AbstractMesh>;
  125009. /**
  125010. * If set to true, the first frame will not be used to reset position
  125011. * The first frame is mainly used when copying transformation from the old camera
  125012. * Mainly used in AR
  125013. */
  125014. ignoreNativeCameraTransformation?: boolean;
  125015. /**
  125016. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  125017. */
  125018. inputOptions?: IWebXRInputOptions;
  125019. /**
  125020. * optional configuration for the output canvas
  125021. */
  125022. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  125023. /**
  125024. * optional UI options. This can be used among other to change session mode and reference space type
  125025. */
  125026. uiOptions?: WebXREnterExitUIOptions;
  125027. /**
  125028. * When loading teleportation and pointer select, use stable versions instead of latest.
  125029. */
  125030. useStablePlugins?: boolean;
  125031. /**
  125032. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  125033. */
  125034. renderingGroupId?: number;
  125035. /**
  125036. * A list of optional features to init the session with
  125037. * If set to true, all features we support will be added
  125038. */
  125039. optionalFeatures?: boolean | string[];
  125040. }
  125041. /**
  125042. * Default experience which provides a similar setup to the previous webVRExperience
  125043. */
  125044. export class WebXRDefaultExperience {
  125045. /**
  125046. * Base experience
  125047. */
  125048. baseExperience: WebXRExperienceHelper;
  125049. /**
  125050. * Enables ui for entering/exiting xr
  125051. */
  125052. enterExitUI: WebXREnterExitUI;
  125053. /**
  125054. * Input experience extension
  125055. */
  125056. input: WebXRInput;
  125057. /**
  125058. * Enables laser pointer and selection
  125059. */
  125060. pointerSelection: WebXRControllerPointerSelection;
  125061. /**
  125062. * Default target xr should render to
  125063. */
  125064. renderTarget: WebXRRenderTarget;
  125065. /**
  125066. * Enables teleportation
  125067. */
  125068. teleportation: WebXRMotionControllerTeleportation;
  125069. private constructor();
  125070. /**
  125071. * Creates the default xr experience
  125072. * @param scene scene
  125073. * @param options options for basic configuration
  125074. * @returns resulting WebXRDefaultExperience
  125075. */
  125076. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  125077. /**
  125078. * DIsposes of the experience helper
  125079. */
  125080. dispose(): void;
  125081. }
  125082. }
  125083. declare module BABYLON {
  125084. /**
  125085. * Options to modify the vr teleportation behavior.
  125086. */
  125087. export interface VRTeleportationOptions {
  125088. /**
  125089. * The name of the mesh which should be used as the teleportation floor. (default: null)
  125090. */
  125091. floorMeshName?: string;
  125092. /**
  125093. * A list of meshes to be used as the teleportation floor. (default: empty)
  125094. */
  125095. floorMeshes?: Mesh[];
  125096. /**
  125097. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  125098. */
  125099. teleportationMode?: number;
  125100. /**
  125101. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  125102. */
  125103. teleportationTime?: number;
  125104. /**
  125105. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  125106. */
  125107. teleportationSpeed?: number;
  125108. /**
  125109. * The easing function used in the animation or null for Linear. (default CircleEase)
  125110. */
  125111. easingFunction?: EasingFunction;
  125112. }
  125113. /**
  125114. * Options to modify the vr experience helper's behavior.
  125115. */
  125116. export interface VRExperienceHelperOptions extends WebVROptions {
  125117. /**
  125118. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  125119. */
  125120. createDeviceOrientationCamera?: boolean;
  125121. /**
  125122. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  125123. */
  125124. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  125125. /**
  125126. * Uses the main button on the controller to toggle the laser casted. (default: true)
  125127. */
  125128. laserToggle?: boolean;
  125129. /**
  125130. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  125131. */
  125132. floorMeshes?: Mesh[];
  125133. /**
  125134. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  125135. */
  125136. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  125137. /**
  125138. * Defines if WebXR should be used instead of WebVR (if available)
  125139. */
  125140. useXR?: boolean;
  125141. }
  125142. /**
  125143. * Event containing information after VR has been entered
  125144. */
  125145. export class OnAfterEnteringVRObservableEvent {
  125146. /**
  125147. * If entering vr was successful
  125148. */
  125149. success: boolean;
  125150. }
  125151. /**
  125152. * Helps to quickly add VR support to an existing scene.
  125153. * See http://doc.babylonjs.com/how_to/webvr_helper
  125154. */
  125155. export class VRExperienceHelper {
  125156. /** Options to modify the vr experience helper's behavior. */
  125157. webVROptions: VRExperienceHelperOptions;
  125158. private _scene;
  125159. private _position;
  125160. private _btnVR;
  125161. private _btnVRDisplayed;
  125162. private _webVRsupported;
  125163. private _webVRready;
  125164. private _webVRrequesting;
  125165. private _webVRpresenting;
  125166. private _hasEnteredVR;
  125167. private _fullscreenVRpresenting;
  125168. private _inputElement;
  125169. private _webVRCamera;
  125170. private _vrDeviceOrientationCamera;
  125171. private _deviceOrientationCamera;
  125172. private _existingCamera;
  125173. private _onKeyDown;
  125174. private _onVrDisplayPresentChange;
  125175. private _onVRDisplayChanged;
  125176. private _onVRRequestPresentStart;
  125177. private _onVRRequestPresentComplete;
  125178. /**
  125179. * 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)
  125180. */
  125181. enableGazeEvenWhenNoPointerLock: boolean;
  125182. /**
  125183. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  125184. */
  125185. exitVROnDoubleTap: boolean;
  125186. /**
  125187. * Observable raised right before entering VR.
  125188. */
  125189. onEnteringVRObservable: Observable<VRExperienceHelper>;
  125190. /**
  125191. * Observable raised when entering VR has completed.
  125192. */
  125193. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  125194. /**
  125195. * Observable raised when exiting VR.
  125196. */
  125197. onExitingVRObservable: Observable<VRExperienceHelper>;
  125198. /**
  125199. * Observable raised when controller mesh is loaded.
  125200. */
  125201. onControllerMeshLoadedObservable: Observable<WebVRController>;
  125202. /** Return this.onEnteringVRObservable
  125203. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  125204. */
  125205. get onEnteringVR(): Observable<VRExperienceHelper>;
  125206. /** Return this.onExitingVRObservable
  125207. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  125208. */
  125209. get onExitingVR(): Observable<VRExperienceHelper>;
  125210. /** Return this.onControllerMeshLoadedObservable
  125211. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  125212. */
  125213. get onControllerMeshLoaded(): Observable<WebVRController>;
  125214. private _rayLength;
  125215. private _useCustomVRButton;
  125216. private _teleportationRequested;
  125217. private _teleportActive;
  125218. private _floorMeshName;
  125219. private _floorMeshesCollection;
  125220. private _teleportationMode;
  125221. private _teleportationTime;
  125222. private _teleportationSpeed;
  125223. private _teleportationEasing;
  125224. private _rotationAllowed;
  125225. private _teleportBackwardsVector;
  125226. private _teleportationTarget;
  125227. private _isDefaultTeleportationTarget;
  125228. private _postProcessMove;
  125229. private _teleportationFillColor;
  125230. private _teleportationBorderColor;
  125231. private _rotationAngle;
  125232. private _haloCenter;
  125233. private _cameraGazer;
  125234. private _padSensibilityUp;
  125235. private _padSensibilityDown;
  125236. private _leftController;
  125237. private _rightController;
  125238. private _gazeColor;
  125239. private _laserColor;
  125240. private _pickedLaserColor;
  125241. private _pickedGazeColor;
  125242. /**
  125243. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  125244. */
  125245. onNewMeshSelected: Observable<AbstractMesh>;
  125246. /**
  125247. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  125248. * This observable will provide the mesh and the controller used to select the mesh
  125249. */
  125250. onMeshSelectedWithController: Observable<{
  125251. mesh: AbstractMesh;
  125252. controller: WebVRController;
  125253. }>;
  125254. /**
  125255. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  125256. */
  125257. onNewMeshPicked: Observable<PickingInfo>;
  125258. private _circleEase;
  125259. /**
  125260. * Observable raised before camera teleportation
  125261. */
  125262. onBeforeCameraTeleport: Observable<Vector3>;
  125263. /**
  125264. * Observable raised after camera teleportation
  125265. */
  125266. onAfterCameraTeleport: Observable<Vector3>;
  125267. /**
  125268. * Observable raised when current selected mesh gets unselected
  125269. */
  125270. onSelectedMeshUnselected: Observable<AbstractMesh>;
  125271. private _raySelectionPredicate;
  125272. /**
  125273. * To be optionaly changed by user to define custom ray selection
  125274. */
  125275. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  125276. /**
  125277. * To be optionaly changed by user to define custom selection logic (after ray selection)
  125278. */
  125279. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  125280. /**
  125281. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  125282. */
  125283. teleportationEnabled: boolean;
  125284. private _defaultHeight;
  125285. private _teleportationInitialized;
  125286. private _interactionsEnabled;
  125287. private _interactionsRequested;
  125288. private _displayGaze;
  125289. private _displayLaserPointer;
  125290. /**
  125291. * The mesh used to display where the user is going to teleport.
  125292. */
  125293. get teleportationTarget(): Mesh;
  125294. /**
  125295. * Sets the mesh to be used to display where the user is going to teleport.
  125296. */
  125297. set teleportationTarget(value: Mesh);
  125298. /**
  125299. * 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
  125300. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  125301. * See http://doc.babylonjs.com/resources/baking_transformations
  125302. */
  125303. get gazeTrackerMesh(): Mesh;
  125304. set gazeTrackerMesh(value: Mesh);
  125305. /**
  125306. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  125307. */
  125308. updateGazeTrackerScale: boolean;
  125309. /**
  125310. * If the gaze trackers color should be updated when selecting meshes
  125311. */
  125312. updateGazeTrackerColor: boolean;
  125313. /**
  125314. * If the controller laser color should be updated when selecting meshes
  125315. */
  125316. updateControllerLaserColor: boolean;
  125317. /**
  125318. * The gaze tracking mesh corresponding to the left controller
  125319. */
  125320. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  125321. /**
  125322. * The gaze tracking mesh corresponding to the right controller
  125323. */
  125324. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  125325. /**
  125326. * If the ray of the gaze should be displayed.
  125327. */
  125328. get displayGaze(): boolean;
  125329. /**
  125330. * Sets if the ray of the gaze should be displayed.
  125331. */
  125332. set displayGaze(value: boolean);
  125333. /**
  125334. * If the ray of the LaserPointer should be displayed.
  125335. */
  125336. get displayLaserPointer(): boolean;
  125337. /**
  125338. * Sets if the ray of the LaserPointer should be displayed.
  125339. */
  125340. set displayLaserPointer(value: boolean);
  125341. /**
  125342. * The deviceOrientationCamera used as the camera when not in VR.
  125343. */
  125344. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  125345. /**
  125346. * Based on the current WebVR support, returns the current VR camera used.
  125347. */
  125348. get currentVRCamera(): Nullable<Camera>;
  125349. /**
  125350. * The webVRCamera which is used when in VR.
  125351. */
  125352. get webVRCamera(): WebVRFreeCamera;
  125353. /**
  125354. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  125355. */
  125356. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  125357. /**
  125358. * The html button that is used to trigger entering into VR.
  125359. */
  125360. get vrButton(): Nullable<HTMLButtonElement>;
  125361. private get _teleportationRequestInitiated();
  125362. /**
  125363. * Defines whether or not Pointer lock should be requested when switching to
  125364. * full screen.
  125365. */
  125366. requestPointerLockOnFullScreen: boolean;
  125367. /**
  125368. * If asking to force XR, this will be populated with the default xr experience
  125369. */
  125370. xr: WebXRDefaultExperience;
  125371. /**
  125372. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  125373. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  125374. */
  125375. xrTestDone: boolean;
  125376. /**
  125377. * Instantiates a VRExperienceHelper.
  125378. * Helps to quickly add VR support to an existing scene.
  125379. * @param scene The scene the VRExperienceHelper belongs to.
  125380. * @param webVROptions Options to modify the vr experience helper's behavior.
  125381. */
  125382. constructor(scene: Scene,
  125383. /** Options to modify the vr experience helper's behavior. */
  125384. webVROptions?: VRExperienceHelperOptions);
  125385. private completeVRInit;
  125386. private _onDefaultMeshLoaded;
  125387. private _onResize;
  125388. private _onFullscreenChange;
  125389. /**
  125390. * Gets a value indicating if we are currently in VR mode.
  125391. */
  125392. get isInVRMode(): boolean;
  125393. private onVrDisplayPresentChange;
  125394. private onVRDisplayChanged;
  125395. private moveButtonToBottomRight;
  125396. private displayVRButton;
  125397. private updateButtonVisibility;
  125398. private _cachedAngularSensibility;
  125399. /**
  125400. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  125401. * Otherwise, will use the fullscreen API.
  125402. */
  125403. enterVR(): void;
  125404. /**
  125405. * Attempt to exit VR, or fullscreen.
  125406. */
  125407. exitVR(): void;
  125408. /**
  125409. * The position of the vr experience helper.
  125410. */
  125411. get position(): Vector3;
  125412. /**
  125413. * Sets the position of the vr experience helper.
  125414. */
  125415. set position(value: Vector3);
  125416. /**
  125417. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  125418. */
  125419. enableInteractions(): void;
  125420. private get _noControllerIsActive();
  125421. private beforeRender;
  125422. private _isTeleportationFloor;
  125423. /**
  125424. * Adds a floor mesh to be used for teleportation.
  125425. * @param floorMesh the mesh to be used for teleportation.
  125426. */
  125427. addFloorMesh(floorMesh: Mesh): void;
  125428. /**
  125429. * Removes a floor mesh from being used for teleportation.
  125430. * @param floorMesh the mesh to be removed.
  125431. */
  125432. removeFloorMesh(floorMesh: Mesh): void;
  125433. /**
  125434. * Enables interactions and teleportation using the VR controllers and gaze.
  125435. * @param vrTeleportationOptions options to modify teleportation behavior.
  125436. */
  125437. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  125438. private _onNewGamepadConnected;
  125439. private _tryEnableInteractionOnController;
  125440. private _onNewGamepadDisconnected;
  125441. private _enableInteractionOnController;
  125442. private _checkTeleportWithRay;
  125443. private _checkRotate;
  125444. private _checkTeleportBackwards;
  125445. private _enableTeleportationOnController;
  125446. private _createTeleportationCircles;
  125447. private _displayTeleportationTarget;
  125448. private _hideTeleportationTarget;
  125449. private _rotateCamera;
  125450. private _moveTeleportationSelectorTo;
  125451. private _workingVector;
  125452. private _workingQuaternion;
  125453. private _workingMatrix;
  125454. /**
  125455. * Time Constant Teleportation Mode
  125456. */
  125457. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  125458. /**
  125459. * Speed Constant Teleportation Mode
  125460. */
  125461. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  125462. /**
  125463. * Teleports the users feet to the desired location
  125464. * @param location The location where the user's feet should be placed
  125465. */
  125466. teleportCamera(location: Vector3): void;
  125467. private _convertNormalToDirectionOfRay;
  125468. private _castRayAndSelectObject;
  125469. private _notifySelectedMeshUnselected;
  125470. /**
  125471. * Permanently set new colors for the laser pointer
  125472. * @param color the new laser color
  125473. * @param pickedColor the new laser color when picked mesh detected
  125474. */
  125475. setLaserColor(color: Color3, pickedColor?: Color3): void;
  125476. /**
  125477. * Set lighting enabled / disabled on the laser pointer of both controllers
  125478. * @param enabled should the lighting be enabled on the laser pointer
  125479. */
  125480. setLaserLightingState(enabled?: boolean): void;
  125481. /**
  125482. * Permanently set new colors for the gaze pointer
  125483. * @param color the new gaze color
  125484. * @param pickedColor the new gaze color when picked mesh detected
  125485. */
  125486. setGazeColor(color: Color3, pickedColor?: Color3): void;
  125487. /**
  125488. * Sets the color of the laser ray from the vr controllers.
  125489. * @param color new color for the ray.
  125490. */
  125491. changeLaserColor(color: Color3): void;
  125492. /**
  125493. * Sets the color of the ray from the vr headsets gaze.
  125494. * @param color new color for the ray.
  125495. */
  125496. changeGazeColor(color: Color3): void;
  125497. /**
  125498. * Exits VR and disposes of the vr experience helper
  125499. */
  125500. dispose(): void;
  125501. /**
  125502. * Gets the name of the VRExperienceHelper class
  125503. * @returns "VRExperienceHelper"
  125504. */
  125505. getClassName(): string;
  125506. }
  125507. }
  125508. declare module BABYLON {
  125509. /**
  125510. * Contains an array of blocks representing the octree
  125511. */
  125512. export interface IOctreeContainer<T> {
  125513. /**
  125514. * Blocks within the octree
  125515. */
  125516. blocks: Array<OctreeBlock<T>>;
  125517. }
  125518. /**
  125519. * Class used to store a cell in an octree
  125520. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  125521. */
  125522. export class OctreeBlock<T> {
  125523. /**
  125524. * Gets the content of the current block
  125525. */
  125526. entries: T[];
  125527. /**
  125528. * Gets the list of block children
  125529. */
  125530. blocks: Array<OctreeBlock<T>>;
  125531. private _depth;
  125532. private _maxDepth;
  125533. private _capacity;
  125534. private _minPoint;
  125535. private _maxPoint;
  125536. private _boundingVectors;
  125537. private _creationFunc;
  125538. /**
  125539. * Creates a new block
  125540. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  125541. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  125542. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  125543. * @param depth defines the current depth of this block in the octree
  125544. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  125545. * @param creationFunc defines a callback to call when an element is added to the block
  125546. */
  125547. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  125548. /**
  125549. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  125550. */
  125551. get capacity(): number;
  125552. /**
  125553. * Gets the minimum vector (in world space) of the block's bounding box
  125554. */
  125555. get minPoint(): Vector3;
  125556. /**
  125557. * Gets the maximum vector (in world space) of the block's bounding box
  125558. */
  125559. get maxPoint(): Vector3;
  125560. /**
  125561. * Add a new element to this block
  125562. * @param entry defines the element to add
  125563. */
  125564. addEntry(entry: T): void;
  125565. /**
  125566. * Remove an element from this block
  125567. * @param entry defines the element to remove
  125568. */
  125569. removeEntry(entry: T): void;
  125570. /**
  125571. * Add an array of elements to this block
  125572. * @param entries defines the array of elements to add
  125573. */
  125574. addEntries(entries: T[]): void;
  125575. /**
  125576. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  125577. * @param frustumPlanes defines the frustum planes to test
  125578. * @param selection defines the array to store current content if selection is positive
  125579. * @param allowDuplicate defines if the selection array can contains duplicated entries
  125580. */
  125581. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  125582. /**
  125583. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  125584. * @param sphereCenter defines the bounding sphere center
  125585. * @param sphereRadius defines the bounding sphere radius
  125586. * @param selection defines the array to store current content if selection is positive
  125587. * @param allowDuplicate defines if the selection array can contains duplicated entries
  125588. */
  125589. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  125590. /**
  125591. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  125592. * @param ray defines the ray to test with
  125593. * @param selection defines the array to store current content if selection is positive
  125594. */
  125595. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  125596. /**
  125597. * Subdivide the content into child blocks (this block will then be empty)
  125598. */
  125599. createInnerBlocks(): void;
  125600. /**
  125601. * @hidden
  125602. */
  125603. 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;
  125604. }
  125605. }
  125606. declare module BABYLON {
  125607. /**
  125608. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  125609. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  125610. */
  125611. export class Octree<T> {
  125612. /** 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.) */
  125613. maxDepth: number;
  125614. /**
  125615. * Blocks within the octree containing objects
  125616. */
  125617. blocks: Array<OctreeBlock<T>>;
  125618. /**
  125619. * Content stored in the octree
  125620. */
  125621. dynamicContent: T[];
  125622. private _maxBlockCapacity;
  125623. private _selectionContent;
  125624. private _creationFunc;
  125625. /**
  125626. * Creates a octree
  125627. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  125628. * @param creationFunc function to be used to instatiate the octree
  125629. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  125630. * @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.)
  125631. */
  125632. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  125633. /** 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.) */
  125634. maxDepth?: number);
  125635. /**
  125636. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  125637. * @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);
  125638. * @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);
  125639. * @param entries meshes to be added to the octree blocks
  125640. */
  125641. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  125642. /**
  125643. * Adds a mesh to the octree
  125644. * @param entry Mesh to add to the octree
  125645. */
  125646. addMesh(entry: T): void;
  125647. /**
  125648. * Remove an element from the octree
  125649. * @param entry defines the element to remove
  125650. */
  125651. removeMesh(entry: T): void;
  125652. /**
  125653. * Selects an array of meshes within the frustum
  125654. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  125655. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  125656. * @returns array of meshes within the frustum
  125657. */
  125658. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  125659. /**
  125660. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  125661. * @param sphereCenter defines the bounding sphere center
  125662. * @param sphereRadius defines the bounding sphere radius
  125663. * @param allowDuplicate defines if the selection array can contains duplicated entries
  125664. * @returns an array of objects that intersect the sphere
  125665. */
  125666. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  125667. /**
  125668. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  125669. * @param ray defines the ray to test with
  125670. * @returns array of intersected objects
  125671. */
  125672. intersectsRay(ray: Ray): SmartArray<T>;
  125673. /**
  125674. * Adds a mesh into the octree block if it intersects the block
  125675. */
  125676. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  125677. /**
  125678. * Adds a submesh into the octree block if it intersects the block
  125679. */
  125680. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  125681. }
  125682. }
  125683. declare module BABYLON {
  125684. interface Scene {
  125685. /**
  125686. * @hidden
  125687. * Backing Filed
  125688. */
  125689. _selectionOctree: Octree<AbstractMesh>;
  125690. /**
  125691. * Gets the octree used to boost mesh selection (picking)
  125692. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  125693. */
  125694. selectionOctree: Octree<AbstractMesh>;
  125695. /**
  125696. * Creates or updates the octree used to boost selection (picking)
  125697. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  125698. * @param maxCapacity defines the maximum capacity per leaf
  125699. * @param maxDepth defines the maximum depth of the octree
  125700. * @returns an octree of AbstractMesh
  125701. */
  125702. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  125703. }
  125704. interface AbstractMesh {
  125705. /**
  125706. * @hidden
  125707. * Backing Field
  125708. */
  125709. _submeshesOctree: Octree<SubMesh>;
  125710. /**
  125711. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  125712. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  125713. * @param maxCapacity defines the maximum size of each block (64 by default)
  125714. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  125715. * @returns the new octree
  125716. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  125717. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  125718. */
  125719. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  125720. }
  125721. /**
  125722. * Defines the octree scene component responsible to manage any octrees
  125723. * in a given scene.
  125724. */
  125725. export class OctreeSceneComponent {
  125726. /**
  125727. * The component name help to identify the component in the list of scene components.
  125728. */
  125729. readonly name: string;
  125730. /**
  125731. * The scene the component belongs to.
  125732. */
  125733. scene: Scene;
  125734. /**
  125735. * Indicates if the meshes have been checked to make sure they are isEnabled()
  125736. */
  125737. readonly checksIsEnabled: boolean;
  125738. /**
  125739. * Creates a new instance of the component for the given scene
  125740. * @param scene Defines the scene to register the component in
  125741. */
  125742. constructor(scene: Scene);
  125743. /**
  125744. * Registers the component in a given scene
  125745. */
  125746. register(): void;
  125747. /**
  125748. * Return the list of active meshes
  125749. * @returns the list of active meshes
  125750. */
  125751. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  125752. /**
  125753. * Return the list of active sub meshes
  125754. * @param mesh The mesh to get the candidates sub meshes from
  125755. * @returns the list of active sub meshes
  125756. */
  125757. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  125758. private _tempRay;
  125759. /**
  125760. * Return the list of sub meshes intersecting with a given local ray
  125761. * @param mesh defines the mesh to find the submesh for
  125762. * @param localRay defines the ray in local space
  125763. * @returns the list of intersecting sub meshes
  125764. */
  125765. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  125766. /**
  125767. * Return the list of sub meshes colliding with a collider
  125768. * @param mesh defines the mesh to find the submesh for
  125769. * @param collider defines the collider to evaluate the collision against
  125770. * @returns the list of colliding sub meshes
  125771. */
  125772. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  125773. /**
  125774. * Rebuilds the elements related to this component in case of
  125775. * context lost for instance.
  125776. */
  125777. rebuild(): void;
  125778. /**
  125779. * Disposes the component and the associated ressources.
  125780. */
  125781. dispose(): void;
  125782. }
  125783. }
  125784. declare module BABYLON {
  125785. /**
  125786. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  125787. */
  125788. export class Gizmo implements IDisposable {
  125789. /** The utility layer the gizmo will be added to */
  125790. gizmoLayer: UtilityLayerRenderer;
  125791. /**
  125792. * The root mesh of the gizmo
  125793. */
  125794. _rootMesh: Mesh;
  125795. private _attachedMesh;
  125796. /**
  125797. * Ratio for the scale of the gizmo (Default: 1)
  125798. */
  125799. scaleRatio: number;
  125800. /**
  125801. * If a custom mesh has been set (Default: false)
  125802. */
  125803. protected _customMeshSet: boolean;
  125804. /**
  125805. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  125806. * * When set, interactions will be enabled
  125807. */
  125808. get attachedMesh(): Nullable<AbstractMesh>;
  125809. set attachedMesh(value: Nullable<AbstractMesh>);
  125810. /**
  125811. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  125812. * @param mesh The mesh to replace the default mesh of the gizmo
  125813. */
  125814. setCustomMesh(mesh: Mesh): void;
  125815. /**
  125816. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  125817. */
  125818. updateGizmoRotationToMatchAttachedMesh: boolean;
  125819. /**
  125820. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  125821. */
  125822. updateGizmoPositionToMatchAttachedMesh: boolean;
  125823. /**
  125824. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  125825. */
  125826. updateScale: boolean;
  125827. protected _interactionsEnabled: boolean;
  125828. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  125829. private _beforeRenderObserver;
  125830. private _tempVector;
  125831. /**
  125832. * Creates a gizmo
  125833. * @param gizmoLayer The utility layer the gizmo will be added to
  125834. */
  125835. constructor(
  125836. /** The utility layer the gizmo will be added to */
  125837. gizmoLayer?: UtilityLayerRenderer);
  125838. /**
  125839. * Updates the gizmo to match the attached mesh's position/rotation
  125840. */
  125841. protected _update(): void;
  125842. /**
  125843. * Disposes of the gizmo
  125844. */
  125845. dispose(): void;
  125846. }
  125847. }
  125848. declare module BABYLON {
  125849. /**
  125850. * Single plane drag gizmo
  125851. */
  125852. export class PlaneDragGizmo extends Gizmo {
  125853. /**
  125854. * Drag behavior responsible for the gizmos dragging interactions
  125855. */
  125856. dragBehavior: PointerDragBehavior;
  125857. private _pointerObserver;
  125858. /**
  125859. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  125860. */
  125861. snapDistance: number;
  125862. /**
  125863. * Event that fires each time the gizmo snaps to a new location.
  125864. * * snapDistance is the the change in distance
  125865. */
  125866. onSnapObservable: Observable<{
  125867. snapDistance: number;
  125868. }>;
  125869. private _plane;
  125870. private _coloredMaterial;
  125871. private _hoverMaterial;
  125872. private _isEnabled;
  125873. private _parent;
  125874. /** @hidden */
  125875. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  125876. /** @hidden */
  125877. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  125878. /**
  125879. * Creates a PlaneDragGizmo
  125880. * @param gizmoLayer The utility layer the gizmo will be added to
  125881. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  125882. * @param color The color of the gizmo
  125883. */
  125884. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  125885. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  125886. /**
  125887. * If the gizmo is enabled
  125888. */
  125889. set isEnabled(value: boolean);
  125890. get isEnabled(): boolean;
  125891. /**
  125892. * Disposes of the gizmo
  125893. */
  125894. dispose(): void;
  125895. }
  125896. }
  125897. declare module BABYLON {
  125898. /**
  125899. * Gizmo that enables dragging a mesh along 3 axis
  125900. */
  125901. export class PositionGizmo extends Gizmo {
  125902. /**
  125903. * Internal gizmo used for interactions on the x axis
  125904. */
  125905. xGizmo: AxisDragGizmo;
  125906. /**
  125907. * Internal gizmo used for interactions on the y axis
  125908. */
  125909. yGizmo: AxisDragGizmo;
  125910. /**
  125911. * Internal gizmo used for interactions on the z axis
  125912. */
  125913. zGizmo: AxisDragGizmo;
  125914. /**
  125915. * Internal gizmo used for interactions on the yz plane
  125916. */
  125917. xPlaneGizmo: PlaneDragGizmo;
  125918. /**
  125919. * Internal gizmo used for interactions on the xz plane
  125920. */
  125921. yPlaneGizmo: PlaneDragGizmo;
  125922. /**
  125923. * Internal gizmo used for interactions on the xy plane
  125924. */
  125925. zPlaneGizmo: PlaneDragGizmo;
  125926. /**
  125927. * private variables
  125928. */
  125929. private _meshAttached;
  125930. private _updateGizmoRotationToMatchAttachedMesh;
  125931. private _snapDistance;
  125932. private _scaleRatio;
  125933. /** Fires an event when any of it's sub gizmos are dragged */
  125934. onDragStartObservable: Observable<unknown>;
  125935. /** Fires an event when any of it's sub gizmos are released from dragging */
  125936. onDragEndObservable: Observable<unknown>;
  125937. /**
  125938. * If set to true, planar drag is enabled
  125939. */
  125940. private _planarGizmoEnabled;
  125941. get attachedMesh(): Nullable<AbstractMesh>;
  125942. set attachedMesh(mesh: Nullable<AbstractMesh>);
  125943. /**
  125944. * Creates a PositionGizmo
  125945. * @param gizmoLayer The utility layer the gizmo will be added to
  125946. */
  125947. constructor(gizmoLayer?: UtilityLayerRenderer);
  125948. /**
  125949. * If the planar drag gizmo is enabled
  125950. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  125951. */
  125952. set planarGizmoEnabled(value: boolean);
  125953. get planarGizmoEnabled(): boolean;
  125954. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  125955. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  125956. /**
  125957. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  125958. */
  125959. set snapDistance(value: number);
  125960. get snapDistance(): number;
  125961. /**
  125962. * Ratio for the scale of the gizmo (Default: 1)
  125963. */
  125964. set scaleRatio(value: number);
  125965. get scaleRatio(): number;
  125966. /**
  125967. * Disposes of the gizmo
  125968. */
  125969. dispose(): void;
  125970. /**
  125971. * CustomMeshes are not supported by this gizmo
  125972. * @param mesh The mesh to replace the default mesh of the gizmo
  125973. */
  125974. setCustomMesh(mesh: Mesh): void;
  125975. }
  125976. }
  125977. declare module BABYLON {
  125978. /**
  125979. * Single axis drag gizmo
  125980. */
  125981. export class AxisDragGizmo extends Gizmo {
  125982. /**
  125983. * Drag behavior responsible for the gizmos dragging interactions
  125984. */
  125985. dragBehavior: PointerDragBehavior;
  125986. private _pointerObserver;
  125987. /**
  125988. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  125989. */
  125990. snapDistance: number;
  125991. /**
  125992. * Event that fires each time the gizmo snaps to a new location.
  125993. * * snapDistance is the the change in distance
  125994. */
  125995. onSnapObservable: Observable<{
  125996. snapDistance: number;
  125997. }>;
  125998. private _isEnabled;
  125999. private _parent;
  126000. private _arrow;
  126001. private _coloredMaterial;
  126002. private _hoverMaterial;
  126003. /** @hidden */
  126004. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  126005. /** @hidden */
  126006. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  126007. /**
  126008. * Creates an AxisDragGizmo
  126009. * @param gizmoLayer The utility layer the gizmo will be added to
  126010. * @param dragAxis The axis which the gizmo will be able to drag on
  126011. * @param color The color of the gizmo
  126012. */
  126013. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  126014. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  126015. /**
  126016. * If the gizmo is enabled
  126017. */
  126018. set isEnabled(value: boolean);
  126019. get isEnabled(): boolean;
  126020. /**
  126021. * Disposes of the gizmo
  126022. */
  126023. dispose(): void;
  126024. }
  126025. }
  126026. declare module BABYLON.Debug {
  126027. /**
  126028. * The Axes viewer will show 3 axes in a specific point in space
  126029. */
  126030. export class AxesViewer {
  126031. private _xAxis;
  126032. private _yAxis;
  126033. private _zAxis;
  126034. private _scaleLinesFactor;
  126035. private _instanced;
  126036. /**
  126037. * Gets the hosting scene
  126038. */
  126039. scene: Scene;
  126040. /**
  126041. * Gets or sets a number used to scale line length
  126042. */
  126043. scaleLines: number;
  126044. /** Gets the node hierarchy used to render x-axis */
  126045. get xAxis(): TransformNode;
  126046. /** Gets the node hierarchy used to render y-axis */
  126047. get yAxis(): TransformNode;
  126048. /** Gets the node hierarchy used to render z-axis */
  126049. get zAxis(): TransformNode;
  126050. /**
  126051. * Creates a new AxesViewer
  126052. * @param scene defines the hosting scene
  126053. * @param scaleLines defines a number used to scale line length (1 by default)
  126054. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  126055. * @param xAxis defines the node hierarchy used to render the x-axis
  126056. * @param yAxis defines the node hierarchy used to render the y-axis
  126057. * @param zAxis defines the node hierarchy used to render the z-axis
  126058. */
  126059. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  126060. /**
  126061. * Force the viewer to update
  126062. * @param position defines the position of the viewer
  126063. * @param xaxis defines the x axis of the viewer
  126064. * @param yaxis defines the y axis of the viewer
  126065. * @param zaxis defines the z axis of the viewer
  126066. */
  126067. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  126068. /**
  126069. * Creates an instance of this axes viewer.
  126070. * @returns a new axes viewer with instanced meshes
  126071. */
  126072. createInstance(): AxesViewer;
  126073. /** Releases resources */
  126074. dispose(): void;
  126075. private static _SetRenderingGroupId;
  126076. }
  126077. }
  126078. declare module BABYLON.Debug {
  126079. /**
  126080. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  126081. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  126082. */
  126083. export class BoneAxesViewer extends AxesViewer {
  126084. /**
  126085. * Gets or sets the target mesh where to display the axes viewer
  126086. */
  126087. mesh: Nullable<Mesh>;
  126088. /**
  126089. * Gets or sets the target bone where to display the axes viewer
  126090. */
  126091. bone: Nullable<Bone>;
  126092. /** Gets current position */
  126093. pos: Vector3;
  126094. /** Gets direction of X axis */
  126095. xaxis: Vector3;
  126096. /** Gets direction of Y axis */
  126097. yaxis: Vector3;
  126098. /** Gets direction of Z axis */
  126099. zaxis: Vector3;
  126100. /**
  126101. * Creates a new BoneAxesViewer
  126102. * @param scene defines the hosting scene
  126103. * @param bone defines the target bone
  126104. * @param mesh defines the target mesh
  126105. * @param scaleLines defines a scaling factor for line length (1 by default)
  126106. */
  126107. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  126108. /**
  126109. * Force the viewer to update
  126110. */
  126111. update(): void;
  126112. /** Releases resources */
  126113. dispose(): void;
  126114. }
  126115. }
  126116. declare module BABYLON {
  126117. /**
  126118. * Interface used to define scene explorer extensibility option
  126119. */
  126120. export interface IExplorerExtensibilityOption {
  126121. /**
  126122. * Define the option label
  126123. */
  126124. label: string;
  126125. /**
  126126. * Defines the action to execute on click
  126127. */
  126128. action: (entity: any) => void;
  126129. }
  126130. /**
  126131. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  126132. */
  126133. export interface IExplorerExtensibilityGroup {
  126134. /**
  126135. * Defines a predicate to test if a given type mut be extended
  126136. */
  126137. predicate: (entity: any) => boolean;
  126138. /**
  126139. * Gets the list of options added to a type
  126140. */
  126141. entries: IExplorerExtensibilityOption[];
  126142. }
  126143. /**
  126144. * Interface used to define the options to use to create the Inspector
  126145. */
  126146. export interface IInspectorOptions {
  126147. /**
  126148. * Display in overlay mode (default: false)
  126149. */
  126150. overlay?: boolean;
  126151. /**
  126152. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  126153. */
  126154. globalRoot?: HTMLElement;
  126155. /**
  126156. * Display the Scene explorer
  126157. */
  126158. showExplorer?: boolean;
  126159. /**
  126160. * Display the property inspector
  126161. */
  126162. showInspector?: boolean;
  126163. /**
  126164. * Display in embed mode (both panes on the right)
  126165. */
  126166. embedMode?: boolean;
  126167. /**
  126168. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  126169. */
  126170. handleResize?: boolean;
  126171. /**
  126172. * Allow the panes to popup (default: true)
  126173. */
  126174. enablePopup?: boolean;
  126175. /**
  126176. * Allow the panes to be closed by users (default: true)
  126177. */
  126178. enableClose?: boolean;
  126179. /**
  126180. * Optional list of extensibility entries
  126181. */
  126182. explorerExtensibility?: IExplorerExtensibilityGroup[];
  126183. /**
  126184. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  126185. */
  126186. inspectorURL?: string;
  126187. /**
  126188. * Optional initial tab (default to DebugLayerTab.Properties)
  126189. */
  126190. initialTab?: DebugLayerTab;
  126191. }
  126192. interface Scene {
  126193. /**
  126194. * @hidden
  126195. * Backing field
  126196. */
  126197. _debugLayer: DebugLayer;
  126198. /**
  126199. * Gets the debug layer (aka Inspector) associated with the scene
  126200. * @see http://doc.babylonjs.com/features/playground_debuglayer
  126201. */
  126202. debugLayer: DebugLayer;
  126203. }
  126204. /**
  126205. * Enum of inspector action tab
  126206. */
  126207. export enum DebugLayerTab {
  126208. /**
  126209. * Properties tag (default)
  126210. */
  126211. Properties = 0,
  126212. /**
  126213. * Debug tab
  126214. */
  126215. Debug = 1,
  126216. /**
  126217. * Statistics tab
  126218. */
  126219. Statistics = 2,
  126220. /**
  126221. * Tools tab
  126222. */
  126223. Tools = 3,
  126224. /**
  126225. * Settings tab
  126226. */
  126227. Settings = 4
  126228. }
  126229. /**
  126230. * The debug layer (aka Inspector) is the go to tool in order to better understand
  126231. * what is happening in your scene
  126232. * @see http://doc.babylonjs.com/features/playground_debuglayer
  126233. */
  126234. export class DebugLayer {
  126235. /**
  126236. * Define the url to get the inspector script from.
  126237. * By default it uses the babylonjs CDN.
  126238. * @ignoreNaming
  126239. */
  126240. static InspectorURL: string;
  126241. private _scene;
  126242. private BJSINSPECTOR;
  126243. private _onPropertyChangedObservable?;
  126244. /**
  126245. * Observable triggered when a property is changed through the inspector.
  126246. */
  126247. get onPropertyChangedObservable(): any;
  126248. /**
  126249. * Instantiates a new debug layer.
  126250. * The debug layer (aka Inspector) is the go to tool in order to better understand
  126251. * what is happening in your scene
  126252. * @see http://doc.babylonjs.com/features/playground_debuglayer
  126253. * @param scene Defines the scene to inspect
  126254. */
  126255. constructor(scene: Scene);
  126256. /** Creates the inspector window. */
  126257. private _createInspector;
  126258. /**
  126259. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  126260. * @param entity defines the entity to select
  126261. * @param lineContainerTitle defines the specific block to highlight
  126262. */
  126263. select(entity: any, lineContainerTitle?: string): void;
  126264. /** Get the inspector from bundle or global */
  126265. private _getGlobalInspector;
  126266. /**
  126267. * Get if the inspector is visible or not.
  126268. * @returns true if visible otherwise, false
  126269. */
  126270. isVisible(): boolean;
  126271. /**
  126272. * Hide the inspector and close its window.
  126273. */
  126274. hide(): void;
  126275. /**
  126276. * Update the scene in the inspector
  126277. */
  126278. setAsActiveScene(): void;
  126279. /**
  126280. * Launch the debugLayer.
  126281. * @param config Define the configuration of the inspector
  126282. * @return a promise fulfilled when the debug layer is visible
  126283. */
  126284. show(config?: IInspectorOptions): Promise<DebugLayer>;
  126285. }
  126286. }
  126287. declare module BABYLON {
  126288. /**
  126289. * Class containing static functions to help procedurally build meshes
  126290. */
  126291. export class BoxBuilder {
  126292. /**
  126293. * Creates a box mesh
  126294. * * The parameter `size` sets the size (float) of each box side (default 1)
  126295. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  126296. * * 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)
  126297. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  126298. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  126299. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  126300. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126301. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  126302. * @param name defines the name of the mesh
  126303. * @param options defines the options used to create the mesh
  126304. * @param scene defines the hosting scene
  126305. * @returns the box mesh
  126306. */
  126307. static CreateBox(name: string, options: {
  126308. size?: number;
  126309. width?: number;
  126310. height?: number;
  126311. depth?: number;
  126312. faceUV?: Vector4[];
  126313. faceColors?: Color4[];
  126314. sideOrientation?: number;
  126315. frontUVs?: Vector4;
  126316. backUVs?: Vector4;
  126317. wrap?: boolean;
  126318. topBaseAt?: number;
  126319. bottomBaseAt?: number;
  126320. updatable?: boolean;
  126321. }, scene?: Nullable<Scene>): Mesh;
  126322. }
  126323. }
  126324. declare module BABYLON.Debug {
  126325. /**
  126326. * Used to show the physics impostor around the specific mesh
  126327. */
  126328. export class PhysicsViewer {
  126329. /** @hidden */
  126330. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  126331. /** @hidden */
  126332. protected _meshes: Array<Nullable<AbstractMesh>>;
  126333. /** @hidden */
  126334. protected _scene: Nullable<Scene>;
  126335. /** @hidden */
  126336. protected _numMeshes: number;
  126337. /** @hidden */
  126338. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  126339. private _renderFunction;
  126340. private _utilityLayer;
  126341. private _debugBoxMesh;
  126342. private _debugSphereMesh;
  126343. private _debugCylinderMesh;
  126344. private _debugMaterial;
  126345. private _debugMeshMeshes;
  126346. /**
  126347. * Creates a new PhysicsViewer
  126348. * @param scene defines the hosting scene
  126349. */
  126350. constructor(scene: Scene);
  126351. /** @hidden */
  126352. protected _updateDebugMeshes(): void;
  126353. /**
  126354. * Renders a specified physic impostor
  126355. * @param impostor defines the impostor to render
  126356. * @param targetMesh defines the mesh represented by the impostor
  126357. * @returns the new debug mesh used to render the impostor
  126358. */
  126359. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  126360. /**
  126361. * Hides a specified physic impostor
  126362. * @param impostor defines the impostor to hide
  126363. */
  126364. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  126365. private _getDebugMaterial;
  126366. private _getDebugBoxMesh;
  126367. private _getDebugSphereMesh;
  126368. private _getDebugCylinderMesh;
  126369. private _getDebugMeshMesh;
  126370. private _getDebugMesh;
  126371. /** Releases all resources */
  126372. dispose(): void;
  126373. }
  126374. }
  126375. declare module BABYLON {
  126376. /**
  126377. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  126378. * in order to better appreciate the issue one might have.
  126379. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  126380. */
  126381. export class RayHelper {
  126382. /**
  126383. * Defines the ray we are currently tryin to visualize.
  126384. */
  126385. ray: Nullable<Ray>;
  126386. private _renderPoints;
  126387. private _renderLine;
  126388. private _renderFunction;
  126389. private _scene;
  126390. private _updateToMeshFunction;
  126391. private _attachedToMesh;
  126392. private _meshSpaceDirection;
  126393. private _meshSpaceOrigin;
  126394. /**
  126395. * Helper function to create a colored helper in a scene in one line.
  126396. * @param ray Defines the ray we are currently tryin to visualize
  126397. * @param scene Defines the scene the ray is used in
  126398. * @param color Defines the color we want to see the ray in
  126399. * @returns The newly created ray helper.
  126400. */
  126401. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  126402. /**
  126403. * Instantiate a new ray helper.
  126404. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  126405. * in order to better appreciate the issue one might have.
  126406. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  126407. * @param ray Defines the ray we are currently tryin to visualize
  126408. */
  126409. constructor(ray: Ray);
  126410. /**
  126411. * Shows the ray we are willing to debug.
  126412. * @param scene Defines the scene the ray needs to be rendered in
  126413. * @param color Defines the color the ray needs to be rendered in
  126414. */
  126415. show(scene: Scene, color?: Color3): void;
  126416. /**
  126417. * Hides the ray we are debugging.
  126418. */
  126419. hide(): void;
  126420. private _render;
  126421. /**
  126422. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  126423. * @param mesh Defines the mesh we want the helper attached to
  126424. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  126425. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  126426. * @param length Defines the length of the ray
  126427. */
  126428. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  126429. /**
  126430. * Detach the ray helper from the mesh it has previously been attached to.
  126431. */
  126432. detachFromMesh(): void;
  126433. private _updateToMesh;
  126434. /**
  126435. * Dispose the helper and release its associated resources.
  126436. */
  126437. dispose(): void;
  126438. }
  126439. }
  126440. declare module BABYLON.Debug {
  126441. /**
  126442. * Class used to render a debug view of a given skeleton
  126443. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  126444. */
  126445. export class SkeletonViewer {
  126446. /** defines the skeleton to render */
  126447. skeleton: Skeleton;
  126448. /** defines the mesh attached to the skeleton */
  126449. mesh: AbstractMesh;
  126450. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  126451. autoUpdateBonesMatrices: boolean;
  126452. /** defines the rendering group id to use with the viewer */
  126453. renderingGroupId: number;
  126454. /** Gets or sets the color used to render the skeleton */
  126455. color: Color3;
  126456. private _scene;
  126457. private _debugLines;
  126458. private _debugMesh;
  126459. private _isEnabled;
  126460. private _renderFunction;
  126461. private _utilityLayer;
  126462. /**
  126463. * Returns the mesh used to render the bones
  126464. */
  126465. get debugMesh(): Nullable<LinesMesh>;
  126466. /**
  126467. * Creates a new SkeletonViewer
  126468. * @param skeleton defines the skeleton to render
  126469. * @param mesh defines the mesh attached to the skeleton
  126470. * @param scene defines the hosting scene
  126471. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  126472. * @param renderingGroupId defines the rendering group id to use with the viewer
  126473. */
  126474. constructor(
  126475. /** defines the skeleton to render */
  126476. skeleton: Skeleton,
  126477. /** defines the mesh attached to the skeleton */
  126478. mesh: AbstractMesh, scene: Scene,
  126479. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  126480. autoUpdateBonesMatrices?: boolean,
  126481. /** defines the rendering group id to use with the viewer */
  126482. renderingGroupId?: number);
  126483. /** Gets or sets a boolean indicating if the viewer is enabled */
  126484. set isEnabled(value: boolean);
  126485. get isEnabled(): boolean;
  126486. private _getBonePosition;
  126487. private _getLinesForBonesWithLength;
  126488. private _getLinesForBonesNoLength;
  126489. /** Update the viewer to sync with current skeleton state */
  126490. update(): void;
  126491. /** Release associated resources */
  126492. dispose(): void;
  126493. }
  126494. }
  126495. declare module BABYLON {
  126496. /**
  126497. * Enum for Device Types
  126498. */
  126499. export enum DeviceType {
  126500. /** Generic */
  126501. Generic = 0,
  126502. /** Keyboard */
  126503. Keyboard = 1,
  126504. /** Mouse */
  126505. Mouse = 2,
  126506. /** Touch Pointers */
  126507. Touch = 3,
  126508. /** PS4 Dual Shock */
  126509. DualShock = 4,
  126510. /** Xbox */
  126511. Xbox = 5,
  126512. /** Switch Controller */
  126513. Switch = 6
  126514. }
  126515. /**
  126516. * Enum for All Pointers (Touch/Mouse)
  126517. */
  126518. export enum PointerInput {
  126519. /** Horizontal Axis */
  126520. Horizontal = 0,
  126521. /** Vertical Axis */
  126522. Vertical = 1,
  126523. /** Left Click or Touch */
  126524. LeftClick = 2,
  126525. /** Middle Click */
  126526. MiddleClick = 3,
  126527. /** Right Click */
  126528. RightClick = 4,
  126529. /** Browser Back */
  126530. BrowserBack = 5,
  126531. /** Browser Forward */
  126532. BrowserForward = 6
  126533. }
  126534. /**
  126535. * Enum for Dual Shock Gamepad
  126536. */
  126537. export enum DualShockInput {
  126538. /** Cross */
  126539. Cross = 0,
  126540. /** Circle */
  126541. Circle = 1,
  126542. /** Square */
  126543. Square = 2,
  126544. /** Triangle */
  126545. Triangle = 3,
  126546. /** L1 */
  126547. L1 = 4,
  126548. /** R1 */
  126549. R1 = 5,
  126550. /** L2 */
  126551. L2 = 6,
  126552. /** R2 */
  126553. R2 = 7,
  126554. /** Share */
  126555. Share = 8,
  126556. /** Options */
  126557. Options = 9,
  126558. /** L3 */
  126559. L3 = 10,
  126560. /** R3 */
  126561. R3 = 11,
  126562. /** DPadUp */
  126563. DPadUp = 12,
  126564. /** DPadDown */
  126565. DPadDown = 13,
  126566. /** DPadLeft */
  126567. DPadLeft = 14,
  126568. /** DRight */
  126569. DPadRight = 15,
  126570. /** Home */
  126571. Home = 16,
  126572. /** TouchPad */
  126573. TouchPad = 17,
  126574. /** LStickXAxis */
  126575. LStickXAxis = 18,
  126576. /** LStickYAxis */
  126577. LStickYAxis = 19,
  126578. /** RStickXAxis */
  126579. RStickXAxis = 20,
  126580. /** RStickYAxis */
  126581. RStickYAxis = 21
  126582. }
  126583. /**
  126584. * Enum for Xbox Gamepad
  126585. */
  126586. export enum XboxInput {
  126587. /** A */
  126588. A = 0,
  126589. /** B */
  126590. B = 1,
  126591. /** X */
  126592. X = 2,
  126593. /** Y */
  126594. Y = 3,
  126595. /** LB */
  126596. LB = 4,
  126597. /** RB */
  126598. RB = 5,
  126599. /** LT */
  126600. LT = 6,
  126601. /** RT */
  126602. RT = 7,
  126603. /** Back */
  126604. Back = 8,
  126605. /** Start */
  126606. Start = 9,
  126607. /** LS */
  126608. LS = 10,
  126609. /** RS */
  126610. RS = 11,
  126611. /** DPadUp */
  126612. DPadUp = 12,
  126613. /** DPadDown */
  126614. DPadDown = 13,
  126615. /** DPadLeft */
  126616. DPadLeft = 14,
  126617. /** DRight */
  126618. DPadRight = 15,
  126619. /** Home */
  126620. Home = 16,
  126621. /** LStickXAxis */
  126622. LStickXAxis = 17,
  126623. /** LStickYAxis */
  126624. LStickYAxis = 18,
  126625. /** RStickXAxis */
  126626. RStickXAxis = 19,
  126627. /** RStickYAxis */
  126628. RStickYAxis = 20
  126629. }
  126630. /**
  126631. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  126632. */
  126633. export enum SwitchInput {
  126634. /** B */
  126635. B = 0,
  126636. /** A */
  126637. A = 1,
  126638. /** Y */
  126639. Y = 2,
  126640. /** X */
  126641. X = 3,
  126642. /** L */
  126643. L = 4,
  126644. /** R */
  126645. R = 5,
  126646. /** ZL */
  126647. ZL = 6,
  126648. /** ZR */
  126649. ZR = 7,
  126650. /** Minus */
  126651. Minus = 8,
  126652. /** Plus */
  126653. Plus = 9,
  126654. /** LS */
  126655. LS = 10,
  126656. /** RS */
  126657. RS = 11,
  126658. /** DPadUp */
  126659. DPadUp = 12,
  126660. /** DPadDown */
  126661. DPadDown = 13,
  126662. /** DPadLeft */
  126663. DPadLeft = 14,
  126664. /** DRight */
  126665. DPadRight = 15,
  126666. /** Home */
  126667. Home = 16,
  126668. /** Capture */
  126669. Capture = 17,
  126670. /** LStickXAxis */
  126671. LStickXAxis = 18,
  126672. /** LStickYAxis */
  126673. LStickYAxis = 19,
  126674. /** RStickXAxis */
  126675. RStickXAxis = 20,
  126676. /** RStickYAxis */
  126677. RStickYAxis = 21
  126678. }
  126679. }
  126680. declare module BABYLON {
  126681. /**
  126682. * This class will take all inputs from Keyboard, Pointer, and
  126683. * any Gamepads and provide a polling system that all devices
  126684. * will use. This class assumes that there will only be one
  126685. * pointer device and one keyboard.
  126686. */
  126687. export class DeviceInputSystem implements IDisposable {
  126688. /**
  126689. * Callback to be triggered when a device is connected
  126690. */
  126691. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  126692. /**
  126693. * Callback to be triggered when a device is disconnected
  126694. */
  126695. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  126696. /**
  126697. * Callback to be triggered when event driven input is updated
  126698. */
  126699. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  126700. private _inputs;
  126701. private _gamepads;
  126702. private _keyboardActive;
  126703. private _pointerActive;
  126704. private _elementToAttachTo;
  126705. private _keyboardDownEvent;
  126706. private _keyboardUpEvent;
  126707. private _pointerMoveEvent;
  126708. private _pointerDownEvent;
  126709. private _pointerUpEvent;
  126710. private _gamepadConnectedEvent;
  126711. private _gamepadDisconnectedEvent;
  126712. private static _MAX_KEYCODES;
  126713. private static _MAX_POINTER_INPUTS;
  126714. /**
  126715. * Default Constructor
  126716. * @param engine - engine to pull input element from
  126717. */
  126718. constructor(engine: Engine);
  126719. /**
  126720. * Checks for current device input value, given an id and input index
  126721. * @param deviceName Id of connected device
  126722. * @param inputIndex Index of device input
  126723. * @returns Current value of input
  126724. */
  126725. /**
  126726. * Checks for current device input value, given an id and input index
  126727. * @param deviceType Enum specifiying device type
  126728. * @param deviceSlot "Slot" or index that device is referenced in
  126729. * @param inputIndex Id of input to be checked
  126730. * @returns Current value of input
  126731. */
  126732. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): Nullable<number>;
  126733. /**
  126734. * Dispose of all the eventlisteners
  126735. */
  126736. dispose(): void;
  126737. /**
  126738. * Add device and inputs to device array
  126739. * @param deviceType Enum specifiying device type
  126740. * @param deviceSlot "Slot" or index that device is referenced in
  126741. * @param numberOfInputs Number of input entries to create for given device
  126742. */
  126743. private _registerDevice;
  126744. /**
  126745. * Given a specific device name, remove that device from the device map
  126746. * @param deviceType Enum specifiying device type
  126747. * @param deviceSlot "Slot" or index that device is referenced in
  126748. */
  126749. private _unregisterDevice;
  126750. /**
  126751. * Handle all actions that come from keyboard interaction
  126752. */
  126753. private _handleKeyActions;
  126754. /**
  126755. * Handle all actions that come from pointer interaction
  126756. */
  126757. private _handlePointerActions;
  126758. /**
  126759. * Handle all actions that come from gamepad interaction
  126760. */
  126761. private _handleGamepadActions;
  126762. /**
  126763. * Update all non-event based devices with each frame
  126764. * @param deviceType Enum specifiying device type
  126765. * @param deviceSlot "Slot" or index that device is referenced in
  126766. * @param inputIndex Id of input to be checked
  126767. */
  126768. private _updateDevice;
  126769. /**
  126770. * Gets DeviceType from the device name
  126771. * @param deviceName Name of Device from DeviceInputSystem
  126772. * @returns DeviceType enum value
  126773. */
  126774. private _getGamepadDeviceType;
  126775. }
  126776. }
  126777. declare module BABYLON {
  126778. /**
  126779. * Type to handle enforcement of inputs
  126780. */
  126781. 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;
  126782. }
  126783. declare module BABYLON {
  126784. /**
  126785. * Class that handles all input for a specific device
  126786. */
  126787. export class DeviceSource<T extends DeviceType> {
  126788. /** Type of device */
  126789. readonly deviceType: DeviceType;
  126790. /** "Slot" or index that device is referenced in */
  126791. readonly deviceSlot: number;
  126792. /**
  126793. * Observable to handle device input changes per device
  126794. */
  126795. readonly onInputChangedObservable: Observable<{
  126796. inputIndex: DeviceInput<T>;
  126797. previousState: Nullable<number>;
  126798. currentState: Nullable<number>;
  126799. }>;
  126800. private readonly _deviceInputSystem;
  126801. /**
  126802. * Default Constructor
  126803. * @param deviceInputSystem Reference to DeviceInputSystem
  126804. * @param deviceType Type of device
  126805. * @param deviceSlot "Slot" or index that device is referenced in
  126806. */
  126807. constructor(deviceInputSystem: DeviceInputSystem,
  126808. /** Type of device */
  126809. deviceType: DeviceType,
  126810. /** "Slot" or index that device is referenced in */
  126811. deviceSlot?: number);
  126812. /**
  126813. * Get input for specific input
  126814. * @param inputIndex index of specific input on device
  126815. * @returns Input value from DeviceInputSystem
  126816. */
  126817. getInput(inputIndex: DeviceInput<T>): Nullable<number>;
  126818. }
  126819. /**
  126820. * Class to keep track of devices
  126821. */
  126822. export class DeviceSourceManager implements IDisposable {
  126823. /**
  126824. * Observable to be triggered when before a device is connected
  126825. */
  126826. readonly onBeforeDeviceConnectedObservable: Observable<{
  126827. deviceType: DeviceType;
  126828. deviceSlot: number;
  126829. }>;
  126830. /**
  126831. * Observable to be triggered when before a device is disconnected
  126832. */
  126833. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  126834. deviceType: DeviceType;
  126835. deviceSlot: number;
  126836. }>;
  126837. /**
  126838. * Observable to be triggered when after a device is connected
  126839. */
  126840. readonly onAfterDeviceConnectedObservable: Observable<{
  126841. deviceType: DeviceType;
  126842. deviceSlot: number;
  126843. }>;
  126844. /**
  126845. * Observable to be triggered when after a device is disconnected
  126846. */
  126847. readonly onAfterDeviceDisconnectedObservable: Observable<{
  126848. deviceType: DeviceType;
  126849. deviceSlot: number;
  126850. }>;
  126851. private readonly _devices;
  126852. private readonly _firstDevice;
  126853. private readonly _deviceInputSystem;
  126854. /**
  126855. * Default Constructor
  126856. * @param engine engine to pull input element from
  126857. */
  126858. constructor(engine: Engine);
  126859. /**
  126860. * Gets a DeviceSource, given a type and slot
  126861. * @param deviceType Enum specifying device type
  126862. * @param deviceSlot "Slot" or index that device is referenced in
  126863. * @returns DeviceSource object
  126864. */
  126865. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  126866. /**
  126867. * Gets an array of DeviceSource objects for a given device type
  126868. * @param deviceType Enum specifying device type
  126869. * @returns Array of DeviceSource objects
  126870. */
  126871. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  126872. /**
  126873. * Dispose of DeviceInputSystem and other parts
  126874. */
  126875. dispose(): void;
  126876. /**
  126877. * Function to add device name to device list
  126878. * @param deviceType Enum specifying device type
  126879. * @param deviceSlot "Slot" or index that device is referenced in
  126880. */
  126881. private _addDevice;
  126882. /**
  126883. * Function to remove device name to device list
  126884. * @param deviceType Enum specifying device type
  126885. * @param deviceSlot "Slot" or index that device is referenced in
  126886. */
  126887. private _removeDevice;
  126888. /**
  126889. * Updates array storing first connected device of each type
  126890. * @param type Type of Device
  126891. */
  126892. private _updateFirstDevices;
  126893. }
  126894. }
  126895. declare module BABYLON {
  126896. /**
  126897. * Options to create the null engine
  126898. */
  126899. export class NullEngineOptions {
  126900. /**
  126901. * Render width (Default: 512)
  126902. */
  126903. renderWidth: number;
  126904. /**
  126905. * Render height (Default: 256)
  126906. */
  126907. renderHeight: number;
  126908. /**
  126909. * Texture size (Default: 512)
  126910. */
  126911. textureSize: number;
  126912. /**
  126913. * If delta time between frames should be constant
  126914. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  126915. */
  126916. deterministicLockstep: boolean;
  126917. /**
  126918. * Maximum about of steps between frames (Default: 4)
  126919. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  126920. */
  126921. lockstepMaxSteps: number;
  126922. }
  126923. /**
  126924. * The null engine class provides support for headless version of babylon.js.
  126925. * This can be used in server side scenario or for testing purposes
  126926. */
  126927. export class NullEngine extends Engine {
  126928. private _options;
  126929. /**
  126930. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  126931. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  126932. * @returns true if engine is in deterministic lock step mode
  126933. */
  126934. isDeterministicLockStep(): boolean;
  126935. /**
  126936. * Gets the max steps when engine is running in deterministic lock step
  126937. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  126938. * @returns the max steps
  126939. */
  126940. getLockstepMaxSteps(): number;
  126941. /**
  126942. * Gets the current hardware scaling level.
  126943. * By default the hardware scaling level is computed from the window device ratio.
  126944. * 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.
  126945. * @returns a number indicating the current hardware scaling level
  126946. */
  126947. getHardwareScalingLevel(): number;
  126948. constructor(options?: NullEngineOptions);
  126949. /**
  126950. * Creates a vertex buffer
  126951. * @param vertices the data for the vertex buffer
  126952. * @returns the new WebGL static buffer
  126953. */
  126954. createVertexBuffer(vertices: FloatArray): DataBuffer;
  126955. /**
  126956. * Creates a new index buffer
  126957. * @param indices defines the content of the index buffer
  126958. * @param updatable defines if the index buffer must be updatable
  126959. * @returns a new webGL buffer
  126960. */
  126961. createIndexBuffer(indices: IndicesArray): DataBuffer;
  126962. /**
  126963. * Clear the current render buffer or the current render target (if any is set up)
  126964. * @param color defines the color to use
  126965. * @param backBuffer defines if the back buffer must be cleared
  126966. * @param depth defines if the depth buffer must be cleared
  126967. * @param stencil defines if the stencil buffer must be cleared
  126968. */
  126969. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  126970. /**
  126971. * Gets the current render width
  126972. * @param useScreen defines if screen size must be used (or the current render target if any)
  126973. * @returns a number defining the current render width
  126974. */
  126975. getRenderWidth(useScreen?: boolean): number;
  126976. /**
  126977. * Gets the current render height
  126978. * @param useScreen defines if screen size must be used (or the current render target if any)
  126979. * @returns a number defining the current render height
  126980. */
  126981. getRenderHeight(useScreen?: boolean): number;
  126982. /**
  126983. * Set the WebGL's viewport
  126984. * @param viewport defines the viewport element to be used
  126985. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  126986. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  126987. */
  126988. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  126989. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  126990. /**
  126991. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  126992. * @param pipelineContext defines the pipeline context to use
  126993. * @param uniformsNames defines the list of uniform names
  126994. * @returns an array of webGL uniform locations
  126995. */
  126996. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  126997. /**
  126998. * Gets the lsit of active attributes for a given webGL program
  126999. * @param pipelineContext defines the pipeline context to use
  127000. * @param attributesNames defines the list of attribute names to get
  127001. * @returns an array of indices indicating the offset of each attribute
  127002. */
  127003. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  127004. /**
  127005. * Binds an effect to the webGL context
  127006. * @param effect defines the effect to bind
  127007. */
  127008. bindSamplers(effect: Effect): void;
  127009. /**
  127010. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  127011. * @param effect defines the effect to activate
  127012. */
  127013. enableEffect(effect: Effect): void;
  127014. /**
  127015. * Set various states to the webGL context
  127016. * @param culling defines backface culling state
  127017. * @param zOffset defines the value to apply to zOffset (0 by default)
  127018. * @param force defines if states must be applied even if cache is up to date
  127019. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  127020. */
  127021. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  127022. /**
  127023. * Set the value of an uniform to an array of int32
  127024. * @param uniform defines the webGL uniform location where to store the value
  127025. * @param array defines the array of int32 to store
  127026. */
  127027. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  127028. /**
  127029. * Set the value of an uniform to an array of int32 (stored as vec2)
  127030. * @param uniform defines the webGL uniform location where to store the value
  127031. * @param array defines the array of int32 to store
  127032. */
  127033. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  127034. /**
  127035. * Set the value of an uniform to an array of int32 (stored as vec3)
  127036. * @param uniform defines the webGL uniform location where to store the value
  127037. * @param array defines the array of int32 to store
  127038. */
  127039. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  127040. /**
  127041. * Set the value of an uniform to an array of int32 (stored as vec4)
  127042. * @param uniform defines the webGL uniform location where to store the value
  127043. * @param array defines the array of int32 to store
  127044. */
  127045. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  127046. /**
  127047. * Set the value of an uniform to an array of float32
  127048. * @param uniform defines the webGL uniform location where to store the value
  127049. * @param array defines the array of float32 to store
  127050. */
  127051. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  127052. /**
  127053. * Set the value of an uniform to an array of float32 (stored as vec2)
  127054. * @param uniform defines the webGL uniform location where to store the value
  127055. * @param array defines the array of float32 to store
  127056. */
  127057. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  127058. /**
  127059. * Set the value of an uniform to an array of float32 (stored as vec3)
  127060. * @param uniform defines the webGL uniform location where to store the value
  127061. * @param array defines the array of float32 to store
  127062. */
  127063. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  127064. /**
  127065. * Set the value of an uniform to an array of float32 (stored as vec4)
  127066. * @param uniform defines the webGL uniform location where to store the value
  127067. * @param array defines the array of float32 to store
  127068. */
  127069. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  127070. /**
  127071. * Set the value of an uniform to an array of number
  127072. * @param uniform defines the webGL uniform location where to store the value
  127073. * @param array defines the array of number to store
  127074. */
  127075. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  127076. /**
  127077. * Set the value of an uniform to an array of number (stored as vec2)
  127078. * @param uniform defines the webGL uniform location where to store the value
  127079. * @param array defines the array of number to store
  127080. */
  127081. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  127082. /**
  127083. * Set the value of an uniform to an array of number (stored as vec3)
  127084. * @param uniform defines the webGL uniform location where to store the value
  127085. * @param array defines the array of number to store
  127086. */
  127087. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  127088. /**
  127089. * Set the value of an uniform to an array of number (stored as vec4)
  127090. * @param uniform defines the webGL uniform location where to store the value
  127091. * @param array defines the array of number to store
  127092. */
  127093. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  127094. /**
  127095. * Set the value of an uniform to an array of float32 (stored as matrices)
  127096. * @param uniform defines the webGL uniform location where to store the value
  127097. * @param matrices defines the array of float32 to store
  127098. */
  127099. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  127100. /**
  127101. * Set the value of an uniform to a matrix (3x3)
  127102. * @param uniform defines the webGL uniform location where to store the value
  127103. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  127104. */
  127105. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  127106. /**
  127107. * Set the value of an uniform to a matrix (2x2)
  127108. * @param uniform defines the webGL uniform location where to store the value
  127109. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  127110. */
  127111. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  127112. /**
  127113. * Set the value of an uniform to a number (float)
  127114. * @param uniform defines the webGL uniform location where to store the value
  127115. * @param value defines the float number to store
  127116. */
  127117. setFloat(uniform: WebGLUniformLocation, value: number): void;
  127118. /**
  127119. * Set the value of an uniform to a vec2
  127120. * @param uniform defines the webGL uniform location where to store the value
  127121. * @param x defines the 1st component of the value
  127122. * @param y defines the 2nd component of the value
  127123. */
  127124. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  127125. /**
  127126. * Set the value of an uniform to a vec3
  127127. * @param uniform defines the webGL uniform location where to store the value
  127128. * @param x defines the 1st component of the value
  127129. * @param y defines the 2nd component of the value
  127130. * @param z defines the 3rd component of the value
  127131. */
  127132. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  127133. /**
  127134. * Set the value of an uniform to a boolean
  127135. * @param uniform defines the webGL uniform location where to store the value
  127136. * @param bool defines the boolean to store
  127137. */
  127138. setBool(uniform: WebGLUniformLocation, bool: number): void;
  127139. /**
  127140. * Set the value of an uniform to a vec4
  127141. * @param uniform defines the webGL uniform location where to store the value
  127142. * @param x defines the 1st component of the value
  127143. * @param y defines the 2nd component of the value
  127144. * @param z defines the 3rd component of the value
  127145. * @param w defines the 4th component of the value
  127146. */
  127147. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  127148. /**
  127149. * Sets the current alpha mode
  127150. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  127151. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  127152. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  127153. */
  127154. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  127155. /**
  127156. * Bind webGl buffers directly to the webGL context
  127157. * @param vertexBuffers defines the vertex buffer to bind
  127158. * @param indexBuffer defines the index buffer to bind
  127159. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  127160. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  127161. * @param effect defines the effect associated with the vertex buffer
  127162. */
  127163. bindBuffers(vertexBuffers: {
  127164. [key: string]: VertexBuffer;
  127165. }, indexBuffer: DataBuffer, effect: Effect): void;
  127166. /**
  127167. * Force the entire cache to be cleared
  127168. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  127169. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  127170. */
  127171. wipeCaches(bruteForce?: boolean): void;
  127172. /**
  127173. * Send a draw order
  127174. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  127175. * @param indexStart defines the starting index
  127176. * @param indexCount defines the number of index to draw
  127177. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  127178. */
  127179. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  127180. /**
  127181. * Draw a list of indexed primitives
  127182. * @param fillMode defines the primitive to use
  127183. * @param indexStart defines the starting index
  127184. * @param indexCount defines the number of index to draw
  127185. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  127186. */
  127187. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  127188. /**
  127189. * Draw a list of unindexed primitives
  127190. * @param fillMode defines the primitive to use
  127191. * @param verticesStart defines the index of first vertex to draw
  127192. * @param verticesCount defines the count of vertices to draw
  127193. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  127194. */
  127195. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  127196. /** @hidden */
  127197. _createTexture(): WebGLTexture;
  127198. /** @hidden */
  127199. _releaseTexture(texture: InternalTexture): void;
  127200. /**
  127201. * Usually called from Texture.ts.
  127202. * Passed information to create a WebGLTexture
  127203. * @param urlArg defines a value which contains one of the following:
  127204. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  127205. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  127206. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  127207. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  127208. * @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)
  127209. * @param scene needed for loading to the correct scene
  127210. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  127211. * @param onLoad optional callback to be called upon successful completion
  127212. * @param onError optional callback to be called upon failure
  127213. * @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
  127214. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  127215. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  127216. * @param forcedExtension defines the extension to use to pick the right loader
  127217. * @param mimeType defines an optional mime type
  127218. * @returns a InternalTexture for assignment back into BABYLON.Texture
  127219. */
  127220. 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;
  127221. /**
  127222. * Creates a new render target texture
  127223. * @param size defines the size of the texture
  127224. * @param options defines the options used to create the texture
  127225. * @returns a new render target texture stored in an InternalTexture
  127226. */
  127227. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  127228. /**
  127229. * Update the sampling mode of a given texture
  127230. * @param samplingMode defines the required sampling mode
  127231. * @param texture defines the texture to update
  127232. */
  127233. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  127234. /**
  127235. * Binds the frame buffer to the specified texture.
  127236. * @param texture The texture to render to or null for the default canvas
  127237. * @param faceIndex The face of the texture to render to in case of cube texture
  127238. * @param requiredWidth The width of the target to render to
  127239. * @param requiredHeight The height of the target to render to
  127240. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  127241. * @param lodLevel defines le lod level to bind to the frame buffer
  127242. */
  127243. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  127244. /**
  127245. * Unbind the current render target texture from the webGL context
  127246. * @param texture defines the render target texture to unbind
  127247. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  127248. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  127249. */
  127250. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  127251. /**
  127252. * Creates a dynamic vertex buffer
  127253. * @param vertices the data for the dynamic vertex buffer
  127254. * @returns the new WebGL dynamic buffer
  127255. */
  127256. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  127257. /**
  127258. * Update the content of a dynamic texture
  127259. * @param texture defines the texture to update
  127260. * @param canvas defines the canvas containing the source
  127261. * @param invertY defines if data must be stored with Y axis inverted
  127262. * @param premulAlpha defines if alpha is stored as premultiplied
  127263. * @param format defines the format of the data
  127264. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  127265. */
  127266. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  127267. /**
  127268. * Gets a boolean indicating if all created effects are ready
  127269. * @returns true if all effects are ready
  127270. */
  127271. areAllEffectsReady(): boolean;
  127272. /**
  127273. * @hidden
  127274. * Get the current error code of the webGL context
  127275. * @returns the error code
  127276. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  127277. */
  127278. getError(): number;
  127279. /** @hidden */
  127280. _getUnpackAlignement(): number;
  127281. /** @hidden */
  127282. _unpackFlipY(value: boolean): void;
  127283. /**
  127284. * Update a dynamic index buffer
  127285. * @param indexBuffer defines the target index buffer
  127286. * @param indices defines the data to update
  127287. * @param offset defines the offset in the target index buffer where update should start
  127288. */
  127289. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  127290. /**
  127291. * Updates a dynamic vertex buffer.
  127292. * @param vertexBuffer the vertex buffer to update
  127293. * @param vertices the data used to update the vertex buffer
  127294. * @param byteOffset the byte offset of the data (optional)
  127295. * @param byteLength the byte length of the data (optional)
  127296. */
  127297. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  127298. /** @hidden */
  127299. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  127300. /** @hidden */
  127301. _bindTexture(channel: number, texture: InternalTexture): void;
  127302. protected _deleteBuffer(buffer: WebGLBuffer): void;
  127303. /**
  127304. * 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
  127305. */
  127306. releaseEffects(): void;
  127307. displayLoadingUI(): void;
  127308. hideLoadingUI(): void;
  127309. /** @hidden */
  127310. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  127311. /** @hidden */
  127312. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  127313. /** @hidden */
  127314. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  127315. /** @hidden */
  127316. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  127317. }
  127318. }
  127319. declare module BABYLON {
  127320. /**
  127321. * @hidden
  127322. **/
  127323. export class _TimeToken {
  127324. _startTimeQuery: Nullable<WebGLQuery>;
  127325. _endTimeQuery: Nullable<WebGLQuery>;
  127326. _timeElapsedQuery: Nullable<WebGLQuery>;
  127327. _timeElapsedQueryEnded: boolean;
  127328. }
  127329. }
  127330. declare module BABYLON {
  127331. /** @hidden */
  127332. export class _OcclusionDataStorage {
  127333. /** @hidden */
  127334. occlusionInternalRetryCounter: number;
  127335. /** @hidden */
  127336. isOcclusionQueryInProgress: boolean;
  127337. /** @hidden */
  127338. isOccluded: boolean;
  127339. /** @hidden */
  127340. occlusionRetryCount: number;
  127341. /** @hidden */
  127342. occlusionType: number;
  127343. /** @hidden */
  127344. occlusionQueryAlgorithmType: number;
  127345. }
  127346. interface Engine {
  127347. /**
  127348. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  127349. * @return the new query
  127350. */
  127351. createQuery(): WebGLQuery;
  127352. /**
  127353. * Delete and release a webGL query
  127354. * @param query defines the query to delete
  127355. * @return the current engine
  127356. */
  127357. deleteQuery(query: WebGLQuery): Engine;
  127358. /**
  127359. * Check if a given query has resolved and got its value
  127360. * @param query defines the query to check
  127361. * @returns true if the query got its value
  127362. */
  127363. isQueryResultAvailable(query: WebGLQuery): boolean;
  127364. /**
  127365. * Gets the value of a given query
  127366. * @param query defines the query to check
  127367. * @returns the value of the query
  127368. */
  127369. getQueryResult(query: WebGLQuery): number;
  127370. /**
  127371. * Initiates an occlusion query
  127372. * @param algorithmType defines the algorithm to use
  127373. * @param query defines the query to use
  127374. * @returns the current engine
  127375. * @see http://doc.babylonjs.com/features/occlusionquery
  127376. */
  127377. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  127378. /**
  127379. * Ends an occlusion query
  127380. * @see http://doc.babylonjs.com/features/occlusionquery
  127381. * @param algorithmType defines the algorithm to use
  127382. * @returns the current engine
  127383. */
  127384. endOcclusionQuery(algorithmType: number): Engine;
  127385. /**
  127386. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  127387. * Please note that only one query can be issued at a time
  127388. * @returns a time token used to track the time span
  127389. */
  127390. startTimeQuery(): Nullable<_TimeToken>;
  127391. /**
  127392. * Ends a time query
  127393. * @param token defines the token used to measure the time span
  127394. * @returns the time spent (in ns)
  127395. */
  127396. endTimeQuery(token: _TimeToken): int;
  127397. /** @hidden */
  127398. _currentNonTimestampToken: Nullable<_TimeToken>;
  127399. /** @hidden */
  127400. _createTimeQuery(): WebGLQuery;
  127401. /** @hidden */
  127402. _deleteTimeQuery(query: WebGLQuery): void;
  127403. /** @hidden */
  127404. _getGlAlgorithmType(algorithmType: number): number;
  127405. /** @hidden */
  127406. _getTimeQueryResult(query: WebGLQuery): any;
  127407. /** @hidden */
  127408. _getTimeQueryAvailability(query: WebGLQuery): any;
  127409. }
  127410. interface AbstractMesh {
  127411. /**
  127412. * Backing filed
  127413. * @hidden
  127414. */
  127415. __occlusionDataStorage: _OcclusionDataStorage;
  127416. /**
  127417. * Access property
  127418. * @hidden
  127419. */
  127420. _occlusionDataStorage: _OcclusionDataStorage;
  127421. /**
  127422. * 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.
  127423. * The default value is -1 which means don't break the query and wait till the result
  127424. * @see http://doc.babylonjs.com/features/occlusionquery
  127425. */
  127426. occlusionRetryCount: number;
  127427. /**
  127428. * 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:
  127429. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  127430. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  127431. * * 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.
  127432. * @see http://doc.babylonjs.com/features/occlusionquery
  127433. */
  127434. occlusionType: number;
  127435. /**
  127436. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  127437. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  127438. * * 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.
  127439. * @see http://doc.babylonjs.com/features/occlusionquery
  127440. */
  127441. occlusionQueryAlgorithmType: number;
  127442. /**
  127443. * 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
  127444. * @see http://doc.babylonjs.com/features/occlusionquery
  127445. */
  127446. isOccluded: boolean;
  127447. /**
  127448. * Flag to check the progress status of the query
  127449. * @see http://doc.babylonjs.com/features/occlusionquery
  127450. */
  127451. isOcclusionQueryInProgress: boolean;
  127452. }
  127453. }
  127454. declare module BABYLON {
  127455. /** @hidden */
  127456. export var _forceTransformFeedbackToBundle: boolean;
  127457. interface Engine {
  127458. /**
  127459. * Creates a webGL transform feedback object
  127460. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  127461. * @returns the webGL transform feedback object
  127462. */
  127463. createTransformFeedback(): WebGLTransformFeedback;
  127464. /**
  127465. * Delete a webGL transform feedback object
  127466. * @param value defines the webGL transform feedback object to delete
  127467. */
  127468. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  127469. /**
  127470. * Bind a webGL transform feedback object to the webgl context
  127471. * @param value defines the webGL transform feedback object to bind
  127472. */
  127473. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  127474. /**
  127475. * Begins a transform feedback operation
  127476. * @param usePoints defines if points or triangles must be used
  127477. */
  127478. beginTransformFeedback(usePoints: boolean): void;
  127479. /**
  127480. * Ends a transform feedback operation
  127481. */
  127482. endTransformFeedback(): void;
  127483. /**
  127484. * Specify the varyings to use with transform feedback
  127485. * @param program defines the associated webGL program
  127486. * @param value defines the list of strings representing the varying names
  127487. */
  127488. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  127489. /**
  127490. * Bind a webGL buffer for a transform feedback operation
  127491. * @param value defines the webGL buffer to bind
  127492. */
  127493. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  127494. }
  127495. }
  127496. declare module BABYLON {
  127497. /**
  127498. * Creation options of the multi render target texture.
  127499. */
  127500. export interface IMultiRenderTargetOptions {
  127501. /**
  127502. * Define if the texture needs to create mip maps after render.
  127503. */
  127504. generateMipMaps?: boolean;
  127505. /**
  127506. * Define the types of all the draw buffers we want to create
  127507. */
  127508. types?: number[];
  127509. /**
  127510. * Define the sampling modes of all the draw buffers we want to create
  127511. */
  127512. samplingModes?: number[];
  127513. /**
  127514. * Define if a depth buffer is required
  127515. */
  127516. generateDepthBuffer?: boolean;
  127517. /**
  127518. * Define if a stencil buffer is required
  127519. */
  127520. generateStencilBuffer?: boolean;
  127521. /**
  127522. * Define if a depth texture is required instead of a depth buffer
  127523. */
  127524. generateDepthTexture?: boolean;
  127525. /**
  127526. * Define the number of desired draw buffers
  127527. */
  127528. textureCount?: number;
  127529. /**
  127530. * Define if aspect ratio should be adapted to the texture or stay the scene one
  127531. */
  127532. doNotChangeAspectRatio?: boolean;
  127533. /**
  127534. * Define the default type of the buffers we are creating
  127535. */
  127536. defaultType?: number;
  127537. }
  127538. /**
  127539. * A multi render target, like a render target provides the ability to render to a texture.
  127540. * Unlike the render target, it can render to several draw buffers in one draw.
  127541. * This is specially interesting in deferred rendering or for any effects requiring more than
  127542. * just one color from a single pass.
  127543. */
  127544. export class MultiRenderTarget extends RenderTargetTexture {
  127545. private _internalTextures;
  127546. private _textures;
  127547. private _multiRenderTargetOptions;
  127548. /**
  127549. * Get if draw buffers are currently supported by the used hardware and browser.
  127550. */
  127551. get isSupported(): boolean;
  127552. /**
  127553. * Get the list of textures generated by the multi render target.
  127554. */
  127555. get textures(): Texture[];
  127556. /**
  127557. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  127558. */
  127559. get depthTexture(): Texture;
  127560. /**
  127561. * Set the wrapping mode on U of all the textures we are rendering to.
  127562. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  127563. */
  127564. set wrapU(wrap: number);
  127565. /**
  127566. * Set the wrapping mode on V of all the textures we are rendering to.
  127567. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  127568. */
  127569. set wrapV(wrap: number);
  127570. /**
  127571. * Instantiate a new multi render target texture.
  127572. * A multi render target, like a render target provides the ability to render to a texture.
  127573. * Unlike the render target, it can render to several draw buffers in one draw.
  127574. * This is specially interesting in deferred rendering or for any effects requiring more than
  127575. * just one color from a single pass.
  127576. * @param name Define the name of the texture
  127577. * @param size Define the size of the buffers to render to
  127578. * @param count Define the number of target we are rendering into
  127579. * @param scene Define the scene the texture belongs to
  127580. * @param options Define the options used to create the multi render target
  127581. */
  127582. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  127583. /** @hidden */
  127584. _rebuild(): void;
  127585. private _createInternalTextures;
  127586. private _createTextures;
  127587. /**
  127588. * Define the number of samples used if MSAA is enabled.
  127589. */
  127590. get samples(): number;
  127591. set samples(value: number);
  127592. /**
  127593. * Resize all the textures in the multi render target.
  127594. * Be carrefull as it will recreate all the data in the new texture.
  127595. * @param size Define the new size
  127596. */
  127597. resize(size: any): void;
  127598. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  127599. /**
  127600. * Dispose the render targets and their associated resources
  127601. */
  127602. dispose(): void;
  127603. /**
  127604. * Release all the underlying texture used as draw buffers.
  127605. */
  127606. releaseInternalTextures(): void;
  127607. }
  127608. }
  127609. declare module BABYLON {
  127610. interface ThinEngine {
  127611. /**
  127612. * Unbind a list of render target textures from the webGL context
  127613. * This is used only when drawBuffer extension or webGL2 are active
  127614. * @param textures defines the render target textures to unbind
  127615. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  127616. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  127617. */
  127618. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  127619. /**
  127620. * Create a multi render target texture
  127621. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  127622. * @param size defines the size of the texture
  127623. * @param options defines the creation options
  127624. * @returns the cube texture as an InternalTexture
  127625. */
  127626. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  127627. /**
  127628. * Update the sample count for a given multiple render target texture
  127629. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  127630. * @param textures defines the textures to update
  127631. * @param samples defines the sample count to set
  127632. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  127633. */
  127634. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  127635. }
  127636. }
  127637. declare module BABYLON {
  127638. /**
  127639. * Class used to define an additional view for the engine
  127640. * @see https://doc.babylonjs.com/how_to/multi_canvases
  127641. */
  127642. export class EngineView {
  127643. /** Defines the canvas where to render the view */
  127644. target: HTMLCanvasElement;
  127645. /** Defines an optional camera used to render the view (will use active camera else) */
  127646. camera?: Camera;
  127647. }
  127648. interface Engine {
  127649. /**
  127650. * Gets or sets the HTML element to use for attaching events
  127651. */
  127652. inputElement: Nullable<HTMLElement>;
  127653. /**
  127654. * Gets the current engine view
  127655. * @see https://doc.babylonjs.com/how_to/multi_canvases
  127656. */
  127657. activeView: Nullable<EngineView>;
  127658. /** Gets or sets the list of views */
  127659. views: EngineView[];
  127660. /**
  127661. * Register a new child canvas
  127662. * @param canvas defines the canvas to register
  127663. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  127664. * @returns the associated view
  127665. */
  127666. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  127667. /**
  127668. * Remove a registered child canvas
  127669. * @param canvas defines the canvas to remove
  127670. * @returns the current engine
  127671. */
  127672. unRegisterView(canvas: HTMLCanvasElement): Engine;
  127673. }
  127674. }
  127675. declare module BABYLON {
  127676. interface Engine {
  127677. /** @hidden */
  127678. _excludedCompressedTextures: string[];
  127679. /** @hidden */
  127680. _textureFormatInUse: string;
  127681. /**
  127682. * Gets the list of texture formats supported
  127683. */
  127684. readonly texturesSupported: Array<string>;
  127685. /**
  127686. * Gets the texture format in use
  127687. */
  127688. readonly textureFormatInUse: Nullable<string>;
  127689. /**
  127690. * Set the compressed texture extensions or file names to skip.
  127691. *
  127692. * @param skippedFiles defines the list of those texture files you want to skip
  127693. * Example: [".dds", ".env", "myfile.png"]
  127694. */
  127695. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  127696. /**
  127697. * Set the compressed texture format to use, based on the formats you have, and the formats
  127698. * supported by the hardware / browser.
  127699. *
  127700. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  127701. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  127702. * to API arguments needed to compressed textures. This puts the burden on the container
  127703. * generator to house the arcane code for determining these for current & future formats.
  127704. *
  127705. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  127706. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  127707. *
  127708. * Note: The result of this call is not taken into account when a texture is base64.
  127709. *
  127710. * @param formatsAvailable defines the list of those format families you have created
  127711. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  127712. *
  127713. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  127714. * @returns The extension selected.
  127715. */
  127716. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  127717. }
  127718. }
  127719. declare module BABYLON {
  127720. /**
  127721. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  127722. */
  127723. export interface CubeMapInfo {
  127724. /**
  127725. * The pixel array for the front face.
  127726. * This is stored in format, left to right, up to down format.
  127727. */
  127728. front: Nullable<ArrayBufferView>;
  127729. /**
  127730. * The pixel array for the back face.
  127731. * This is stored in format, left to right, up to down format.
  127732. */
  127733. back: Nullable<ArrayBufferView>;
  127734. /**
  127735. * The pixel array for the left face.
  127736. * This is stored in format, left to right, up to down format.
  127737. */
  127738. left: Nullable<ArrayBufferView>;
  127739. /**
  127740. * The pixel array for the right face.
  127741. * This is stored in format, left to right, up to down format.
  127742. */
  127743. right: Nullable<ArrayBufferView>;
  127744. /**
  127745. * The pixel array for the up face.
  127746. * This is stored in format, left to right, up to down format.
  127747. */
  127748. up: Nullable<ArrayBufferView>;
  127749. /**
  127750. * The pixel array for the down face.
  127751. * This is stored in format, left to right, up to down format.
  127752. */
  127753. down: Nullable<ArrayBufferView>;
  127754. /**
  127755. * The size of the cubemap stored.
  127756. *
  127757. * Each faces will be size * size pixels.
  127758. */
  127759. size: number;
  127760. /**
  127761. * The format of the texture.
  127762. *
  127763. * RGBA, RGB.
  127764. */
  127765. format: number;
  127766. /**
  127767. * The type of the texture data.
  127768. *
  127769. * UNSIGNED_INT, FLOAT.
  127770. */
  127771. type: number;
  127772. /**
  127773. * Specifies whether the texture is in gamma space.
  127774. */
  127775. gammaSpace: boolean;
  127776. }
  127777. /**
  127778. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  127779. */
  127780. export class PanoramaToCubeMapTools {
  127781. private static FACE_LEFT;
  127782. private static FACE_RIGHT;
  127783. private static FACE_FRONT;
  127784. private static FACE_BACK;
  127785. private static FACE_DOWN;
  127786. private static FACE_UP;
  127787. /**
  127788. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  127789. *
  127790. * @param float32Array The source data.
  127791. * @param inputWidth The width of the input panorama.
  127792. * @param inputHeight The height of the input panorama.
  127793. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  127794. * @return The cubemap data
  127795. */
  127796. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  127797. private static CreateCubemapTexture;
  127798. private static CalcProjectionSpherical;
  127799. }
  127800. }
  127801. declare module BABYLON {
  127802. /**
  127803. * Helper class dealing with the extraction of spherical polynomial dataArray
  127804. * from a cube map.
  127805. */
  127806. export class CubeMapToSphericalPolynomialTools {
  127807. private static FileFaces;
  127808. /**
  127809. * Converts a texture to the according Spherical Polynomial data.
  127810. * This extracts the first 3 orders only as they are the only one used in the lighting.
  127811. *
  127812. * @param texture The texture to extract the information from.
  127813. * @return The Spherical Polynomial data.
  127814. */
  127815. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  127816. /**
  127817. * Converts a cubemap to the according Spherical Polynomial data.
  127818. * This extracts the first 3 orders only as they are the only one used in the lighting.
  127819. *
  127820. * @param cubeInfo The Cube map to extract the information from.
  127821. * @return The Spherical Polynomial data.
  127822. */
  127823. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  127824. }
  127825. }
  127826. declare module BABYLON {
  127827. interface BaseTexture {
  127828. /**
  127829. * Get the polynomial representation of the texture data.
  127830. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  127831. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  127832. */
  127833. sphericalPolynomial: Nullable<SphericalPolynomial>;
  127834. }
  127835. }
  127836. declare module BABYLON {
  127837. /** @hidden */
  127838. export var rgbdEncodePixelShader: {
  127839. name: string;
  127840. shader: string;
  127841. };
  127842. }
  127843. declare module BABYLON {
  127844. /** @hidden */
  127845. export var rgbdDecodePixelShader: {
  127846. name: string;
  127847. shader: string;
  127848. };
  127849. }
  127850. declare module BABYLON {
  127851. /**
  127852. * Raw texture data and descriptor sufficient for WebGL texture upload
  127853. */
  127854. export interface EnvironmentTextureInfo {
  127855. /**
  127856. * Version of the environment map
  127857. */
  127858. version: number;
  127859. /**
  127860. * Width of image
  127861. */
  127862. width: number;
  127863. /**
  127864. * Irradiance information stored in the file.
  127865. */
  127866. irradiance: any;
  127867. /**
  127868. * Specular information stored in the file.
  127869. */
  127870. specular: any;
  127871. }
  127872. /**
  127873. * Defines One Image in the file. It requires only the position in the file
  127874. * as well as the length.
  127875. */
  127876. interface BufferImageData {
  127877. /**
  127878. * Length of the image data.
  127879. */
  127880. length: number;
  127881. /**
  127882. * Position of the data from the null terminator delimiting the end of the JSON.
  127883. */
  127884. position: number;
  127885. }
  127886. /**
  127887. * Defines the specular data enclosed in the file.
  127888. * This corresponds to the version 1 of the data.
  127889. */
  127890. export interface EnvironmentTextureSpecularInfoV1 {
  127891. /**
  127892. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  127893. */
  127894. specularDataPosition?: number;
  127895. /**
  127896. * This contains all the images data needed to reconstruct the cubemap.
  127897. */
  127898. mipmaps: Array<BufferImageData>;
  127899. /**
  127900. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  127901. */
  127902. lodGenerationScale: number;
  127903. }
  127904. /**
  127905. * Sets of helpers addressing the serialization and deserialization of environment texture
  127906. * stored in a BabylonJS env file.
  127907. * Those files are usually stored as .env files.
  127908. */
  127909. export class EnvironmentTextureTools {
  127910. /**
  127911. * Magic number identifying the env file.
  127912. */
  127913. private static _MagicBytes;
  127914. /**
  127915. * Gets the environment info from an env file.
  127916. * @param data The array buffer containing the .env bytes.
  127917. * @returns the environment file info (the json header) if successfully parsed.
  127918. */
  127919. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  127920. /**
  127921. * Creates an environment texture from a loaded cube texture.
  127922. * @param texture defines the cube texture to convert in env file
  127923. * @return a promise containing the environment data if succesfull.
  127924. */
  127925. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  127926. /**
  127927. * Creates a JSON representation of the spherical data.
  127928. * @param texture defines the texture containing the polynomials
  127929. * @return the JSON representation of the spherical info
  127930. */
  127931. private static _CreateEnvTextureIrradiance;
  127932. /**
  127933. * Creates the ArrayBufferViews used for initializing environment texture image data.
  127934. * @param data the image data
  127935. * @param info parameters that determine what views will be created for accessing the underlying buffer
  127936. * @return the views described by info providing access to the underlying buffer
  127937. */
  127938. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  127939. /**
  127940. * Uploads the texture info contained in the env file to the GPU.
  127941. * @param texture defines the internal texture to upload to
  127942. * @param data defines the data to load
  127943. * @param info defines the texture info retrieved through the GetEnvInfo method
  127944. * @returns a promise
  127945. */
  127946. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  127947. private static _OnImageReadyAsync;
  127948. /**
  127949. * Uploads the levels of image data to the GPU.
  127950. * @param texture defines the internal texture to upload to
  127951. * @param imageData defines the array buffer views of image data [mipmap][face]
  127952. * @returns a promise
  127953. */
  127954. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  127955. /**
  127956. * Uploads spherical polynomials information to the texture.
  127957. * @param texture defines the texture we are trying to upload the information to
  127958. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  127959. */
  127960. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  127961. /** @hidden */
  127962. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  127963. }
  127964. }
  127965. declare module BABYLON {
  127966. /** @hidden */
  127967. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  127968. private _genericAttributeLocation;
  127969. private _varyingLocationCount;
  127970. private _varyingLocationMap;
  127971. private _replacements;
  127972. private _textureCount;
  127973. private _uniforms;
  127974. lineProcessor(line: string): string;
  127975. attributeProcessor(attribute: string): string;
  127976. varyingProcessor(varying: string, isFragment: boolean): string;
  127977. uniformProcessor(uniform: string): string;
  127978. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  127979. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  127980. }
  127981. }
  127982. declare module BABYLON {
  127983. /** @hidden */
  127984. export class ShaderCodeInliner {
  127985. static readonly InlineToken: string;
  127986. static readonly RegexpFindFunctionNameAndType: RegExp;
  127987. private _sourceCode;
  127988. private _functionDescr;
  127989. private _numMaxIterations;
  127990. debug: boolean;
  127991. get code(): string;
  127992. constructor(sourceCode: string, numMaxIterations?: number);
  127993. processCode(): void;
  127994. private _collectFunctions;
  127995. private _processInlining;
  127996. private _extractBetweenMarkers;
  127997. private _skipWhitespaces;
  127998. private _removeComments;
  127999. private _replaceFunctionCallsByCode;
  128000. private _findBackward;
  128001. private _escapeRegExp;
  128002. private _replaceNames;
  128003. }
  128004. }
  128005. declare module BABYLON {
  128006. /**
  128007. * Container for accessors for natively-stored mesh data buffers.
  128008. */
  128009. class NativeDataBuffer extends DataBuffer {
  128010. /**
  128011. * Accessor value used to identify/retrieve a natively-stored index buffer.
  128012. */
  128013. nativeIndexBuffer?: any;
  128014. /**
  128015. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  128016. */
  128017. nativeVertexBuffer?: any;
  128018. }
  128019. /** @hidden */
  128020. class NativeTexture extends InternalTexture {
  128021. getInternalTexture(): InternalTexture;
  128022. getViewCount(): number;
  128023. }
  128024. /** @hidden */
  128025. export class NativeEngine extends Engine {
  128026. private readonly _native;
  128027. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  128028. private readonly INVALID_HANDLE;
  128029. getHardwareScalingLevel(): number;
  128030. constructor();
  128031. dispose(): void;
  128032. /**
  128033. * Can be used to override the current requestAnimationFrame requester.
  128034. * @hidden
  128035. */
  128036. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  128037. /**
  128038. * Override default engine behavior.
  128039. * @param color
  128040. * @param backBuffer
  128041. * @param depth
  128042. * @param stencil
  128043. */
  128044. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  128045. /**
  128046. * Gets host document
  128047. * @returns the host document object
  128048. */
  128049. getHostDocument(): Nullable<Document>;
  128050. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  128051. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  128052. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  128053. recordVertexArrayObject(vertexBuffers: {
  128054. [key: string]: VertexBuffer;
  128055. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  128056. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  128057. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  128058. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  128059. /**
  128060. * Draw a list of indexed primitives
  128061. * @param fillMode defines the primitive to use
  128062. * @param indexStart defines the starting index
  128063. * @param indexCount defines the number of index to draw
  128064. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  128065. */
  128066. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  128067. /**
  128068. * Draw a list of unindexed primitives
  128069. * @param fillMode defines the primitive to use
  128070. * @param verticesStart defines the index of first vertex to draw
  128071. * @param verticesCount defines the count of vertices to draw
  128072. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  128073. */
  128074. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  128075. createPipelineContext(): IPipelineContext;
  128076. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  128077. /** @hidden */
  128078. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  128079. /** @hidden */
  128080. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  128081. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  128082. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  128083. protected _setProgram(program: WebGLProgram): void;
  128084. _releaseEffect(effect: Effect): void;
  128085. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  128086. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  128087. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  128088. bindSamplers(effect: Effect): void;
  128089. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  128090. getRenderWidth(useScreen?: boolean): number;
  128091. getRenderHeight(useScreen?: boolean): number;
  128092. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  128093. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  128094. /**
  128095. * Set the z offset to apply to current rendering
  128096. * @param value defines the offset to apply
  128097. */
  128098. setZOffset(value: number): void;
  128099. /**
  128100. * Gets the current value of the zOffset
  128101. * @returns the current zOffset state
  128102. */
  128103. getZOffset(): number;
  128104. /**
  128105. * Enable or disable depth buffering
  128106. * @param enable defines the state to set
  128107. */
  128108. setDepthBuffer(enable: boolean): void;
  128109. /**
  128110. * Gets a boolean indicating if depth writing is enabled
  128111. * @returns the current depth writing state
  128112. */
  128113. getDepthWrite(): boolean;
  128114. /**
  128115. * Enable or disable depth writing
  128116. * @param enable defines the state to set
  128117. */
  128118. setDepthWrite(enable: boolean): void;
  128119. /**
  128120. * Enable or disable color writing
  128121. * @param enable defines the state to set
  128122. */
  128123. setColorWrite(enable: boolean): void;
  128124. /**
  128125. * Gets a boolean indicating if color writing is enabled
  128126. * @returns the current color writing state
  128127. */
  128128. getColorWrite(): boolean;
  128129. /**
  128130. * Sets alpha constants used by some alpha blending modes
  128131. * @param r defines the red component
  128132. * @param g defines the green component
  128133. * @param b defines the blue component
  128134. * @param a defines the alpha component
  128135. */
  128136. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  128137. /**
  128138. * Sets the current alpha mode
  128139. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  128140. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  128141. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  128142. */
  128143. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  128144. /**
  128145. * Gets the current alpha mode
  128146. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  128147. * @returns the current alpha mode
  128148. */
  128149. getAlphaMode(): number;
  128150. setInt(uniform: WebGLUniformLocation, int: number): void;
  128151. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  128152. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  128153. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  128154. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  128155. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  128156. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  128157. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  128158. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  128159. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  128160. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  128161. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  128162. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  128163. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  128164. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  128165. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  128166. setFloat(uniform: WebGLUniformLocation, value: number): void;
  128167. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  128168. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  128169. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  128170. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  128171. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  128172. wipeCaches(bruteForce?: boolean): void;
  128173. _createTexture(): WebGLTexture;
  128174. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  128175. /**
  128176. * Usually called from Texture.ts.
  128177. * Passed information to create a WebGLTexture
  128178. * @param url defines a value which contains one of the following:
  128179. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  128180. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  128181. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  128182. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  128183. * @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)
  128184. * @param scene needed for loading to the correct scene
  128185. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  128186. * @param onLoad optional callback to be called upon successful completion
  128187. * @param onError optional callback to be called upon failure
  128188. * @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
  128189. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  128190. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  128191. * @param forcedExtension defines the extension to use to pick the right loader
  128192. * @param mimeType defines an optional mime type
  128193. * @returns a InternalTexture for assignment back into BABYLON.Texture
  128194. */
  128195. 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;
  128196. /**
  128197. * Creates a cube texture
  128198. * @param rootUrl defines the url where the files to load is located
  128199. * @param scene defines the current scene
  128200. * @param files defines the list of files to load (1 per face)
  128201. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  128202. * @param onLoad defines an optional callback raised when the texture is loaded
  128203. * @param onError defines an optional callback raised if there is an issue to load the texture
  128204. * @param format defines the format of the data
  128205. * @param forcedExtension defines the extension to use to pick the right loader
  128206. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  128207. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  128208. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  128209. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  128210. * @returns the cube texture as an InternalTexture
  128211. */
  128212. 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;
  128213. private _getSamplingFilter;
  128214. private static _GetNativeTextureFormat;
  128215. createRenderTargetTexture(size: number | {
  128216. width: number;
  128217. height: number;
  128218. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  128219. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  128220. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  128221. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  128222. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  128223. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  128224. /**
  128225. * Updates a dynamic vertex buffer.
  128226. * @param vertexBuffer the vertex buffer to update
  128227. * @param data the data used to update the vertex buffer
  128228. * @param byteOffset the byte offset of the data (optional)
  128229. * @param byteLength the byte length of the data (optional)
  128230. */
  128231. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  128232. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  128233. private _updateAnisotropicLevel;
  128234. private _getAddressMode;
  128235. /** @hidden */
  128236. _bindTexture(channel: number, texture: InternalTexture): void;
  128237. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  128238. releaseEffects(): void;
  128239. /** @hidden */
  128240. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  128241. /** @hidden */
  128242. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  128243. /** @hidden */
  128244. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  128245. /** @hidden */
  128246. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  128247. }
  128248. }
  128249. declare module BABYLON {
  128250. /**
  128251. * Gather the list of clipboard event types as constants.
  128252. */
  128253. export class ClipboardEventTypes {
  128254. /**
  128255. * The clipboard event is fired when a copy command is active (pressed).
  128256. */
  128257. static readonly COPY: number;
  128258. /**
  128259. * The clipboard event is fired when a cut command is active (pressed).
  128260. */
  128261. static readonly CUT: number;
  128262. /**
  128263. * The clipboard event is fired when a paste command is active (pressed).
  128264. */
  128265. static readonly PASTE: number;
  128266. }
  128267. /**
  128268. * This class is used to store clipboard related info for the onClipboardObservable event.
  128269. */
  128270. export class ClipboardInfo {
  128271. /**
  128272. * Defines the type of event (BABYLON.ClipboardEventTypes)
  128273. */
  128274. type: number;
  128275. /**
  128276. * Defines the related dom event
  128277. */
  128278. event: ClipboardEvent;
  128279. /**
  128280. *Creates an instance of ClipboardInfo.
  128281. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  128282. * @param event Defines the related dom event
  128283. */
  128284. constructor(
  128285. /**
  128286. * Defines the type of event (BABYLON.ClipboardEventTypes)
  128287. */
  128288. type: number,
  128289. /**
  128290. * Defines the related dom event
  128291. */
  128292. event: ClipboardEvent);
  128293. /**
  128294. * Get the clipboard event's type from the keycode.
  128295. * @param keyCode Defines the keyCode for the current keyboard event.
  128296. * @return {number}
  128297. */
  128298. static GetTypeFromCharacter(keyCode: number): number;
  128299. }
  128300. }
  128301. declare module BABYLON {
  128302. /**
  128303. * Google Daydream controller
  128304. */
  128305. export class DaydreamController extends WebVRController {
  128306. /**
  128307. * Base Url for the controller model.
  128308. */
  128309. static MODEL_BASE_URL: string;
  128310. /**
  128311. * File name for the controller model.
  128312. */
  128313. static MODEL_FILENAME: string;
  128314. /**
  128315. * Gamepad Id prefix used to identify Daydream Controller.
  128316. */
  128317. static readonly GAMEPAD_ID_PREFIX: string;
  128318. /**
  128319. * Creates a new DaydreamController from a gamepad
  128320. * @param vrGamepad the gamepad that the controller should be created from
  128321. */
  128322. constructor(vrGamepad: any);
  128323. /**
  128324. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  128325. * @param scene scene in which to add meshes
  128326. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  128327. */
  128328. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  128329. /**
  128330. * Called once for each button that changed state since the last frame
  128331. * @param buttonIdx Which button index changed
  128332. * @param state New state of the button
  128333. * @param changes Which properties on the state changed since last frame
  128334. */
  128335. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  128336. }
  128337. }
  128338. declare module BABYLON {
  128339. /**
  128340. * Gear VR Controller
  128341. */
  128342. export class GearVRController extends WebVRController {
  128343. /**
  128344. * Base Url for the controller model.
  128345. */
  128346. static MODEL_BASE_URL: string;
  128347. /**
  128348. * File name for the controller model.
  128349. */
  128350. static MODEL_FILENAME: string;
  128351. /**
  128352. * Gamepad Id prefix used to identify this controller.
  128353. */
  128354. static readonly GAMEPAD_ID_PREFIX: string;
  128355. private readonly _buttonIndexToObservableNameMap;
  128356. /**
  128357. * Creates a new GearVRController from a gamepad
  128358. * @param vrGamepad the gamepad that the controller should be created from
  128359. */
  128360. constructor(vrGamepad: any);
  128361. /**
  128362. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  128363. * @param scene scene in which to add meshes
  128364. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  128365. */
  128366. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  128367. /**
  128368. * Called once for each button that changed state since the last frame
  128369. * @param buttonIdx Which button index changed
  128370. * @param state New state of the button
  128371. * @param changes Which properties on the state changed since last frame
  128372. */
  128373. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  128374. }
  128375. }
  128376. declare module BABYLON {
  128377. /**
  128378. * Generic Controller
  128379. */
  128380. export class GenericController extends WebVRController {
  128381. /**
  128382. * Base Url for the controller model.
  128383. */
  128384. static readonly MODEL_BASE_URL: string;
  128385. /**
  128386. * File name for the controller model.
  128387. */
  128388. static readonly MODEL_FILENAME: string;
  128389. /**
  128390. * Creates a new GenericController from a gamepad
  128391. * @param vrGamepad the gamepad that the controller should be created from
  128392. */
  128393. constructor(vrGamepad: any);
  128394. /**
  128395. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  128396. * @param scene scene in which to add meshes
  128397. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  128398. */
  128399. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  128400. /**
  128401. * Called once for each button that changed state since the last frame
  128402. * @param buttonIdx Which button index changed
  128403. * @param state New state of the button
  128404. * @param changes Which properties on the state changed since last frame
  128405. */
  128406. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  128407. }
  128408. }
  128409. declare module BABYLON {
  128410. /**
  128411. * Oculus Touch Controller
  128412. */
  128413. export class OculusTouchController extends WebVRController {
  128414. /**
  128415. * Base Url for the controller model.
  128416. */
  128417. static MODEL_BASE_URL: string;
  128418. /**
  128419. * File name for the left controller model.
  128420. */
  128421. static MODEL_LEFT_FILENAME: string;
  128422. /**
  128423. * File name for the right controller model.
  128424. */
  128425. static MODEL_RIGHT_FILENAME: string;
  128426. /**
  128427. * Base Url for the Quest controller model.
  128428. */
  128429. static QUEST_MODEL_BASE_URL: string;
  128430. /**
  128431. * @hidden
  128432. * If the controllers are running on a device that needs the updated Quest controller models
  128433. */
  128434. static _IsQuest: boolean;
  128435. /**
  128436. * Fired when the secondary trigger on this controller is modified
  128437. */
  128438. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  128439. /**
  128440. * Fired when the thumb rest on this controller is modified
  128441. */
  128442. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  128443. /**
  128444. * Creates a new OculusTouchController from a gamepad
  128445. * @param vrGamepad the gamepad that the controller should be created from
  128446. */
  128447. constructor(vrGamepad: any);
  128448. /**
  128449. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  128450. * @param scene scene in which to add meshes
  128451. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  128452. */
  128453. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  128454. /**
  128455. * Fired when the A button on this controller is modified
  128456. */
  128457. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  128458. /**
  128459. * Fired when the B button on this controller is modified
  128460. */
  128461. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  128462. /**
  128463. * Fired when the X button on this controller is modified
  128464. */
  128465. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  128466. /**
  128467. * Fired when the Y button on this controller is modified
  128468. */
  128469. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  128470. /**
  128471. * Called once for each button that changed state since the last frame
  128472. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  128473. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  128474. * 2) secondary trigger (same)
  128475. * 3) A (right) X (left), touch, pressed = value
  128476. * 4) B / Y
  128477. * 5) thumb rest
  128478. * @param buttonIdx Which button index changed
  128479. * @param state New state of the button
  128480. * @param changes Which properties on the state changed since last frame
  128481. */
  128482. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  128483. }
  128484. }
  128485. declare module BABYLON {
  128486. /**
  128487. * Vive Controller
  128488. */
  128489. export class ViveController extends WebVRController {
  128490. /**
  128491. * Base Url for the controller model.
  128492. */
  128493. static MODEL_BASE_URL: string;
  128494. /**
  128495. * File name for the controller model.
  128496. */
  128497. static MODEL_FILENAME: string;
  128498. /**
  128499. * Creates a new ViveController from a gamepad
  128500. * @param vrGamepad the gamepad that the controller should be created from
  128501. */
  128502. constructor(vrGamepad: any);
  128503. /**
  128504. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  128505. * @param scene scene in which to add meshes
  128506. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  128507. */
  128508. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  128509. /**
  128510. * Fired when the left button on this controller is modified
  128511. */
  128512. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  128513. /**
  128514. * Fired when the right button on this controller is modified
  128515. */
  128516. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  128517. /**
  128518. * Fired when the menu button on this controller is modified
  128519. */
  128520. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  128521. /**
  128522. * Called once for each button that changed state since the last frame
  128523. * Vive mapping:
  128524. * 0: touchpad
  128525. * 1: trigger
  128526. * 2: left AND right buttons
  128527. * 3: menu button
  128528. * @param buttonIdx Which button index changed
  128529. * @param state New state of the button
  128530. * @param changes Which properties on the state changed since last frame
  128531. */
  128532. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  128533. }
  128534. }
  128535. declare module BABYLON {
  128536. /**
  128537. * Defines the WindowsMotionController object that the state of the windows motion controller
  128538. */
  128539. export class WindowsMotionController extends WebVRController {
  128540. /**
  128541. * The base url used to load the left and right controller models
  128542. */
  128543. static MODEL_BASE_URL: string;
  128544. /**
  128545. * The name of the left controller model file
  128546. */
  128547. static MODEL_LEFT_FILENAME: string;
  128548. /**
  128549. * The name of the right controller model file
  128550. */
  128551. static MODEL_RIGHT_FILENAME: string;
  128552. /**
  128553. * The controller name prefix for this controller type
  128554. */
  128555. static readonly GAMEPAD_ID_PREFIX: string;
  128556. /**
  128557. * The controller id pattern for this controller type
  128558. */
  128559. private static readonly GAMEPAD_ID_PATTERN;
  128560. private _loadedMeshInfo;
  128561. protected readonly _mapping: {
  128562. buttons: string[];
  128563. buttonMeshNames: {
  128564. trigger: string;
  128565. menu: string;
  128566. grip: string;
  128567. thumbstick: string;
  128568. trackpad: string;
  128569. };
  128570. buttonObservableNames: {
  128571. trigger: string;
  128572. menu: string;
  128573. grip: string;
  128574. thumbstick: string;
  128575. trackpad: string;
  128576. };
  128577. axisMeshNames: string[];
  128578. pointingPoseMeshName: string;
  128579. };
  128580. /**
  128581. * Fired when the trackpad on this controller is clicked
  128582. */
  128583. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  128584. /**
  128585. * Fired when the trackpad on this controller is modified
  128586. */
  128587. onTrackpadValuesChangedObservable: Observable<StickValues>;
  128588. /**
  128589. * The current x and y values of this controller's trackpad
  128590. */
  128591. trackpad: StickValues;
  128592. /**
  128593. * Creates a new WindowsMotionController from a gamepad
  128594. * @param vrGamepad the gamepad that the controller should be created from
  128595. */
  128596. constructor(vrGamepad: any);
  128597. /**
  128598. * Fired when the trigger on this controller is modified
  128599. */
  128600. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  128601. /**
  128602. * Fired when the menu button on this controller is modified
  128603. */
  128604. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  128605. /**
  128606. * Fired when the grip button on this controller is modified
  128607. */
  128608. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  128609. /**
  128610. * Fired when the thumbstick button on this controller is modified
  128611. */
  128612. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  128613. /**
  128614. * Fired when the touchpad button on this controller is modified
  128615. */
  128616. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  128617. /**
  128618. * Fired when the touchpad values on this controller are modified
  128619. */
  128620. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  128621. protected _updateTrackpad(): void;
  128622. /**
  128623. * Called once per frame by the engine.
  128624. */
  128625. update(): void;
  128626. /**
  128627. * Called once for each button that changed state since the last frame
  128628. * @param buttonIdx Which button index changed
  128629. * @param state New state of the button
  128630. * @param changes Which properties on the state changed since last frame
  128631. */
  128632. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  128633. /**
  128634. * Moves the buttons on the controller mesh based on their current state
  128635. * @param buttonName the name of the button to move
  128636. * @param buttonValue the value of the button which determines the buttons new position
  128637. */
  128638. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  128639. /**
  128640. * Moves the axis on the controller mesh based on its current state
  128641. * @param axis the index of the axis
  128642. * @param axisValue the value of the axis which determines the meshes new position
  128643. * @hidden
  128644. */
  128645. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  128646. /**
  128647. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  128648. * @param scene scene in which to add meshes
  128649. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  128650. */
  128651. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  128652. /**
  128653. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  128654. * can be transformed by button presses and axes values, based on this._mapping.
  128655. *
  128656. * @param scene scene in which the meshes exist
  128657. * @param meshes list of meshes that make up the controller model to process
  128658. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  128659. */
  128660. private processModel;
  128661. private createMeshInfo;
  128662. /**
  128663. * Gets the ray of the controller in the direction the controller is pointing
  128664. * @param length the length the resulting ray should be
  128665. * @returns a ray in the direction the controller is pointing
  128666. */
  128667. getForwardRay(length?: number): Ray;
  128668. /**
  128669. * Disposes of the controller
  128670. */
  128671. dispose(): void;
  128672. }
  128673. /**
  128674. * This class represents a new windows motion controller in XR.
  128675. */
  128676. export class XRWindowsMotionController extends WindowsMotionController {
  128677. /**
  128678. * Changing the original WIndowsMotionController mapping to fir the new mapping
  128679. */
  128680. protected readonly _mapping: {
  128681. buttons: string[];
  128682. buttonMeshNames: {
  128683. trigger: string;
  128684. menu: string;
  128685. grip: string;
  128686. thumbstick: string;
  128687. trackpad: string;
  128688. };
  128689. buttonObservableNames: {
  128690. trigger: string;
  128691. menu: string;
  128692. grip: string;
  128693. thumbstick: string;
  128694. trackpad: string;
  128695. };
  128696. axisMeshNames: string[];
  128697. pointingPoseMeshName: string;
  128698. };
  128699. /**
  128700. * Construct a new XR-Based windows motion controller
  128701. *
  128702. * @param gamepadInfo the gamepad object from the browser
  128703. */
  128704. constructor(gamepadInfo: any);
  128705. /**
  128706. * holds the thumbstick values (X,Y)
  128707. */
  128708. thumbstickValues: StickValues;
  128709. /**
  128710. * Fired when the thumbstick on this controller is clicked
  128711. */
  128712. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  128713. /**
  128714. * Fired when the thumbstick on this controller is modified
  128715. */
  128716. onThumbstickValuesChangedObservable: Observable<StickValues>;
  128717. /**
  128718. * Fired when the touchpad button on this controller is modified
  128719. */
  128720. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  128721. /**
  128722. * Fired when the touchpad values on this controller are modified
  128723. */
  128724. onTrackpadValuesChangedObservable: Observable<StickValues>;
  128725. /**
  128726. * Fired when the thumbstick button on this controller is modified
  128727. * here to prevent breaking changes
  128728. */
  128729. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  128730. /**
  128731. * updating the thumbstick(!) and not the trackpad.
  128732. * This is named this way due to the difference between WebVR and XR and to avoid
  128733. * changing the parent class.
  128734. */
  128735. protected _updateTrackpad(): void;
  128736. /**
  128737. * Disposes the class with joy
  128738. */
  128739. dispose(): void;
  128740. }
  128741. }
  128742. declare module BABYLON {
  128743. /**
  128744. * Class containing static functions to help procedurally build meshes
  128745. */
  128746. export class PolyhedronBuilder {
  128747. /**
  128748. * Creates a polyhedron mesh
  128749. * * 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
  128750. * * The parameter `size` (positive float, default 1) sets the polygon size
  128751. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  128752. * * 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`
  128753. * * 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
  128754. * * 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)`)
  128755. * * 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
  128756. * * 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
  128757. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  128758. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  128759. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  128760. * @param name defines the name of the mesh
  128761. * @param options defines the options used to create the mesh
  128762. * @param scene defines the hosting scene
  128763. * @returns the polyhedron mesh
  128764. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  128765. */
  128766. static CreatePolyhedron(name: string, options: {
  128767. type?: number;
  128768. size?: number;
  128769. sizeX?: number;
  128770. sizeY?: number;
  128771. sizeZ?: number;
  128772. custom?: any;
  128773. faceUV?: Vector4[];
  128774. faceColors?: Color4[];
  128775. flat?: boolean;
  128776. updatable?: boolean;
  128777. sideOrientation?: number;
  128778. frontUVs?: Vector4;
  128779. backUVs?: Vector4;
  128780. }, scene?: Nullable<Scene>): Mesh;
  128781. }
  128782. }
  128783. declare module BABYLON {
  128784. /**
  128785. * Gizmo that enables scaling a mesh along 3 axis
  128786. */
  128787. export class ScaleGizmo extends Gizmo {
  128788. /**
  128789. * Internal gizmo used for interactions on the x axis
  128790. */
  128791. xGizmo: AxisScaleGizmo;
  128792. /**
  128793. * Internal gizmo used for interactions on the y axis
  128794. */
  128795. yGizmo: AxisScaleGizmo;
  128796. /**
  128797. * Internal gizmo used for interactions on the z axis
  128798. */
  128799. zGizmo: AxisScaleGizmo;
  128800. /**
  128801. * Internal gizmo used to scale all axis equally
  128802. */
  128803. uniformScaleGizmo: AxisScaleGizmo;
  128804. private _meshAttached;
  128805. private _updateGizmoRotationToMatchAttachedMesh;
  128806. private _snapDistance;
  128807. private _scaleRatio;
  128808. private _uniformScalingMesh;
  128809. private _octahedron;
  128810. private _sensitivity;
  128811. /** Fires an event when any of it's sub gizmos are dragged */
  128812. onDragStartObservable: Observable<unknown>;
  128813. /** Fires an event when any of it's sub gizmos are released from dragging */
  128814. onDragEndObservable: Observable<unknown>;
  128815. get attachedMesh(): Nullable<AbstractMesh>;
  128816. set attachedMesh(mesh: Nullable<AbstractMesh>);
  128817. /**
  128818. * Creates a ScaleGizmo
  128819. * @param gizmoLayer The utility layer the gizmo will be added to
  128820. */
  128821. constructor(gizmoLayer?: UtilityLayerRenderer);
  128822. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  128823. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  128824. /**
  128825. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  128826. */
  128827. set snapDistance(value: number);
  128828. get snapDistance(): number;
  128829. /**
  128830. * Ratio for the scale of the gizmo (Default: 1)
  128831. */
  128832. set scaleRatio(value: number);
  128833. get scaleRatio(): number;
  128834. /**
  128835. * Sensitivity factor for dragging (Default: 1)
  128836. */
  128837. set sensitivity(value: number);
  128838. get sensitivity(): number;
  128839. /**
  128840. * Disposes of the gizmo
  128841. */
  128842. dispose(): void;
  128843. }
  128844. }
  128845. declare module BABYLON {
  128846. /**
  128847. * Single axis scale gizmo
  128848. */
  128849. export class AxisScaleGizmo extends Gizmo {
  128850. /**
  128851. * Drag behavior responsible for the gizmos dragging interactions
  128852. */
  128853. dragBehavior: PointerDragBehavior;
  128854. private _pointerObserver;
  128855. /**
  128856. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  128857. */
  128858. snapDistance: number;
  128859. /**
  128860. * Event that fires each time the gizmo snaps to a new location.
  128861. * * snapDistance is the the change in distance
  128862. */
  128863. onSnapObservable: Observable<{
  128864. snapDistance: number;
  128865. }>;
  128866. /**
  128867. * If the scaling operation should be done on all axis (default: false)
  128868. */
  128869. uniformScaling: boolean;
  128870. /**
  128871. * Custom sensitivity value for the drag strength
  128872. */
  128873. sensitivity: number;
  128874. private _isEnabled;
  128875. private _parent;
  128876. private _arrow;
  128877. private _coloredMaterial;
  128878. private _hoverMaterial;
  128879. /**
  128880. * Creates an AxisScaleGizmo
  128881. * @param gizmoLayer The utility layer the gizmo will be added to
  128882. * @param dragAxis The axis which the gizmo will be able to scale on
  128883. * @param color The color of the gizmo
  128884. */
  128885. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  128886. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  128887. /**
  128888. * If the gizmo is enabled
  128889. */
  128890. set isEnabled(value: boolean);
  128891. get isEnabled(): boolean;
  128892. /**
  128893. * Disposes of the gizmo
  128894. */
  128895. dispose(): void;
  128896. /**
  128897. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  128898. * @param mesh The mesh to replace the default mesh of the gizmo
  128899. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  128900. */
  128901. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  128902. }
  128903. }
  128904. declare module BABYLON {
  128905. /**
  128906. * Bounding box gizmo
  128907. */
  128908. export class BoundingBoxGizmo extends Gizmo {
  128909. private _lineBoundingBox;
  128910. private _rotateSpheresParent;
  128911. private _scaleBoxesParent;
  128912. private _boundingDimensions;
  128913. private _renderObserver;
  128914. private _pointerObserver;
  128915. private _scaleDragSpeed;
  128916. private _tmpQuaternion;
  128917. private _tmpVector;
  128918. private _tmpRotationMatrix;
  128919. /**
  128920. * 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)
  128921. */
  128922. ignoreChildren: boolean;
  128923. /**
  128924. * 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)
  128925. */
  128926. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  128927. /**
  128928. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  128929. */
  128930. rotationSphereSize: number;
  128931. /**
  128932. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  128933. */
  128934. scaleBoxSize: number;
  128935. /**
  128936. * 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)
  128937. */
  128938. fixedDragMeshScreenSize: boolean;
  128939. /**
  128940. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  128941. */
  128942. fixedDragMeshScreenSizeDistanceFactor: number;
  128943. /**
  128944. * Fired when a rotation sphere or scale box is dragged
  128945. */
  128946. onDragStartObservable: Observable<{}>;
  128947. /**
  128948. * Fired when a scale box is dragged
  128949. */
  128950. onScaleBoxDragObservable: Observable<{}>;
  128951. /**
  128952. * Fired when a scale box drag is ended
  128953. */
  128954. onScaleBoxDragEndObservable: Observable<{}>;
  128955. /**
  128956. * Fired when a rotation sphere is dragged
  128957. */
  128958. onRotationSphereDragObservable: Observable<{}>;
  128959. /**
  128960. * Fired when a rotation sphere drag is ended
  128961. */
  128962. onRotationSphereDragEndObservable: Observable<{}>;
  128963. /**
  128964. * 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)
  128965. */
  128966. scalePivot: Nullable<Vector3>;
  128967. /**
  128968. * Mesh used as a pivot to rotate the attached mesh
  128969. */
  128970. private _anchorMesh;
  128971. private _existingMeshScale;
  128972. private _dragMesh;
  128973. private pointerDragBehavior;
  128974. private coloredMaterial;
  128975. private hoverColoredMaterial;
  128976. /**
  128977. * Sets the color of the bounding box gizmo
  128978. * @param color the color to set
  128979. */
  128980. setColor(color: Color3): void;
  128981. /**
  128982. * Creates an BoundingBoxGizmo
  128983. * @param gizmoLayer The utility layer the gizmo will be added to
  128984. * @param color The color of the gizmo
  128985. */
  128986. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  128987. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  128988. private _selectNode;
  128989. /**
  128990. * Updates the bounding box information for the Gizmo
  128991. */
  128992. updateBoundingBox(): void;
  128993. private _updateRotationSpheres;
  128994. private _updateScaleBoxes;
  128995. /**
  128996. * Enables rotation on the specified axis and disables rotation on the others
  128997. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  128998. */
  128999. setEnabledRotationAxis(axis: string): void;
  129000. /**
  129001. * Enables/disables scaling
  129002. * @param enable if scaling should be enabled
  129003. * @param homogeneousScaling defines if scaling should only be homogeneous
  129004. */
  129005. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  129006. private _updateDummy;
  129007. /**
  129008. * Enables a pointer drag behavior on the bounding box of the gizmo
  129009. */
  129010. enableDragBehavior(): void;
  129011. /**
  129012. * Disposes of the gizmo
  129013. */
  129014. dispose(): void;
  129015. /**
  129016. * 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)
  129017. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  129018. * @returns the bounding box mesh with the passed in mesh as a child
  129019. */
  129020. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  129021. /**
  129022. * CustomMeshes are not supported by this gizmo
  129023. * @param mesh The mesh to replace the default mesh of the gizmo
  129024. */
  129025. setCustomMesh(mesh: Mesh): void;
  129026. }
  129027. }
  129028. declare module BABYLON {
  129029. /**
  129030. * Single plane rotation gizmo
  129031. */
  129032. export class PlaneRotationGizmo extends Gizmo {
  129033. /**
  129034. * Drag behavior responsible for the gizmos dragging interactions
  129035. */
  129036. dragBehavior: PointerDragBehavior;
  129037. private _pointerObserver;
  129038. /**
  129039. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  129040. */
  129041. snapDistance: number;
  129042. /**
  129043. * Event that fires each time the gizmo snaps to a new location.
  129044. * * snapDistance is the the change in distance
  129045. */
  129046. onSnapObservable: Observable<{
  129047. snapDistance: number;
  129048. }>;
  129049. private _isEnabled;
  129050. private _parent;
  129051. /**
  129052. * Creates a PlaneRotationGizmo
  129053. * @param gizmoLayer The utility layer the gizmo will be added to
  129054. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  129055. * @param color The color of the gizmo
  129056. * @param tessellation Amount of tessellation to be used when creating rotation circles
  129057. * @param useEulerRotation Use and update Euler angle instead of quaternion
  129058. */
  129059. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  129060. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  129061. /**
  129062. * If the gizmo is enabled
  129063. */
  129064. set isEnabled(value: boolean);
  129065. get isEnabled(): boolean;
  129066. /**
  129067. * Disposes of the gizmo
  129068. */
  129069. dispose(): void;
  129070. }
  129071. }
  129072. declare module BABYLON {
  129073. /**
  129074. * Gizmo that enables rotating a mesh along 3 axis
  129075. */
  129076. export class RotationGizmo extends Gizmo {
  129077. /**
  129078. * Internal gizmo used for interactions on the x axis
  129079. */
  129080. xGizmo: PlaneRotationGizmo;
  129081. /**
  129082. * Internal gizmo used for interactions on the y axis
  129083. */
  129084. yGizmo: PlaneRotationGizmo;
  129085. /**
  129086. * Internal gizmo used for interactions on the z axis
  129087. */
  129088. zGizmo: PlaneRotationGizmo;
  129089. /** Fires an event when any of it's sub gizmos are dragged */
  129090. onDragStartObservable: Observable<unknown>;
  129091. /** Fires an event when any of it's sub gizmos are released from dragging */
  129092. onDragEndObservable: Observable<unknown>;
  129093. private _meshAttached;
  129094. get attachedMesh(): Nullable<AbstractMesh>;
  129095. set attachedMesh(mesh: Nullable<AbstractMesh>);
  129096. /**
  129097. * Creates a RotationGizmo
  129098. * @param gizmoLayer The utility layer the gizmo will be added to
  129099. * @param tessellation Amount of tessellation to be used when creating rotation circles
  129100. * @param useEulerRotation Use and update Euler angle instead of quaternion
  129101. */
  129102. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  129103. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  129104. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  129105. /**
  129106. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  129107. */
  129108. set snapDistance(value: number);
  129109. get snapDistance(): number;
  129110. /**
  129111. * Ratio for the scale of the gizmo (Default: 1)
  129112. */
  129113. set scaleRatio(value: number);
  129114. get scaleRatio(): number;
  129115. /**
  129116. * Disposes of the gizmo
  129117. */
  129118. dispose(): void;
  129119. /**
  129120. * CustomMeshes are not supported by this gizmo
  129121. * @param mesh The mesh to replace the default mesh of the gizmo
  129122. */
  129123. setCustomMesh(mesh: Mesh): void;
  129124. }
  129125. }
  129126. declare module BABYLON {
  129127. /**
  129128. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  129129. */
  129130. export class GizmoManager implements IDisposable {
  129131. private scene;
  129132. /**
  129133. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  129134. */
  129135. gizmos: {
  129136. positionGizmo: Nullable<PositionGizmo>;
  129137. rotationGizmo: Nullable<RotationGizmo>;
  129138. scaleGizmo: Nullable<ScaleGizmo>;
  129139. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  129140. };
  129141. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  129142. clearGizmoOnEmptyPointerEvent: boolean;
  129143. /** Fires an event when the manager is attached to a mesh */
  129144. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  129145. private _gizmosEnabled;
  129146. private _pointerObserver;
  129147. private _attachedMesh;
  129148. private _boundingBoxColor;
  129149. private _defaultUtilityLayer;
  129150. private _defaultKeepDepthUtilityLayer;
  129151. /**
  129152. * When bounding box gizmo is enabled, this can be used to track drag/end events
  129153. */
  129154. boundingBoxDragBehavior: SixDofDragBehavior;
  129155. /**
  129156. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  129157. */
  129158. attachableMeshes: Nullable<Array<AbstractMesh>>;
  129159. /**
  129160. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  129161. */
  129162. usePointerToAttachGizmos: boolean;
  129163. /**
  129164. * Utility layer that the bounding box gizmo belongs to
  129165. */
  129166. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  129167. /**
  129168. * Utility layer that all gizmos besides bounding box belong to
  129169. */
  129170. get utilityLayer(): UtilityLayerRenderer;
  129171. /**
  129172. * Instatiates a gizmo manager
  129173. * @param scene the scene to overlay the gizmos on top of
  129174. */
  129175. constructor(scene: Scene);
  129176. /**
  129177. * Attaches a set of gizmos to the specified mesh
  129178. * @param mesh The mesh the gizmo's should be attached to
  129179. */
  129180. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  129181. /**
  129182. * If the position gizmo is enabled
  129183. */
  129184. set positionGizmoEnabled(value: boolean);
  129185. get positionGizmoEnabled(): boolean;
  129186. /**
  129187. * If the rotation gizmo is enabled
  129188. */
  129189. set rotationGizmoEnabled(value: boolean);
  129190. get rotationGizmoEnabled(): boolean;
  129191. /**
  129192. * If the scale gizmo is enabled
  129193. */
  129194. set scaleGizmoEnabled(value: boolean);
  129195. get scaleGizmoEnabled(): boolean;
  129196. /**
  129197. * If the boundingBox gizmo is enabled
  129198. */
  129199. set boundingBoxGizmoEnabled(value: boolean);
  129200. get boundingBoxGizmoEnabled(): boolean;
  129201. /**
  129202. * Disposes of the gizmo manager
  129203. */
  129204. dispose(): void;
  129205. }
  129206. }
  129207. declare module BABYLON {
  129208. /**
  129209. * A directional light is defined by a direction (what a surprise!).
  129210. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  129211. * 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.
  129212. * Documentation: https://doc.babylonjs.com/babylon101/lights
  129213. */
  129214. export class DirectionalLight extends ShadowLight {
  129215. private _shadowFrustumSize;
  129216. /**
  129217. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  129218. */
  129219. get shadowFrustumSize(): number;
  129220. /**
  129221. * Specifies a fix frustum size for the shadow generation.
  129222. */
  129223. set shadowFrustumSize(value: number);
  129224. private _shadowOrthoScale;
  129225. /**
  129226. * Gets the shadow projection scale against the optimal computed one.
  129227. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  129228. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  129229. */
  129230. get shadowOrthoScale(): number;
  129231. /**
  129232. * Sets the shadow projection scale against the optimal computed one.
  129233. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  129234. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  129235. */
  129236. set shadowOrthoScale(value: number);
  129237. /**
  129238. * Automatically compute the projection matrix to best fit (including all the casters)
  129239. * on each frame.
  129240. */
  129241. autoUpdateExtends: boolean;
  129242. /**
  129243. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  129244. * on each frame. autoUpdateExtends must be set to true for this to work
  129245. */
  129246. autoCalcShadowZBounds: boolean;
  129247. private _orthoLeft;
  129248. private _orthoRight;
  129249. private _orthoTop;
  129250. private _orthoBottom;
  129251. /**
  129252. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  129253. * The directional light is emitted from everywhere in the given direction.
  129254. * It can cast shadows.
  129255. * Documentation : https://doc.babylonjs.com/babylon101/lights
  129256. * @param name The friendly name of the light
  129257. * @param direction The direction of the light
  129258. * @param scene The scene the light belongs to
  129259. */
  129260. constructor(name: string, direction: Vector3, scene: Scene);
  129261. /**
  129262. * Returns the string "DirectionalLight".
  129263. * @return The class name
  129264. */
  129265. getClassName(): string;
  129266. /**
  129267. * Returns the integer 1.
  129268. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  129269. */
  129270. getTypeID(): number;
  129271. /**
  129272. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  129273. * Returns the DirectionalLight Shadow projection matrix.
  129274. */
  129275. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  129276. /**
  129277. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  129278. * Returns the DirectionalLight Shadow projection matrix.
  129279. */
  129280. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  129281. /**
  129282. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  129283. * Returns the DirectionalLight Shadow projection matrix.
  129284. */
  129285. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  129286. protected _buildUniformLayout(): void;
  129287. /**
  129288. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  129289. * @param effect The effect to update
  129290. * @param lightIndex The index of the light in the effect to update
  129291. * @returns The directional light
  129292. */
  129293. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  129294. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  129295. /**
  129296. * Gets the minZ used for shadow according to both the scene and the light.
  129297. *
  129298. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  129299. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  129300. * @param activeCamera The camera we are returning the min for
  129301. * @returns the depth min z
  129302. */
  129303. getDepthMinZ(activeCamera: Camera): number;
  129304. /**
  129305. * Gets the maxZ used for shadow according to both the scene and the light.
  129306. *
  129307. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  129308. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  129309. * @param activeCamera The camera we are returning the max for
  129310. * @returns the depth max z
  129311. */
  129312. getDepthMaxZ(activeCamera: Camera): number;
  129313. /**
  129314. * Prepares the list of defines specific to the light type.
  129315. * @param defines the list of defines
  129316. * @param lightIndex defines the index of the light for the effect
  129317. */
  129318. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  129319. }
  129320. }
  129321. declare module BABYLON {
  129322. /**
  129323. * Class containing static functions to help procedurally build meshes
  129324. */
  129325. export class HemisphereBuilder {
  129326. /**
  129327. * Creates a hemisphere mesh
  129328. * @param name defines the name of the mesh
  129329. * @param options defines the options used to create the mesh
  129330. * @param scene defines the hosting scene
  129331. * @returns the hemisphere mesh
  129332. */
  129333. static CreateHemisphere(name: string, options: {
  129334. segments?: number;
  129335. diameter?: number;
  129336. sideOrientation?: number;
  129337. }, scene: any): Mesh;
  129338. }
  129339. }
  129340. declare module BABYLON {
  129341. /**
  129342. * A spot light is defined by a position, a direction, an angle, and an exponent.
  129343. * These values define a cone of light starting from the position, emitting toward the direction.
  129344. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  129345. * and the exponent defines the speed of the decay of the light with distance (reach).
  129346. * Documentation: https://doc.babylonjs.com/babylon101/lights
  129347. */
  129348. export class SpotLight extends ShadowLight {
  129349. private _angle;
  129350. private _innerAngle;
  129351. private _cosHalfAngle;
  129352. private _lightAngleScale;
  129353. private _lightAngleOffset;
  129354. /**
  129355. * Gets the cone angle of the spot light in Radians.
  129356. */
  129357. get angle(): number;
  129358. /**
  129359. * Sets the cone angle of the spot light in Radians.
  129360. */
  129361. set angle(value: number);
  129362. /**
  129363. * Only used in gltf falloff mode, this defines the angle where
  129364. * the directional falloff will start before cutting at angle which could be seen
  129365. * as outer angle.
  129366. */
  129367. get innerAngle(): number;
  129368. /**
  129369. * Only used in gltf falloff mode, this defines the angle where
  129370. * the directional falloff will start before cutting at angle which could be seen
  129371. * as outer angle.
  129372. */
  129373. set innerAngle(value: number);
  129374. private _shadowAngleScale;
  129375. /**
  129376. * Allows scaling the angle of the light for shadow generation only.
  129377. */
  129378. get shadowAngleScale(): number;
  129379. /**
  129380. * Allows scaling the angle of the light for shadow generation only.
  129381. */
  129382. set shadowAngleScale(value: number);
  129383. /**
  129384. * The light decay speed with the distance from the emission spot.
  129385. */
  129386. exponent: number;
  129387. private _projectionTextureMatrix;
  129388. /**
  129389. * Allows reading the projecton texture
  129390. */
  129391. get projectionTextureMatrix(): Matrix;
  129392. protected _projectionTextureLightNear: number;
  129393. /**
  129394. * Gets the near clip of the Spotlight for texture projection.
  129395. */
  129396. get projectionTextureLightNear(): number;
  129397. /**
  129398. * Sets the near clip of the Spotlight for texture projection.
  129399. */
  129400. set projectionTextureLightNear(value: number);
  129401. protected _projectionTextureLightFar: number;
  129402. /**
  129403. * Gets the far clip of the Spotlight for texture projection.
  129404. */
  129405. get projectionTextureLightFar(): number;
  129406. /**
  129407. * Sets the far clip of the Spotlight for texture projection.
  129408. */
  129409. set projectionTextureLightFar(value: number);
  129410. protected _projectionTextureUpDirection: Vector3;
  129411. /**
  129412. * Gets the Up vector of the Spotlight for texture projection.
  129413. */
  129414. get projectionTextureUpDirection(): Vector3;
  129415. /**
  129416. * Sets the Up vector of the Spotlight for texture projection.
  129417. */
  129418. set projectionTextureUpDirection(value: Vector3);
  129419. private _projectionTexture;
  129420. /**
  129421. * Gets the projection texture of the light.
  129422. */
  129423. get projectionTexture(): Nullable<BaseTexture>;
  129424. /**
  129425. * Sets the projection texture of the light.
  129426. */
  129427. set projectionTexture(value: Nullable<BaseTexture>);
  129428. private _projectionTextureViewLightDirty;
  129429. private _projectionTextureProjectionLightDirty;
  129430. private _projectionTextureDirty;
  129431. private _projectionTextureViewTargetVector;
  129432. private _projectionTextureViewLightMatrix;
  129433. private _projectionTextureProjectionLightMatrix;
  129434. private _projectionTextureScalingMatrix;
  129435. /**
  129436. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  129437. * It can cast shadows.
  129438. * Documentation : https://doc.babylonjs.com/babylon101/lights
  129439. * @param name The light friendly name
  129440. * @param position The position of the spot light in the scene
  129441. * @param direction The direction of the light in the scene
  129442. * @param angle The cone angle of the light in Radians
  129443. * @param exponent The light decay speed with the distance from the emission spot
  129444. * @param scene The scene the lights belongs to
  129445. */
  129446. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  129447. /**
  129448. * Returns the string "SpotLight".
  129449. * @returns the class name
  129450. */
  129451. getClassName(): string;
  129452. /**
  129453. * Returns the integer 2.
  129454. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  129455. */
  129456. getTypeID(): number;
  129457. /**
  129458. * Overrides the direction setter to recompute the projection texture view light Matrix.
  129459. */
  129460. protected _setDirection(value: Vector3): void;
  129461. /**
  129462. * Overrides the position setter to recompute the projection texture view light Matrix.
  129463. */
  129464. protected _setPosition(value: Vector3): void;
  129465. /**
  129466. * 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.
  129467. * Returns the SpotLight.
  129468. */
  129469. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  129470. protected _computeProjectionTextureViewLightMatrix(): void;
  129471. protected _computeProjectionTextureProjectionLightMatrix(): void;
  129472. /**
  129473. * Main function for light texture projection matrix computing.
  129474. */
  129475. protected _computeProjectionTextureMatrix(): void;
  129476. protected _buildUniformLayout(): void;
  129477. private _computeAngleValues;
  129478. /**
  129479. * Sets the passed Effect "effect" with the Light textures.
  129480. * @param effect The effect to update
  129481. * @param lightIndex The index of the light in the effect to update
  129482. * @returns The light
  129483. */
  129484. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  129485. /**
  129486. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  129487. * @param effect The effect to update
  129488. * @param lightIndex The index of the light in the effect to update
  129489. * @returns The spot light
  129490. */
  129491. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  129492. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  129493. /**
  129494. * Disposes the light and the associated resources.
  129495. */
  129496. dispose(): void;
  129497. /**
  129498. * Prepares the list of defines specific to the light type.
  129499. * @param defines the list of defines
  129500. * @param lightIndex defines the index of the light for the effect
  129501. */
  129502. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  129503. }
  129504. }
  129505. declare module BABYLON {
  129506. /**
  129507. * Gizmo that enables viewing a light
  129508. */
  129509. export class LightGizmo extends Gizmo {
  129510. private _lightMesh;
  129511. private _material;
  129512. private _cachedPosition;
  129513. private _cachedForward;
  129514. private _attachedMeshParent;
  129515. /**
  129516. * Creates a LightGizmo
  129517. * @param gizmoLayer The utility layer the gizmo will be added to
  129518. */
  129519. constructor(gizmoLayer?: UtilityLayerRenderer);
  129520. private _light;
  129521. /**
  129522. * The light that the gizmo is attached to
  129523. */
  129524. set light(light: Nullable<Light>);
  129525. get light(): Nullable<Light>;
  129526. /**
  129527. * Gets the material used to render the light gizmo
  129528. */
  129529. get material(): StandardMaterial;
  129530. /**
  129531. * @hidden
  129532. * Updates the gizmo to match the attached mesh's position/rotation
  129533. */
  129534. protected _update(): void;
  129535. private static _Scale;
  129536. /**
  129537. * Creates the lines for a light mesh
  129538. */
  129539. private static _CreateLightLines;
  129540. /**
  129541. * Disposes of the light gizmo
  129542. */
  129543. dispose(): void;
  129544. private static _CreateHemisphericLightMesh;
  129545. private static _CreatePointLightMesh;
  129546. private static _CreateSpotLightMesh;
  129547. private static _CreateDirectionalLightMesh;
  129548. }
  129549. }
  129550. declare module BABYLON {
  129551. /** @hidden */
  129552. export var backgroundFragmentDeclaration: {
  129553. name: string;
  129554. shader: string;
  129555. };
  129556. }
  129557. declare module BABYLON {
  129558. /** @hidden */
  129559. export var backgroundUboDeclaration: {
  129560. name: string;
  129561. shader: string;
  129562. };
  129563. }
  129564. declare module BABYLON {
  129565. /** @hidden */
  129566. export var backgroundPixelShader: {
  129567. name: string;
  129568. shader: string;
  129569. };
  129570. }
  129571. declare module BABYLON {
  129572. /** @hidden */
  129573. export var backgroundVertexDeclaration: {
  129574. name: string;
  129575. shader: string;
  129576. };
  129577. }
  129578. declare module BABYLON {
  129579. /** @hidden */
  129580. export var backgroundVertexShader: {
  129581. name: string;
  129582. shader: string;
  129583. };
  129584. }
  129585. declare module BABYLON {
  129586. /**
  129587. * Background material used to create an efficient environement around your scene.
  129588. */
  129589. export class BackgroundMaterial extends PushMaterial {
  129590. /**
  129591. * Standard reflectance value at parallel view angle.
  129592. */
  129593. static StandardReflectance0: number;
  129594. /**
  129595. * Standard reflectance value at grazing angle.
  129596. */
  129597. static StandardReflectance90: number;
  129598. protected _primaryColor: Color3;
  129599. /**
  129600. * Key light Color (multiply against the environement texture)
  129601. */
  129602. primaryColor: Color3;
  129603. protected __perceptualColor: Nullable<Color3>;
  129604. /**
  129605. * Experimental Internal Use Only.
  129606. *
  129607. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  129608. * This acts as a helper to set the primary color to a more "human friendly" value.
  129609. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  129610. * output color as close as possible from the chosen value.
  129611. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  129612. * part of lighting setup.)
  129613. */
  129614. get _perceptualColor(): Nullable<Color3>;
  129615. set _perceptualColor(value: Nullable<Color3>);
  129616. protected _primaryColorShadowLevel: float;
  129617. /**
  129618. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  129619. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  129620. */
  129621. get primaryColorShadowLevel(): float;
  129622. set primaryColorShadowLevel(value: float);
  129623. protected _primaryColorHighlightLevel: float;
  129624. /**
  129625. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  129626. * The primary color is used at the level chosen to define what the white area would look.
  129627. */
  129628. get primaryColorHighlightLevel(): float;
  129629. set primaryColorHighlightLevel(value: float);
  129630. protected _reflectionTexture: Nullable<BaseTexture>;
  129631. /**
  129632. * Reflection Texture used in the material.
  129633. * Should be author in a specific way for the best result (refer to the documentation).
  129634. */
  129635. reflectionTexture: Nullable<BaseTexture>;
  129636. protected _reflectionBlur: float;
  129637. /**
  129638. * Reflection Texture level of blur.
  129639. *
  129640. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  129641. * texture twice.
  129642. */
  129643. reflectionBlur: float;
  129644. protected _diffuseTexture: Nullable<BaseTexture>;
  129645. /**
  129646. * Diffuse Texture used in the material.
  129647. * Should be author in a specific way for the best result (refer to the documentation).
  129648. */
  129649. diffuseTexture: Nullable<BaseTexture>;
  129650. protected _shadowLights: Nullable<IShadowLight[]>;
  129651. /**
  129652. * Specify the list of lights casting shadow on the material.
  129653. * All scene shadow lights will be included if null.
  129654. */
  129655. shadowLights: Nullable<IShadowLight[]>;
  129656. protected _shadowLevel: float;
  129657. /**
  129658. * Helps adjusting the shadow to a softer level if required.
  129659. * 0 means black shadows and 1 means no shadows.
  129660. */
  129661. shadowLevel: float;
  129662. protected _sceneCenter: Vector3;
  129663. /**
  129664. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  129665. * It is usually zero but might be interesting to modify according to your setup.
  129666. */
  129667. sceneCenter: Vector3;
  129668. protected _opacityFresnel: boolean;
  129669. /**
  129670. * This helps specifying that the material is falling off to the sky box at grazing angle.
  129671. * This helps ensuring a nice transition when the camera goes under the ground.
  129672. */
  129673. opacityFresnel: boolean;
  129674. protected _reflectionFresnel: boolean;
  129675. /**
  129676. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  129677. * This helps adding a mirror texture on the ground.
  129678. */
  129679. reflectionFresnel: boolean;
  129680. protected _reflectionFalloffDistance: number;
  129681. /**
  129682. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  129683. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  129684. */
  129685. reflectionFalloffDistance: number;
  129686. protected _reflectionAmount: number;
  129687. /**
  129688. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  129689. */
  129690. reflectionAmount: number;
  129691. protected _reflectionReflectance0: number;
  129692. /**
  129693. * This specifies the weight of the reflection at grazing angle.
  129694. */
  129695. reflectionReflectance0: number;
  129696. protected _reflectionReflectance90: number;
  129697. /**
  129698. * This specifies the weight of the reflection at a perpendicular point of view.
  129699. */
  129700. reflectionReflectance90: number;
  129701. /**
  129702. * Sets the reflection reflectance fresnel values according to the default standard
  129703. * empirically know to work well :-)
  129704. */
  129705. set reflectionStandardFresnelWeight(value: number);
  129706. protected _useRGBColor: boolean;
  129707. /**
  129708. * Helps to directly use the maps channels instead of their level.
  129709. */
  129710. useRGBColor: boolean;
  129711. protected _enableNoise: boolean;
  129712. /**
  129713. * This helps reducing the banding effect that could occur on the background.
  129714. */
  129715. enableNoise: boolean;
  129716. /**
  129717. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  129718. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  129719. * Recommended to be keep at 1.0 except for special cases.
  129720. */
  129721. get fovMultiplier(): number;
  129722. set fovMultiplier(value: number);
  129723. private _fovMultiplier;
  129724. /**
  129725. * Enable the FOV adjustment feature controlled by fovMultiplier.
  129726. */
  129727. useEquirectangularFOV: boolean;
  129728. private _maxSimultaneousLights;
  129729. /**
  129730. * Number of Simultaneous lights allowed on the material.
  129731. */
  129732. maxSimultaneousLights: int;
  129733. /**
  129734. * Default configuration related to image processing available in the Background Material.
  129735. */
  129736. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  129737. /**
  129738. * Keep track of the image processing observer to allow dispose and replace.
  129739. */
  129740. private _imageProcessingObserver;
  129741. /**
  129742. * Attaches a new image processing configuration to the PBR Material.
  129743. * @param configuration (if null the scene configuration will be use)
  129744. */
  129745. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  129746. /**
  129747. * Gets the image processing configuration used either in this material.
  129748. */
  129749. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  129750. /**
  129751. * Sets the Default image processing configuration used either in the this material.
  129752. *
  129753. * If sets to null, the scene one is in use.
  129754. */
  129755. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  129756. /**
  129757. * Gets wether the color curves effect is enabled.
  129758. */
  129759. get cameraColorCurvesEnabled(): boolean;
  129760. /**
  129761. * Sets wether the color curves effect is enabled.
  129762. */
  129763. set cameraColorCurvesEnabled(value: boolean);
  129764. /**
  129765. * Gets wether the color grading effect is enabled.
  129766. */
  129767. get cameraColorGradingEnabled(): boolean;
  129768. /**
  129769. * Gets wether the color grading effect is enabled.
  129770. */
  129771. set cameraColorGradingEnabled(value: boolean);
  129772. /**
  129773. * Gets wether tonemapping is enabled or not.
  129774. */
  129775. get cameraToneMappingEnabled(): boolean;
  129776. /**
  129777. * Sets wether tonemapping is enabled or not
  129778. */
  129779. set cameraToneMappingEnabled(value: boolean);
  129780. /**
  129781. * The camera exposure used on this material.
  129782. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  129783. * This corresponds to a photographic exposure.
  129784. */
  129785. get cameraExposure(): float;
  129786. /**
  129787. * The camera exposure used on this material.
  129788. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  129789. * This corresponds to a photographic exposure.
  129790. */
  129791. set cameraExposure(value: float);
  129792. /**
  129793. * Gets The camera contrast used on this material.
  129794. */
  129795. get cameraContrast(): float;
  129796. /**
  129797. * Sets The camera contrast used on this material.
  129798. */
  129799. set cameraContrast(value: float);
  129800. /**
  129801. * Gets the Color Grading 2D Lookup Texture.
  129802. */
  129803. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  129804. /**
  129805. * Sets the Color Grading 2D Lookup Texture.
  129806. */
  129807. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  129808. /**
  129809. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  129810. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  129811. * 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;
  129812. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  129813. */
  129814. get cameraColorCurves(): Nullable<ColorCurves>;
  129815. /**
  129816. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  129817. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  129818. * 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;
  129819. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  129820. */
  129821. set cameraColorCurves(value: Nullable<ColorCurves>);
  129822. /**
  129823. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  129824. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  129825. */
  129826. switchToBGR: boolean;
  129827. private _renderTargets;
  129828. private _reflectionControls;
  129829. private _white;
  129830. private _primaryShadowColor;
  129831. private _primaryHighlightColor;
  129832. /**
  129833. * Instantiates a Background Material in the given scene
  129834. * @param name The friendly name of the material
  129835. * @param scene The scene to add the material to
  129836. */
  129837. constructor(name: string, scene: Scene);
  129838. /**
  129839. * Gets a boolean indicating that current material needs to register RTT
  129840. */
  129841. get hasRenderTargetTextures(): boolean;
  129842. /**
  129843. * The entire material has been created in order to prevent overdraw.
  129844. * @returns false
  129845. */
  129846. needAlphaTesting(): boolean;
  129847. /**
  129848. * The entire material has been created in order to prevent overdraw.
  129849. * @returns true if blending is enable
  129850. */
  129851. needAlphaBlending(): boolean;
  129852. /**
  129853. * Checks wether the material is ready to be rendered for a given mesh.
  129854. * @param mesh The mesh to render
  129855. * @param subMesh The submesh to check against
  129856. * @param useInstances Specify wether or not the material is used with instances
  129857. * @returns true if all the dependencies are ready (Textures, Effects...)
  129858. */
  129859. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  129860. /**
  129861. * Compute the primary color according to the chosen perceptual color.
  129862. */
  129863. private _computePrimaryColorFromPerceptualColor;
  129864. /**
  129865. * Compute the highlights and shadow colors according to their chosen levels.
  129866. */
  129867. private _computePrimaryColors;
  129868. /**
  129869. * Build the uniform buffer used in the material.
  129870. */
  129871. buildUniformLayout(): void;
  129872. /**
  129873. * Unbind the material.
  129874. */
  129875. unbind(): void;
  129876. /**
  129877. * Bind only the world matrix to the material.
  129878. * @param world The world matrix to bind.
  129879. */
  129880. bindOnlyWorldMatrix(world: Matrix): void;
  129881. /**
  129882. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  129883. * @param world The world matrix to bind.
  129884. * @param subMesh The submesh to bind for.
  129885. */
  129886. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  129887. /**
  129888. * Checks to see if a texture is used in the material.
  129889. * @param texture - Base texture to use.
  129890. * @returns - Boolean specifying if a texture is used in the material.
  129891. */
  129892. hasTexture(texture: BaseTexture): boolean;
  129893. /**
  129894. * Dispose the material.
  129895. * @param forceDisposeEffect Force disposal of the associated effect.
  129896. * @param forceDisposeTextures Force disposal of the associated textures.
  129897. */
  129898. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  129899. /**
  129900. * Clones the material.
  129901. * @param name The cloned name.
  129902. * @returns The cloned material.
  129903. */
  129904. clone(name: string): BackgroundMaterial;
  129905. /**
  129906. * Serializes the current material to its JSON representation.
  129907. * @returns The JSON representation.
  129908. */
  129909. serialize(): any;
  129910. /**
  129911. * Gets the class name of the material
  129912. * @returns "BackgroundMaterial"
  129913. */
  129914. getClassName(): string;
  129915. /**
  129916. * Parse a JSON input to create back a background material.
  129917. * @param source The JSON data to parse
  129918. * @param scene The scene to create the parsed material in
  129919. * @param rootUrl The root url of the assets the material depends upon
  129920. * @returns the instantiated BackgroundMaterial.
  129921. */
  129922. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  129923. }
  129924. }
  129925. declare module BABYLON {
  129926. /**
  129927. * Represents the different options available during the creation of
  129928. * a Environment helper.
  129929. *
  129930. * This can control the default ground, skybox and image processing setup of your scene.
  129931. */
  129932. export interface IEnvironmentHelperOptions {
  129933. /**
  129934. * Specifies whether or not to create a ground.
  129935. * True by default.
  129936. */
  129937. createGround: boolean;
  129938. /**
  129939. * Specifies the ground size.
  129940. * 15 by default.
  129941. */
  129942. groundSize: number;
  129943. /**
  129944. * The texture used on the ground for the main color.
  129945. * Comes from the BabylonJS CDN by default.
  129946. *
  129947. * Remarks: Can be either a texture or a url.
  129948. */
  129949. groundTexture: string | BaseTexture;
  129950. /**
  129951. * The color mixed in the ground texture by default.
  129952. * BabylonJS clearColor by default.
  129953. */
  129954. groundColor: Color3;
  129955. /**
  129956. * Specifies the ground opacity.
  129957. * 1 by default.
  129958. */
  129959. groundOpacity: number;
  129960. /**
  129961. * Enables the ground to receive shadows.
  129962. * True by default.
  129963. */
  129964. enableGroundShadow: boolean;
  129965. /**
  129966. * Helps preventing the shadow to be fully black on the ground.
  129967. * 0.5 by default.
  129968. */
  129969. groundShadowLevel: number;
  129970. /**
  129971. * Creates a mirror texture attach to the ground.
  129972. * false by default.
  129973. */
  129974. enableGroundMirror: boolean;
  129975. /**
  129976. * Specifies the ground mirror size ratio.
  129977. * 0.3 by default as the default kernel is 64.
  129978. */
  129979. groundMirrorSizeRatio: number;
  129980. /**
  129981. * Specifies the ground mirror blur kernel size.
  129982. * 64 by default.
  129983. */
  129984. groundMirrorBlurKernel: number;
  129985. /**
  129986. * Specifies the ground mirror visibility amount.
  129987. * 1 by default
  129988. */
  129989. groundMirrorAmount: number;
  129990. /**
  129991. * Specifies the ground mirror reflectance weight.
  129992. * This uses the standard weight of the background material to setup the fresnel effect
  129993. * of the mirror.
  129994. * 1 by default.
  129995. */
  129996. groundMirrorFresnelWeight: number;
  129997. /**
  129998. * Specifies the ground mirror Falloff distance.
  129999. * This can helps reducing the size of the reflection.
  130000. * 0 by Default.
  130001. */
  130002. groundMirrorFallOffDistance: number;
  130003. /**
  130004. * Specifies the ground mirror texture type.
  130005. * Unsigned Int by Default.
  130006. */
  130007. groundMirrorTextureType: number;
  130008. /**
  130009. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  130010. * the shown objects.
  130011. */
  130012. groundYBias: number;
  130013. /**
  130014. * Specifies whether or not to create a skybox.
  130015. * True by default.
  130016. */
  130017. createSkybox: boolean;
  130018. /**
  130019. * Specifies the skybox size.
  130020. * 20 by default.
  130021. */
  130022. skyboxSize: number;
  130023. /**
  130024. * The texture used on the skybox for the main color.
  130025. * Comes from the BabylonJS CDN by default.
  130026. *
  130027. * Remarks: Can be either a texture or a url.
  130028. */
  130029. skyboxTexture: string | BaseTexture;
  130030. /**
  130031. * The color mixed in the skybox texture by default.
  130032. * BabylonJS clearColor by default.
  130033. */
  130034. skyboxColor: Color3;
  130035. /**
  130036. * The background rotation around the Y axis of the scene.
  130037. * This helps aligning the key lights of your scene with the background.
  130038. * 0 by default.
  130039. */
  130040. backgroundYRotation: number;
  130041. /**
  130042. * Compute automatically the size of the elements to best fit with the scene.
  130043. */
  130044. sizeAuto: boolean;
  130045. /**
  130046. * Default position of the rootMesh if autoSize is not true.
  130047. */
  130048. rootPosition: Vector3;
  130049. /**
  130050. * Sets up the image processing in the scene.
  130051. * true by default.
  130052. */
  130053. setupImageProcessing: boolean;
  130054. /**
  130055. * The texture used as your environment texture in the scene.
  130056. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  130057. *
  130058. * Remarks: Can be either a texture or a url.
  130059. */
  130060. environmentTexture: string | BaseTexture;
  130061. /**
  130062. * The value of the exposure to apply to the scene.
  130063. * 0.6 by default if setupImageProcessing is true.
  130064. */
  130065. cameraExposure: number;
  130066. /**
  130067. * The value of the contrast to apply to the scene.
  130068. * 1.6 by default if setupImageProcessing is true.
  130069. */
  130070. cameraContrast: number;
  130071. /**
  130072. * Specifies whether or not tonemapping should be enabled in the scene.
  130073. * true by default if setupImageProcessing is true.
  130074. */
  130075. toneMappingEnabled: boolean;
  130076. }
  130077. /**
  130078. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  130079. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  130080. * It also helps with the default setup of your imageProcessing configuration.
  130081. */
  130082. export class EnvironmentHelper {
  130083. /**
  130084. * Default ground texture URL.
  130085. */
  130086. private static _groundTextureCDNUrl;
  130087. /**
  130088. * Default skybox texture URL.
  130089. */
  130090. private static _skyboxTextureCDNUrl;
  130091. /**
  130092. * Default environment texture URL.
  130093. */
  130094. private static _environmentTextureCDNUrl;
  130095. /**
  130096. * Creates the default options for the helper.
  130097. */
  130098. private static _getDefaultOptions;
  130099. private _rootMesh;
  130100. /**
  130101. * Gets the root mesh created by the helper.
  130102. */
  130103. get rootMesh(): Mesh;
  130104. private _skybox;
  130105. /**
  130106. * Gets the skybox created by the helper.
  130107. */
  130108. get skybox(): Nullable<Mesh>;
  130109. private _skyboxTexture;
  130110. /**
  130111. * Gets the skybox texture created by the helper.
  130112. */
  130113. get skyboxTexture(): Nullable<BaseTexture>;
  130114. private _skyboxMaterial;
  130115. /**
  130116. * Gets the skybox material created by the helper.
  130117. */
  130118. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  130119. private _ground;
  130120. /**
  130121. * Gets the ground mesh created by the helper.
  130122. */
  130123. get ground(): Nullable<Mesh>;
  130124. private _groundTexture;
  130125. /**
  130126. * Gets the ground texture created by the helper.
  130127. */
  130128. get groundTexture(): Nullable<BaseTexture>;
  130129. private _groundMirror;
  130130. /**
  130131. * Gets the ground mirror created by the helper.
  130132. */
  130133. get groundMirror(): Nullable<MirrorTexture>;
  130134. /**
  130135. * Gets the ground mirror render list to helps pushing the meshes
  130136. * you wish in the ground reflection.
  130137. */
  130138. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  130139. private _groundMaterial;
  130140. /**
  130141. * Gets the ground material created by the helper.
  130142. */
  130143. get groundMaterial(): Nullable<BackgroundMaterial>;
  130144. /**
  130145. * Stores the creation options.
  130146. */
  130147. private readonly _scene;
  130148. private _options;
  130149. /**
  130150. * This observable will be notified with any error during the creation of the environment,
  130151. * mainly texture creation errors.
  130152. */
  130153. onErrorObservable: Observable<{
  130154. message?: string;
  130155. exception?: any;
  130156. }>;
  130157. /**
  130158. * constructor
  130159. * @param options Defines the options we want to customize the helper
  130160. * @param scene The scene to add the material to
  130161. */
  130162. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  130163. /**
  130164. * Updates the background according to the new options
  130165. * @param options
  130166. */
  130167. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  130168. /**
  130169. * Sets the primary color of all the available elements.
  130170. * @param color the main color to affect to the ground and the background
  130171. */
  130172. setMainColor(color: Color3): void;
  130173. /**
  130174. * Setup the image processing according to the specified options.
  130175. */
  130176. private _setupImageProcessing;
  130177. /**
  130178. * Setup the environment texture according to the specified options.
  130179. */
  130180. private _setupEnvironmentTexture;
  130181. /**
  130182. * Setup the background according to the specified options.
  130183. */
  130184. private _setupBackground;
  130185. /**
  130186. * Get the scene sizes according to the setup.
  130187. */
  130188. private _getSceneSize;
  130189. /**
  130190. * Setup the ground according to the specified options.
  130191. */
  130192. private _setupGround;
  130193. /**
  130194. * Setup the ground material according to the specified options.
  130195. */
  130196. private _setupGroundMaterial;
  130197. /**
  130198. * Setup the ground diffuse texture according to the specified options.
  130199. */
  130200. private _setupGroundDiffuseTexture;
  130201. /**
  130202. * Setup the ground mirror texture according to the specified options.
  130203. */
  130204. private _setupGroundMirrorTexture;
  130205. /**
  130206. * Setup the ground to receive the mirror texture.
  130207. */
  130208. private _setupMirrorInGroundMaterial;
  130209. /**
  130210. * Setup the skybox according to the specified options.
  130211. */
  130212. private _setupSkybox;
  130213. /**
  130214. * Setup the skybox material according to the specified options.
  130215. */
  130216. private _setupSkyboxMaterial;
  130217. /**
  130218. * Setup the skybox reflection texture according to the specified options.
  130219. */
  130220. private _setupSkyboxReflectionTexture;
  130221. private _errorHandler;
  130222. /**
  130223. * Dispose all the elements created by the Helper.
  130224. */
  130225. dispose(): void;
  130226. }
  130227. }
  130228. declare module BABYLON {
  130229. /**
  130230. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  130231. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  130232. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  130233. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  130234. */
  130235. export class PhotoDome extends TransformNode {
  130236. /**
  130237. * Define the image as a Monoscopic panoramic 360 image.
  130238. */
  130239. static readonly MODE_MONOSCOPIC: number;
  130240. /**
  130241. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  130242. */
  130243. static readonly MODE_TOPBOTTOM: number;
  130244. /**
  130245. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  130246. */
  130247. static readonly MODE_SIDEBYSIDE: number;
  130248. private _useDirectMapping;
  130249. /**
  130250. * The texture being displayed on the sphere
  130251. */
  130252. protected _photoTexture: Texture;
  130253. /**
  130254. * Gets or sets the texture being displayed on the sphere
  130255. */
  130256. get photoTexture(): Texture;
  130257. set photoTexture(value: Texture);
  130258. /**
  130259. * Observable raised when an error occured while loading the 360 image
  130260. */
  130261. onLoadErrorObservable: Observable<string>;
  130262. /**
  130263. * The skybox material
  130264. */
  130265. protected _material: BackgroundMaterial;
  130266. /**
  130267. * The surface used for the skybox
  130268. */
  130269. protected _mesh: Mesh;
  130270. /**
  130271. * Gets the mesh used for the skybox.
  130272. */
  130273. get mesh(): Mesh;
  130274. /**
  130275. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  130276. * Also see the options.resolution property.
  130277. */
  130278. get fovMultiplier(): number;
  130279. set fovMultiplier(value: number);
  130280. private _imageMode;
  130281. /**
  130282. * Gets or set the current video mode for the video. It can be:
  130283. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  130284. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  130285. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  130286. */
  130287. get imageMode(): number;
  130288. set imageMode(value: number);
  130289. /**
  130290. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  130291. * @param name Element's name, child elements will append suffixes for their own names.
  130292. * @param urlsOfPhoto defines the url of the photo to display
  130293. * @param options defines an object containing optional or exposed sub element properties
  130294. * @param onError defines a callback called when an error occured while loading the texture
  130295. */
  130296. constructor(name: string, urlOfPhoto: string, options: {
  130297. resolution?: number;
  130298. size?: number;
  130299. useDirectMapping?: boolean;
  130300. faceForward?: boolean;
  130301. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  130302. private _onBeforeCameraRenderObserver;
  130303. private _changeImageMode;
  130304. /**
  130305. * Releases resources associated with this node.
  130306. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  130307. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  130308. */
  130309. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  130310. }
  130311. }
  130312. declare module BABYLON {
  130313. /**
  130314. * Class used to host RGBD texture specific utilities
  130315. */
  130316. export class RGBDTextureTools {
  130317. /**
  130318. * Expand the RGBD Texture from RGBD to Half Float if possible.
  130319. * @param texture the texture to expand.
  130320. */
  130321. static ExpandRGBDTexture(texture: Texture): void;
  130322. }
  130323. }
  130324. declare module BABYLON {
  130325. /**
  130326. * Class used to host texture specific utilities
  130327. */
  130328. export class BRDFTextureTools {
  130329. /**
  130330. * Prevents texture cache collision
  130331. */
  130332. private static _instanceNumber;
  130333. /**
  130334. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  130335. * @param scene defines the hosting scene
  130336. * @returns the environment BRDF texture
  130337. */
  130338. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  130339. private static _environmentBRDFBase64Texture;
  130340. }
  130341. }
  130342. declare module BABYLON {
  130343. /**
  130344. * @hidden
  130345. */
  130346. export interface IMaterialClearCoatDefines {
  130347. CLEARCOAT: boolean;
  130348. CLEARCOAT_DEFAULTIOR: boolean;
  130349. CLEARCOAT_TEXTURE: boolean;
  130350. CLEARCOAT_TEXTUREDIRECTUV: number;
  130351. CLEARCOAT_BUMP: boolean;
  130352. CLEARCOAT_BUMPDIRECTUV: number;
  130353. CLEARCOAT_TINT: boolean;
  130354. CLEARCOAT_TINT_TEXTURE: boolean;
  130355. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  130356. /** @hidden */
  130357. _areTexturesDirty: boolean;
  130358. }
  130359. /**
  130360. * Define the code related to the clear coat parameters of the pbr material.
  130361. */
  130362. export class PBRClearCoatConfiguration {
  130363. /**
  130364. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  130365. * The default fits with a polyurethane material.
  130366. */
  130367. private static readonly _DefaultIndexOfRefraction;
  130368. private _isEnabled;
  130369. /**
  130370. * Defines if the clear coat is enabled in the material.
  130371. */
  130372. isEnabled: boolean;
  130373. /**
  130374. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  130375. */
  130376. intensity: number;
  130377. /**
  130378. * Defines the clear coat layer roughness.
  130379. */
  130380. roughness: number;
  130381. private _indexOfRefraction;
  130382. /**
  130383. * Defines the index of refraction of the clear coat.
  130384. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  130385. * The default fits with a polyurethane material.
  130386. * Changing the default value is more performance intensive.
  130387. */
  130388. indexOfRefraction: number;
  130389. private _texture;
  130390. /**
  130391. * Stores the clear coat values in a texture.
  130392. */
  130393. texture: Nullable<BaseTexture>;
  130394. private _bumpTexture;
  130395. /**
  130396. * Define the clear coat specific bump texture.
  130397. */
  130398. bumpTexture: Nullable<BaseTexture>;
  130399. private _isTintEnabled;
  130400. /**
  130401. * Defines if the clear coat tint is enabled in the material.
  130402. */
  130403. isTintEnabled: boolean;
  130404. /**
  130405. * Defines the clear coat tint of the material.
  130406. * This is only use if tint is enabled
  130407. */
  130408. tintColor: Color3;
  130409. /**
  130410. * Defines the distance at which the tint color should be found in the
  130411. * clear coat media.
  130412. * This is only use if tint is enabled
  130413. */
  130414. tintColorAtDistance: number;
  130415. /**
  130416. * Defines the clear coat layer thickness.
  130417. * This is only use if tint is enabled
  130418. */
  130419. tintThickness: number;
  130420. private _tintTexture;
  130421. /**
  130422. * Stores the clear tint values in a texture.
  130423. * rgb is tint
  130424. * a is a thickness factor
  130425. */
  130426. tintTexture: Nullable<BaseTexture>;
  130427. /** @hidden */
  130428. private _internalMarkAllSubMeshesAsTexturesDirty;
  130429. /** @hidden */
  130430. _markAllSubMeshesAsTexturesDirty(): void;
  130431. /**
  130432. * Instantiate a new istance of clear coat configuration.
  130433. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  130434. */
  130435. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  130436. /**
  130437. * Gets wehter the submesh is ready to be used or not.
  130438. * @param defines the list of "defines" to update.
  130439. * @param scene defines the scene the material belongs to.
  130440. * @param engine defines the engine the material belongs to.
  130441. * @param disableBumpMap defines wether the material disables bump or not.
  130442. * @returns - boolean indicating that the submesh is ready or not.
  130443. */
  130444. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  130445. /**
  130446. * Checks to see if a texture is used in the material.
  130447. * @param defines the list of "defines" to update.
  130448. * @param scene defines the scene to the material belongs to.
  130449. */
  130450. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  130451. /**
  130452. * Binds the material data.
  130453. * @param uniformBuffer defines the Uniform buffer to fill in.
  130454. * @param scene defines the scene the material belongs to.
  130455. * @param engine defines the engine the material belongs to.
  130456. * @param disableBumpMap defines wether the material disables bump or not.
  130457. * @param isFrozen defines wether the material is frozen or not.
  130458. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  130459. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  130460. */
  130461. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  130462. /**
  130463. * Checks to see if a texture is used in the material.
  130464. * @param texture - Base texture to use.
  130465. * @returns - Boolean specifying if a texture is used in the material.
  130466. */
  130467. hasTexture(texture: BaseTexture): boolean;
  130468. /**
  130469. * Returns an array of the actively used textures.
  130470. * @param activeTextures Array of BaseTextures
  130471. */
  130472. getActiveTextures(activeTextures: BaseTexture[]): void;
  130473. /**
  130474. * Returns the animatable textures.
  130475. * @param animatables Array of animatable textures.
  130476. */
  130477. getAnimatables(animatables: IAnimatable[]): void;
  130478. /**
  130479. * Disposes the resources of the material.
  130480. * @param forceDisposeTextures - Forces the disposal of all textures.
  130481. */
  130482. dispose(forceDisposeTextures?: boolean): void;
  130483. /**
  130484. * Get the current class name of the texture useful for serialization or dynamic coding.
  130485. * @returns "PBRClearCoatConfiguration"
  130486. */
  130487. getClassName(): string;
  130488. /**
  130489. * Add fallbacks to the effect fallbacks list.
  130490. * @param defines defines the Base texture to use.
  130491. * @param fallbacks defines the current fallback list.
  130492. * @param currentRank defines the current fallback rank.
  130493. * @returns the new fallback rank.
  130494. */
  130495. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  130496. /**
  130497. * Add the required uniforms to the current list.
  130498. * @param uniforms defines the current uniform list.
  130499. */
  130500. static AddUniforms(uniforms: string[]): void;
  130501. /**
  130502. * Add the required samplers to the current list.
  130503. * @param samplers defines the current sampler list.
  130504. */
  130505. static AddSamplers(samplers: string[]): void;
  130506. /**
  130507. * Add the required uniforms to the current buffer.
  130508. * @param uniformBuffer defines the current uniform buffer.
  130509. */
  130510. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  130511. /**
  130512. * Makes a duplicate of the current configuration into another one.
  130513. * @param clearCoatConfiguration define the config where to copy the info
  130514. */
  130515. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  130516. /**
  130517. * Serializes this clear coat configuration.
  130518. * @returns - An object with the serialized config.
  130519. */
  130520. serialize(): any;
  130521. /**
  130522. * Parses a anisotropy Configuration from a serialized object.
  130523. * @param source - Serialized object.
  130524. * @param scene Defines the scene we are parsing for
  130525. * @param rootUrl Defines the rootUrl to load from
  130526. */
  130527. parse(source: any, scene: Scene, rootUrl: string): void;
  130528. }
  130529. }
  130530. declare module BABYLON {
  130531. /**
  130532. * @hidden
  130533. */
  130534. export interface IMaterialAnisotropicDefines {
  130535. ANISOTROPIC: boolean;
  130536. ANISOTROPIC_TEXTURE: boolean;
  130537. ANISOTROPIC_TEXTUREDIRECTUV: number;
  130538. MAINUV1: boolean;
  130539. _areTexturesDirty: boolean;
  130540. _needUVs: boolean;
  130541. }
  130542. /**
  130543. * Define the code related to the anisotropic parameters of the pbr material.
  130544. */
  130545. export class PBRAnisotropicConfiguration {
  130546. private _isEnabled;
  130547. /**
  130548. * Defines if the anisotropy is enabled in the material.
  130549. */
  130550. isEnabled: boolean;
  130551. /**
  130552. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  130553. */
  130554. intensity: number;
  130555. /**
  130556. * Defines if the effect is along the tangents, bitangents or in between.
  130557. * By default, the effect is "strectching" the highlights along the tangents.
  130558. */
  130559. direction: Vector2;
  130560. private _texture;
  130561. /**
  130562. * Stores the anisotropy values in a texture.
  130563. * rg is direction (like normal from -1 to 1)
  130564. * b is a intensity
  130565. */
  130566. texture: Nullable<BaseTexture>;
  130567. /** @hidden */
  130568. private _internalMarkAllSubMeshesAsTexturesDirty;
  130569. /** @hidden */
  130570. _markAllSubMeshesAsTexturesDirty(): void;
  130571. /**
  130572. * Instantiate a new istance of anisotropy configuration.
  130573. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  130574. */
  130575. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  130576. /**
  130577. * Specifies that the submesh is ready to be used.
  130578. * @param defines the list of "defines" to update.
  130579. * @param scene defines the scene the material belongs to.
  130580. * @returns - boolean indicating that the submesh is ready or not.
  130581. */
  130582. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  130583. /**
  130584. * Checks to see if a texture is used in the material.
  130585. * @param defines the list of "defines" to update.
  130586. * @param mesh the mesh we are preparing the defines for.
  130587. * @param scene defines the scene the material belongs to.
  130588. */
  130589. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  130590. /**
  130591. * Binds the material data.
  130592. * @param uniformBuffer defines the Uniform buffer to fill in.
  130593. * @param scene defines the scene the material belongs to.
  130594. * @param isFrozen defines wether the material is frozen or not.
  130595. */
  130596. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  130597. /**
  130598. * Checks to see if a texture is used in the material.
  130599. * @param texture - Base texture to use.
  130600. * @returns - Boolean specifying if a texture is used in the material.
  130601. */
  130602. hasTexture(texture: BaseTexture): boolean;
  130603. /**
  130604. * Returns an array of the actively used textures.
  130605. * @param activeTextures Array of BaseTextures
  130606. */
  130607. getActiveTextures(activeTextures: BaseTexture[]): void;
  130608. /**
  130609. * Returns the animatable textures.
  130610. * @param animatables Array of animatable textures.
  130611. */
  130612. getAnimatables(animatables: IAnimatable[]): void;
  130613. /**
  130614. * Disposes the resources of the material.
  130615. * @param forceDisposeTextures - Forces the disposal of all textures.
  130616. */
  130617. dispose(forceDisposeTextures?: boolean): void;
  130618. /**
  130619. * Get the current class name of the texture useful for serialization or dynamic coding.
  130620. * @returns "PBRAnisotropicConfiguration"
  130621. */
  130622. getClassName(): string;
  130623. /**
  130624. * Add fallbacks to the effect fallbacks list.
  130625. * @param defines defines the Base texture to use.
  130626. * @param fallbacks defines the current fallback list.
  130627. * @param currentRank defines the current fallback rank.
  130628. * @returns the new fallback rank.
  130629. */
  130630. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  130631. /**
  130632. * Add the required uniforms to the current list.
  130633. * @param uniforms defines the current uniform list.
  130634. */
  130635. static AddUniforms(uniforms: string[]): void;
  130636. /**
  130637. * Add the required uniforms to the current buffer.
  130638. * @param uniformBuffer defines the current uniform buffer.
  130639. */
  130640. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  130641. /**
  130642. * Add the required samplers to the current list.
  130643. * @param samplers defines the current sampler list.
  130644. */
  130645. static AddSamplers(samplers: string[]): void;
  130646. /**
  130647. * Makes a duplicate of the current configuration into another one.
  130648. * @param anisotropicConfiguration define the config where to copy the info
  130649. */
  130650. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  130651. /**
  130652. * Serializes this anisotropy configuration.
  130653. * @returns - An object with the serialized config.
  130654. */
  130655. serialize(): any;
  130656. /**
  130657. * Parses a anisotropy Configuration from a serialized object.
  130658. * @param source - Serialized object.
  130659. * @param scene Defines the scene we are parsing for
  130660. * @param rootUrl Defines the rootUrl to load from
  130661. */
  130662. parse(source: any, scene: Scene, rootUrl: string): void;
  130663. }
  130664. }
  130665. declare module BABYLON {
  130666. /**
  130667. * @hidden
  130668. */
  130669. export interface IMaterialBRDFDefines {
  130670. BRDF_V_HEIGHT_CORRELATED: boolean;
  130671. MS_BRDF_ENERGY_CONSERVATION: boolean;
  130672. SPHERICAL_HARMONICS: boolean;
  130673. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  130674. /** @hidden */
  130675. _areMiscDirty: boolean;
  130676. }
  130677. /**
  130678. * Define the code related to the BRDF parameters of the pbr material.
  130679. */
  130680. export class PBRBRDFConfiguration {
  130681. /**
  130682. * Default value used for the energy conservation.
  130683. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  130684. */
  130685. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  130686. /**
  130687. * Default value used for the Smith Visibility Height Correlated mode.
  130688. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  130689. */
  130690. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  130691. /**
  130692. * Default value used for the IBL diffuse part.
  130693. * This can help switching back to the polynomials mode globally which is a tiny bit
  130694. * less GPU intensive at the drawback of a lower quality.
  130695. */
  130696. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  130697. /**
  130698. * Default value used for activating energy conservation for the specular workflow.
  130699. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  130700. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  130701. */
  130702. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  130703. private _useEnergyConservation;
  130704. /**
  130705. * Defines if the material uses energy conservation.
  130706. */
  130707. useEnergyConservation: boolean;
  130708. private _useSmithVisibilityHeightCorrelated;
  130709. /**
  130710. * LEGACY Mode set to false
  130711. * Defines if the material uses height smith correlated visibility term.
  130712. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  130713. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  130714. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  130715. * Not relying on height correlated will also disable energy conservation.
  130716. */
  130717. useSmithVisibilityHeightCorrelated: boolean;
  130718. private _useSphericalHarmonics;
  130719. /**
  130720. * LEGACY Mode set to false
  130721. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  130722. * diffuse part of the IBL.
  130723. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  130724. * to the ground truth.
  130725. */
  130726. useSphericalHarmonics: boolean;
  130727. private _useSpecularGlossinessInputEnergyConservation;
  130728. /**
  130729. * Defines if the material uses energy conservation, when the specular workflow is active.
  130730. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  130731. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  130732. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  130733. */
  130734. useSpecularGlossinessInputEnergyConservation: boolean;
  130735. /** @hidden */
  130736. private _internalMarkAllSubMeshesAsMiscDirty;
  130737. /** @hidden */
  130738. _markAllSubMeshesAsMiscDirty(): void;
  130739. /**
  130740. * Instantiate a new istance of clear coat configuration.
  130741. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  130742. */
  130743. constructor(markAllSubMeshesAsMiscDirty: () => void);
  130744. /**
  130745. * Checks to see if a texture is used in the material.
  130746. * @param defines the list of "defines" to update.
  130747. */
  130748. prepareDefines(defines: IMaterialBRDFDefines): void;
  130749. /**
  130750. * Get the current class name of the texture useful for serialization or dynamic coding.
  130751. * @returns "PBRClearCoatConfiguration"
  130752. */
  130753. getClassName(): string;
  130754. /**
  130755. * Makes a duplicate of the current configuration into another one.
  130756. * @param brdfConfiguration define the config where to copy the info
  130757. */
  130758. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  130759. /**
  130760. * Serializes this BRDF configuration.
  130761. * @returns - An object with the serialized config.
  130762. */
  130763. serialize(): any;
  130764. /**
  130765. * Parses a anisotropy Configuration from a serialized object.
  130766. * @param source - Serialized object.
  130767. * @param scene Defines the scene we are parsing for
  130768. * @param rootUrl Defines the rootUrl to load from
  130769. */
  130770. parse(source: any, scene: Scene, rootUrl: string): void;
  130771. }
  130772. }
  130773. declare module BABYLON {
  130774. /**
  130775. * @hidden
  130776. */
  130777. export interface IMaterialSheenDefines {
  130778. SHEEN: boolean;
  130779. SHEEN_TEXTURE: boolean;
  130780. SHEEN_TEXTUREDIRECTUV: number;
  130781. SHEEN_LINKWITHALBEDO: boolean;
  130782. SHEEN_ROUGHNESS: boolean;
  130783. SHEEN_ALBEDOSCALING: boolean;
  130784. /** @hidden */
  130785. _areTexturesDirty: boolean;
  130786. }
  130787. /**
  130788. * Define the code related to the Sheen parameters of the pbr material.
  130789. */
  130790. export class PBRSheenConfiguration {
  130791. private _isEnabled;
  130792. /**
  130793. * Defines if the material uses sheen.
  130794. */
  130795. isEnabled: boolean;
  130796. private _linkSheenWithAlbedo;
  130797. /**
  130798. * Defines if the sheen is linked to the sheen color.
  130799. */
  130800. linkSheenWithAlbedo: boolean;
  130801. /**
  130802. * Defines the sheen intensity.
  130803. */
  130804. intensity: number;
  130805. /**
  130806. * Defines the sheen color.
  130807. */
  130808. color: Color3;
  130809. private _texture;
  130810. /**
  130811. * Stores the sheen tint values in a texture.
  130812. * rgb is tint
  130813. * a is a intensity
  130814. */
  130815. texture: Nullable<BaseTexture>;
  130816. private _roughness;
  130817. /**
  130818. * Defines the sheen roughness.
  130819. * It is not taken into account if linkSheenWithAlbedo is true.
  130820. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  130821. */
  130822. roughness: Nullable<number>;
  130823. private _albedoScaling;
  130824. /**
  130825. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  130826. * It allows the strength of the sheen effect to not depend on the base color of the material,
  130827. * making it easier to setup and tweak the effect
  130828. */
  130829. albedoScaling: boolean;
  130830. /** @hidden */
  130831. private _internalMarkAllSubMeshesAsTexturesDirty;
  130832. /** @hidden */
  130833. _markAllSubMeshesAsTexturesDirty(): void;
  130834. /**
  130835. * Instantiate a new istance of clear coat configuration.
  130836. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  130837. */
  130838. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  130839. /**
  130840. * Specifies that the submesh is ready to be used.
  130841. * @param defines the list of "defines" to update.
  130842. * @param scene defines the scene the material belongs to.
  130843. * @returns - boolean indicating that the submesh is ready or not.
  130844. */
  130845. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  130846. /**
  130847. * Checks to see if a texture is used in the material.
  130848. * @param defines the list of "defines" to update.
  130849. * @param scene defines the scene the material belongs to.
  130850. */
  130851. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  130852. /**
  130853. * Binds the material data.
  130854. * @param uniformBuffer defines the Uniform buffer to fill in.
  130855. * @param scene defines the scene the material belongs to.
  130856. * @param isFrozen defines wether the material is frozen or not.
  130857. */
  130858. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  130859. /**
  130860. * Checks to see if a texture is used in the material.
  130861. * @param texture - Base texture to use.
  130862. * @returns - Boolean specifying if a texture is used in the material.
  130863. */
  130864. hasTexture(texture: BaseTexture): boolean;
  130865. /**
  130866. * Returns an array of the actively used textures.
  130867. * @param activeTextures Array of BaseTextures
  130868. */
  130869. getActiveTextures(activeTextures: BaseTexture[]): void;
  130870. /**
  130871. * Returns the animatable textures.
  130872. * @param animatables Array of animatable textures.
  130873. */
  130874. getAnimatables(animatables: IAnimatable[]): void;
  130875. /**
  130876. * Disposes the resources of the material.
  130877. * @param forceDisposeTextures - Forces the disposal of all textures.
  130878. */
  130879. dispose(forceDisposeTextures?: boolean): void;
  130880. /**
  130881. * Get the current class name of the texture useful for serialization or dynamic coding.
  130882. * @returns "PBRSheenConfiguration"
  130883. */
  130884. getClassName(): string;
  130885. /**
  130886. * Add fallbacks to the effect fallbacks list.
  130887. * @param defines defines the Base texture to use.
  130888. * @param fallbacks defines the current fallback list.
  130889. * @param currentRank defines the current fallback rank.
  130890. * @returns the new fallback rank.
  130891. */
  130892. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  130893. /**
  130894. * Add the required uniforms to the current list.
  130895. * @param uniforms defines the current uniform list.
  130896. */
  130897. static AddUniforms(uniforms: string[]): void;
  130898. /**
  130899. * Add the required uniforms to the current buffer.
  130900. * @param uniformBuffer defines the current uniform buffer.
  130901. */
  130902. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  130903. /**
  130904. * Add the required samplers to the current list.
  130905. * @param samplers defines the current sampler list.
  130906. */
  130907. static AddSamplers(samplers: string[]): void;
  130908. /**
  130909. * Makes a duplicate of the current configuration into another one.
  130910. * @param sheenConfiguration define the config where to copy the info
  130911. */
  130912. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  130913. /**
  130914. * Serializes this BRDF configuration.
  130915. * @returns - An object with the serialized config.
  130916. */
  130917. serialize(): any;
  130918. /**
  130919. * Parses a anisotropy Configuration from a serialized object.
  130920. * @param source - Serialized object.
  130921. * @param scene Defines the scene we are parsing for
  130922. * @param rootUrl Defines the rootUrl to load from
  130923. */
  130924. parse(source: any, scene: Scene, rootUrl: string): void;
  130925. }
  130926. }
  130927. declare module BABYLON {
  130928. /**
  130929. * @hidden
  130930. */
  130931. export interface IMaterialSubSurfaceDefines {
  130932. SUBSURFACE: boolean;
  130933. SS_REFRACTION: boolean;
  130934. SS_TRANSLUCENCY: boolean;
  130935. SS_SCATERRING: boolean;
  130936. SS_THICKNESSANDMASK_TEXTURE: boolean;
  130937. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  130938. SS_REFRACTIONMAP_3D: boolean;
  130939. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  130940. SS_LODINREFRACTIONALPHA: boolean;
  130941. SS_GAMMAREFRACTION: boolean;
  130942. SS_RGBDREFRACTION: boolean;
  130943. SS_LINEARSPECULARREFRACTION: boolean;
  130944. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  130945. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  130946. /** @hidden */
  130947. _areTexturesDirty: boolean;
  130948. }
  130949. /**
  130950. * Define the code related to the sub surface parameters of the pbr material.
  130951. */
  130952. export class PBRSubSurfaceConfiguration {
  130953. private _isRefractionEnabled;
  130954. /**
  130955. * Defines if the refraction is enabled in the material.
  130956. */
  130957. isRefractionEnabled: boolean;
  130958. private _isTranslucencyEnabled;
  130959. /**
  130960. * Defines if the translucency is enabled in the material.
  130961. */
  130962. isTranslucencyEnabled: boolean;
  130963. private _isScatteringEnabled;
  130964. /**
  130965. * Defines the refraction intensity of the material.
  130966. * The refraction when enabled replaces the Diffuse part of the material.
  130967. * The intensity helps transitionning between diffuse and refraction.
  130968. */
  130969. refractionIntensity: number;
  130970. /**
  130971. * Defines the translucency intensity of the material.
  130972. * When translucency has been enabled, this defines how much of the "translucency"
  130973. * is addded to the diffuse part of the material.
  130974. */
  130975. translucencyIntensity: number;
  130976. /**
  130977. * Defines the scattering intensity of the material.
  130978. * When scattering has been enabled, this defines how much of the "scattered light"
  130979. * is addded to the diffuse part of the material.
  130980. */
  130981. scatteringIntensity: number;
  130982. private _thicknessTexture;
  130983. /**
  130984. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  130985. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  130986. * 0 would mean minimumThickness
  130987. * 1 would mean maximumThickness
  130988. * The other channels might be use as a mask to vary the different effects intensity.
  130989. */
  130990. thicknessTexture: Nullable<BaseTexture>;
  130991. private _refractionTexture;
  130992. /**
  130993. * Defines the texture to use for refraction.
  130994. */
  130995. refractionTexture: Nullable<BaseTexture>;
  130996. private _indexOfRefraction;
  130997. /**
  130998. * Index of refraction of the material base layer.
  130999. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  131000. *
  131001. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  131002. *
  131003. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  131004. */
  131005. indexOfRefraction: number;
  131006. private _invertRefractionY;
  131007. /**
  131008. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  131009. */
  131010. invertRefractionY: boolean;
  131011. private _linkRefractionWithTransparency;
  131012. /**
  131013. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  131014. * Materials half opaque for instance using refraction could benefit from this control.
  131015. */
  131016. linkRefractionWithTransparency: boolean;
  131017. /**
  131018. * Defines the minimum thickness stored in the thickness map.
  131019. * If no thickness map is defined, this value will be used to simulate thickness.
  131020. */
  131021. minimumThickness: number;
  131022. /**
  131023. * Defines the maximum thickness stored in the thickness map.
  131024. */
  131025. maximumThickness: number;
  131026. /**
  131027. * Defines the volume tint of the material.
  131028. * This is used for both translucency and scattering.
  131029. */
  131030. tintColor: Color3;
  131031. /**
  131032. * Defines the distance at which the tint color should be found in the media.
  131033. * This is used for refraction only.
  131034. */
  131035. tintColorAtDistance: number;
  131036. /**
  131037. * Defines how far each channel transmit through the media.
  131038. * It is defined as a color to simplify it selection.
  131039. */
  131040. diffusionDistance: Color3;
  131041. private _useMaskFromThicknessTexture;
  131042. /**
  131043. * Stores the intensity of the different subsurface effects in the thickness texture.
  131044. * * the green channel is the translucency intensity.
  131045. * * the blue channel is the scattering intensity.
  131046. * * the alpha channel is the refraction intensity.
  131047. */
  131048. useMaskFromThicknessTexture: boolean;
  131049. /** @hidden */
  131050. private _internalMarkAllSubMeshesAsTexturesDirty;
  131051. /** @hidden */
  131052. _markAllSubMeshesAsTexturesDirty(): void;
  131053. /**
  131054. * Instantiate a new istance of sub surface configuration.
  131055. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  131056. */
  131057. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  131058. /**
  131059. * Gets wehter the submesh is ready to be used or not.
  131060. * @param defines the list of "defines" to update.
  131061. * @param scene defines the scene the material belongs to.
  131062. * @returns - boolean indicating that the submesh is ready or not.
  131063. */
  131064. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  131065. /**
  131066. * Checks to see if a texture is used in the material.
  131067. * @param defines the list of "defines" to update.
  131068. * @param scene defines the scene to the material belongs to.
  131069. */
  131070. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  131071. /**
  131072. * Binds the material data.
  131073. * @param uniformBuffer defines the Uniform buffer to fill in.
  131074. * @param scene defines the scene the material belongs to.
  131075. * @param engine defines the engine the material belongs to.
  131076. * @param isFrozen defines whether the material is frozen or not.
  131077. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  131078. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  131079. */
  131080. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  131081. /**
  131082. * Unbinds the material from the mesh.
  131083. * @param activeEffect defines the effect that should be unbound from.
  131084. * @returns true if unbound, otherwise false
  131085. */
  131086. unbind(activeEffect: Effect): boolean;
  131087. /**
  131088. * Returns the texture used for refraction or null if none is used.
  131089. * @param scene defines the scene the material belongs to.
  131090. * @returns - Refraction texture if present. If no refraction texture and refraction
  131091. * is linked with transparency, returns environment texture. Otherwise, returns null.
  131092. */
  131093. private _getRefractionTexture;
  131094. /**
  131095. * Returns true if alpha blending should be disabled.
  131096. */
  131097. get disableAlphaBlending(): boolean;
  131098. /**
  131099. * Fills the list of render target textures.
  131100. * @param renderTargets the list of render targets to update
  131101. */
  131102. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  131103. /**
  131104. * Checks to see if a texture is used in the material.
  131105. * @param texture - Base texture to use.
  131106. * @returns - Boolean specifying if a texture is used in the material.
  131107. */
  131108. hasTexture(texture: BaseTexture): boolean;
  131109. /**
  131110. * Gets a boolean indicating that current material needs to register RTT
  131111. * @returns true if this uses a render target otherwise false.
  131112. */
  131113. hasRenderTargetTextures(): boolean;
  131114. /**
  131115. * Returns an array of the actively used textures.
  131116. * @param activeTextures Array of BaseTextures
  131117. */
  131118. getActiveTextures(activeTextures: BaseTexture[]): void;
  131119. /**
  131120. * Returns the animatable textures.
  131121. * @param animatables Array of animatable textures.
  131122. */
  131123. getAnimatables(animatables: IAnimatable[]): void;
  131124. /**
  131125. * Disposes the resources of the material.
  131126. * @param forceDisposeTextures - Forces the disposal of all textures.
  131127. */
  131128. dispose(forceDisposeTextures?: boolean): void;
  131129. /**
  131130. * Get the current class name of the texture useful for serialization or dynamic coding.
  131131. * @returns "PBRSubSurfaceConfiguration"
  131132. */
  131133. getClassName(): string;
  131134. /**
  131135. * Add fallbacks to the effect fallbacks list.
  131136. * @param defines defines the Base texture to use.
  131137. * @param fallbacks defines the current fallback list.
  131138. * @param currentRank defines the current fallback rank.
  131139. * @returns the new fallback rank.
  131140. */
  131141. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  131142. /**
  131143. * Add the required uniforms to the current list.
  131144. * @param uniforms defines the current uniform list.
  131145. */
  131146. static AddUniforms(uniforms: string[]): void;
  131147. /**
  131148. * Add the required samplers to the current list.
  131149. * @param samplers defines the current sampler list.
  131150. */
  131151. static AddSamplers(samplers: string[]): void;
  131152. /**
  131153. * Add the required uniforms to the current buffer.
  131154. * @param uniformBuffer defines the current uniform buffer.
  131155. */
  131156. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  131157. /**
  131158. * Makes a duplicate of the current configuration into another one.
  131159. * @param configuration define the config where to copy the info
  131160. */
  131161. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  131162. /**
  131163. * Serializes this Sub Surface configuration.
  131164. * @returns - An object with the serialized config.
  131165. */
  131166. serialize(): any;
  131167. /**
  131168. * Parses a anisotropy Configuration from a serialized object.
  131169. * @param source - Serialized object.
  131170. * @param scene Defines the scene we are parsing for
  131171. * @param rootUrl Defines the rootUrl to load from
  131172. */
  131173. parse(source: any, scene: Scene, rootUrl: string): void;
  131174. }
  131175. }
  131176. declare module BABYLON {
  131177. /** @hidden */
  131178. export var pbrFragmentDeclaration: {
  131179. name: string;
  131180. shader: string;
  131181. };
  131182. }
  131183. declare module BABYLON {
  131184. /** @hidden */
  131185. export var pbrUboDeclaration: {
  131186. name: string;
  131187. shader: string;
  131188. };
  131189. }
  131190. declare module BABYLON {
  131191. /** @hidden */
  131192. export var pbrFragmentExtraDeclaration: {
  131193. name: string;
  131194. shader: string;
  131195. };
  131196. }
  131197. declare module BABYLON {
  131198. /** @hidden */
  131199. export var pbrFragmentSamplersDeclaration: {
  131200. name: string;
  131201. shader: string;
  131202. };
  131203. }
  131204. declare module BABYLON {
  131205. /** @hidden */
  131206. export var importanceSampling: {
  131207. name: string;
  131208. shader: string;
  131209. };
  131210. }
  131211. declare module BABYLON {
  131212. /** @hidden */
  131213. export var pbrHelperFunctions: {
  131214. name: string;
  131215. shader: string;
  131216. };
  131217. }
  131218. declare module BABYLON {
  131219. /** @hidden */
  131220. export var harmonicsFunctions: {
  131221. name: string;
  131222. shader: string;
  131223. };
  131224. }
  131225. declare module BABYLON {
  131226. /** @hidden */
  131227. export var pbrDirectLightingSetupFunctions: {
  131228. name: string;
  131229. shader: string;
  131230. };
  131231. }
  131232. declare module BABYLON {
  131233. /** @hidden */
  131234. export var pbrDirectLightingFalloffFunctions: {
  131235. name: string;
  131236. shader: string;
  131237. };
  131238. }
  131239. declare module BABYLON {
  131240. /** @hidden */
  131241. export var pbrBRDFFunctions: {
  131242. name: string;
  131243. shader: string;
  131244. };
  131245. }
  131246. declare module BABYLON {
  131247. /** @hidden */
  131248. export var hdrFilteringFunctions: {
  131249. name: string;
  131250. shader: string;
  131251. };
  131252. }
  131253. declare module BABYLON {
  131254. /** @hidden */
  131255. export var pbrDirectLightingFunctions: {
  131256. name: string;
  131257. shader: string;
  131258. };
  131259. }
  131260. declare module BABYLON {
  131261. /** @hidden */
  131262. export var pbrIBLFunctions: {
  131263. name: string;
  131264. shader: string;
  131265. };
  131266. }
  131267. declare module BABYLON {
  131268. /** @hidden */
  131269. export var pbrBlockAlbedoOpacity: {
  131270. name: string;
  131271. shader: string;
  131272. };
  131273. }
  131274. declare module BABYLON {
  131275. /** @hidden */
  131276. export var pbrBlockReflectivity: {
  131277. name: string;
  131278. shader: string;
  131279. };
  131280. }
  131281. declare module BABYLON {
  131282. /** @hidden */
  131283. export var pbrBlockAmbientOcclusion: {
  131284. name: string;
  131285. shader: string;
  131286. };
  131287. }
  131288. declare module BABYLON {
  131289. /** @hidden */
  131290. export var pbrBlockAlphaFresnel: {
  131291. name: string;
  131292. shader: string;
  131293. };
  131294. }
  131295. declare module BABYLON {
  131296. /** @hidden */
  131297. export var pbrBlockAnisotropic: {
  131298. name: string;
  131299. shader: string;
  131300. };
  131301. }
  131302. declare module BABYLON {
  131303. /** @hidden */
  131304. export var pbrBlockReflection: {
  131305. name: string;
  131306. shader: string;
  131307. };
  131308. }
  131309. declare module BABYLON {
  131310. /** @hidden */
  131311. export var pbrBlockSheen: {
  131312. name: string;
  131313. shader: string;
  131314. };
  131315. }
  131316. declare module BABYLON {
  131317. /** @hidden */
  131318. export var pbrBlockClearcoat: {
  131319. name: string;
  131320. shader: string;
  131321. };
  131322. }
  131323. declare module BABYLON {
  131324. /** @hidden */
  131325. export var pbrBlockSubSurface: {
  131326. name: string;
  131327. shader: string;
  131328. };
  131329. }
  131330. declare module BABYLON {
  131331. /** @hidden */
  131332. export var pbrBlockNormalGeometric: {
  131333. name: string;
  131334. shader: string;
  131335. };
  131336. }
  131337. declare module BABYLON {
  131338. /** @hidden */
  131339. export var pbrBlockNormalFinal: {
  131340. name: string;
  131341. shader: string;
  131342. };
  131343. }
  131344. declare module BABYLON {
  131345. /** @hidden */
  131346. export var pbrBlockGeometryInfo: {
  131347. name: string;
  131348. shader: string;
  131349. };
  131350. }
  131351. declare module BABYLON {
  131352. /** @hidden */
  131353. export var pbrBlockReflectance0: {
  131354. name: string;
  131355. shader: string;
  131356. };
  131357. }
  131358. declare module BABYLON {
  131359. /** @hidden */
  131360. export var pbrBlockReflectance: {
  131361. name: string;
  131362. shader: string;
  131363. };
  131364. }
  131365. declare module BABYLON {
  131366. /** @hidden */
  131367. export var pbrBlockDirectLighting: {
  131368. name: string;
  131369. shader: string;
  131370. };
  131371. }
  131372. declare module BABYLON {
  131373. /** @hidden */
  131374. export var pbrBlockFinalLitComponents: {
  131375. name: string;
  131376. shader: string;
  131377. };
  131378. }
  131379. declare module BABYLON {
  131380. /** @hidden */
  131381. export var pbrBlockFinalUnlitComponents: {
  131382. name: string;
  131383. shader: string;
  131384. };
  131385. }
  131386. declare module BABYLON {
  131387. /** @hidden */
  131388. export var pbrBlockFinalColorComposition: {
  131389. name: string;
  131390. shader: string;
  131391. };
  131392. }
  131393. declare module BABYLON {
  131394. /** @hidden */
  131395. export var pbrBlockImageProcessing: {
  131396. name: string;
  131397. shader: string;
  131398. };
  131399. }
  131400. declare module BABYLON {
  131401. /** @hidden */
  131402. export var pbrDebug: {
  131403. name: string;
  131404. shader: string;
  131405. };
  131406. }
  131407. declare module BABYLON {
  131408. /** @hidden */
  131409. export var pbrPixelShader: {
  131410. name: string;
  131411. shader: string;
  131412. };
  131413. }
  131414. declare module BABYLON {
  131415. /** @hidden */
  131416. export var pbrVertexDeclaration: {
  131417. name: string;
  131418. shader: string;
  131419. };
  131420. }
  131421. declare module BABYLON {
  131422. /** @hidden */
  131423. export var pbrVertexShader: {
  131424. name: string;
  131425. shader: string;
  131426. };
  131427. }
  131428. declare module BABYLON {
  131429. /**
  131430. * Manages the defines for the PBR Material.
  131431. * @hidden
  131432. */
  131433. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  131434. PBR: boolean;
  131435. NUM_SAMPLES: string;
  131436. REALTIME_FILTERING: boolean;
  131437. MAINUV1: boolean;
  131438. MAINUV2: boolean;
  131439. UV1: boolean;
  131440. UV2: boolean;
  131441. ALBEDO: boolean;
  131442. GAMMAALBEDO: boolean;
  131443. ALBEDODIRECTUV: number;
  131444. VERTEXCOLOR: boolean;
  131445. AMBIENT: boolean;
  131446. AMBIENTDIRECTUV: number;
  131447. AMBIENTINGRAYSCALE: boolean;
  131448. OPACITY: boolean;
  131449. VERTEXALPHA: boolean;
  131450. OPACITYDIRECTUV: number;
  131451. OPACITYRGB: boolean;
  131452. ALPHATEST: boolean;
  131453. DEPTHPREPASS: boolean;
  131454. ALPHABLEND: boolean;
  131455. ALPHAFROMALBEDO: boolean;
  131456. ALPHATESTVALUE: string;
  131457. SPECULAROVERALPHA: boolean;
  131458. RADIANCEOVERALPHA: boolean;
  131459. ALPHAFRESNEL: boolean;
  131460. LINEARALPHAFRESNEL: boolean;
  131461. PREMULTIPLYALPHA: boolean;
  131462. EMISSIVE: boolean;
  131463. EMISSIVEDIRECTUV: number;
  131464. REFLECTIVITY: boolean;
  131465. REFLECTIVITYDIRECTUV: number;
  131466. SPECULARTERM: boolean;
  131467. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  131468. MICROSURFACEAUTOMATIC: boolean;
  131469. LODBASEDMICROSFURACE: boolean;
  131470. MICROSURFACEMAP: boolean;
  131471. MICROSURFACEMAPDIRECTUV: number;
  131472. METALLICWORKFLOW: boolean;
  131473. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  131474. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  131475. METALLNESSSTOREINMETALMAPBLUE: boolean;
  131476. AOSTOREINMETALMAPRED: boolean;
  131477. METALLIC_REFLECTANCE: boolean;
  131478. METALLIC_REFLECTANCEDIRECTUV: number;
  131479. ENVIRONMENTBRDF: boolean;
  131480. ENVIRONMENTBRDF_RGBD: boolean;
  131481. NORMAL: boolean;
  131482. TANGENT: boolean;
  131483. BUMP: boolean;
  131484. BUMPDIRECTUV: number;
  131485. OBJECTSPACE_NORMALMAP: boolean;
  131486. PARALLAX: boolean;
  131487. PARALLAXOCCLUSION: boolean;
  131488. NORMALXYSCALE: boolean;
  131489. LIGHTMAP: boolean;
  131490. LIGHTMAPDIRECTUV: number;
  131491. USELIGHTMAPASSHADOWMAP: boolean;
  131492. GAMMALIGHTMAP: boolean;
  131493. RGBDLIGHTMAP: boolean;
  131494. REFLECTION: boolean;
  131495. REFLECTIONMAP_3D: boolean;
  131496. REFLECTIONMAP_SPHERICAL: boolean;
  131497. REFLECTIONMAP_PLANAR: boolean;
  131498. REFLECTIONMAP_CUBIC: boolean;
  131499. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  131500. REFLECTIONMAP_PROJECTION: boolean;
  131501. REFLECTIONMAP_SKYBOX: boolean;
  131502. REFLECTIONMAP_EXPLICIT: boolean;
  131503. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  131504. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  131505. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  131506. INVERTCUBICMAP: boolean;
  131507. USESPHERICALFROMREFLECTIONMAP: boolean;
  131508. USEIRRADIANCEMAP: boolean;
  131509. SPHERICAL_HARMONICS: boolean;
  131510. USESPHERICALINVERTEX: boolean;
  131511. REFLECTIONMAP_OPPOSITEZ: boolean;
  131512. LODINREFLECTIONALPHA: boolean;
  131513. GAMMAREFLECTION: boolean;
  131514. RGBDREFLECTION: boolean;
  131515. LINEARSPECULARREFLECTION: boolean;
  131516. RADIANCEOCCLUSION: boolean;
  131517. HORIZONOCCLUSION: boolean;
  131518. INSTANCES: boolean;
  131519. NUM_BONE_INFLUENCERS: number;
  131520. BonesPerMesh: number;
  131521. BONETEXTURE: boolean;
  131522. NONUNIFORMSCALING: boolean;
  131523. MORPHTARGETS: boolean;
  131524. MORPHTARGETS_NORMAL: boolean;
  131525. MORPHTARGETS_TANGENT: boolean;
  131526. MORPHTARGETS_UV: boolean;
  131527. NUM_MORPH_INFLUENCERS: number;
  131528. IMAGEPROCESSING: boolean;
  131529. VIGNETTE: boolean;
  131530. VIGNETTEBLENDMODEMULTIPLY: boolean;
  131531. VIGNETTEBLENDMODEOPAQUE: boolean;
  131532. TONEMAPPING: boolean;
  131533. TONEMAPPING_ACES: boolean;
  131534. CONTRAST: boolean;
  131535. COLORCURVES: boolean;
  131536. COLORGRADING: boolean;
  131537. COLORGRADING3D: boolean;
  131538. SAMPLER3DGREENDEPTH: boolean;
  131539. SAMPLER3DBGRMAP: boolean;
  131540. IMAGEPROCESSINGPOSTPROCESS: boolean;
  131541. EXPOSURE: boolean;
  131542. MULTIVIEW: boolean;
  131543. USEPHYSICALLIGHTFALLOFF: boolean;
  131544. USEGLTFLIGHTFALLOFF: boolean;
  131545. TWOSIDEDLIGHTING: boolean;
  131546. SHADOWFLOAT: boolean;
  131547. CLIPPLANE: boolean;
  131548. CLIPPLANE2: boolean;
  131549. CLIPPLANE3: boolean;
  131550. CLIPPLANE4: boolean;
  131551. CLIPPLANE5: boolean;
  131552. CLIPPLANE6: boolean;
  131553. POINTSIZE: boolean;
  131554. FOG: boolean;
  131555. LOGARITHMICDEPTH: boolean;
  131556. FORCENORMALFORWARD: boolean;
  131557. SPECULARAA: boolean;
  131558. CLEARCOAT: boolean;
  131559. CLEARCOAT_DEFAULTIOR: boolean;
  131560. CLEARCOAT_TEXTURE: boolean;
  131561. CLEARCOAT_TEXTUREDIRECTUV: number;
  131562. CLEARCOAT_BUMP: boolean;
  131563. CLEARCOAT_BUMPDIRECTUV: number;
  131564. CLEARCOAT_TINT: boolean;
  131565. CLEARCOAT_TINT_TEXTURE: boolean;
  131566. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  131567. ANISOTROPIC: boolean;
  131568. ANISOTROPIC_TEXTURE: boolean;
  131569. ANISOTROPIC_TEXTUREDIRECTUV: number;
  131570. BRDF_V_HEIGHT_CORRELATED: boolean;
  131571. MS_BRDF_ENERGY_CONSERVATION: boolean;
  131572. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  131573. SHEEN: boolean;
  131574. SHEEN_TEXTURE: boolean;
  131575. SHEEN_TEXTUREDIRECTUV: number;
  131576. SHEEN_LINKWITHALBEDO: boolean;
  131577. SHEEN_ROUGHNESS: boolean;
  131578. SHEEN_ALBEDOSCALING: boolean;
  131579. SUBSURFACE: boolean;
  131580. SS_REFRACTION: boolean;
  131581. SS_TRANSLUCENCY: boolean;
  131582. SS_SCATERRING: boolean;
  131583. SS_THICKNESSANDMASK_TEXTURE: boolean;
  131584. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  131585. SS_REFRACTIONMAP_3D: boolean;
  131586. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  131587. SS_LODINREFRACTIONALPHA: boolean;
  131588. SS_GAMMAREFRACTION: boolean;
  131589. SS_RGBDREFRACTION: boolean;
  131590. SS_LINEARSPECULARREFRACTION: boolean;
  131591. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  131592. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  131593. UNLIT: boolean;
  131594. DEBUGMODE: number;
  131595. /**
  131596. * Initializes the PBR Material defines.
  131597. */
  131598. constructor();
  131599. /**
  131600. * Resets the PBR Material defines.
  131601. */
  131602. reset(): void;
  131603. }
  131604. /**
  131605. * The Physically based material base class of BJS.
  131606. *
  131607. * This offers the main features of a standard PBR material.
  131608. * For more information, please refer to the documentation :
  131609. * https://doc.babylonjs.com/how_to/physically_based_rendering
  131610. */
  131611. export abstract class PBRBaseMaterial extends PushMaterial {
  131612. /**
  131613. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  131614. */
  131615. static readonly PBRMATERIAL_OPAQUE: number;
  131616. /**
  131617. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  131618. */
  131619. static readonly PBRMATERIAL_ALPHATEST: number;
  131620. /**
  131621. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  131622. */
  131623. static readonly PBRMATERIAL_ALPHABLEND: number;
  131624. /**
  131625. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  131626. * They are also discarded below the alpha cutoff threshold to improve performances.
  131627. */
  131628. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  131629. /**
  131630. * Defines the default value of how much AO map is occluding the analytical lights
  131631. * (point spot...).
  131632. */
  131633. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  131634. /**
  131635. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  131636. */
  131637. static readonly LIGHTFALLOFF_PHYSICAL: number;
  131638. /**
  131639. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  131640. * to enhance interoperability with other engines.
  131641. */
  131642. static readonly LIGHTFALLOFF_GLTF: number;
  131643. /**
  131644. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  131645. * to enhance interoperability with other materials.
  131646. */
  131647. static readonly LIGHTFALLOFF_STANDARD: number;
  131648. /**
  131649. * Intensity of the direct lights e.g. the four lights available in your scene.
  131650. * This impacts both the direct diffuse and specular highlights.
  131651. */
  131652. protected _directIntensity: number;
  131653. /**
  131654. * Intensity of the emissive part of the material.
  131655. * This helps controlling the emissive effect without modifying the emissive color.
  131656. */
  131657. protected _emissiveIntensity: number;
  131658. /**
  131659. * Intensity of the environment e.g. how much the environment will light the object
  131660. * either through harmonics for rough material or through the refelction for shiny ones.
  131661. */
  131662. protected _environmentIntensity: number;
  131663. /**
  131664. * This is a special control allowing the reduction of the specular highlights coming from the
  131665. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  131666. */
  131667. protected _specularIntensity: number;
  131668. /**
  131669. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  131670. */
  131671. private _lightingInfos;
  131672. /**
  131673. * Debug Control allowing disabling the bump map on this material.
  131674. */
  131675. protected _disableBumpMap: boolean;
  131676. /**
  131677. * AKA Diffuse Texture in standard nomenclature.
  131678. */
  131679. protected _albedoTexture: Nullable<BaseTexture>;
  131680. /**
  131681. * AKA Occlusion Texture in other nomenclature.
  131682. */
  131683. protected _ambientTexture: Nullable<BaseTexture>;
  131684. /**
  131685. * AKA Occlusion Texture Intensity in other nomenclature.
  131686. */
  131687. protected _ambientTextureStrength: number;
  131688. /**
  131689. * Defines how much the AO map is occluding the analytical lights (point spot...).
  131690. * 1 means it completely occludes it
  131691. * 0 mean it has no impact
  131692. */
  131693. protected _ambientTextureImpactOnAnalyticalLights: number;
  131694. /**
  131695. * Stores the alpha values in a texture.
  131696. */
  131697. protected _opacityTexture: Nullable<BaseTexture>;
  131698. /**
  131699. * Stores the reflection values in a texture.
  131700. */
  131701. protected _reflectionTexture: Nullable<BaseTexture>;
  131702. /**
  131703. * Stores the emissive values in a texture.
  131704. */
  131705. protected _emissiveTexture: Nullable<BaseTexture>;
  131706. /**
  131707. * AKA Specular texture in other nomenclature.
  131708. */
  131709. protected _reflectivityTexture: Nullable<BaseTexture>;
  131710. /**
  131711. * Used to switch from specular/glossiness to metallic/roughness workflow.
  131712. */
  131713. protected _metallicTexture: Nullable<BaseTexture>;
  131714. /**
  131715. * Specifies the metallic scalar of the metallic/roughness workflow.
  131716. * Can also be used to scale the metalness values of the metallic texture.
  131717. */
  131718. protected _metallic: Nullable<number>;
  131719. /**
  131720. * Specifies the roughness scalar of the metallic/roughness workflow.
  131721. * Can also be used to scale the roughness values of the metallic texture.
  131722. */
  131723. protected _roughness: Nullable<number>;
  131724. /**
  131725. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  131726. * By default the indexOfrefraction is used to compute F0;
  131727. *
  131728. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  131729. *
  131730. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  131731. * F90 = metallicReflectanceColor;
  131732. */
  131733. protected _metallicF0Factor: number;
  131734. /**
  131735. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  131736. * By default the F90 is always 1;
  131737. *
  131738. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  131739. *
  131740. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  131741. * F90 = metallicReflectanceColor;
  131742. */
  131743. protected _metallicReflectanceColor: Color3;
  131744. /**
  131745. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  131746. * This is multiply against the scalar values defined in the material.
  131747. */
  131748. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  131749. /**
  131750. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  131751. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  131752. */
  131753. protected _microSurfaceTexture: Nullable<BaseTexture>;
  131754. /**
  131755. * Stores surface normal data used to displace a mesh in a texture.
  131756. */
  131757. protected _bumpTexture: Nullable<BaseTexture>;
  131758. /**
  131759. * Stores the pre-calculated light information of a mesh in a texture.
  131760. */
  131761. protected _lightmapTexture: Nullable<BaseTexture>;
  131762. /**
  131763. * The color of a material in ambient lighting.
  131764. */
  131765. protected _ambientColor: Color3;
  131766. /**
  131767. * AKA Diffuse Color in other nomenclature.
  131768. */
  131769. protected _albedoColor: Color3;
  131770. /**
  131771. * AKA Specular Color in other nomenclature.
  131772. */
  131773. protected _reflectivityColor: Color3;
  131774. /**
  131775. * The color applied when light is reflected from a material.
  131776. */
  131777. protected _reflectionColor: Color3;
  131778. /**
  131779. * The color applied when light is emitted from a material.
  131780. */
  131781. protected _emissiveColor: Color3;
  131782. /**
  131783. * AKA Glossiness in other nomenclature.
  131784. */
  131785. protected _microSurface: number;
  131786. /**
  131787. * Specifies that the material will use the light map as a show map.
  131788. */
  131789. protected _useLightmapAsShadowmap: boolean;
  131790. /**
  131791. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  131792. * makes the reflect vector face the model (under horizon).
  131793. */
  131794. protected _useHorizonOcclusion: boolean;
  131795. /**
  131796. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  131797. * too much the area relying on ambient texture to define their ambient occlusion.
  131798. */
  131799. protected _useRadianceOcclusion: boolean;
  131800. /**
  131801. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  131802. */
  131803. protected _useAlphaFromAlbedoTexture: boolean;
  131804. /**
  131805. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  131806. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  131807. */
  131808. protected _useSpecularOverAlpha: boolean;
  131809. /**
  131810. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  131811. */
  131812. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  131813. /**
  131814. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  131815. */
  131816. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  131817. /**
  131818. * Specifies if the metallic texture contains the roughness information in its green channel.
  131819. */
  131820. protected _useRoughnessFromMetallicTextureGreen: boolean;
  131821. /**
  131822. * Specifies if the metallic texture contains the metallness information in its blue channel.
  131823. */
  131824. protected _useMetallnessFromMetallicTextureBlue: boolean;
  131825. /**
  131826. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  131827. */
  131828. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  131829. /**
  131830. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  131831. */
  131832. protected _useAmbientInGrayScale: boolean;
  131833. /**
  131834. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  131835. * The material will try to infer what glossiness each pixel should be.
  131836. */
  131837. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  131838. /**
  131839. * Defines the falloff type used in this material.
  131840. * It by default is Physical.
  131841. */
  131842. protected _lightFalloff: number;
  131843. /**
  131844. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  131845. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  131846. */
  131847. protected _useRadianceOverAlpha: boolean;
  131848. /**
  131849. * Allows using an object space normal map (instead of tangent space).
  131850. */
  131851. protected _useObjectSpaceNormalMap: boolean;
  131852. /**
  131853. * Allows using the bump map in parallax mode.
  131854. */
  131855. protected _useParallax: boolean;
  131856. /**
  131857. * Allows using the bump map in parallax occlusion mode.
  131858. */
  131859. protected _useParallaxOcclusion: boolean;
  131860. /**
  131861. * Controls the scale bias of the parallax mode.
  131862. */
  131863. protected _parallaxScaleBias: number;
  131864. /**
  131865. * If sets to true, disables all the lights affecting the material.
  131866. */
  131867. protected _disableLighting: boolean;
  131868. /**
  131869. * Number of Simultaneous lights allowed on the material.
  131870. */
  131871. protected _maxSimultaneousLights: number;
  131872. /**
  131873. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  131874. */
  131875. protected _invertNormalMapX: boolean;
  131876. /**
  131877. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  131878. */
  131879. protected _invertNormalMapY: boolean;
  131880. /**
  131881. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  131882. */
  131883. protected _twoSidedLighting: boolean;
  131884. /**
  131885. * Defines the alpha limits in alpha test mode.
  131886. */
  131887. protected _alphaCutOff: number;
  131888. /**
  131889. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  131890. */
  131891. protected _forceAlphaTest: boolean;
  131892. /**
  131893. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  131894. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  131895. */
  131896. protected _useAlphaFresnel: boolean;
  131897. /**
  131898. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  131899. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  131900. */
  131901. protected _useLinearAlphaFresnel: boolean;
  131902. /**
  131903. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  131904. * from cos thetav and roughness:
  131905. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  131906. */
  131907. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  131908. /**
  131909. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  131910. */
  131911. protected _forceIrradianceInFragment: boolean;
  131912. private _realTimeFiltering;
  131913. /**
  131914. * Enables realtime filtering on the texture.
  131915. */
  131916. get realTimeFiltering(): boolean;
  131917. set realTimeFiltering(b: boolean);
  131918. private _realTimeFilteringQuality;
  131919. /**
  131920. * Quality switch for realtime filtering
  131921. */
  131922. get realTimeFilteringQuality(): number;
  131923. set realTimeFilteringQuality(n: number);
  131924. /**
  131925. * Force normal to face away from face.
  131926. */
  131927. protected _forceNormalForward: boolean;
  131928. /**
  131929. * Enables specular anti aliasing in the PBR shader.
  131930. * It will both interacts on the Geometry for analytical and IBL lighting.
  131931. * It also prefilter the roughness map based on the bump values.
  131932. */
  131933. protected _enableSpecularAntiAliasing: boolean;
  131934. /**
  131935. * Default configuration related to image processing available in the PBR Material.
  131936. */
  131937. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  131938. /**
  131939. * Keep track of the image processing observer to allow dispose and replace.
  131940. */
  131941. private _imageProcessingObserver;
  131942. /**
  131943. * Attaches a new image processing configuration to the PBR Material.
  131944. * @param configuration
  131945. */
  131946. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  131947. /**
  131948. * Stores the available render targets.
  131949. */
  131950. private _renderTargets;
  131951. /**
  131952. * Sets the global ambient color for the material used in lighting calculations.
  131953. */
  131954. private _globalAmbientColor;
  131955. /**
  131956. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  131957. */
  131958. private _useLogarithmicDepth;
  131959. /**
  131960. * If set to true, no lighting calculations will be applied.
  131961. */
  131962. private _unlit;
  131963. private _debugMode;
  131964. /**
  131965. * @hidden
  131966. * This is reserved for the inspector.
  131967. * Defines the material debug mode.
  131968. * It helps seeing only some components of the material while troubleshooting.
  131969. */
  131970. debugMode: number;
  131971. /**
  131972. * @hidden
  131973. * This is reserved for the inspector.
  131974. * Specify from where on screen the debug mode should start.
  131975. * The value goes from -1 (full screen) to 1 (not visible)
  131976. * It helps with side by side comparison against the final render
  131977. * This defaults to -1
  131978. */
  131979. private debugLimit;
  131980. /**
  131981. * @hidden
  131982. * This is reserved for the inspector.
  131983. * As the default viewing range might not be enough (if the ambient is really small for instance)
  131984. * You can use the factor to better multiply the final value.
  131985. */
  131986. private debugFactor;
  131987. /**
  131988. * Defines the clear coat layer parameters for the material.
  131989. */
  131990. readonly clearCoat: PBRClearCoatConfiguration;
  131991. /**
  131992. * Defines the anisotropic parameters for the material.
  131993. */
  131994. readonly anisotropy: PBRAnisotropicConfiguration;
  131995. /**
  131996. * Defines the BRDF parameters for the material.
  131997. */
  131998. readonly brdf: PBRBRDFConfiguration;
  131999. /**
  132000. * Defines the Sheen parameters for the material.
  132001. */
  132002. readonly sheen: PBRSheenConfiguration;
  132003. /**
  132004. * Defines the SubSurface parameters for the material.
  132005. */
  132006. readonly subSurface: PBRSubSurfaceConfiguration;
  132007. protected _rebuildInParallel: boolean;
  132008. /**
  132009. * Instantiates a new PBRMaterial instance.
  132010. *
  132011. * @param name The material name
  132012. * @param scene The scene the material will be use in.
  132013. */
  132014. constructor(name: string, scene: Scene);
  132015. /**
  132016. * Gets a boolean indicating that current material needs to register RTT
  132017. */
  132018. get hasRenderTargetTextures(): boolean;
  132019. /**
  132020. * Gets the name of the material class.
  132021. */
  132022. getClassName(): string;
  132023. /**
  132024. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  132025. */
  132026. get useLogarithmicDepth(): boolean;
  132027. /**
  132028. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  132029. */
  132030. set useLogarithmicDepth(value: boolean);
  132031. /**
  132032. * Returns true if alpha blending should be disabled.
  132033. */
  132034. protected get _disableAlphaBlending(): boolean;
  132035. /**
  132036. * Specifies whether or not this material should be rendered in alpha blend mode.
  132037. */
  132038. needAlphaBlending(): boolean;
  132039. /**
  132040. * Specifies whether or not this material should be rendered in alpha test mode.
  132041. */
  132042. needAlphaTesting(): boolean;
  132043. /**
  132044. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  132045. */
  132046. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  132047. /**
  132048. * Gets the texture used for the alpha test.
  132049. */
  132050. getAlphaTestTexture(): Nullable<BaseTexture>;
  132051. /**
  132052. * Specifies that the submesh is ready to be used.
  132053. * @param mesh - BJS mesh.
  132054. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  132055. * @param useInstances - Specifies that instances should be used.
  132056. * @returns - boolean indicating that the submesh is ready or not.
  132057. */
  132058. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  132059. /**
  132060. * Specifies if the material uses metallic roughness workflow.
  132061. * @returns boolean specifiying if the material uses metallic roughness workflow.
  132062. */
  132063. isMetallicWorkflow(): boolean;
  132064. private _prepareEffect;
  132065. private _prepareDefines;
  132066. /**
  132067. * Force shader compilation
  132068. */
  132069. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  132070. /**
  132071. * Initializes the uniform buffer layout for the shader.
  132072. */
  132073. buildUniformLayout(): void;
  132074. /**
  132075. * Unbinds the material from the mesh
  132076. */
  132077. unbind(): void;
  132078. /**
  132079. * Binds the submesh data.
  132080. * @param world - The world matrix.
  132081. * @param mesh - The BJS mesh.
  132082. * @param subMesh - A submesh of the BJS mesh.
  132083. */
  132084. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  132085. /**
  132086. * Returns the animatable textures.
  132087. * @returns - Array of animatable textures.
  132088. */
  132089. getAnimatables(): IAnimatable[];
  132090. /**
  132091. * Returns the texture used for reflections.
  132092. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  132093. */
  132094. private _getReflectionTexture;
  132095. /**
  132096. * Returns an array of the actively used textures.
  132097. * @returns - Array of BaseTextures
  132098. */
  132099. getActiveTextures(): BaseTexture[];
  132100. /**
  132101. * Checks to see if a texture is used in the material.
  132102. * @param texture - Base texture to use.
  132103. * @returns - Boolean specifying if a texture is used in the material.
  132104. */
  132105. hasTexture(texture: BaseTexture): boolean;
  132106. /**
  132107. * Disposes the resources of the material.
  132108. * @param forceDisposeEffect - Forces the disposal of effects.
  132109. * @param forceDisposeTextures - Forces the disposal of all textures.
  132110. */
  132111. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  132112. }
  132113. }
  132114. declare module BABYLON {
  132115. /**
  132116. * The Physically based material of BJS.
  132117. *
  132118. * This offers the main features of a standard PBR material.
  132119. * For more information, please refer to the documentation :
  132120. * https://doc.babylonjs.com/how_to/physically_based_rendering
  132121. */
  132122. export class PBRMaterial extends PBRBaseMaterial {
  132123. /**
  132124. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  132125. */
  132126. static readonly PBRMATERIAL_OPAQUE: number;
  132127. /**
  132128. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  132129. */
  132130. static readonly PBRMATERIAL_ALPHATEST: number;
  132131. /**
  132132. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  132133. */
  132134. static readonly PBRMATERIAL_ALPHABLEND: number;
  132135. /**
  132136. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  132137. * They are also discarded below the alpha cutoff threshold to improve performances.
  132138. */
  132139. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  132140. /**
  132141. * Defines the default value of how much AO map is occluding the analytical lights
  132142. * (point spot...).
  132143. */
  132144. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  132145. /**
  132146. * Intensity of the direct lights e.g. the four lights available in your scene.
  132147. * This impacts both the direct diffuse and specular highlights.
  132148. */
  132149. directIntensity: number;
  132150. /**
  132151. * Intensity of the emissive part of the material.
  132152. * This helps controlling the emissive effect without modifying the emissive color.
  132153. */
  132154. emissiveIntensity: number;
  132155. /**
  132156. * Intensity of the environment e.g. how much the environment will light the object
  132157. * either through harmonics for rough material or through the refelction for shiny ones.
  132158. */
  132159. environmentIntensity: number;
  132160. /**
  132161. * This is a special control allowing the reduction of the specular highlights coming from the
  132162. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  132163. */
  132164. specularIntensity: number;
  132165. /**
  132166. * Debug Control allowing disabling the bump map on this material.
  132167. */
  132168. disableBumpMap: boolean;
  132169. /**
  132170. * AKA Diffuse Texture in standard nomenclature.
  132171. */
  132172. albedoTexture: BaseTexture;
  132173. /**
  132174. * AKA Occlusion Texture in other nomenclature.
  132175. */
  132176. ambientTexture: BaseTexture;
  132177. /**
  132178. * AKA Occlusion Texture Intensity in other nomenclature.
  132179. */
  132180. ambientTextureStrength: number;
  132181. /**
  132182. * Defines how much the AO map is occluding the analytical lights (point spot...).
  132183. * 1 means it completely occludes it
  132184. * 0 mean it has no impact
  132185. */
  132186. ambientTextureImpactOnAnalyticalLights: number;
  132187. /**
  132188. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  132189. */
  132190. opacityTexture: BaseTexture;
  132191. /**
  132192. * Stores the reflection values in a texture.
  132193. */
  132194. reflectionTexture: Nullable<BaseTexture>;
  132195. /**
  132196. * Stores the emissive values in a texture.
  132197. */
  132198. emissiveTexture: BaseTexture;
  132199. /**
  132200. * AKA Specular texture in other nomenclature.
  132201. */
  132202. reflectivityTexture: BaseTexture;
  132203. /**
  132204. * Used to switch from specular/glossiness to metallic/roughness workflow.
  132205. */
  132206. metallicTexture: BaseTexture;
  132207. /**
  132208. * Specifies the metallic scalar of the metallic/roughness workflow.
  132209. * Can also be used to scale the metalness values of the metallic texture.
  132210. */
  132211. metallic: Nullable<number>;
  132212. /**
  132213. * Specifies the roughness scalar of the metallic/roughness workflow.
  132214. * Can also be used to scale the roughness values of the metallic texture.
  132215. */
  132216. roughness: Nullable<number>;
  132217. /**
  132218. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  132219. * By default the indexOfrefraction is used to compute F0;
  132220. *
  132221. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  132222. *
  132223. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  132224. * F90 = metallicReflectanceColor;
  132225. */
  132226. metallicF0Factor: number;
  132227. /**
  132228. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  132229. * By default the F90 is always 1;
  132230. *
  132231. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  132232. *
  132233. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  132234. * F90 = metallicReflectanceColor;
  132235. */
  132236. metallicReflectanceColor: Color3;
  132237. /**
  132238. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  132239. * This is multiply against the scalar values defined in the material.
  132240. */
  132241. metallicReflectanceTexture: Nullable<BaseTexture>;
  132242. /**
  132243. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  132244. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  132245. */
  132246. microSurfaceTexture: BaseTexture;
  132247. /**
  132248. * Stores surface normal data used to displace a mesh in a texture.
  132249. */
  132250. bumpTexture: BaseTexture;
  132251. /**
  132252. * Stores the pre-calculated light information of a mesh in a texture.
  132253. */
  132254. lightmapTexture: BaseTexture;
  132255. /**
  132256. * Stores the refracted light information in a texture.
  132257. */
  132258. get refractionTexture(): Nullable<BaseTexture>;
  132259. set refractionTexture(value: Nullable<BaseTexture>);
  132260. /**
  132261. * The color of a material in ambient lighting.
  132262. */
  132263. ambientColor: Color3;
  132264. /**
  132265. * AKA Diffuse Color in other nomenclature.
  132266. */
  132267. albedoColor: Color3;
  132268. /**
  132269. * AKA Specular Color in other nomenclature.
  132270. */
  132271. reflectivityColor: Color3;
  132272. /**
  132273. * The color reflected from the material.
  132274. */
  132275. reflectionColor: Color3;
  132276. /**
  132277. * The color emitted from the material.
  132278. */
  132279. emissiveColor: Color3;
  132280. /**
  132281. * AKA Glossiness in other nomenclature.
  132282. */
  132283. microSurface: number;
  132284. /**
  132285. * Index of refraction of the material base layer.
  132286. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  132287. *
  132288. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  132289. *
  132290. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  132291. */
  132292. get indexOfRefraction(): number;
  132293. set indexOfRefraction(value: number);
  132294. /**
  132295. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  132296. */
  132297. get invertRefractionY(): boolean;
  132298. set invertRefractionY(value: boolean);
  132299. /**
  132300. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  132301. * Materials half opaque for instance using refraction could benefit from this control.
  132302. */
  132303. get linkRefractionWithTransparency(): boolean;
  132304. set linkRefractionWithTransparency(value: boolean);
  132305. /**
  132306. * If true, the light map contains occlusion information instead of lighting info.
  132307. */
  132308. useLightmapAsShadowmap: boolean;
  132309. /**
  132310. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  132311. */
  132312. useAlphaFromAlbedoTexture: boolean;
  132313. /**
  132314. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  132315. */
  132316. forceAlphaTest: boolean;
  132317. /**
  132318. * Defines the alpha limits in alpha test mode.
  132319. */
  132320. alphaCutOff: number;
  132321. /**
  132322. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  132323. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  132324. */
  132325. useSpecularOverAlpha: boolean;
  132326. /**
  132327. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  132328. */
  132329. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  132330. /**
  132331. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  132332. */
  132333. useRoughnessFromMetallicTextureAlpha: boolean;
  132334. /**
  132335. * Specifies if the metallic texture contains the roughness information in its green channel.
  132336. */
  132337. useRoughnessFromMetallicTextureGreen: boolean;
  132338. /**
  132339. * Specifies if the metallic texture contains the metallness information in its blue channel.
  132340. */
  132341. useMetallnessFromMetallicTextureBlue: boolean;
  132342. /**
  132343. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  132344. */
  132345. useAmbientOcclusionFromMetallicTextureRed: boolean;
  132346. /**
  132347. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  132348. */
  132349. useAmbientInGrayScale: boolean;
  132350. /**
  132351. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  132352. * The material will try to infer what glossiness each pixel should be.
  132353. */
  132354. useAutoMicroSurfaceFromReflectivityMap: boolean;
  132355. /**
  132356. * BJS is using an harcoded light falloff based on a manually sets up range.
  132357. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  132358. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  132359. */
  132360. get usePhysicalLightFalloff(): boolean;
  132361. /**
  132362. * BJS is using an harcoded light falloff based on a manually sets up range.
  132363. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  132364. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  132365. */
  132366. set usePhysicalLightFalloff(value: boolean);
  132367. /**
  132368. * In order to support the falloff compatibility with gltf, a special mode has been added
  132369. * to reproduce the gltf light falloff.
  132370. */
  132371. get useGLTFLightFalloff(): boolean;
  132372. /**
  132373. * In order to support the falloff compatibility with gltf, a special mode has been added
  132374. * to reproduce the gltf light falloff.
  132375. */
  132376. set useGLTFLightFalloff(value: boolean);
  132377. /**
  132378. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  132379. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  132380. */
  132381. useRadianceOverAlpha: boolean;
  132382. /**
  132383. * Allows using an object space normal map (instead of tangent space).
  132384. */
  132385. useObjectSpaceNormalMap: boolean;
  132386. /**
  132387. * Allows using the bump map in parallax mode.
  132388. */
  132389. useParallax: boolean;
  132390. /**
  132391. * Allows using the bump map in parallax occlusion mode.
  132392. */
  132393. useParallaxOcclusion: boolean;
  132394. /**
  132395. * Controls the scale bias of the parallax mode.
  132396. */
  132397. parallaxScaleBias: number;
  132398. /**
  132399. * If sets to true, disables all the lights affecting the material.
  132400. */
  132401. disableLighting: boolean;
  132402. /**
  132403. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  132404. */
  132405. forceIrradianceInFragment: boolean;
  132406. /**
  132407. * Number of Simultaneous lights allowed on the material.
  132408. */
  132409. maxSimultaneousLights: number;
  132410. /**
  132411. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  132412. */
  132413. invertNormalMapX: boolean;
  132414. /**
  132415. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  132416. */
  132417. invertNormalMapY: boolean;
  132418. /**
  132419. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  132420. */
  132421. twoSidedLighting: boolean;
  132422. /**
  132423. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  132424. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  132425. */
  132426. useAlphaFresnel: boolean;
  132427. /**
  132428. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  132429. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  132430. */
  132431. useLinearAlphaFresnel: boolean;
  132432. /**
  132433. * Let user defines the brdf lookup texture used for IBL.
  132434. * A default 8bit version is embedded but you could point at :
  132435. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  132436. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  132437. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  132438. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  132439. */
  132440. environmentBRDFTexture: Nullable<BaseTexture>;
  132441. /**
  132442. * Force normal to face away from face.
  132443. */
  132444. forceNormalForward: boolean;
  132445. /**
  132446. * Enables specular anti aliasing in the PBR shader.
  132447. * It will both interacts on the Geometry for analytical and IBL lighting.
  132448. * It also prefilter the roughness map based on the bump values.
  132449. */
  132450. enableSpecularAntiAliasing: boolean;
  132451. /**
  132452. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  132453. * makes the reflect vector face the model (under horizon).
  132454. */
  132455. useHorizonOcclusion: boolean;
  132456. /**
  132457. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  132458. * too much the area relying on ambient texture to define their ambient occlusion.
  132459. */
  132460. useRadianceOcclusion: boolean;
  132461. /**
  132462. * If set to true, no lighting calculations will be applied.
  132463. */
  132464. unlit: boolean;
  132465. /**
  132466. * Gets the image processing configuration used either in this material.
  132467. */
  132468. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  132469. /**
  132470. * Sets the Default image processing configuration used either in the this material.
  132471. *
  132472. * If sets to null, the scene one is in use.
  132473. */
  132474. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  132475. /**
  132476. * Gets wether the color curves effect is enabled.
  132477. */
  132478. get cameraColorCurvesEnabled(): boolean;
  132479. /**
  132480. * Sets wether the color curves effect is enabled.
  132481. */
  132482. set cameraColorCurvesEnabled(value: boolean);
  132483. /**
  132484. * Gets wether the color grading effect is enabled.
  132485. */
  132486. get cameraColorGradingEnabled(): boolean;
  132487. /**
  132488. * Gets wether the color grading effect is enabled.
  132489. */
  132490. set cameraColorGradingEnabled(value: boolean);
  132491. /**
  132492. * Gets wether tonemapping is enabled or not.
  132493. */
  132494. get cameraToneMappingEnabled(): boolean;
  132495. /**
  132496. * Sets wether tonemapping is enabled or not
  132497. */
  132498. set cameraToneMappingEnabled(value: boolean);
  132499. /**
  132500. * The camera exposure used on this material.
  132501. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  132502. * This corresponds to a photographic exposure.
  132503. */
  132504. get cameraExposure(): number;
  132505. /**
  132506. * The camera exposure used on this material.
  132507. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  132508. * This corresponds to a photographic exposure.
  132509. */
  132510. set cameraExposure(value: number);
  132511. /**
  132512. * Gets The camera contrast used on this material.
  132513. */
  132514. get cameraContrast(): number;
  132515. /**
  132516. * Sets The camera contrast used on this material.
  132517. */
  132518. set cameraContrast(value: number);
  132519. /**
  132520. * Gets the Color Grading 2D Lookup Texture.
  132521. */
  132522. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  132523. /**
  132524. * Sets the Color Grading 2D Lookup Texture.
  132525. */
  132526. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  132527. /**
  132528. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  132529. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  132530. * 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;
  132531. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  132532. */
  132533. get cameraColorCurves(): Nullable<ColorCurves>;
  132534. /**
  132535. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  132536. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  132537. * 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;
  132538. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  132539. */
  132540. set cameraColorCurves(value: Nullable<ColorCurves>);
  132541. /**
  132542. * Instantiates a new PBRMaterial instance.
  132543. *
  132544. * @param name The material name
  132545. * @param scene The scene the material will be use in.
  132546. */
  132547. constructor(name: string, scene: Scene);
  132548. /**
  132549. * Returns the name of this material class.
  132550. */
  132551. getClassName(): string;
  132552. /**
  132553. * Makes a duplicate of the current material.
  132554. * @param name - name to use for the new material.
  132555. */
  132556. clone(name: string): PBRMaterial;
  132557. /**
  132558. * Serializes this PBR Material.
  132559. * @returns - An object with the serialized material.
  132560. */
  132561. serialize(): any;
  132562. /**
  132563. * Parses a PBR Material from a serialized object.
  132564. * @param source - Serialized object.
  132565. * @param scene - BJS scene instance.
  132566. * @param rootUrl - url for the scene object
  132567. * @returns - PBRMaterial
  132568. */
  132569. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  132570. }
  132571. }
  132572. declare module BABYLON {
  132573. /**
  132574. * Direct draw surface info
  132575. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  132576. */
  132577. export interface DDSInfo {
  132578. /**
  132579. * Width of the texture
  132580. */
  132581. width: number;
  132582. /**
  132583. * Width of the texture
  132584. */
  132585. height: number;
  132586. /**
  132587. * Number of Mipmaps for the texture
  132588. * @see https://en.wikipedia.org/wiki/Mipmap
  132589. */
  132590. mipmapCount: number;
  132591. /**
  132592. * If the textures format is a known fourCC format
  132593. * @see https://www.fourcc.org/
  132594. */
  132595. isFourCC: boolean;
  132596. /**
  132597. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  132598. */
  132599. isRGB: boolean;
  132600. /**
  132601. * If the texture is a lumincance format
  132602. */
  132603. isLuminance: boolean;
  132604. /**
  132605. * If this is a cube texture
  132606. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  132607. */
  132608. isCube: boolean;
  132609. /**
  132610. * If the texture is a compressed format eg. FOURCC_DXT1
  132611. */
  132612. isCompressed: boolean;
  132613. /**
  132614. * The dxgiFormat of the texture
  132615. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  132616. */
  132617. dxgiFormat: number;
  132618. /**
  132619. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  132620. */
  132621. textureType: number;
  132622. /**
  132623. * Sphericle polynomial created for the dds texture
  132624. */
  132625. sphericalPolynomial?: SphericalPolynomial;
  132626. }
  132627. /**
  132628. * Class used to provide DDS decompression tools
  132629. */
  132630. export class DDSTools {
  132631. /**
  132632. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  132633. */
  132634. static StoreLODInAlphaChannel: boolean;
  132635. /**
  132636. * Gets DDS information from an array buffer
  132637. * @param data defines the array buffer view to read data from
  132638. * @returns the DDS information
  132639. */
  132640. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  132641. private static _FloatView;
  132642. private static _Int32View;
  132643. private static _ToHalfFloat;
  132644. private static _FromHalfFloat;
  132645. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  132646. private static _GetHalfFloatRGBAArrayBuffer;
  132647. private static _GetFloatRGBAArrayBuffer;
  132648. private static _GetFloatAsUIntRGBAArrayBuffer;
  132649. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  132650. private static _GetRGBAArrayBuffer;
  132651. private static _ExtractLongWordOrder;
  132652. private static _GetRGBArrayBuffer;
  132653. private static _GetLuminanceArrayBuffer;
  132654. /**
  132655. * Uploads DDS Levels to a Babylon Texture
  132656. * @hidden
  132657. */
  132658. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  132659. }
  132660. interface ThinEngine {
  132661. /**
  132662. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  132663. * @param rootUrl defines the url where the file to load is located
  132664. * @param scene defines the current scene
  132665. * @param lodScale defines scale to apply to the mip map selection
  132666. * @param lodOffset defines offset to apply to the mip map selection
  132667. * @param onLoad defines an optional callback raised when the texture is loaded
  132668. * @param onError defines an optional callback raised if there is an issue to load the texture
  132669. * @param format defines the format of the data
  132670. * @param forcedExtension defines the extension to use to pick the right loader
  132671. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  132672. * @returns the cube texture as an InternalTexture
  132673. */
  132674. 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;
  132675. }
  132676. }
  132677. declare module BABYLON {
  132678. /**
  132679. * Implementation of the DDS Texture Loader.
  132680. * @hidden
  132681. */
  132682. export class _DDSTextureLoader implements IInternalTextureLoader {
  132683. /**
  132684. * Defines wether the loader supports cascade loading the different faces.
  132685. */
  132686. readonly supportCascades: boolean;
  132687. /**
  132688. * This returns if the loader support the current file information.
  132689. * @param extension defines the file extension of the file being loaded
  132690. * @returns true if the loader can load the specified file
  132691. */
  132692. canLoad(extension: string): boolean;
  132693. /**
  132694. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  132695. * @param data contains the texture data
  132696. * @param texture defines the BabylonJS internal texture
  132697. * @param createPolynomials will be true if polynomials have been requested
  132698. * @param onLoad defines the callback to trigger once the texture is ready
  132699. * @param onError defines the callback to trigger in case of error
  132700. */
  132701. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  132702. /**
  132703. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  132704. * @param data contains the texture data
  132705. * @param texture defines the BabylonJS internal texture
  132706. * @param callback defines the method to call once ready to upload
  132707. */
  132708. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  132709. }
  132710. }
  132711. declare module BABYLON {
  132712. /**
  132713. * Implementation of the ENV Texture Loader.
  132714. * @hidden
  132715. */
  132716. export class _ENVTextureLoader implements IInternalTextureLoader {
  132717. /**
  132718. * Defines wether the loader supports cascade loading the different faces.
  132719. */
  132720. readonly supportCascades: boolean;
  132721. /**
  132722. * This returns if the loader support the current file information.
  132723. * @param extension defines the file extension of the file being loaded
  132724. * @returns true if the loader can load the specified file
  132725. */
  132726. canLoad(extension: string): boolean;
  132727. /**
  132728. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  132729. * @param data contains the texture data
  132730. * @param texture defines the BabylonJS internal texture
  132731. * @param createPolynomials will be true if polynomials have been requested
  132732. * @param onLoad defines the callback to trigger once the texture is ready
  132733. * @param onError defines the callback to trigger in case of error
  132734. */
  132735. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  132736. /**
  132737. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  132738. * @param data contains the texture data
  132739. * @param texture defines the BabylonJS internal texture
  132740. * @param callback defines the method to call once ready to upload
  132741. */
  132742. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  132743. }
  132744. }
  132745. declare module BABYLON {
  132746. /**
  132747. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  132748. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  132749. */
  132750. export class KhronosTextureContainer {
  132751. /** contents of the KTX container file */
  132752. data: ArrayBufferView;
  132753. private static HEADER_LEN;
  132754. private static COMPRESSED_2D;
  132755. private static COMPRESSED_3D;
  132756. private static TEX_2D;
  132757. private static TEX_3D;
  132758. /**
  132759. * Gets the openGL type
  132760. */
  132761. glType: number;
  132762. /**
  132763. * Gets the openGL type size
  132764. */
  132765. glTypeSize: number;
  132766. /**
  132767. * Gets the openGL format
  132768. */
  132769. glFormat: number;
  132770. /**
  132771. * Gets the openGL internal format
  132772. */
  132773. glInternalFormat: number;
  132774. /**
  132775. * Gets the base internal format
  132776. */
  132777. glBaseInternalFormat: number;
  132778. /**
  132779. * Gets image width in pixel
  132780. */
  132781. pixelWidth: number;
  132782. /**
  132783. * Gets image height in pixel
  132784. */
  132785. pixelHeight: number;
  132786. /**
  132787. * Gets image depth in pixels
  132788. */
  132789. pixelDepth: number;
  132790. /**
  132791. * Gets the number of array elements
  132792. */
  132793. numberOfArrayElements: number;
  132794. /**
  132795. * Gets the number of faces
  132796. */
  132797. numberOfFaces: number;
  132798. /**
  132799. * Gets the number of mipmap levels
  132800. */
  132801. numberOfMipmapLevels: number;
  132802. /**
  132803. * Gets the bytes of key value data
  132804. */
  132805. bytesOfKeyValueData: number;
  132806. /**
  132807. * Gets the load type
  132808. */
  132809. loadType: number;
  132810. /**
  132811. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  132812. */
  132813. isInvalid: boolean;
  132814. /**
  132815. * Creates a new KhronosTextureContainer
  132816. * @param data contents of the KTX container file
  132817. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  132818. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  132819. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  132820. */
  132821. constructor(
  132822. /** contents of the KTX container file */
  132823. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  132824. /**
  132825. * Uploads KTX content to a Babylon Texture.
  132826. * It is assumed that the texture has already been created & is currently bound
  132827. * @hidden
  132828. */
  132829. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  132830. private _upload2DCompressedLevels;
  132831. /**
  132832. * Checks if the given data starts with a KTX file identifier.
  132833. * @param data the data to check
  132834. * @returns true if the data is a KTX file or false otherwise
  132835. */
  132836. static IsValid(data: ArrayBufferView): boolean;
  132837. }
  132838. }
  132839. declare module BABYLON {
  132840. /**
  132841. * Class for loading KTX2 files
  132842. * !!! Experimental Extension Subject to Changes !!!
  132843. * @hidden
  132844. */
  132845. export class KhronosTextureContainer2 {
  132846. private static _ModulePromise;
  132847. private static _TranscodeFormat;
  132848. constructor(engine: ThinEngine);
  132849. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  132850. private _determineTranscodeFormat;
  132851. /**
  132852. * Checks if the given data starts with a KTX2 file identifier.
  132853. * @param data the data to check
  132854. * @returns true if the data is a KTX2 file or false otherwise
  132855. */
  132856. static IsValid(data: ArrayBufferView): boolean;
  132857. }
  132858. }
  132859. declare module BABYLON {
  132860. /**
  132861. * Implementation of the KTX Texture Loader.
  132862. * @hidden
  132863. */
  132864. export class _KTXTextureLoader implements IInternalTextureLoader {
  132865. /**
  132866. * Defines wether the loader supports cascade loading the different faces.
  132867. */
  132868. readonly supportCascades: boolean;
  132869. /**
  132870. * This returns if the loader support the current file information.
  132871. * @param extension defines the file extension of the file being loaded
  132872. * @returns true if the loader can load the specified file
  132873. */
  132874. canLoad(extension: string): boolean;
  132875. /**
  132876. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  132877. * @param data contains the texture data
  132878. * @param texture defines the BabylonJS internal texture
  132879. * @param createPolynomials will be true if polynomials have been requested
  132880. * @param onLoad defines the callback to trigger once the texture is ready
  132881. * @param onError defines the callback to trigger in case of error
  132882. */
  132883. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  132884. /**
  132885. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  132886. * @param data contains the texture data
  132887. * @param texture defines the BabylonJS internal texture
  132888. * @param callback defines the method to call once ready to upload
  132889. */
  132890. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  132891. }
  132892. }
  132893. declare module BABYLON {
  132894. /** @hidden */
  132895. export var _forceSceneHelpersToBundle: boolean;
  132896. interface Scene {
  132897. /**
  132898. * Creates a default light for the scene.
  132899. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  132900. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  132901. */
  132902. createDefaultLight(replace?: boolean): void;
  132903. /**
  132904. * Creates a default camera for the scene.
  132905. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  132906. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  132907. * @param replace has default false, when true replaces the active camera in the scene
  132908. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  132909. */
  132910. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  132911. /**
  132912. * Creates a default camera and a default light.
  132913. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  132914. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  132915. * @param replace has the default false, when true replaces the active camera/light in the scene
  132916. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  132917. */
  132918. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  132919. /**
  132920. * Creates a new sky box
  132921. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  132922. * @param environmentTexture defines the texture to use as environment texture
  132923. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  132924. * @param scale defines the overall scale of the skybox
  132925. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  132926. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  132927. * @returns a new mesh holding the sky box
  132928. */
  132929. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  132930. /**
  132931. * Creates a new environment
  132932. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  132933. * @param options defines the options you can use to configure the environment
  132934. * @returns the new EnvironmentHelper
  132935. */
  132936. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  132937. /**
  132938. * Creates a new VREXperienceHelper
  132939. * @see http://doc.babylonjs.com/how_to/webvr_helper
  132940. * @param webVROptions defines the options used to create the new VREXperienceHelper
  132941. * @returns a new VREXperienceHelper
  132942. */
  132943. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  132944. /**
  132945. * Creates a new WebXRDefaultExperience
  132946. * @see http://doc.babylonjs.com/how_to/webxr
  132947. * @param options experience options
  132948. * @returns a promise for a new WebXRDefaultExperience
  132949. */
  132950. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  132951. }
  132952. }
  132953. declare module BABYLON {
  132954. /**
  132955. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  132956. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  132957. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  132958. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  132959. */
  132960. export class VideoDome extends TransformNode {
  132961. /**
  132962. * Define the video source as a Monoscopic panoramic 360 video.
  132963. */
  132964. static readonly MODE_MONOSCOPIC: number;
  132965. /**
  132966. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  132967. */
  132968. static readonly MODE_TOPBOTTOM: number;
  132969. /**
  132970. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  132971. */
  132972. static readonly MODE_SIDEBYSIDE: number;
  132973. private _halfDome;
  132974. private _useDirectMapping;
  132975. /**
  132976. * The video texture being displayed on the sphere
  132977. */
  132978. protected _videoTexture: VideoTexture;
  132979. /**
  132980. * Gets the video texture being displayed on the sphere
  132981. */
  132982. get videoTexture(): VideoTexture;
  132983. /**
  132984. * The skybox material
  132985. */
  132986. protected _material: BackgroundMaterial;
  132987. /**
  132988. * The surface used for the skybox
  132989. */
  132990. protected _mesh: Mesh;
  132991. /**
  132992. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  132993. */
  132994. private _halfDomeMask;
  132995. /**
  132996. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  132997. * Also see the options.resolution property.
  132998. */
  132999. get fovMultiplier(): number;
  133000. set fovMultiplier(value: number);
  133001. private _videoMode;
  133002. /**
  133003. * Gets or set the current video mode for the video. It can be:
  133004. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  133005. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  133006. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  133007. */
  133008. get videoMode(): number;
  133009. set videoMode(value: number);
  133010. /**
  133011. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  133012. *
  133013. */
  133014. get halfDome(): boolean;
  133015. /**
  133016. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  133017. */
  133018. set halfDome(enabled: boolean);
  133019. /**
  133020. * Oberserver used in Stereoscopic VR Mode.
  133021. */
  133022. private _onBeforeCameraRenderObserver;
  133023. /**
  133024. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  133025. * @param name Element's name, child elements will append suffixes for their own names.
  133026. * @param urlsOrVideo defines the url(s) or the video element to use
  133027. * @param options An object containing optional or exposed sub element properties
  133028. */
  133029. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  133030. resolution?: number;
  133031. clickToPlay?: boolean;
  133032. autoPlay?: boolean;
  133033. loop?: boolean;
  133034. size?: number;
  133035. poster?: string;
  133036. faceForward?: boolean;
  133037. useDirectMapping?: boolean;
  133038. halfDomeMode?: boolean;
  133039. }, scene: Scene);
  133040. private _changeVideoMode;
  133041. /**
  133042. * Releases resources associated with this node.
  133043. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  133044. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  133045. */
  133046. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  133047. }
  133048. }
  133049. declare module BABYLON {
  133050. /**
  133051. * This class can be used to get instrumentation data from a Babylon engine
  133052. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  133053. */
  133054. export class EngineInstrumentation implements IDisposable {
  133055. /**
  133056. * Define the instrumented engine.
  133057. */
  133058. engine: Engine;
  133059. private _captureGPUFrameTime;
  133060. private _gpuFrameTimeToken;
  133061. private _gpuFrameTime;
  133062. private _captureShaderCompilationTime;
  133063. private _shaderCompilationTime;
  133064. private _onBeginFrameObserver;
  133065. private _onEndFrameObserver;
  133066. private _onBeforeShaderCompilationObserver;
  133067. private _onAfterShaderCompilationObserver;
  133068. /**
  133069. * Gets the perf counter used for GPU frame time
  133070. */
  133071. get gpuFrameTimeCounter(): PerfCounter;
  133072. /**
  133073. * Gets the GPU frame time capture status
  133074. */
  133075. get captureGPUFrameTime(): boolean;
  133076. /**
  133077. * Enable or disable the GPU frame time capture
  133078. */
  133079. set captureGPUFrameTime(value: boolean);
  133080. /**
  133081. * Gets the perf counter used for shader compilation time
  133082. */
  133083. get shaderCompilationTimeCounter(): PerfCounter;
  133084. /**
  133085. * Gets the shader compilation time capture status
  133086. */
  133087. get captureShaderCompilationTime(): boolean;
  133088. /**
  133089. * Enable or disable the shader compilation time capture
  133090. */
  133091. set captureShaderCompilationTime(value: boolean);
  133092. /**
  133093. * Instantiates a new engine instrumentation.
  133094. * This class can be used to get instrumentation data from a Babylon engine
  133095. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  133096. * @param engine Defines the engine to instrument
  133097. */
  133098. constructor(
  133099. /**
  133100. * Define the instrumented engine.
  133101. */
  133102. engine: Engine);
  133103. /**
  133104. * Dispose and release associated resources.
  133105. */
  133106. dispose(): void;
  133107. }
  133108. }
  133109. declare module BABYLON {
  133110. /**
  133111. * This class can be used to get instrumentation data from a Babylon engine
  133112. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  133113. */
  133114. export class SceneInstrumentation implements IDisposable {
  133115. /**
  133116. * Defines the scene to instrument
  133117. */
  133118. scene: Scene;
  133119. private _captureActiveMeshesEvaluationTime;
  133120. private _activeMeshesEvaluationTime;
  133121. private _captureRenderTargetsRenderTime;
  133122. private _renderTargetsRenderTime;
  133123. private _captureFrameTime;
  133124. private _frameTime;
  133125. private _captureRenderTime;
  133126. private _renderTime;
  133127. private _captureInterFrameTime;
  133128. private _interFrameTime;
  133129. private _captureParticlesRenderTime;
  133130. private _particlesRenderTime;
  133131. private _captureSpritesRenderTime;
  133132. private _spritesRenderTime;
  133133. private _capturePhysicsTime;
  133134. private _physicsTime;
  133135. private _captureAnimationsTime;
  133136. private _animationsTime;
  133137. private _captureCameraRenderTime;
  133138. private _cameraRenderTime;
  133139. private _onBeforeActiveMeshesEvaluationObserver;
  133140. private _onAfterActiveMeshesEvaluationObserver;
  133141. private _onBeforeRenderTargetsRenderObserver;
  133142. private _onAfterRenderTargetsRenderObserver;
  133143. private _onAfterRenderObserver;
  133144. private _onBeforeDrawPhaseObserver;
  133145. private _onAfterDrawPhaseObserver;
  133146. private _onBeforeAnimationsObserver;
  133147. private _onBeforeParticlesRenderingObserver;
  133148. private _onAfterParticlesRenderingObserver;
  133149. private _onBeforeSpritesRenderingObserver;
  133150. private _onAfterSpritesRenderingObserver;
  133151. private _onBeforePhysicsObserver;
  133152. private _onAfterPhysicsObserver;
  133153. private _onAfterAnimationsObserver;
  133154. private _onBeforeCameraRenderObserver;
  133155. private _onAfterCameraRenderObserver;
  133156. /**
  133157. * Gets the perf counter used for active meshes evaluation time
  133158. */
  133159. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  133160. /**
  133161. * Gets the active meshes evaluation time capture status
  133162. */
  133163. get captureActiveMeshesEvaluationTime(): boolean;
  133164. /**
  133165. * Enable or disable the active meshes evaluation time capture
  133166. */
  133167. set captureActiveMeshesEvaluationTime(value: boolean);
  133168. /**
  133169. * Gets the perf counter used for render targets render time
  133170. */
  133171. get renderTargetsRenderTimeCounter(): PerfCounter;
  133172. /**
  133173. * Gets the render targets render time capture status
  133174. */
  133175. get captureRenderTargetsRenderTime(): boolean;
  133176. /**
  133177. * Enable or disable the render targets render time capture
  133178. */
  133179. set captureRenderTargetsRenderTime(value: boolean);
  133180. /**
  133181. * Gets the perf counter used for particles render time
  133182. */
  133183. get particlesRenderTimeCounter(): PerfCounter;
  133184. /**
  133185. * Gets the particles render time capture status
  133186. */
  133187. get captureParticlesRenderTime(): boolean;
  133188. /**
  133189. * Enable or disable the particles render time capture
  133190. */
  133191. set captureParticlesRenderTime(value: boolean);
  133192. /**
  133193. * Gets the perf counter used for sprites render time
  133194. */
  133195. get spritesRenderTimeCounter(): PerfCounter;
  133196. /**
  133197. * Gets the sprites render time capture status
  133198. */
  133199. get captureSpritesRenderTime(): boolean;
  133200. /**
  133201. * Enable or disable the sprites render time capture
  133202. */
  133203. set captureSpritesRenderTime(value: boolean);
  133204. /**
  133205. * Gets the perf counter used for physics time
  133206. */
  133207. get physicsTimeCounter(): PerfCounter;
  133208. /**
  133209. * Gets the physics time capture status
  133210. */
  133211. get capturePhysicsTime(): boolean;
  133212. /**
  133213. * Enable or disable the physics time capture
  133214. */
  133215. set capturePhysicsTime(value: boolean);
  133216. /**
  133217. * Gets the perf counter used for animations time
  133218. */
  133219. get animationsTimeCounter(): PerfCounter;
  133220. /**
  133221. * Gets the animations time capture status
  133222. */
  133223. get captureAnimationsTime(): boolean;
  133224. /**
  133225. * Enable or disable the animations time capture
  133226. */
  133227. set captureAnimationsTime(value: boolean);
  133228. /**
  133229. * Gets the perf counter used for frame time capture
  133230. */
  133231. get frameTimeCounter(): PerfCounter;
  133232. /**
  133233. * Gets the frame time capture status
  133234. */
  133235. get captureFrameTime(): boolean;
  133236. /**
  133237. * Enable or disable the frame time capture
  133238. */
  133239. set captureFrameTime(value: boolean);
  133240. /**
  133241. * Gets the perf counter used for inter-frames time capture
  133242. */
  133243. get interFrameTimeCounter(): PerfCounter;
  133244. /**
  133245. * Gets the inter-frames time capture status
  133246. */
  133247. get captureInterFrameTime(): boolean;
  133248. /**
  133249. * Enable or disable the inter-frames time capture
  133250. */
  133251. set captureInterFrameTime(value: boolean);
  133252. /**
  133253. * Gets the perf counter used for render time capture
  133254. */
  133255. get renderTimeCounter(): PerfCounter;
  133256. /**
  133257. * Gets the render time capture status
  133258. */
  133259. get captureRenderTime(): boolean;
  133260. /**
  133261. * Enable or disable the render time capture
  133262. */
  133263. set captureRenderTime(value: boolean);
  133264. /**
  133265. * Gets the perf counter used for camera render time capture
  133266. */
  133267. get cameraRenderTimeCounter(): PerfCounter;
  133268. /**
  133269. * Gets the camera render time capture status
  133270. */
  133271. get captureCameraRenderTime(): boolean;
  133272. /**
  133273. * Enable or disable the camera render time capture
  133274. */
  133275. set captureCameraRenderTime(value: boolean);
  133276. /**
  133277. * Gets the perf counter used for draw calls
  133278. */
  133279. get drawCallsCounter(): PerfCounter;
  133280. /**
  133281. * Instantiates a new scene instrumentation.
  133282. * This class can be used to get instrumentation data from a Babylon engine
  133283. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  133284. * @param scene Defines the scene to instrument
  133285. */
  133286. constructor(
  133287. /**
  133288. * Defines the scene to instrument
  133289. */
  133290. scene: Scene);
  133291. /**
  133292. * Dispose and release associated resources.
  133293. */
  133294. dispose(): void;
  133295. }
  133296. }
  133297. declare module BABYLON {
  133298. /** @hidden */
  133299. export var glowMapGenerationPixelShader: {
  133300. name: string;
  133301. shader: string;
  133302. };
  133303. }
  133304. declare module BABYLON {
  133305. /** @hidden */
  133306. export var glowMapGenerationVertexShader: {
  133307. name: string;
  133308. shader: string;
  133309. };
  133310. }
  133311. declare module BABYLON {
  133312. /**
  133313. * Effect layer options. This helps customizing the behaviour
  133314. * of the effect layer.
  133315. */
  133316. export interface IEffectLayerOptions {
  133317. /**
  133318. * Multiplication factor apply to the canvas size to compute the render target size
  133319. * used to generated the objects (the smaller the faster).
  133320. */
  133321. mainTextureRatio: number;
  133322. /**
  133323. * Enforces a fixed size texture to ensure effect stability across devices.
  133324. */
  133325. mainTextureFixedSize?: number;
  133326. /**
  133327. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  133328. */
  133329. alphaBlendingMode: number;
  133330. /**
  133331. * The camera attached to the layer.
  133332. */
  133333. camera: Nullable<Camera>;
  133334. /**
  133335. * The rendering group to draw the layer in.
  133336. */
  133337. renderingGroupId: number;
  133338. }
  133339. /**
  133340. * The effect layer Helps adding post process effect blended with the main pass.
  133341. *
  133342. * This can be for instance use to generate glow or higlight effects on the scene.
  133343. *
  133344. * The effect layer class can not be used directly and is intented to inherited from to be
  133345. * customized per effects.
  133346. */
  133347. export abstract class EffectLayer {
  133348. private _vertexBuffers;
  133349. private _indexBuffer;
  133350. private _cachedDefines;
  133351. private _effectLayerMapGenerationEffect;
  133352. private _effectLayerOptions;
  133353. private _mergeEffect;
  133354. protected _scene: Scene;
  133355. protected _engine: Engine;
  133356. protected _maxSize: number;
  133357. protected _mainTextureDesiredSize: ISize;
  133358. protected _mainTexture: RenderTargetTexture;
  133359. protected _shouldRender: boolean;
  133360. protected _postProcesses: PostProcess[];
  133361. protected _textures: BaseTexture[];
  133362. protected _emissiveTextureAndColor: {
  133363. texture: Nullable<BaseTexture>;
  133364. color: Color4;
  133365. };
  133366. /**
  133367. * The name of the layer
  133368. */
  133369. name: string;
  133370. /**
  133371. * The clear color of the texture used to generate the glow map.
  133372. */
  133373. neutralColor: Color4;
  133374. /**
  133375. * Specifies whether the highlight layer is enabled or not.
  133376. */
  133377. isEnabled: boolean;
  133378. /**
  133379. * Gets the camera attached to the layer.
  133380. */
  133381. get camera(): Nullable<Camera>;
  133382. /**
  133383. * Gets the rendering group id the layer should render in.
  133384. */
  133385. get renderingGroupId(): number;
  133386. set renderingGroupId(renderingGroupId: number);
  133387. /**
  133388. * An event triggered when the effect layer has been disposed.
  133389. */
  133390. onDisposeObservable: Observable<EffectLayer>;
  133391. /**
  133392. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  133393. */
  133394. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  133395. /**
  133396. * An event triggered when the generated texture is being merged in the scene.
  133397. */
  133398. onBeforeComposeObservable: Observable<EffectLayer>;
  133399. /**
  133400. * An event triggered when the mesh is rendered into the effect render target.
  133401. */
  133402. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  133403. /**
  133404. * An event triggered after the mesh has been rendered into the effect render target.
  133405. */
  133406. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  133407. /**
  133408. * An event triggered when the generated texture has been merged in the scene.
  133409. */
  133410. onAfterComposeObservable: Observable<EffectLayer>;
  133411. /**
  133412. * An event triggered when the efffect layer changes its size.
  133413. */
  133414. onSizeChangedObservable: Observable<EffectLayer>;
  133415. /** @hidden */
  133416. static _SceneComponentInitialization: (scene: Scene) => void;
  133417. /**
  133418. * Instantiates a new effect Layer and references it in the scene.
  133419. * @param name The name of the layer
  133420. * @param scene The scene to use the layer in
  133421. */
  133422. constructor(
  133423. /** The Friendly of the effect in the scene */
  133424. name: string, scene: Scene);
  133425. /**
  133426. * Get the effect name of the layer.
  133427. * @return The effect name
  133428. */
  133429. abstract getEffectName(): string;
  133430. /**
  133431. * Checks for the readiness of the element composing the layer.
  133432. * @param subMesh the mesh to check for
  133433. * @param useInstances specify whether or not to use instances to render the mesh
  133434. * @return true if ready otherwise, false
  133435. */
  133436. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  133437. /**
  133438. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  133439. * @returns true if the effect requires stencil during the main canvas render pass.
  133440. */
  133441. abstract needStencil(): boolean;
  133442. /**
  133443. * Create the merge effect. This is the shader use to blit the information back
  133444. * to the main canvas at the end of the scene rendering.
  133445. * @returns The effect containing the shader used to merge the effect on the main canvas
  133446. */
  133447. protected abstract _createMergeEffect(): Effect;
  133448. /**
  133449. * Creates the render target textures and post processes used in the effect layer.
  133450. */
  133451. protected abstract _createTextureAndPostProcesses(): void;
  133452. /**
  133453. * Implementation specific of rendering the generating effect on the main canvas.
  133454. * @param effect The effect used to render through
  133455. */
  133456. protected abstract _internalRender(effect: Effect): void;
  133457. /**
  133458. * Sets the required values for both the emissive texture and and the main color.
  133459. */
  133460. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  133461. /**
  133462. * Free any resources and references associated to a mesh.
  133463. * Internal use
  133464. * @param mesh The mesh to free.
  133465. */
  133466. abstract _disposeMesh(mesh: Mesh): void;
  133467. /**
  133468. * Serializes this layer (Glow or Highlight for example)
  133469. * @returns a serialized layer object
  133470. */
  133471. abstract serialize?(): any;
  133472. /**
  133473. * Initializes the effect layer with the required options.
  133474. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  133475. */
  133476. protected _init(options: Partial<IEffectLayerOptions>): void;
  133477. /**
  133478. * Generates the index buffer of the full screen quad blending to the main canvas.
  133479. */
  133480. private _generateIndexBuffer;
  133481. /**
  133482. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  133483. */
  133484. private _generateVertexBuffer;
  133485. /**
  133486. * Sets the main texture desired size which is the closest power of two
  133487. * of the engine canvas size.
  133488. */
  133489. private _setMainTextureSize;
  133490. /**
  133491. * Creates the main texture for the effect layer.
  133492. */
  133493. protected _createMainTexture(): void;
  133494. /**
  133495. * Adds specific effects defines.
  133496. * @param defines The defines to add specifics to.
  133497. */
  133498. protected _addCustomEffectDefines(defines: string[]): void;
  133499. /**
  133500. * Checks for the readiness of the element composing the layer.
  133501. * @param subMesh the mesh to check for
  133502. * @param useInstances specify whether or not to use instances to render the mesh
  133503. * @param emissiveTexture the associated emissive texture used to generate the glow
  133504. * @return true if ready otherwise, false
  133505. */
  133506. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  133507. /**
  133508. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  133509. */
  133510. render(): void;
  133511. /**
  133512. * Determine if a given mesh will be used in the current effect.
  133513. * @param mesh mesh to test
  133514. * @returns true if the mesh will be used
  133515. */
  133516. hasMesh(mesh: AbstractMesh): boolean;
  133517. /**
  133518. * Returns true if the layer contains information to display, otherwise false.
  133519. * @returns true if the glow layer should be rendered
  133520. */
  133521. shouldRender(): boolean;
  133522. /**
  133523. * Returns true if the mesh should render, otherwise false.
  133524. * @param mesh The mesh to render
  133525. * @returns true if it should render otherwise false
  133526. */
  133527. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  133528. /**
  133529. * Returns true if the mesh can be rendered, otherwise false.
  133530. * @param mesh The mesh to render
  133531. * @param material The material used on the mesh
  133532. * @returns true if it can be rendered otherwise false
  133533. */
  133534. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  133535. /**
  133536. * Returns true if the mesh should render, otherwise false.
  133537. * @param mesh The mesh to render
  133538. * @returns true if it should render otherwise false
  133539. */
  133540. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  133541. /**
  133542. * Renders the submesh passed in parameter to the generation map.
  133543. */
  133544. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  133545. /**
  133546. * Defines whether the current material of the mesh should be use to render the effect.
  133547. * @param mesh defines the current mesh to render
  133548. */
  133549. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  133550. /**
  133551. * Rebuild the required buffers.
  133552. * @hidden Internal use only.
  133553. */
  133554. _rebuild(): void;
  133555. /**
  133556. * Dispose only the render target textures and post process.
  133557. */
  133558. private _disposeTextureAndPostProcesses;
  133559. /**
  133560. * Dispose the highlight layer and free resources.
  133561. */
  133562. dispose(): void;
  133563. /**
  133564. * Gets the class name of the effect layer
  133565. * @returns the string with the class name of the effect layer
  133566. */
  133567. getClassName(): string;
  133568. /**
  133569. * Creates an effect layer from parsed effect layer data
  133570. * @param parsedEffectLayer defines effect layer data
  133571. * @param scene defines the current scene
  133572. * @param rootUrl defines the root URL containing the effect layer information
  133573. * @returns a parsed effect Layer
  133574. */
  133575. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  133576. }
  133577. }
  133578. declare module BABYLON {
  133579. interface AbstractScene {
  133580. /**
  133581. * The list of effect layers (highlights/glow) added to the scene
  133582. * @see http://doc.babylonjs.com/how_to/highlight_layer
  133583. * @see http://doc.babylonjs.com/how_to/glow_layer
  133584. */
  133585. effectLayers: Array<EffectLayer>;
  133586. /**
  133587. * Removes the given effect layer from this scene.
  133588. * @param toRemove defines the effect layer to remove
  133589. * @returns the index of the removed effect layer
  133590. */
  133591. removeEffectLayer(toRemove: EffectLayer): number;
  133592. /**
  133593. * Adds the given effect layer to this scene
  133594. * @param newEffectLayer defines the effect layer to add
  133595. */
  133596. addEffectLayer(newEffectLayer: EffectLayer): void;
  133597. }
  133598. /**
  133599. * Defines the layer scene component responsible to manage any effect layers
  133600. * in a given scene.
  133601. */
  133602. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  133603. /**
  133604. * The component name helpfull to identify the component in the list of scene components.
  133605. */
  133606. readonly name: string;
  133607. /**
  133608. * The scene the component belongs to.
  133609. */
  133610. scene: Scene;
  133611. private _engine;
  133612. private _renderEffects;
  133613. private _needStencil;
  133614. private _previousStencilState;
  133615. /**
  133616. * Creates a new instance of the component for the given scene
  133617. * @param scene Defines the scene to register the component in
  133618. */
  133619. constructor(scene: Scene);
  133620. /**
  133621. * Registers the component in a given scene
  133622. */
  133623. register(): void;
  133624. /**
  133625. * Rebuilds the elements related to this component in case of
  133626. * context lost for instance.
  133627. */
  133628. rebuild(): void;
  133629. /**
  133630. * Serializes the component data to the specified json object
  133631. * @param serializationObject The object to serialize to
  133632. */
  133633. serialize(serializationObject: any): void;
  133634. /**
  133635. * Adds all the elements from the container to the scene
  133636. * @param container the container holding the elements
  133637. */
  133638. addFromContainer(container: AbstractScene): void;
  133639. /**
  133640. * Removes all the elements in the container from the scene
  133641. * @param container contains the elements to remove
  133642. * @param dispose if the removed element should be disposed (default: false)
  133643. */
  133644. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  133645. /**
  133646. * Disposes the component and the associated ressources.
  133647. */
  133648. dispose(): void;
  133649. private _isReadyForMesh;
  133650. private _renderMainTexture;
  133651. private _setStencil;
  133652. private _setStencilBack;
  133653. private _draw;
  133654. private _drawCamera;
  133655. private _drawRenderingGroup;
  133656. }
  133657. }
  133658. declare module BABYLON {
  133659. /** @hidden */
  133660. export var glowMapMergePixelShader: {
  133661. name: string;
  133662. shader: string;
  133663. };
  133664. }
  133665. declare module BABYLON {
  133666. /** @hidden */
  133667. export var glowMapMergeVertexShader: {
  133668. name: string;
  133669. shader: string;
  133670. };
  133671. }
  133672. declare module BABYLON {
  133673. interface AbstractScene {
  133674. /**
  133675. * Return a the first highlight layer of the scene with a given name.
  133676. * @param name The name of the highlight layer to look for.
  133677. * @return The highlight layer if found otherwise null.
  133678. */
  133679. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  133680. }
  133681. /**
  133682. * Glow layer options. This helps customizing the behaviour
  133683. * of the glow layer.
  133684. */
  133685. export interface IGlowLayerOptions {
  133686. /**
  133687. * Multiplication factor apply to the canvas size to compute the render target size
  133688. * used to generated the glowing objects (the smaller the faster).
  133689. */
  133690. mainTextureRatio: number;
  133691. /**
  133692. * Enforces a fixed size texture to ensure resize independant blur.
  133693. */
  133694. mainTextureFixedSize?: number;
  133695. /**
  133696. * How big is the kernel of the blur texture.
  133697. */
  133698. blurKernelSize: number;
  133699. /**
  133700. * The camera attached to the layer.
  133701. */
  133702. camera: Nullable<Camera>;
  133703. /**
  133704. * Enable MSAA by chosing the number of samples.
  133705. */
  133706. mainTextureSamples?: number;
  133707. /**
  133708. * The rendering group to draw the layer in.
  133709. */
  133710. renderingGroupId: number;
  133711. }
  133712. /**
  133713. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  133714. *
  133715. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  133716. *
  133717. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  133718. */
  133719. export class GlowLayer extends EffectLayer {
  133720. /**
  133721. * Effect Name of the layer.
  133722. */
  133723. static readonly EffectName: string;
  133724. /**
  133725. * The default blur kernel size used for the glow.
  133726. */
  133727. static DefaultBlurKernelSize: number;
  133728. /**
  133729. * The default texture size ratio used for the glow.
  133730. */
  133731. static DefaultTextureRatio: number;
  133732. /**
  133733. * Sets the kernel size of the blur.
  133734. */
  133735. set blurKernelSize(value: number);
  133736. /**
  133737. * Gets the kernel size of the blur.
  133738. */
  133739. get blurKernelSize(): number;
  133740. /**
  133741. * Sets the glow intensity.
  133742. */
  133743. set intensity(value: number);
  133744. /**
  133745. * Gets the glow intensity.
  133746. */
  133747. get intensity(): number;
  133748. private _options;
  133749. private _intensity;
  133750. private _horizontalBlurPostprocess1;
  133751. private _verticalBlurPostprocess1;
  133752. private _horizontalBlurPostprocess2;
  133753. private _verticalBlurPostprocess2;
  133754. private _blurTexture1;
  133755. private _blurTexture2;
  133756. private _postProcesses1;
  133757. private _postProcesses2;
  133758. private _includedOnlyMeshes;
  133759. private _excludedMeshes;
  133760. private _meshesUsingTheirOwnMaterials;
  133761. /**
  133762. * Callback used to let the user override the color selection on a per mesh basis
  133763. */
  133764. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  133765. /**
  133766. * Callback used to let the user override the texture selection on a per mesh basis
  133767. */
  133768. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  133769. /**
  133770. * Instantiates a new glow Layer and references it to the scene.
  133771. * @param name The name of the layer
  133772. * @param scene The scene to use the layer in
  133773. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  133774. */
  133775. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  133776. /**
  133777. * Get the effect name of the layer.
  133778. * @return The effect name
  133779. */
  133780. getEffectName(): string;
  133781. /**
  133782. * Create the merge effect. This is the shader use to blit the information back
  133783. * to the main canvas at the end of the scene rendering.
  133784. */
  133785. protected _createMergeEffect(): Effect;
  133786. /**
  133787. * Creates the render target textures and post processes used in the glow layer.
  133788. */
  133789. protected _createTextureAndPostProcesses(): void;
  133790. /**
  133791. * Checks for the readiness of the element composing the layer.
  133792. * @param subMesh the mesh to check for
  133793. * @param useInstances specify wether or not to use instances to render the mesh
  133794. * @param emissiveTexture the associated emissive texture used to generate the glow
  133795. * @return true if ready otherwise, false
  133796. */
  133797. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  133798. /**
  133799. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  133800. */
  133801. needStencil(): boolean;
  133802. /**
  133803. * Returns true if the mesh can be rendered, otherwise false.
  133804. * @param mesh The mesh to render
  133805. * @param material The material used on the mesh
  133806. * @returns true if it can be rendered otherwise false
  133807. */
  133808. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  133809. /**
  133810. * Implementation specific of rendering the generating effect on the main canvas.
  133811. * @param effect The effect used to render through
  133812. */
  133813. protected _internalRender(effect: Effect): void;
  133814. /**
  133815. * Sets the required values for both the emissive texture and and the main color.
  133816. */
  133817. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  133818. /**
  133819. * Returns true if the mesh should render, otherwise false.
  133820. * @param mesh The mesh to render
  133821. * @returns true if it should render otherwise false
  133822. */
  133823. protected _shouldRenderMesh(mesh: Mesh): boolean;
  133824. /**
  133825. * Adds specific effects defines.
  133826. * @param defines The defines to add specifics to.
  133827. */
  133828. protected _addCustomEffectDefines(defines: string[]): void;
  133829. /**
  133830. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  133831. * @param mesh The mesh to exclude from the glow layer
  133832. */
  133833. addExcludedMesh(mesh: Mesh): void;
  133834. /**
  133835. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  133836. * @param mesh The mesh to remove
  133837. */
  133838. removeExcludedMesh(mesh: Mesh): void;
  133839. /**
  133840. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  133841. * @param mesh The mesh to include in the glow layer
  133842. */
  133843. addIncludedOnlyMesh(mesh: Mesh): void;
  133844. /**
  133845. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  133846. * @param mesh The mesh to remove
  133847. */
  133848. removeIncludedOnlyMesh(mesh: Mesh): void;
  133849. /**
  133850. * Determine if a given mesh will be used in the glow layer
  133851. * @param mesh The mesh to test
  133852. * @returns true if the mesh will be highlighted by the current glow layer
  133853. */
  133854. hasMesh(mesh: AbstractMesh): boolean;
  133855. /**
  133856. * Defines whether the current material of the mesh should be use to render the effect.
  133857. * @param mesh defines the current mesh to render
  133858. */
  133859. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  133860. /**
  133861. * Add a mesh to be rendered through its own material and not with emissive only.
  133862. * @param mesh The mesh for which we need to use its material
  133863. */
  133864. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  133865. /**
  133866. * Remove a mesh from being rendered through its own material and not with emissive only.
  133867. * @param mesh The mesh for which we need to not use its material
  133868. */
  133869. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  133870. /**
  133871. * Free any resources and references associated to a mesh.
  133872. * Internal use
  133873. * @param mesh The mesh to free.
  133874. * @hidden
  133875. */
  133876. _disposeMesh(mesh: Mesh): void;
  133877. /**
  133878. * Gets the class name of the effect layer
  133879. * @returns the string with the class name of the effect layer
  133880. */
  133881. getClassName(): string;
  133882. /**
  133883. * Serializes this glow layer
  133884. * @returns a serialized glow layer object
  133885. */
  133886. serialize(): any;
  133887. /**
  133888. * Creates a Glow Layer from parsed glow layer data
  133889. * @param parsedGlowLayer defines glow layer data
  133890. * @param scene defines the current scene
  133891. * @param rootUrl defines the root URL containing the glow layer information
  133892. * @returns a parsed Glow Layer
  133893. */
  133894. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  133895. }
  133896. }
  133897. declare module BABYLON {
  133898. /** @hidden */
  133899. export var glowBlurPostProcessPixelShader: {
  133900. name: string;
  133901. shader: string;
  133902. };
  133903. }
  133904. declare module BABYLON {
  133905. interface AbstractScene {
  133906. /**
  133907. * Return a the first highlight layer of the scene with a given name.
  133908. * @param name The name of the highlight layer to look for.
  133909. * @return The highlight layer if found otherwise null.
  133910. */
  133911. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  133912. }
  133913. /**
  133914. * Highlight layer options. This helps customizing the behaviour
  133915. * of the highlight layer.
  133916. */
  133917. export interface IHighlightLayerOptions {
  133918. /**
  133919. * Multiplication factor apply to the canvas size to compute the render target size
  133920. * used to generated the glowing objects (the smaller the faster).
  133921. */
  133922. mainTextureRatio: number;
  133923. /**
  133924. * Enforces a fixed size texture to ensure resize independant blur.
  133925. */
  133926. mainTextureFixedSize?: number;
  133927. /**
  133928. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  133929. * of the picture to blur (the smaller the faster).
  133930. */
  133931. blurTextureSizeRatio: number;
  133932. /**
  133933. * How big in texel of the blur texture is the vertical blur.
  133934. */
  133935. blurVerticalSize: number;
  133936. /**
  133937. * How big in texel of the blur texture is the horizontal blur.
  133938. */
  133939. blurHorizontalSize: number;
  133940. /**
  133941. * Alpha blending mode used to apply the blur. Default is combine.
  133942. */
  133943. alphaBlendingMode: number;
  133944. /**
  133945. * The camera attached to the layer.
  133946. */
  133947. camera: Nullable<Camera>;
  133948. /**
  133949. * Should we display highlight as a solid stroke?
  133950. */
  133951. isStroke?: boolean;
  133952. /**
  133953. * The rendering group to draw the layer in.
  133954. */
  133955. renderingGroupId: number;
  133956. }
  133957. /**
  133958. * The highlight layer Helps adding a glow effect around a mesh.
  133959. *
  133960. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  133961. * glowy meshes to your scene.
  133962. *
  133963. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  133964. */
  133965. export class HighlightLayer extends EffectLayer {
  133966. name: string;
  133967. /**
  133968. * Effect Name of the highlight layer.
  133969. */
  133970. static readonly EffectName: string;
  133971. /**
  133972. * The neutral color used during the preparation of the glow effect.
  133973. * This is black by default as the blend operation is a blend operation.
  133974. */
  133975. static NeutralColor: Color4;
  133976. /**
  133977. * Stencil value used for glowing meshes.
  133978. */
  133979. static GlowingMeshStencilReference: number;
  133980. /**
  133981. * Stencil value used for the other meshes in the scene.
  133982. */
  133983. static NormalMeshStencilReference: number;
  133984. /**
  133985. * Specifies whether or not the inner glow is ACTIVE in the layer.
  133986. */
  133987. innerGlow: boolean;
  133988. /**
  133989. * Specifies whether or not the outer glow is ACTIVE in the layer.
  133990. */
  133991. outerGlow: boolean;
  133992. /**
  133993. * Specifies the horizontal size of the blur.
  133994. */
  133995. set blurHorizontalSize(value: number);
  133996. /**
  133997. * Specifies the vertical size of the blur.
  133998. */
  133999. set blurVerticalSize(value: number);
  134000. /**
  134001. * Gets the horizontal size of the blur.
  134002. */
  134003. get blurHorizontalSize(): number;
  134004. /**
  134005. * Gets the vertical size of the blur.
  134006. */
  134007. get blurVerticalSize(): number;
  134008. /**
  134009. * An event triggered when the highlight layer is being blurred.
  134010. */
  134011. onBeforeBlurObservable: Observable<HighlightLayer>;
  134012. /**
  134013. * An event triggered when the highlight layer has been blurred.
  134014. */
  134015. onAfterBlurObservable: Observable<HighlightLayer>;
  134016. private _instanceGlowingMeshStencilReference;
  134017. private _options;
  134018. private _downSamplePostprocess;
  134019. private _horizontalBlurPostprocess;
  134020. private _verticalBlurPostprocess;
  134021. private _blurTexture;
  134022. private _meshes;
  134023. private _excludedMeshes;
  134024. /**
  134025. * Instantiates a new highlight Layer and references it to the scene..
  134026. * @param name The name of the layer
  134027. * @param scene The scene to use the layer in
  134028. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  134029. */
  134030. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  134031. /**
  134032. * Get the effect name of the layer.
  134033. * @return The effect name
  134034. */
  134035. getEffectName(): string;
  134036. /**
  134037. * Create the merge effect. This is the shader use to blit the information back
  134038. * to the main canvas at the end of the scene rendering.
  134039. */
  134040. protected _createMergeEffect(): Effect;
  134041. /**
  134042. * Creates the render target textures and post processes used in the highlight layer.
  134043. */
  134044. protected _createTextureAndPostProcesses(): void;
  134045. /**
  134046. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  134047. */
  134048. needStencil(): boolean;
  134049. /**
  134050. * Checks for the readiness of the element composing the layer.
  134051. * @param subMesh the mesh to check for
  134052. * @param useInstances specify wether or not to use instances to render the mesh
  134053. * @param emissiveTexture the associated emissive texture used to generate the glow
  134054. * @return true if ready otherwise, false
  134055. */
  134056. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  134057. /**
  134058. * Implementation specific of rendering the generating effect on the main canvas.
  134059. * @param effect The effect used to render through
  134060. */
  134061. protected _internalRender(effect: Effect): void;
  134062. /**
  134063. * Returns true if the layer contains information to display, otherwise false.
  134064. */
  134065. shouldRender(): boolean;
  134066. /**
  134067. * Returns true if the mesh should render, otherwise false.
  134068. * @param mesh The mesh to render
  134069. * @returns true if it should render otherwise false
  134070. */
  134071. protected _shouldRenderMesh(mesh: Mesh): boolean;
  134072. /**
  134073. * Adds specific effects defines.
  134074. * @param defines The defines to add specifics to.
  134075. */
  134076. protected _addCustomEffectDefines(defines: string[]): void;
  134077. /**
  134078. * Sets the required values for both the emissive texture and and the main color.
  134079. */
  134080. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  134081. /**
  134082. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  134083. * @param mesh The mesh to exclude from the highlight layer
  134084. */
  134085. addExcludedMesh(mesh: Mesh): void;
  134086. /**
  134087. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  134088. * @param mesh The mesh to highlight
  134089. */
  134090. removeExcludedMesh(mesh: Mesh): void;
  134091. /**
  134092. * Determine if a given mesh will be highlighted by the current HighlightLayer
  134093. * @param mesh mesh to test
  134094. * @returns true if the mesh will be highlighted by the current HighlightLayer
  134095. */
  134096. hasMesh(mesh: AbstractMesh): boolean;
  134097. /**
  134098. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  134099. * @param mesh The mesh to highlight
  134100. * @param color The color of the highlight
  134101. * @param glowEmissiveOnly Extract the glow from the emissive texture
  134102. */
  134103. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  134104. /**
  134105. * Remove a mesh from the highlight layer in order to make it stop glowing.
  134106. * @param mesh The mesh to highlight
  134107. */
  134108. removeMesh(mesh: Mesh): void;
  134109. /**
  134110. * Remove all the meshes currently referenced in the highlight layer
  134111. */
  134112. removeAllMeshes(): void;
  134113. /**
  134114. * Force the stencil to the normal expected value for none glowing parts
  134115. */
  134116. private _defaultStencilReference;
  134117. /**
  134118. * Free any resources and references associated to a mesh.
  134119. * Internal use
  134120. * @param mesh The mesh to free.
  134121. * @hidden
  134122. */
  134123. _disposeMesh(mesh: Mesh): void;
  134124. /**
  134125. * Dispose the highlight layer and free resources.
  134126. */
  134127. dispose(): void;
  134128. /**
  134129. * Gets the class name of the effect layer
  134130. * @returns the string with the class name of the effect layer
  134131. */
  134132. getClassName(): string;
  134133. /**
  134134. * Serializes this Highlight layer
  134135. * @returns a serialized Highlight layer object
  134136. */
  134137. serialize(): any;
  134138. /**
  134139. * Creates a Highlight layer from parsed Highlight layer data
  134140. * @param parsedHightlightLayer defines the Highlight layer data
  134141. * @param scene defines the current scene
  134142. * @param rootUrl defines the root URL containing the Highlight layer information
  134143. * @returns a parsed Highlight layer
  134144. */
  134145. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  134146. }
  134147. }
  134148. declare module BABYLON {
  134149. interface AbstractScene {
  134150. /**
  134151. * The list of layers (background and foreground) of the scene
  134152. */
  134153. layers: Array<Layer>;
  134154. }
  134155. /**
  134156. * Defines the layer scene component responsible to manage any layers
  134157. * in a given scene.
  134158. */
  134159. export class LayerSceneComponent implements ISceneComponent {
  134160. /**
  134161. * The component name helpfull to identify the component in the list of scene components.
  134162. */
  134163. readonly name: string;
  134164. /**
  134165. * The scene the component belongs to.
  134166. */
  134167. scene: Scene;
  134168. private _engine;
  134169. /**
  134170. * Creates a new instance of the component for the given scene
  134171. * @param scene Defines the scene to register the component in
  134172. */
  134173. constructor(scene: Scene);
  134174. /**
  134175. * Registers the component in a given scene
  134176. */
  134177. register(): void;
  134178. /**
  134179. * Rebuilds the elements related to this component in case of
  134180. * context lost for instance.
  134181. */
  134182. rebuild(): void;
  134183. /**
  134184. * Disposes the component and the associated ressources.
  134185. */
  134186. dispose(): void;
  134187. private _draw;
  134188. private _drawCameraPredicate;
  134189. private _drawCameraBackground;
  134190. private _drawCameraForeground;
  134191. private _drawRenderTargetPredicate;
  134192. private _drawRenderTargetBackground;
  134193. private _drawRenderTargetForeground;
  134194. /**
  134195. * Adds all the elements from the container to the scene
  134196. * @param container the container holding the elements
  134197. */
  134198. addFromContainer(container: AbstractScene): void;
  134199. /**
  134200. * Removes all the elements in the container from the scene
  134201. * @param container contains the elements to remove
  134202. * @param dispose if the removed element should be disposed (default: false)
  134203. */
  134204. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  134205. }
  134206. }
  134207. declare module BABYLON {
  134208. /** @hidden */
  134209. export var layerPixelShader: {
  134210. name: string;
  134211. shader: string;
  134212. };
  134213. }
  134214. declare module BABYLON {
  134215. /** @hidden */
  134216. export var layerVertexShader: {
  134217. name: string;
  134218. shader: string;
  134219. };
  134220. }
  134221. declare module BABYLON {
  134222. /**
  134223. * This represents a full screen 2d layer.
  134224. * This can be useful to display a picture in the background of your scene for instance.
  134225. * @see https://www.babylonjs-playground.com/#08A2BS#1
  134226. */
  134227. export class Layer {
  134228. /**
  134229. * Define the name of the layer.
  134230. */
  134231. name: string;
  134232. /**
  134233. * Define the texture the layer should display.
  134234. */
  134235. texture: Nullable<Texture>;
  134236. /**
  134237. * Is the layer in background or foreground.
  134238. */
  134239. isBackground: boolean;
  134240. /**
  134241. * Define the color of the layer (instead of texture).
  134242. */
  134243. color: Color4;
  134244. /**
  134245. * Define the scale of the layer in order to zoom in out of the texture.
  134246. */
  134247. scale: Vector2;
  134248. /**
  134249. * Define an offset for the layer in order to shift the texture.
  134250. */
  134251. offset: Vector2;
  134252. /**
  134253. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  134254. */
  134255. alphaBlendingMode: number;
  134256. /**
  134257. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  134258. * Alpha test will not mix with the background color in case of transparency.
  134259. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  134260. */
  134261. alphaTest: boolean;
  134262. /**
  134263. * Define a mask to restrict the layer to only some of the scene cameras.
  134264. */
  134265. layerMask: number;
  134266. /**
  134267. * Define the list of render target the layer is visible into.
  134268. */
  134269. renderTargetTextures: RenderTargetTexture[];
  134270. /**
  134271. * Define if the layer is only used in renderTarget or if it also
  134272. * renders in the main frame buffer of the canvas.
  134273. */
  134274. renderOnlyInRenderTargetTextures: boolean;
  134275. private _scene;
  134276. private _vertexBuffers;
  134277. private _indexBuffer;
  134278. private _effect;
  134279. private _previousDefines;
  134280. /**
  134281. * An event triggered when the layer is disposed.
  134282. */
  134283. onDisposeObservable: Observable<Layer>;
  134284. private _onDisposeObserver;
  134285. /**
  134286. * Back compatibility with callback before the onDisposeObservable existed.
  134287. * The set callback will be triggered when the layer has been disposed.
  134288. */
  134289. set onDispose(callback: () => void);
  134290. /**
  134291. * An event triggered before rendering the scene
  134292. */
  134293. onBeforeRenderObservable: Observable<Layer>;
  134294. private _onBeforeRenderObserver;
  134295. /**
  134296. * Back compatibility with callback before the onBeforeRenderObservable existed.
  134297. * The set callback will be triggered just before rendering the layer.
  134298. */
  134299. set onBeforeRender(callback: () => void);
  134300. /**
  134301. * An event triggered after rendering the scene
  134302. */
  134303. onAfterRenderObservable: Observable<Layer>;
  134304. private _onAfterRenderObserver;
  134305. /**
  134306. * Back compatibility with callback before the onAfterRenderObservable existed.
  134307. * The set callback will be triggered just after rendering the layer.
  134308. */
  134309. set onAfterRender(callback: () => void);
  134310. /**
  134311. * Instantiates a new layer.
  134312. * This represents a full screen 2d layer.
  134313. * This can be useful to display a picture in the background of your scene for instance.
  134314. * @see https://www.babylonjs-playground.com/#08A2BS#1
  134315. * @param name Define the name of the layer in the scene
  134316. * @param imgUrl Define the url of the texture to display in the layer
  134317. * @param scene Define the scene the layer belongs to
  134318. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  134319. * @param color Defines a color for the layer
  134320. */
  134321. constructor(
  134322. /**
  134323. * Define the name of the layer.
  134324. */
  134325. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  134326. private _createIndexBuffer;
  134327. /** @hidden */
  134328. _rebuild(): void;
  134329. /**
  134330. * Renders the layer in the scene.
  134331. */
  134332. render(): void;
  134333. /**
  134334. * Disposes and releases the associated ressources.
  134335. */
  134336. dispose(): void;
  134337. }
  134338. }
  134339. declare module BABYLON {
  134340. /** @hidden */
  134341. export var lensFlarePixelShader: {
  134342. name: string;
  134343. shader: string;
  134344. };
  134345. }
  134346. declare module BABYLON {
  134347. /** @hidden */
  134348. export var lensFlareVertexShader: {
  134349. name: string;
  134350. shader: string;
  134351. };
  134352. }
  134353. declare module BABYLON {
  134354. /**
  134355. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  134356. * It is usually composed of several `lensFlare`.
  134357. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  134358. */
  134359. export class LensFlareSystem {
  134360. /**
  134361. * Define the name of the lens flare system
  134362. */
  134363. name: string;
  134364. /**
  134365. * List of lens flares used in this system.
  134366. */
  134367. lensFlares: LensFlare[];
  134368. /**
  134369. * Define a limit from the border the lens flare can be visible.
  134370. */
  134371. borderLimit: number;
  134372. /**
  134373. * Define a viewport border we do not want to see the lens flare in.
  134374. */
  134375. viewportBorder: number;
  134376. /**
  134377. * Define a predicate which could limit the list of meshes able to occlude the effect.
  134378. */
  134379. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  134380. /**
  134381. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  134382. */
  134383. layerMask: number;
  134384. /**
  134385. * Define the id of the lens flare system in the scene.
  134386. * (equal to name by default)
  134387. */
  134388. id: string;
  134389. private _scene;
  134390. private _emitter;
  134391. private _vertexBuffers;
  134392. private _indexBuffer;
  134393. private _effect;
  134394. private _positionX;
  134395. private _positionY;
  134396. private _isEnabled;
  134397. /** @hidden */
  134398. static _SceneComponentInitialization: (scene: Scene) => void;
  134399. /**
  134400. * Instantiates a lens flare system.
  134401. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  134402. * It is usually composed of several `lensFlare`.
  134403. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  134404. * @param name Define the name of the lens flare system in the scene
  134405. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  134406. * @param scene Define the scene the lens flare system belongs to
  134407. */
  134408. constructor(
  134409. /**
  134410. * Define the name of the lens flare system
  134411. */
  134412. name: string, emitter: any, scene: Scene);
  134413. /**
  134414. * Define if the lens flare system is enabled.
  134415. */
  134416. get isEnabled(): boolean;
  134417. set isEnabled(value: boolean);
  134418. /**
  134419. * Get the scene the effects belongs to.
  134420. * @returns the scene holding the lens flare system
  134421. */
  134422. getScene(): Scene;
  134423. /**
  134424. * Get the emitter of the lens flare system.
  134425. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  134426. * @returns the emitter of the lens flare system
  134427. */
  134428. getEmitter(): any;
  134429. /**
  134430. * Set the emitter of the lens flare system.
  134431. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  134432. * @param newEmitter Define the new emitter of the system
  134433. */
  134434. setEmitter(newEmitter: any): void;
  134435. /**
  134436. * Get the lens flare system emitter position.
  134437. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  134438. * @returns the position
  134439. */
  134440. getEmitterPosition(): Vector3;
  134441. /**
  134442. * @hidden
  134443. */
  134444. computeEffectivePosition(globalViewport: Viewport): boolean;
  134445. /** @hidden */
  134446. _isVisible(): boolean;
  134447. /**
  134448. * @hidden
  134449. */
  134450. render(): boolean;
  134451. /**
  134452. * Dispose and release the lens flare with its associated resources.
  134453. */
  134454. dispose(): void;
  134455. /**
  134456. * Parse a lens flare system from a JSON repressentation
  134457. * @param parsedLensFlareSystem Define the JSON to parse
  134458. * @param scene Define the scene the parsed system should be instantiated in
  134459. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  134460. * @returns the parsed system
  134461. */
  134462. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  134463. /**
  134464. * Serialize the current Lens Flare System into a JSON representation.
  134465. * @returns the serialized JSON
  134466. */
  134467. serialize(): any;
  134468. }
  134469. }
  134470. declare module BABYLON {
  134471. /**
  134472. * This represents one of the lens effect in a `lensFlareSystem`.
  134473. * It controls one of the indiviual texture used in the effect.
  134474. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  134475. */
  134476. export class LensFlare {
  134477. /**
  134478. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  134479. */
  134480. size: number;
  134481. /**
  134482. * 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.
  134483. */
  134484. position: number;
  134485. /**
  134486. * Define the lens color.
  134487. */
  134488. color: Color3;
  134489. /**
  134490. * Define the lens texture.
  134491. */
  134492. texture: Nullable<Texture>;
  134493. /**
  134494. * Define the alpha mode to render this particular lens.
  134495. */
  134496. alphaMode: number;
  134497. private _system;
  134498. /**
  134499. * Creates a new Lens Flare.
  134500. * This represents one of the lens effect in a `lensFlareSystem`.
  134501. * It controls one of the indiviual texture used in the effect.
  134502. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  134503. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  134504. * @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.
  134505. * @param color Define the lens color
  134506. * @param imgUrl Define the lens texture url
  134507. * @param system Define the `lensFlareSystem` this flare is part of
  134508. * @returns The newly created Lens Flare
  134509. */
  134510. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  134511. /**
  134512. * Instantiates a new Lens Flare.
  134513. * This represents one of the lens effect in a `lensFlareSystem`.
  134514. * It controls one of the indiviual texture used in the effect.
  134515. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  134516. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  134517. * @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.
  134518. * @param color Define the lens color
  134519. * @param imgUrl Define the lens texture url
  134520. * @param system Define the `lensFlareSystem` this flare is part of
  134521. */
  134522. constructor(
  134523. /**
  134524. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  134525. */
  134526. size: number,
  134527. /**
  134528. * 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.
  134529. */
  134530. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  134531. /**
  134532. * Dispose and release the lens flare with its associated resources.
  134533. */
  134534. dispose(): void;
  134535. }
  134536. }
  134537. declare module BABYLON {
  134538. interface AbstractScene {
  134539. /**
  134540. * The list of lens flare system added to the scene
  134541. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  134542. */
  134543. lensFlareSystems: Array<LensFlareSystem>;
  134544. /**
  134545. * Removes the given lens flare system from this scene.
  134546. * @param toRemove The lens flare system to remove
  134547. * @returns The index of the removed lens flare system
  134548. */
  134549. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  134550. /**
  134551. * Adds the given lens flare system to this scene
  134552. * @param newLensFlareSystem The lens flare system to add
  134553. */
  134554. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  134555. /**
  134556. * Gets a lens flare system using its name
  134557. * @param name defines the name to look for
  134558. * @returns the lens flare system or null if not found
  134559. */
  134560. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  134561. /**
  134562. * Gets a lens flare system using its id
  134563. * @param id defines the id to look for
  134564. * @returns the lens flare system or null if not found
  134565. */
  134566. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  134567. }
  134568. /**
  134569. * Defines the lens flare scene component responsible to manage any lens flares
  134570. * in a given scene.
  134571. */
  134572. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  134573. /**
  134574. * The component name helpfull to identify the component in the list of scene components.
  134575. */
  134576. readonly name: string;
  134577. /**
  134578. * The scene the component belongs to.
  134579. */
  134580. scene: Scene;
  134581. /**
  134582. * Creates a new instance of the component for the given scene
  134583. * @param scene Defines the scene to register the component in
  134584. */
  134585. constructor(scene: Scene);
  134586. /**
  134587. * Registers the component in a given scene
  134588. */
  134589. register(): void;
  134590. /**
  134591. * Rebuilds the elements related to this component in case of
  134592. * context lost for instance.
  134593. */
  134594. rebuild(): void;
  134595. /**
  134596. * Adds all the elements from the container to the scene
  134597. * @param container the container holding the elements
  134598. */
  134599. addFromContainer(container: AbstractScene): void;
  134600. /**
  134601. * Removes all the elements in the container from the scene
  134602. * @param container contains the elements to remove
  134603. * @param dispose if the removed element should be disposed (default: false)
  134604. */
  134605. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  134606. /**
  134607. * Serializes the component data to the specified json object
  134608. * @param serializationObject The object to serialize to
  134609. */
  134610. serialize(serializationObject: any): void;
  134611. /**
  134612. * Disposes the component and the associated ressources.
  134613. */
  134614. dispose(): void;
  134615. private _draw;
  134616. }
  134617. }
  134618. declare module BABYLON {
  134619. /** @hidden */
  134620. export var depthPixelShader: {
  134621. name: string;
  134622. shader: string;
  134623. };
  134624. }
  134625. declare module BABYLON {
  134626. /** @hidden */
  134627. export var depthVertexShader: {
  134628. name: string;
  134629. shader: string;
  134630. };
  134631. }
  134632. declare module BABYLON {
  134633. /**
  134634. * This represents a depth renderer in Babylon.
  134635. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  134636. */
  134637. export class DepthRenderer {
  134638. private _scene;
  134639. private _depthMap;
  134640. private _effect;
  134641. private readonly _storeNonLinearDepth;
  134642. private readonly _clearColor;
  134643. /** Get if the depth renderer is using packed depth or not */
  134644. readonly isPacked: boolean;
  134645. private _cachedDefines;
  134646. private _camera;
  134647. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  134648. enabled: boolean;
  134649. /**
  134650. * Specifiess that the depth renderer will only be used within
  134651. * the camera it is created for.
  134652. * This can help forcing its rendering during the camera processing.
  134653. */
  134654. useOnlyInActiveCamera: boolean;
  134655. /** @hidden */
  134656. static _SceneComponentInitialization: (scene: Scene) => void;
  134657. /**
  134658. * Instantiates a depth renderer
  134659. * @param scene The scene the renderer belongs to
  134660. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  134661. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  134662. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  134663. */
  134664. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  134665. /**
  134666. * Creates the depth rendering effect and checks if the effect is ready.
  134667. * @param subMesh The submesh to be used to render the depth map of
  134668. * @param useInstances If multiple world instances should be used
  134669. * @returns if the depth renderer is ready to render the depth map
  134670. */
  134671. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  134672. /**
  134673. * Gets the texture which the depth map will be written to.
  134674. * @returns The depth map texture
  134675. */
  134676. getDepthMap(): RenderTargetTexture;
  134677. /**
  134678. * Disposes of the depth renderer.
  134679. */
  134680. dispose(): void;
  134681. }
  134682. }
  134683. declare module BABYLON {
  134684. /** @hidden */
  134685. export var minmaxReduxPixelShader: {
  134686. name: string;
  134687. shader: string;
  134688. };
  134689. }
  134690. declare module BABYLON {
  134691. /**
  134692. * This class computes a min/max reduction from a texture: it means it computes the minimum
  134693. * and maximum values from all values of the texture.
  134694. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  134695. * The source values are read from the red channel of the texture.
  134696. */
  134697. export class MinMaxReducer {
  134698. /**
  134699. * Observable triggered when the computation has been performed
  134700. */
  134701. onAfterReductionPerformed: Observable<{
  134702. min: number;
  134703. max: number;
  134704. }>;
  134705. protected _camera: Camera;
  134706. protected _sourceTexture: Nullable<RenderTargetTexture>;
  134707. protected _reductionSteps: Nullable<Array<PostProcess>>;
  134708. protected _postProcessManager: PostProcessManager;
  134709. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  134710. protected _forceFullscreenViewport: boolean;
  134711. /**
  134712. * Creates a min/max reducer
  134713. * @param camera The camera to use for the post processes
  134714. */
  134715. constructor(camera: Camera);
  134716. /**
  134717. * Gets the texture used to read the values from.
  134718. */
  134719. get sourceTexture(): Nullable<RenderTargetTexture>;
  134720. /**
  134721. * Sets the source texture to read the values from.
  134722. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  134723. * because in such textures '1' value must not be taken into account to compute the maximum
  134724. * as this value is used to clear the texture.
  134725. * Note that the computation is not activated by calling this function, you must call activate() for that!
  134726. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  134727. * @param depthRedux Indicates if the texture is a depth texture or not
  134728. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  134729. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  134730. */
  134731. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  134732. /**
  134733. * Defines the refresh rate of the computation.
  134734. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  134735. */
  134736. get refreshRate(): number;
  134737. set refreshRate(value: number);
  134738. protected _activated: boolean;
  134739. /**
  134740. * Gets the activation status of the reducer
  134741. */
  134742. get activated(): boolean;
  134743. /**
  134744. * Activates the reduction computation.
  134745. * When activated, the observers registered in onAfterReductionPerformed are
  134746. * called after the compuation is performed
  134747. */
  134748. activate(): void;
  134749. /**
  134750. * Deactivates the reduction computation.
  134751. */
  134752. deactivate(): void;
  134753. /**
  134754. * Disposes the min/max reducer
  134755. * @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.
  134756. */
  134757. dispose(disposeAll?: boolean): void;
  134758. }
  134759. }
  134760. declare module BABYLON {
  134761. /**
  134762. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  134763. */
  134764. export class DepthReducer extends MinMaxReducer {
  134765. private _depthRenderer;
  134766. private _depthRendererId;
  134767. /**
  134768. * Gets the depth renderer used for the computation.
  134769. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  134770. */
  134771. get depthRenderer(): Nullable<DepthRenderer>;
  134772. /**
  134773. * Creates a depth reducer
  134774. * @param camera The camera used to render the depth texture
  134775. */
  134776. constructor(camera: Camera);
  134777. /**
  134778. * Sets the depth renderer to use to generate the depth map
  134779. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  134780. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  134781. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  134782. */
  134783. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  134784. /** @hidden */
  134785. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  134786. /**
  134787. * Activates the reduction computation.
  134788. * When activated, the observers registered in onAfterReductionPerformed are
  134789. * called after the compuation is performed
  134790. */
  134791. activate(): void;
  134792. /**
  134793. * Deactivates the reduction computation.
  134794. */
  134795. deactivate(): void;
  134796. /**
  134797. * Disposes the depth reducer
  134798. * @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.
  134799. */
  134800. dispose(disposeAll?: boolean): void;
  134801. }
  134802. }
  134803. declare module BABYLON {
  134804. /**
  134805. * A CSM implementation allowing casting shadows on large scenes.
  134806. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  134807. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  134808. */
  134809. export class CascadedShadowGenerator extends ShadowGenerator {
  134810. private static readonly frustumCornersNDCSpace;
  134811. /**
  134812. * Name of the CSM class
  134813. */
  134814. static CLASSNAME: string;
  134815. /**
  134816. * Defines the default number of cascades used by the CSM.
  134817. */
  134818. static readonly DEFAULT_CASCADES_COUNT: number;
  134819. /**
  134820. * Defines the minimum number of cascades used by the CSM.
  134821. */
  134822. static readonly MIN_CASCADES_COUNT: number;
  134823. /**
  134824. * Defines the maximum number of cascades used by the CSM.
  134825. */
  134826. static readonly MAX_CASCADES_COUNT: number;
  134827. protected _validateFilter(filter: number): number;
  134828. /**
  134829. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  134830. */
  134831. penumbraDarkness: number;
  134832. private _numCascades;
  134833. /**
  134834. * Gets or set the number of cascades used by the CSM.
  134835. */
  134836. get numCascades(): number;
  134837. set numCascades(value: number);
  134838. /**
  134839. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  134840. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  134841. */
  134842. stabilizeCascades: boolean;
  134843. private _freezeShadowCastersBoundingInfo;
  134844. private _freezeShadowCastersBoundingInfoObservable;
  134845. /**
  134846. * Enables or disables the shadow casters bounding info computation.
  134847. * If your shadow casters don't move, you can disable this feature.
  134848. * If it is enabled, the bounding box computation is done every frame.
  134849. */
  134850. get freezeShadowCastersBoundingInfo(): boolean;
  134851. set freezeShadowCastersBoundingInfo(freeze: boolean);
  134852. private _scbiMin;
  134853. private _scbiMax;
  134854. protected _computeShadowCastersBoundingInfo(): void;
  134855. protected _shadowCastersBoundingInfo: BoundingInfo;
  134856. /**
  134857. * Gets or sets the shadow casters bounding info.
  134858. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  134859. * so that the system won't overwrite the bounds you provide
  134860. */
  134861. get shadowCastersBoundingInfo(): BoundingInfo;
  134862. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  134863. protected _breaksAreDirty: boolean;
  134864. protected _minDistance: number;
  134865. protected _maxDistance: number;
  134866. /**
  134867. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  134868. *
  134869. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  134870. * If you don't know these values, simply leave them to their defaults and don't call this function.
  134871. * @param min minimal distance for the breaks (default to 0.)
  134872. * @param max maximal distance for the breaks (default to 1.)
  134873. */
  134874. setMinMaxDistance(min: number, max: number): void;
  134875. /** Gets the minimal distance used in the cascade break computation */
  134876. get minDistance(): number;
  134877. /** Gets the maximal distance used in the cascade break computation */
  134878. get maxDistance(): number;
  134879. /**
  134880. * Gets the class name of that object
  134881. * @returns "CascadedShadowGenerator"
  134882. */
  134883. getClassName(): string;
  134884. private _cascadeMinExtents;
  134885. private _cascadeMaxExtents;
  134886. /**
  134887. * Gets a cascade minimum extents
  134888. * @param cascadeIndex index of the cascade
  134889. * @returns the minimum cascade extents
  134890. */
  134891. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  134892. /**
  134893. * Gets a cascade maximum extents
  134894. * @param cascadeIndex index of the cascade
  134895. * @returns the maximum cascade extents
  134896. */
  134897. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  134898. private _cascades;
  134899. private _currentLayer;
  134900. private _viewSpaceFrustumsZ;
  134901. private _viewMatrices;
  134902. private _projectionMatrices;
  134903. private _transformMatrices;
  134904. private _transformMatricesAsArray;
  134905. private _frustumLengths;
  134906. private _lightSizeUVCorrection;
  134907. private _depthCorrection;
  134908. private _frustumCornersWorldSpace;
  134909. private _frustumCenter;
  134910. private _shadowCameraPos;
  134911. private _shadowMaxZ;
  134912. /**
  134913. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  134914. * It defaults to camera.maxZ
  134915. */
  134916. get shadowMaxZ(): number;
  134917. /**
  134918. * Sets the shadow max z distance.
  134919. */
  134920. set shadowMaxZ(value: number);
  134921. protected _debug: boolean;
  134922. /**
  134923. * Gets or sets the debug flag.
  134924. * When enabled, the cascades are materialized by different colors on the screen.
  134925. */
  134926. get debug(): boolean;
  134927. set debug(dbg: boolean);
  134928. private _depthClamp;
  134929. /**
  134930. * Gets or sets the depth clamping value.
  134931. *
  134932. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  134933. * to account for the shadow casters far away.
  134934. *
  134935. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  134936. */
  134937. get depthClamp(): boolean;
  134938. set depthClamp(value: boolean);
  134939. private _cascadeBlendPercentage;
  134940. /**
  134941. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  134942. * It defaults to 0.1 (10% blending).
  134943. */
  134944. get cascadeBlendPercentage(): number;
  134945. set cascadeBlendPercentage(value: number);
  134946. private _lambda;
  134947. /**
  134948. * Gets or set the lambda parameter.
  134949. * This parameter is used to split the camera frustum and create the cascades.
  134950. * 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.
  134951. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  134952. */
  134953. get lambda(): number;
  134954. set lambda(value: number);
  134955. /**
  134956. * Gets the view matrix corresponding to a given cascade
  134957. * @param cascadeNum cascade to retrieve the view matrix from
  134958. * @returns the cascade view matrix
  134959. */
  134960. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  134961. /**
  134962. * Gets the projection matrix corresponding to a given cascade
  134963. * @param cascadeNum cascade to retrieve the projection matrix from
  134964. * @returns the cascade projection matrix
  134965. */
  134966. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  134967. /**
  134968. * Gets the transformation matrix corresponding to a given cascade
  134969. * @param cascadeNum cascade to retrieve the transformation matrix from
  134970. * @returns the cascade transformation matrix
  134971. */
  134972. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  134973. private _depthRenderer;
  134974. /**
  134975. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  134976. *
  134977. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  134978. *
  134979. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  134980. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  134981. * @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
  134982. */
  134983. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  134984. private _depthReducer;
  134985. private _autoCalcDepthBounds;
  134986. /**
  134987. * Gets or sets the autoCalcDepthBounds property.
  134988. *
  134989. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  134990. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  134991. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  134992. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  134993. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  134994. */
  134995. get autoCalcDepthBounds(): boolean;
  134996. set autoCalcDepthBounds(value: boolean);
  134997. /**
  134998. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  134999. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  135000. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  135001. * for setting the refresh rate on the renderer yourself!
  135002. */
  135003. get autoCalcDepthBoundsRefreshRate(): number;
  135004. set autoCalcDepthBoundsRefreshRate(value: number);
  135005. /**
  135006. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  135007. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  135008. * you change the camera near/far planes!
  135009. */
  135010. splitFrustum(): void;
  135011. private _splitFrustum;
  135012. private _computeMatrices;
  135013. private _computeFrustumInWorldSpace;
  135014. private _computeCascadeFrustum;
  135015. /**
  135016. * Support test.
  135017. */
  135018. static get IsSupported(): boolean;
  135019. /** @hidden */
  135020. static _SceneComponentInitialization: (scene: Scene) => void;
  135021. /**
  135022. * Creates a Cascaded Shadow Generator object.
  135023. * A ShadowGenerator is the required tool to use the shadows.
  135024. * Each directional light casting shadows needs to use its own ShadowGenerator.
  135025. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  135026. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  135027. * @param light The directional light object generating the shadows.
  135028. * @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.
  135029. */
  135030. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  135031. protected _initializeGenerator(): void;
  135032. protected _createTargetRenderTexture(): void;
  135033. protected _initializeShadowMap(): void;
  135034. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  135035. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  135036. /**
  135037. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  135038. * @param defines Defines of the material we want to update
  135039. * @param lightIndex Index of the light in the enabled light list of the material
  135040. */
  135041. prepareDefines(defines: any, lightIndex: number): void;
  135042. /**
  135043. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  135044. * defined in the generator but impacting the effect).
  135045. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  135046. * @param effect The effect we are binfing the information for
  135047. */
  135048. bindShadowLight(lightIndex: string, effect: Effect): void;
  135049. /**
  135050. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  135051. * (eq to view projection * shadow projection matrices)
  135052. * @returns The transform matrix used to create the shadow map
  135053. */
  135054. getTransformMatrix(): Matrix;
  135055. /**
  135056. * Disposes the ShadowGenerator.
  135057. * Returns nothing.
  135058. */
  135059. dispose(): void;
  135060. /**
  135061. * Serializes the shadow generator setup to a json object.
  135062. * @returns The serialized JSON object
  135063. */
  135064. serialize(): any;
  135065. /**
  135066. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  135067. * @param parsedShadowGenerator The JSON object to parse
  135068. * @param scene The scene to create the shadow map for
  135069. * @returns The parsed shadow generator
  135070. */
  135071. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  135072. }
  135073. }
  135074. declare module BABYLON {
  135075. /**
  135076. * Defines the shadow generator component responsible to manage any shadow generators
  135077. * in a given scene.
  135078. */
  135079. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  135080. /**
  135081. * The component name helpfull to identify the component in the list of scene components.
  135082. */
  135083. readonly name: string;
  135084. /**
  135085. * The scene the component belongs to.
  135086. */
  135087. scene: Scene;
  135088. /**
  135089. * Creates a new instance of the component for the given scene
  135090. * @param scene Defines the scene to register the component in
  135091. */
  135092. constructor(scene: Scene);
  135093. /**
  135094. * Registers the component in a given scene
  135095. */
  135096. register(): void;
  135097. /**
  135098. * Rebuilds the elements related to this component in case of
  135099. * context lost for instance.
  135100. */
  135101. rebuild(): void;
  135102. /**
  135103. * Serializes the component data to the specified json object
  135104. * @param serializationObject The object to serialize to
  135105. */
  135106. serialize(serializationObject: any): void;
  135107. /**
  135108. * Adds all the elements from the container to the scene
  135109. * @param container the container holding the elements
  135110. */
  135111. addFromContainer(container: AbstractScene): void;
  135112. /**
  135113. * Removes all the elements in the container from the scene
  135114. * @param container contains the elements to remove
  135115. * @param dispose if the removed element should be disposed (default: false)
  135116. */
  135117. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  135118. /**
  135119. * Rebuilds the elements related to this component in case of
  135120. * context lost for instance.
  135121. */
  135122. dispose(): void;
  135123. private _gatherRenderTargets;
  135124. }
  135125. }
  135126. declare module BABYLON {
  135127. /**
  135128. * A point light is a light defined by an unique point in world space.
  135129. * The light is emitted in every direction from this point.
  135130. * A good example of a point light is a standard light bulb.
  135131. * Documentation: https://doc.babylonjs.com/babylon101/lights
  135132. */
  135133. export class PointLight extends ShadowLight {
  135134. private _shadowAngle;
  135135. /**
  135136. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  135137. * This specifies what angle the shadow will use to be created.
  135138. *
  135139. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  135140. */
  135141. get shadowAngle(): number;
  135142. /**
  135143. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  135144. * This specifies what angle the shadow will use to be created.
  135145. *
  135146. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  135147. */
  135148. set shadowAngle(value: number);
  135149. /**
  135150. * Gets the direction if it has been set.
  135151. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  135152. */
  135153. get direction(): Vector3;
  135154. /**
  135155. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  135156. */
  135157. set direction(value: Vector3);
  135158. /**
  135159. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  135160. * A PointLight emits the light in every direction.
  135161. * It can cast shadows.
  135162. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  135163. * ```javascript
  135164. * var pointLight = new PointLight("pl", camera.position, scene);
  135165. * ```
  135166. * Documentation : https://doc.babylonjs.com/babylon101/lights
  135167. * @param name The light friendly name
  135168. * @param position The position of the point light in the scene
  135169. * @param scene The scene the lights belongs to
  135170. */
  135171. constructor(name: string, position: Vector3, scene: Scene);
  135172. /**
  135173. * Returns the string "PointLight"
  135174. * @returns the class name
  135175. */
  135176. getClassName(): string;
  135177. /**
  135178. * Returns the integer 0.
  135179. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  135180. */
  135181. getTypeID(): number;
  135182. /**
  135183. * Specifies wether or not the shadowmap should be a cube texture.
  135184. * @returns true if the shadowmap needs to be a cube texture.
  135185. */
  135186. needCube(): boolean;
  135187. /**
  135188. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  135189. * @param faceIndex The index of the face we are computed the direction to generate shadow
  135190. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  135191. */
  135192. getShadowDirection(faceIndex?: number): Vector3;
  135193. /**
  135194. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  135195. * - fov = PI / 2
  135196. * - aspect ratio : 1.0
  135197. * - z-near and far equal to the active camera minZ and maxZ.
  135198. * Returns the PointLight.
  135199. */
  135200. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  135201. protected _buildUniformLayout(): void;
  135202. /**
  135203. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  135204. * @param effect The effect to update
  135205. * @param lightIndex The index of the light in the effect to update
  135206. * @returns The point light
  135207. */
  135208. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  135209. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  135210. /**
  135211. * Prepares the list of defines specific to the light type.
  135212. * @param defines the list of defines
  135213. * @param lightIndex defines the index of the light for the effect
  135214. */
  135215. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  135216. }
  135217. }
  135218. declare module BABYLON {
  135219. /**
  135220. * Header information of HDR texture files.
  135221. */
  135222. export interface HDRInfo {
  135223. /**
  135224. * The height of the texture in pixels.
  135225. */
  135226. height: number;
  135227. /**
  135228. * The width of the texture in pixels.
  135229. */
  135230. width: number;
  135231. /**
  135232. * The index of the beginning of the data in the binary file.
  135233. */
  135234. dataPosition: number;
  135235. }
  135236. /**
  135237. * This groups tools to convert HDR texture to native colors array.
  135238. */
  135239. export class HDRTools {
  135240. private static Ldexp;
  135241. private static Rgbe2float;
  135242. private static readStringLine;
  135243. /**
  135244. * Reads header information from an RGBE texture stored in a native array.
  135245. * More information on this format are available here:
  135246. * https://en.wikipedia.org/wiki/RGBE_image_format
  135247. *
  135248. * @param uint8array The binary file stored in native array.
  135249. * @return The header information.
  135250. */
  135251. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  135252. /**
  135253. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  135254. * This RGBE texture needs to store the information as a panorama.
  135255. *
  135256. * More information on this format are available here:
  135257. * https://en.wikipedia.org/wiki/RGBE_image_format
  135258. *
  135259. * @param buffer The binary file stored in an array buffer.
  135260. * @param size The expected size of the extracted cubemap.
  135261. * @return The Cube Map information.
  135262. */
  135263. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  135264. /**
  135265. * Returns the pixels data extracted from an RGBE texture.
  135266. * This pixels will be stored left to right up to down in the R G B order in one array.
  135267. *
  135268. * More information on this format are available here:
  135269. * https://en.wikipedia.org/wiki/RGBE_image_format
  135270. *
  135271. * @param uint8array The binary file stored in an array buffer.
  135272. * @param hdrInfo The header information of the file.
  135273. * @return The pixels data in RGB right to left up to down order.
  135274. */
  135275. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  135276. private static RGBE_ReadPixels_RLE;
  135277. }
  135278. }
  135279. declare module BABYLON {
  135280. /**
  135281. * Effect Render Options
  135282. */
  135283. export interface IEffectRendererOptions {
  135284. /**
  135285. * Defines the vertices positions.
  135286. */
  135287. positions?: number[];
  135288. /**
  135289. * Defines the indices.
  135290. */
  135291. indices?: number[];
  135292. }
  135293. /**
  135294. * Helper class to render one or more effects.
  135295. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  135296. */
  135297. export class EffectRenderer {
  135298. private engine;
  135299. private static _DefaultOptions;
  135300. private _vertexBuffers;
  135301. private _indexBuffer;
  135302. private _fullscreenViewport;
  135303. /**
  135304. * Creates an effect renderer
  135305. * @param engine the engine to use for rendering
  135306. * @param options defines the options of the effect renderer
  135307. */
  135308. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  135309. /**
  135310. * Sets the current viewport in normalized coordinates 0-1
  135311. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  135312. */
  135313. setViewport(viewport?: Viewport): void;
  135314. /**
  135315. * Binds the embedded attributes buffer to the effect.
  135316. * @param effect Defines the effect to bind the attributes for
  135317. */
  135318. bindBuffers(effect: Effect): void;
  135319. /**
  135320. * Sets the current effect wrapper to use during draw.
  135321. * The effect needs to be ready before calling this api.
  135322. * This also sets the default full screen position attribute.
  135323. * @param effectWrapper Defines the effect to draw with
  135324. */
  135325. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  135326. /**
  135327. * Restores engine states
  135328. */
  135329. restoreStates(): void;
  135330. /**
  135331. * Draws a full screen quad.
  135332. */
  135333. draw(): void;
  135334. private isRenderTargetTexture;
  135335. /**
  135336. * renders one or more effects to a specified texture
  135337. * @param effectWrapper the effect to renderer
  135338. * @param outputTexture texture to draw to, if null it will render to the screen.
  135339. */
  135340. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  135341. /**
  135342. * Disposes of the effect renderer
  135343. */
  135344. dispose(): void;
  135345. }
  135346. /**
  135347. * Options to create an EffectWrapper
  135348. */
  135349. interface EffectWrapperCreationOptions {
  135350. /**
  135351. * Engine to use to create the effect
  135352. */
  135353. engine: ThinEngine;
  135354. /**
  135355. * Fragment shader for the effect
  135356. */
  135357. fragmentShader: string;
  135358. /**
  135359. * Use the shader store instead of direct source code
  135360. */
  135361. useShaderStore?: boolean;
  135362. /**
  135363. * Vertex shader for the effect
  135364. */
  135365. vertexShader?: string;
  135366. /**
  135367. * Attributes to use in the shader
  135368. */
  135369. attributeNames?: Array<string>;
  135370. /**
  135371. * Uniforms to use in the shader
  135372. */
  135373. uniformNames?: Array<string>;
  135374. /**
  135375. * Texture sampler names to use in the shader
  135376. */
  135377. samplerNames?: Array<string>;
  135378. /**
  135379. * Defines to use in the shader
  135380. */
  135381. defines?: Array<string>;
  135382. /**
  135383. * Callback when effect is compiled
  135384. */
  135385. onCompiled?: Nullable<(effect: Effect) => void>;
  135386. /**
  135387. * The friendly name of the effect displayed in Spector.
  135388. */
  135389. name?: string;
  135390. }
  135391. /**
  135392. * Wraps an effect to be used for rendering
  135393. */
  135394. export class EffectWrapper {
  135395. /**
  135396. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  135397. */
  135398. onApplyObservable: Observable<{}>;
  135399. /**
  135400. * The underlying effect
  135401. */
  135402. effect: Effect;
  135403. /**
  135404. * Creates an effect to be renderer
  135405. * @param creationOptions options to create the effect
  135406. */
  135407. constructor(creationOptions: EffectWrapperCreationOptions);
  135408. /**
  135409. * Disposes of the effect wrapper
  135410. */
  135411. dispose(): void;
  135412. }
  135413. }
  135414. declare module BABYLON {
  135415. /** @hidden */
  135416. export var hdrFilteringVertexShader: {
  135417. name: string;
  135418. shader: string;
  135419. };
  135420. }
  135421. declare module BABYLON {
  135422. /** @hidden */
  135423. export var hdrFilteringPixelShader: {
  135424. name: string;
  135425. shader: string;
  135426. };
  135427. }
  135428. declare module BABYLON {
  135429. /**
  135430. * Options for texture filtering
  135431. */
  135432. interface IHDRFilteringOptions {
  135433. /**
  135434. * Scales pixel intensity for the input HDR map.
  135435. */
  135436. hdrScale?: number;
  135437. /**
  135438. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  135439. */
  135440. quality?: number;
  135441. }
  135442. /**
  135443. * Filters HDR maps to get correct renderings of PBR reflections
  135444. */
  135445. export class HDRFiltering {
  135446. private _engine;
  135447. private _effectRenderer;
  135448. private _effectWrapper;
  135449. private _lodGenerationOffset;
  135450. private _lodGenerationScale;
  135451. /**
  135452. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  135453. * you care about baking speed.
  135454. */
  135455. quality: number;
  135456. /**
  135457. * Scales pixel intensity for the input HDR map.
  135458. */
  135459. hdrScale: number;
  135460. /**
  135461. * Instantiates HDR filter for reflection maps
  135462. *
  135463. * @param engine Thin engine
  135464. * @param options Options
  135465. */
  135466. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  135467. private _createRenderTarget;
  135468. private _prefilterInternal;
  135469. private _createEffect;
  135470. /**
  135471. * Get a value indicating if the filter is ready to be used
  135472. * @param texture Texture to filter
  135473. * @returns true if the filter is ready
  135474. */
  135475. isReady(texture: BaseTexture): boolean;
  135476. /**
  135477. * Prefilters a cube texture to have mipmap levels representing roughness values.
  135478. * Prefiltering will be invoked at the end of next rendering pass.
  135479. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  135480. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  135481. * @param texture Texture to filter
  135482. * @param onFinished Callback when filtering is done
  135483. * @return Promise called when prefiltering is done
  135484. */
  135485. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  135486. }
  135487. }
  135488. declare module BABYLON {
  135489. /**
  135490. * This represents a texture coming from an HDR input.
  135491. *
  135492. * The only supported format is currently panorama picture stored in RGBE format.
  135493. * Example of such files can be found on HDRLib: http://hdrlib.com/
  135494. */
  135495. export class HDRCubeTexture extends BaseTexture {
  135496. private static _facesMapping;
  135497. private _generateHarmonics;
  135498. private _noMipmap;
  135499. private _prefilterOnLoad;
  135500. private _textureMatrix;
  135501. private _size;
  135502. private _onLoad;
  135503. private _onError;
  135504. /**
  135505. * The texture URL.
  135506. */
  135507. url: string;
  135508. /**
  135509. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  135510. */
  135511. coordinatesMode: number;
  135512. protected _isBlocking: boolean;
  135513. /**
  135514. * Sets wether or not the texture is blocking during loading.
  135515. */
  135516. set isBlocking(value: boolean);
  135517. /**
  135518. * Gets wether or not the texture is blocking during loading.
  135519. */
  135520. get isBlocking(): boolean;
  135521. protected _rotationY: number;
  135522. /**
  135523. * Sets texture matrix rotation angle around Y axis in radians.
  135524. */
  135525. set rotationY(value: number);
  135526. /**
  135527. * Gets texture matrix rotation angle around Y axis radians.
  135528. */
  135529. get rotationY(): number;
  135530. /**
  135531. * Gets or sets the center of the bounding box associated with the cube texture
  135532. * It must define where the camera used to render the texture was set
  135533. */
  135534. boundingBoxPosition: Vector3;
  135535. private _boundingBoxSize;
  135536. /**
  135537. * Gets or sets the size of the bounding box associated with the cube texture
  135538. * When defined, the cubemap will switch to local mode
  135539. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  135540. * @example https://www.babylonjs-playground.com/#RNASML
  135541. */
  135542. set boundingBoxSize(value: Vector3);
  135543. get boundingBoxSize(): Vector3;
  135544. /**
  135545. * Instantiates an HDRTexture from the following parameters.
  135546. *
  135547. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  135548. * @param sceneOrEngine The scene or engine the texture will be used in
  135549. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  135550. * @param noMipmap Forces to not generate the mipmap if true
  135551. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  135552. * @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)
  135553. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  135554. */
  135555. 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>);
  135556. /**
  135557. * Get the current class name of the texture useful for serialization or dynamic coding.
  135558. * @returns "HDRCubeTexture"
  135559. */
  135560. getClassName(): string;
  135561. /**
  135562. * Occurs when the file is raw .hdr file.
  135563. */
  135564. private loadTexture;
  135565. clone(): HDRCubeTexture;
  135566. delayLoad(): void;
  135567. /**
  135568. * Get the texture reflection matrix used to rotate/transform the reflection.
  135569. * @returns the reflection matrix
  135570. */
  135571. getReflectionTextureMatrix(): Matrix;
  135572. /**
  135573. * Set the texture reflection matrix used to rotate/transform the reflection.
  135574. * @param value Define the reflection matrix to set
  135575. */
  135576. setReflectionTextureMatrix(value: Matrix): void;
  135577. /**
  135578. * Parses a JSON representation of an HDR Texture in order to create the texture
  135579. * @param parsedTexture Define the JSON representation
  135580. * @param scene Define the scene the texture should be created in
  135581. * @param rootUrl Define the root url in case we need to load relative dependencies
  135582. * @returns the newly created texture after parsing
  135583. */
  135584. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  135585. serialize(): any;
  135586. }
  135587. }
  135588. declare module BABYLON {
  135589. /**
  135590. * Class used to control physics engine
  135591. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  135592. */
  135593. export class PhysicsEngine implements IPhysicsEngine {
  135594. private _physicsPlugin;
  135595. /**
  135596. * Global value used to control the smallest number supported by the simulation
  135597. */
  135598. static Epsilon: number;
  135599. private _impostors;
  135600. private _joints;
  135601. private _subTimeStep;
  135602. /**
  135603. * Gets the gravity vector used by the simulation
  135604. */
  135605. gravity: Vector3;
  135606. /**
  135607. * Factory used to create the default physics plugin.
  135608. * @returns The default physics plugin
  135609. */
  135610. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  135611. /**
  135612. * Creates a new Physics Engine
  135613. * @param gravity defines the gravity vector used by the simulation
  135614. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  135615. */
  135616. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  135617. /**
  135618. * Sets the gravity vector used by the simulation
  135619. * @param gravity defines the gravity vector to use
  135620. */
  135621. setGravity(gravity: Vector3): void;
  135622. /**
  135623. * Set the time step of the physics engine.
  135624. * Default is 1/60.
  135625. * To slow it down, enter 1/600 for example.
  135626. * To speed it up, 1/30
  135627. * @param newTimeStep defines the new timestep to apply to this world.
  135628. */
  135629. setTimeStep(newTimeStep?: number): void;
  135630. /**
  135631. * Get the time step of the physics engine.
  135632. * @returns the current time step
  135633. */
  135634. getTimeStep(): number;
  135635. /**
  135636. * Set the sub time step of the physics engine.
  135637. * Default is 0 meaning there is no sub steps
  135638. * To increase physics resolution precision, set a small value (like 1 ms)
  135639. * @param subTimeStep defines the new sub timestep used for physics resolution.
  135640. */
  135641. setSubTimeStep(subTimeStep?: number): void;
  135642. /**
  135643. * Get the sub time step of the physics engine.
  135644. * @returns the current sub time step
  135645. */
  135646. getSubTimeStep(): number;
  135647. /**
  135648. * Release all resources
  135649. */
  135650. dispose(): void;
  135651. /**
  135652. * Gets the name of the current physics plugin
  135653. * @returns the name of the plugin
  135654. */
  135655. getPhysicsPluginName(): string;
  135656. /**
  135657. * Adding a new impostor for the impostor tracking.
  135658. * This will be done by the impostor itself.
  135659. * @param impostor the impostor to add
  135660. */
  135661. addImpostor(impostor: PhysicsImpostor): void;
  135662. /**
  135663. * Remove an impostor from the engine.
  135664. * This impostor and its mesh will not longer be updated by the physics engine.
  135665. * @param impostor the impostor to remove
  135666. */
  135667. removeImpostor(impostor: PhysicsImpostor): void;
  135668. /**
  135669. * Add a joint to the physics engine
  135670. * @param mainImpostor defines the main impostor to which the joint is added.
  135671. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  135672. * @param joint defines the joint that will connect both impostors.
  135673. */
  135674. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  135675. /**
  135676. * Removes a joint from the simulation
  135677. * @param mainImpostor defines the impostor used with the joint
  135678. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  135679. * @param joint defines the joint to remove
  135680. */
  135681. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  135682. /**
  135683. * Called by the scene. No need to call it.
  135684. * @param delta defines the timespam between frames
  135685. */
  135686. _step(delta: number): void;
  135687. /**
  135688. * Gets the current plugin used to run the simulation
  135689. * @returns current plugin
  135690. */
  135691. getPhysicsPlugin(): IPhysicsEnginePlugin;
  135692. /**
  135693. * Gets the list of physic impostors
  135694. * @returns an array of PhysicsImpostor
  135695. */
  135696. getImpostors(): Array<PhysicsImpostor>;
  135697. /**
  135698. * Gets the impostor for a physics enabled object
  135699. * @param object defines the object impersonated by the impostor
  135700. * @returns the PhysicsImpostor or null if not found
  135701. */
  135702. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  135703. /**
  135704. * Gets the impostor for a physics body object
  135705. * @param body defines physics body used by the impostor
  135706. * @returns the PhysicsImpostor or null if not found
  135707. */
  135708. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  135709. /**
  135710. * Does a raycast in the physics world
  135711. * @param from when should the ray start?
  135712. * @param to when should the ray end?
  135713. * @returns PhysicsRaycastResult
  135714. */
  135715. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  135716. }
  135717. }
  135718. declare module BABYLON {
  135719. /** @hidden */
  135720. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  135721. private _useDeltaForWorldStep;
  135722. world: any;
  135723. name: string;
  135724. private _physicsMaterials;
  135725. private _fixedTimeStep;
  135726. private _cannonRaycastResult;
  135727. private _raycastResult;
  135728. private _physicsBodysToRemoveAfterStep;
  135729. private _firstFrame;
  135730. BJSCANNON: any;
  135731. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  135732. setGravity(gravity: Vector3): void;
  135733. setTimeStep(timeStep: number): void;
  135734. getTimeStep(): number;
  135735. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  135736. private _removeMarkedPhysicsBodiesFromWorld;
  135737. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  135738. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  135739. generatePhysicsBody(impostor: PhysicsImpostor): void;
  135740. private _processChildMeshes;
  135741. removePhysicsBody(impostor: PhysicsImpostor): void;
  135742. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  135743. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  135744. private _addMaterial;
  135745. private _checkWithEpsilon;
  135746. private _createShape;
  135747. private _createHeightmap;
  135748. private _minus90X;
  135749. private _plus90X;
  135750. private _tmpPosition;
  135751. private _tmpDeltaPosition;
  135752. private _tmpUnityRotation;
  135753. private _updatePhysicsBodyTransformation;
  135754. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  135755. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  135756. isSupported(): boolean;
  135757. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  135758. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  135759. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  135760. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  135761. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  135762. getBodyMass(impostor: PhysicsImpostor): number;
  135763. getBodyFriction(impostor: PhysicsImpostor): number;
  135764. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  135765. getBodyRestitution(impostor: PhysicsImpostor): number;
  135766. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  135767. sleepBody(impostor: PhysicsImpostor): void;
  135768. wakeUpBody(impostor: PhysicsImpostor): void;
  135769. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  135770. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  135771. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  135772. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  135773. getRadius(impostor: PhysicsImpostor): number;
  135774. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  135775. dispose(): void;
  135776. private _extendNamespace;
  135777. /**
  135778. * Does a raycast in the physics world
  135779. * @param from when should the ray start?
  135780. * @param to when should the ray end?
  135781. * @returns PhysicsRaycastResult
  135782. */
  135783. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  135784. }
  135785. }
  135786. declare module BABYLON {
  135787. /** @hidden */
  135788. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  135789. private _useDeltaForWorldStep;
  135790. world: any;
  135791. name: string;
  135792. BJSOIMO: any;
  135793. private _raycastResult;
  135794. private _fixedTimeStep;
  135795. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  135796. setGravity(gravity: Vector3): void;
  135797. setTimeStep(timeStep: number): void;
  135798. getTimeStep(): number;
  135799. private _tmpImpostorsArray;
  135800. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  135801. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  135802. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  135803. generatePhysicsBody(impostor: PhysicsImpostor): void;
  135804. private _tmpPositionVector;
  135805. removePhysicsBody(impostor: PhysicsImpostor): void;
  135806. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  135807. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  135808. isSupported(): boolean;
  135809. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  135810. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  135811. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  135812. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  135813. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  135814. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  135815. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  135816. getBodyMass(impostor: PhysicsImpostor): number;
  135817. getBodyFriction(impostor: PhysicsImpostor): number;
  135818. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  135819. getBodyRestitution(impostor: PhysicsImpostor): number;
  135820. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  135821. sleepBody(impostor: PhysicsImpostor): void;
  135822. wakeUpBody(impostor: PhysicsImpostor): void;
  135823. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  135824. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  135825. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  135826. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  135827. getRadius(impostor: PhysicsImpostor): number;
  135828. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  135829. dispose(): void;
  135830. /**
  135831. * Does a raycast in the physics world
  135832. * @param from when should the ray start?
  135833. * @param to when should the ray end?
  135834. * @returns PhysicsRaycastResult
  135835. */
  135836. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  135837. }
  135838. }
  135839. declare module BABYLON {
  135840. /**
  135841. * Class containing static functions to help procedurally build meshes
  135842. */
  135843. export class RibbonBuilder {
  135844. /**
  135845. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  135846. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  135847. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  135848. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  135849. * * 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
  135850. * * 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
  135851. * * 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
  135852. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135853. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135854. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  135855. * * 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
  135856. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  135857. * * 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
  135858. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  135859. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135860. * @param name defines the name of the mesh
  135861. * @param options defines the options used to create the mesh
  135862. * @param scene defines the hosting scene
  135863. * @returns the ribbon mesh
  135864. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  135865. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  135866. */
  135867. static CreateRibbon(name: string, options: {
  135868. pathArray: Vector3[][];
  135869. closeArray?: boolean;
  135870. closePath?: boolean;
  135871. offset?: number;
  135872. updatable?: boolean;
  135873. sideOrientation?: number;
  135874. frontUVs?: Vector4;
  135875. backUVs?: Vector4;
  135876. instance?: Mesh;
  135877. invertUV?: boolean;
  135878. uvs?: Vector2[];
  135879. colors?: Color4[];
  135880. }, scene?: Nullable<Scene>): Mesh;
  135881. }
  135882. }
  135883. declare module BABYLON {
  135884. /**
  135885. * Class containing static functions to help procedurally build meshes
  135886. */
  135887. export class ShapeBuilder {
  135888. /**
  135889. * 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.
  135890. * * 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.
  135891. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  135892. * * 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.
  135893. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  135894. * * 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
  135895. * * 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
  135896. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  135897. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135898. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135899. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  135900. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  135901. * @param name defines the name of the mesh
  135902. * @param options defines the options used to create the mesh
  135903. * @param scene defines the hosting scene
  135904. * @returns the extruded shape mesh
  135905. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  135906. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  135907. */
  135908. static ExtrudeShape(name: string, options: {
  135909. shape: Vector3[];
  135910. path: Vector3[];
  135911. scale?: number;
  135912. rotation?: number;
  135913. cap?: number;
  135914. updatable?: boolean;
  135915. sideOrientation?: number;
  135916. frontUVs?: Vector4;
  135917. backUVs?: Vector4;
  135918. instance?: Mesh;
  135919. invertUV?: boolean;
  135920. }, scene?: Nullable<Scene>): Mesh;
  135921. /**
  135922. * Creates an custom extruded shape mesh.
  135923. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  135924. * * 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.
  135925. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  135926. * * 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
  135927. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  135928. * * 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
  135929. * * It must returns a float value that will be the scale value applied to the shape on each path point
  135930. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  135931. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  135932. * * 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
  135933. * * 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
  135934. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  135935. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135936. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135937. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  135938. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135939. * @param name defines the name of the mesh
  135940. * @param options defines the options used to create the mesh
  135941. * @param scene defines the hosting scene
  135942. * @returns the custom extruded shape mesh
  135943. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  135944. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  135945. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  135946. */
  135947. static ExtrudeShapeCustom(name: string, options: {
  135948. shape: Vector3[];
  135949. path: Vector3[];
  135950. scaleFunction?: any;
  135951. rotationFunction?: any;
  135952. ribbonCloseArray?: boolean;
  135953. ribbonClosePath?: boolean;
  135954. cap?: number;
  135955. updatable?: boolean;
  135956. sideOrientation?: number;
  135957. frontUVs?: Vector4;
  135958. backUVs?: Vector4;
  135959. instance?: Mesh;
  135960. invertUV?: boolean;
  135961. }, scene?: Nullable<Scene>): Mesh;
  135962. private static _ExtrudeShapeGeneric;
  135963. }
  135964. }
  135965. declare module BABYLON {
  135966. /**
  135967. * AmmoJS Physics plugin
  135968. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  135969. * @see https://github.com/kripken/ammo.js/
  135970. */
  135971. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  135972. private _useDeltaForWorldStep;
  135973. /**
  135974. * Reference to the Ammo library
  135975. */
  135976. bjsAMMO: any;
  135977. /**
  135978. * Created ammoJS world which physics bodies are added to
  135979. */
  135980. world: any;
  135981. /**
  135982. * Name of the plugin
  135983. */
  135984. name: string;
  135985. private _timeStep;
  135986. private _fixedTimeStep;
  135987. private _maxSteps;
  135988. private _tmpQuaternion;
  135989. private _tmpAmmoTransform;
  135990. private _tmpAmmoQuaternion;
  135991. private _tmpAmmoConcreteContactResultCallback;
  135992. private _collisionConfiguration;
  135993. private _dispatcher;
  135994. private _overlappingPairCache;
  135995. private _solver;
  135996. private _softBodySolver;
  135997. private _tmpAmmoVectorA;
  135998. private _tmpAmmoVectorB;
  135999. private _tmpAmmoVectorC;
  136000. private _tmpAmmoVectorD;
  136001. private _tmpContactCallbackResult;
  136002. private _tmpAmmoVectorRCA;
  136003. private _tmpAmmoVectorRCB;
  136004. private _raycastResult;
  136005. private static readonly DISABLE_COLLISION_FLAG;
  136006. private static readonly KINEMATIC_FLAG;
  136007. private static readonly DISABLE_DEACTIVATION_FLAG;
  136008. /**
  136009. * Initializes the ammoJS plugin
  136010. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  136011. * @param ammoInjection can be used to inject your own ammo reference
  136012. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  136013. */
  136014. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  136015. /**
  136016. * Sets the gravity of the physics world (m/(s^2))
  136017. * @param gravity Gravity to set
  136018. */
  136019. setGravity(gravity: Vector3): void;
  136020. /**
  136021. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  136022. * @param timeStep timestep to use in seconds
  136023. */
  136024. setTimeStep(timeStep: number): void;
  136025. /**
  136026. * 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)
  136027. * @param fixedTimeStep fixedTimeStep to use in seconds
  136028. */
  136029. setFixedTimeStep(fixedTimeStep: number): void;
  136030. /**
  136031. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  136032. * @param maxSteps the maximum number of steps by the physics engine per frame
  136033. */
  136034. setMaxSteps(maxSteps: number): void;
  136035. /**
  136036. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  136037. * @returns the current timestep in seconds
  136038. */
  136039. getTimeStep(): number;
  136040. /**
  136041. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  136042. */
  136043. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  136044. private _isImpostorInContact;
  136045. private _isImpostorPairInContact;
  136046. private _stepSimulation;
  136047. /**
  136048. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  136049. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  136050. * After the step the babylon meshes are set to the position of the physics imposters
  136051. * @param delta amount of time to step forward
  136052. * @param impostors array of imposters to update before/after the step
  136053. */
  136054. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  136055. /**
  136056. * Update babylon mesh to match physics world object
  136057. * @param impostor imposter to match
  136058. */
  136059. private _afterSoftStep;
  136060. /**
  136061. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  136062. * @param impostor imposter to match
  136063. */
  136064. private _ropeStep;
  136065. /**
  136066. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  136067. * @param impostor imposter to match
  136068. */
  136069. private _softbodyOrClothStep;
  136070. private _tmpMatrix;
  136071. /**
  136072. * Applies an impulse on the imposter
  136073. * @param impostor imposter to apply impulse to
  136074. * @param force amount of force to be applied to the imposter
  136075. * @param contactPoint the location to apply the impulse on the imposter
  136076. */
  136077. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  136078. /**
  136079. * Applies a force on the imposter
  136080. * @param impostor imposter to apply force
  136081. * @param force amount of force to be applied to the imposter
  136082. * @param contactPoint the location to apply the force on the imposter
  136083. */
  136084. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  136085. /**
  136086. * Creates a physics body using the plugin
  136087. * @param impostor the imposter to create the physics body on
  136088. */
  136089. generatePhysicsBody(impostor: PhysicsImpostor): void;
  136090. /**
  136091. * Removes the physics body from the imposter and disposes of the body's memory
  136092. * @param impostor imposter to remove the physics body from
  136093. */
  136094. removePhysicsBody(impostor: PhysicsImpostor): void;
  136095. /**
  136096. * Generates a joint
  136097. * @param impostorJoint the imposter joint to create the joint with
  136098. */
  136099. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  136100. /**
  136101. * Removes a joint
  136102. * @param impostorJoint the imposter joint to remove the joint from
  136103. */
  136104. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  136105. private _addMeshVerts;
  136106. /**
  136107. * Initialise the soft body vertices to match its object's (mesh) vertices
  136108. * Softbody vertices (nodes) are in world space and to match this
  136109. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  136110. * @param impostor to create the softbody for
  136111. */
  136112. private _softVertexData;
  136113. /**
  136114. * Create an impostor's soft body
  136115. * @param impostor to create the softbody for
  136116. */
  136117. private _createSoftbody;
  136118. /**
  136119. * Create cloth for an impostor
  136120. * @param impostor to create the softbody for
  136121. */
  136122. private _createCloth;
  136123. /**
  136124. * Create rope for an impostor
  136125. * @param impostor to create the softbody for
  136126. */
  136127. private _createRope;
  136128. /**
  136129. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  136130. * @param impostor to create the custom physics shape for
  136131. */
  136132. private _createCustom;
  136133. private _addHullVerts;
  136134. private _createShape;
  136135. /**
  136136. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  136137. * @param impostor imposter containing the physics body and babylon object
  136138. */
  136139. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  136140. /**
  136141. * Sets the babylon object's position/rotation from the physics body's position/rotation
  136142. * @param impostor imposter containing the physics body and babylon object
  136143. * @param newPosition new position
  136144. * @param newRotation new rotation
  136145. */
  136146. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  136147. /**
  136148. * If this plugin is supported
  136149. * @returns true if its supported
  136150. */
  136151. isSupported(): boolean;
  136152. /**
  136153. * Sets the linear velocity of the physics body
  136154. * @param impostor imposter to set the velocity on
  136155. * @param velocity velocity to set
  136156. */
  136157. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  136158. /**
  136159. * Sets the angular velocity of the physics body
  136160. * @param impostor imposter to set the velocity on
  136161. * @param velocity velocity to set
  136162. */
  136163. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  136164. /**
  136165. * gets the linear velocity
  136166. * @param impostor imposter to get linear velocity from
  136167. * @returns linear velocity
  136168. */
  136169. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  136170. /**
  136171. * gets the angular velocity
  136172. * @param impostor imposter to get angular velocity from
  136173. * @returns angular velocity
  136174. */
  136175. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  136176. /**
  136177. * Sets the mass of physics body
  136178. * @param impostor imposter to set the mass on
  136179. * @param mass mass to set
  136180. */
  136181. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  136182. /**
  136183. * Gets the mass of the physics body
  136184. * @param impostor imposter to get the mass from
  136185. * @returns mass
  136186. */
  136187. getBodyMass(impostor: PhysicsImpostor): number;
  136188. /**
  136189. * Gets friction of the impostor
  136190. * @param impostor impostor to get friction from
  136191. * @returns friction value
  136192. */
  136193. getBodyFriction(impostor: PhysicsImpostor): number;
  136194. /**
  136195. * Sets friction of the impostor
  136196. * @param impostor impostor to set friction on
  136197. * @param friction friction value
  136198. */
  136199. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  136200. /**
  136201. * Gets restitution of the impostor
  136202. * @param impostor impostor to get restitution from
  136203. * @returns restitution value
  136204. */
  136205. getBodyRestitution(impostor: PhysicsImpostor): number;
  136206. /**
  136207. * Sets resitution of the impostor
  136208. * @param impostor impostor to set resitution on
  136209. * @param restitution resitution value
  136210. */
  136211. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  136212. /**
  136213. * Gets pressure inside the impostor
  136214. * @param impostor impostor to get pressure from
  136215. * @returns pressure value
  136216. */
  136217. getBodyPressure(impostor: PhysicsImpostor): number;
  136218. /**
  136219. * Sets pressure inside a soft body impostor
  136220. * Cloth and rope must remain 0 pressure
  136221. * @param impostor impostor to set pressure on
  136222. * @param pressure pressure value
  136223. */
  136224. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  136225. /**
  136226. * Gets stiffness of the impostor
  136227. * @param impostor impostor to get stiffness from
  136228. * @returns pressure value
  136229. */
  136230. getBodyStiffness(impostor: PhysicsImpostor): number;
  136231. /**
  136232. * Sets stiffness of the impostor
  136233. * @param impostor impostor to set stiffness on
  136234. * @param stiffness stiffness value from 0 to 1
  136235. */
  136236. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  136237. /**
  136238. * Gets velocityIterations of the impostor
  136239. * @param impostor impostor to get velocity iterations from
  136240. * @returns velocityIterations value
  136241. */
  136242. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  136243. /**
  136244. * Sets velocityIterations of the impostor
  136245. * @param impostor impostor to set velocity iterations on
  136246. * @param velocityIterations velocityIterations value
  136247. */
  136248. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  136249. /**
  136250. * Gets positionIterations of the impostor
  136251. * @param impostor impostor to get position iterations from
  136252. * @returns positionIterations value
  136253. */
  136254. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  136255. /**
  136256. * Sets positionIterations of the impostor
  136257. * @param impostor impostor to set position on
  136258. * @param positionIterations positionIterations value
  136259. */
  136260. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  136261. /**
  136262. * Append an anchor to a cloth object
  136263. * @param impostor is the cloth impostor to add anchor to
  136264. * @param otherImpostor is the rigid impostor to anchor to
  136265. * @param width ratio across width from 0 to 1
  136266. * @param height ratio up height from 0 to 1
  136267. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  136268. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  136269. */
  136270. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  136271. /**
  136272. * Append an hook to a rope object
  136273. * @param impostor is the rope impostor to add hook to
  136274. * @param otherImpostor is the rigid impostor to hook to
  136275. * @param length ratio along the rope from 0 to 1
  136276. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  136277. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  136278. */
  136279. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  136280. /**
  136281. * Sleeps the physics body and stops it from being active
  136282. * @param impostor impostor to sleep
  136283. */
  136284. sleepBody(impostor: PhysicsImpostor): void;
  136285. /**
  136286. * Activates the physics body
  136287. * @param impostor impostor to activate
  136288. */
  136289. wakeUpBody(impostor: PhysicsImpostor): void;
  136290. /**
  136291. * Updates the distance parameters of the joint
  136292. * @param joint joint to update
  136293. * @param maxDistance maximum distance of the joint
  136294. * @param minDistance minimum distance of the joint
  136295. */
  136296. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  136297. /**
  136298. * Sets a motor on the joint
  136299. * @param joint joint to set motor on
  136300. * @param speed speed of the motor
  136301. * @param maxForce maximum force of the motor
  136302. * @param motorIndex index of the motor
  136303. */
  136304. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  136305. /**
  136306. * Sets the motors limit
  136307. * @param joint joint to set limit on
  136308. * @param upperLimit upper limit
  136309. * @param lowerLimit lower limit
  136310. */
  136311. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  136312. /**
  136313. * Syncs the position and rotation of a mesh with the impostor
  136314. * @param mesh mesh to sync
  136315. * @param impostor impostor to update the mesh with
  136316. */
  136317. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  136318. /**
  136319. * Gets the radius of the impostor
  136320. * @param impostor impostor to get radius from
  136321. * @returns the radius
  136322. */
  136323. getRadius(impostor: PhysicsImpostor): number;
  136324. /**
  136325. * Gets the box size of the impostor
  136326. * @param impostor impostor to get box size from
  136327. * @param result the resulting box size
  136328. */
  136329. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  136330. /**
  136331. * Disposes of the impostor
  136332. */
  136333. dispose(): void;
  136334. /**
  136335. * Does a raycast in the physics world
  136336. * @param from when should the ray start?
  136337. * @param to when should the ray end?
  136338. * @returns PhysicsRaycastResult
  136339. */
  136340. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  136341. }
  136342. }
  136343. declare module BABYLON {
  136344. interface AbstractScene {
  136345. /**
  136346. * The list of reflection probes added to the scene
  136347. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  136348. */
  136349. reflectionProbes: Array<ReflectionProbe>;
  136350. /**
  136351. * Removes the given reflection probe from this scene.
  136352. * @param toRemove The reflection probe to remove
  136353. * @returns The index of the removed reflection probe
  136354. */
  136355. removeReflectionProbe(toRemove: ReflectionProbe): number;
  136356. /**
  136357. * Adds the given reflection probe to this scene.
  136358. * @param newReflectionProbe The reflection probe to add
  136359. */
  136360. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  136361. }
  136362. /**
  136363. * Class used to generate realtime reflection / refraction cube textures
  136364. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  136365. */
  136366. export class ReflectionProbe {
  136367. /** defines the name of the probe */
  136368. name: string;
  136369. private _scene;
  136370. private _renderTargetTexture;
  136371. private _projectionMatrix;
  136372. private _viewMatrix;
  136373. private _target;
  136374. private _add;
  136375. private _attachedMesh;
  136376. private _invertYAxis;
  136377. /** Gets or sets probe position (center of the cube map) */
  136378. position: Vector3;
  136379. /**
  136380. * Creates a new reflection probe
  136381. * @param name defines the name of the probe
  136382. * @param size defines the texture resolution (for each face)
  136383. * @param scene defines the hosting scene
  136384. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  136385. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  136386. */
  136387. constructor(
  136388. /** defines the name of the probe */
  136389. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  136390. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  136391. get samples(): number;
  136392. set samples(value: number);
  136393. /** Gets or sets the refresh rate to use (on every frame by default) */
  136394. get refreshRate(): number;
  136395. set refreshRate(value: number);
  136396. /**
  136397. * Gets the hosting scene
  136398. * @returns a Scene
  136399. */
  136400. getScene(): Scene;
  136401. /** Gets the internal CubeTexture used to render to */
  136402. get cubeTexture(): RenderTargetTexture;
  136403. /** Gets the list of meshes to render */
  136404. get renderList(): Nullable<AbstractMesh[]>;
  136405. /**
  136406. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  136407. * @param mesh defines the mesh to attach to
  136408. */
  136409. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  136410. /**
  136411. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  136412. * @param renderingGroupId The rendering group id corresponding to its index
  136413. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  136414. */
  136415. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  136416. /**
  136417. * Clean all associated resources
  136418. */
  136419. dispose(): void;
  136420. /**
  136421. * Converts the reflection probe information to a readable string for debug purpose.
  136422. * @param fullDetails Supports for multiple levels of logging within scene loading
  136423. * @returns the human readable reflection probe info
  136424. */
  136425. toString(fullDetails?: boolean): string;
  136426. /**
  136427. * Get the class name of the relfection probe.
  136428. * @returns "ReflectionProbe"
  136429. */
  136430. getClassName(): string;
  136431. /**
  136432. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  136433. * @returns The JSON representation of the texture
  136434. */
  136435. serialize(): any;
  136436. /**
  136437. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  136438. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  136439. * @param scene Define the scene the parsed reflection probe should be instantiated in
  136440. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  136441. * @returns The parsed reflection probe if successful
  136442. */
  136443. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  136444. }
  136445. }
  136446. declare module BABYLON {
  136447. /** @hidden */
  136448. export var _BabylonLoaderRegistered: boolean;
  136449. /**
  136450. * Helps setting up some configuration for the babylon file loader.
  136451. */
  136452. export class BabylonFileLoaderConfiguration {
  136453. /**
  136454. * The loader does not allow injecting custom physix engine into the plugins.
  136455. * Unfortunately in ES6, we need to manually inject them into the plugin.
  136456. * So you could set this variable to your engine import to make it work.
  136457. */
  136458. static LoaderInjectedPhysicsEngine: any;
  136459. }
  136460. }
  136461. declare module BABYLON {
  136462. /**
  136463. * The Physically based simple base material of BJS.
  136464. *
  136465. * This enables better naming and convention enforcements on top of the pbrMaterial.
  136466. * It is used as the base class for both the specGloss and metalRough conventions.
  136467. */
  136468. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  136469. /**
  136470. * Number of Simultaneous lights allowed on the material.
  136471. */
  136472. maxSimultaneousLights: number;
  136473. /**
  136474. * If sets to true, disables all the lights affecting the material.
  136475. */
  136476. disableLighting: boolean;
  136477. /**
  136478. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  136479. */
  136480. environmentTexture: BaseTexture;
  136481. /**
  136482. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  136483. */
  136484. invertNormalMapX: boolean;
  136485. /**
  136486. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  136487. */
  136488. invertNormalMapY: boolean;
  136489. /**
  136490. * Normal map used in the model.
  136491. */
  136492. normalTexture: BaseTexture;
  136493. /**
  136494. * Emissivie color used to self-illuminate the model.
  136495. */
  136496. emissiveColor: Color3;
  136497. /**
  136498. * Emissivie texture used to self-illuminate the model.
  136499. */
  136500. emissiveTexture: BaseTexture;
  136501. /**
  136502. * Occlusion Channel Strenght.
  136503. */
  136504. occlusionStrength: number;
  136505. /**
  136506. * Occlusion Texture of the material (adding extra occlusion effects).
  136507. */
  136508. occlusionTexture: BaseTexture;
  136509. /**
  136510. * Defines the alpha limits in alpha test mode.
  136511. */
  136512. alphaCutOff: number;
  136513. /**
  136514. * Gets the current double sided mode.
  136515. */
  136516. get doubleSided(): boolean;
  136517. /**
  136518. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  136519. */
  136520. set doubleSided(value: boolean);
  136521. /**
  136522. * Stores the pre-calculated light information of a mesh in a texture.
  136523. */
  136524. lightmapTexture: BaseTexture;
  136525. /**
  136526. * If true, the light map contains occlusion information instead of lighting info.
  136527. */
  136528. useLightmapAsShadowmap: boolean;
  136529. /**
  136530. * Instantiates a new PBRMaterial instance.
  136531. *
  136532. * @param name The material name
  136533. * @param scene The scene the material will be use in.
  136534. */
  136535. constructor(name: string, scene: Scene);
  136536. getClassName(): string;
  136537. }
  136538. }
  136539. declare module BABYLON {
  136540. /**
  136541. * The PBR material of BJS following the metal roughness convention.
  136542. *
  136543. * This fits to the PBR convention in the GLTF definition:
  136544. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  136545. */
  136546. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  136547. /**
  136548. * The base color has two different interpretations depending on the value of metalness.
  136549. * When the material is a metal, the base color is the specific measured reflectance value
  136550. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  136551. * of the material.
  136552. */
  136553. baseColor: Color3;
  136554. /**
  136555. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  136556. * well as opacity information in the alpha channel.
  136557. */
  136558. baseTexture: BaseTexture;
  136559. /**
  136560. * Specifies the metallic scalar value of the material.
  136561. * Can also be used to scale the metalness values of the metallic texture.
  136562. */
  136563. metallic: number;
  136564. /**
  136565. * Specifies the roughness scalar value of the material.
  136566. * Can also be used to scale the roughness values of the metallic texture.
  136567. */
  136568. roughness: number;
  136569. /**
  136570. * Texture containing both the metallic value in the B channel and the
  136571. * roughness value in the G channel to keep better precision.
  136572. */
  136573. metallicRoughnessTexture: BaseTexture;
  136574. /**
  136575. * Instantiates a new PBRMetalRoughnessMaterial instance.
  136576. *
  136577. * @param name The material name
  136578. * @param scene The scene the material will be use in.
  136579. */
  136580. constructor(name: string, scene: Scene);
  136581. /**
  136582. * Return the currrent class name of the material.
  136583. */
  136584. getClassName(): string;
  136585. /**
  136586. * Makes a duplicate of the current material.
  136587. * @param name - name to use for the new material.
  136588. */
  136589. clone(name: string): PBRMetallicRoughnessMaterial;
  136590. /**
  136591. * Serialize the material to a parsable JSON object.
  136592. */
  136593. serialize(): any;
  136594. /**
  136595. * Parses a JSON object correponding to the serialize function.
  136596. */
  136597. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  136598. }
  136599. }
  136600. declare module BABYLON {
  136601. /**
  136602. * The PBR material of BJS following the specular glossiness convention.
  136603. *
  136604. * This fits to the PBR convention in the GLTF definition:
  136605. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  136606. */
  136607. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  136608. /**
  136609. * Specifies the diffuse color of the material.
  136610. */
  136611. diffuseColor: Color3;
  136612. /**
  136613. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  136614. * channel.
  136615. */
  136616. diffuseTexture: BaseTexture;
  136617. /**
  136618. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  136619. */
  136620. specularColor: Color3;
  136621. /**
  136622. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  136623. */
  136624. glossiness: number;
  136625. /**
  136626. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  136627. */
  136628. specularGlossinessTexture: BaseTexture;
  136629. /**
  136630. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  136631. *
  136632. * @param name The material name
  136633. * @param scene The scene the material will be use in.
  136634. */
  136635. constructor(name: string, scene: Scene);
  136636. /**
  136637. * Return the currrent class name of the material.
  136638. */
  136639. getClassName(): string;
  136640. /**
  136641. * Makes a duplicate of the current material.
  136642. * @param name - name to use for the new material.
  136643. */
  136644. clone(name: string): PBRSpecularGlossinessMaterial;
  136645. /**
  136646. * Serialize the material to a parsable JSON object.
  136647. */
  136648. serialize(): any;
  136649. /**
  136650. * Parses a JSON object correponding to the serialize function.
  136651. */
  136652. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  136653. }
  136654. }
  136655. declare module BABYLON {
  136656. /**
  136657. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  136658. * It can help converting any input color in a desired output one. This can then be used to create effects
  136659. * from sepia, black and white to sixties or futuristic rendering...
  136660. *
  136661. * The only supported format is currently 3dl.
  136662. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  136663. */
  136664. export class ColorGradingTexture extends BaseTexture {
  136665. /**
  136666. * The texture URL.
  136667. */
  136668. url: string;
  136669. /**
  136670. * Empty line regex stored for GC.
  136671. */
  136672. private static _noneEmptyLineRegex;
  136673. private _textureMatrix;
  136674. private _onLoad;
  136675. /**
  136676. * Instantiates a ColorGradingTexture from the following parameters.
  136677. *
  136678. * @param url The location of the color gradind data (currently only supporting 3dl)
  136679. * @param sceneOrEngine The scene or engine the texture will be used in
  136680. * @param onLoad defines a callback triggered when the texture has been loaded
  136681. */
  136682. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  136683. /**
  136684. * Fires the onload event from the constructor if requested.
  136685. */
  136686. private _triggerOnLoad;
  136687. /**
  136688. * Returns the texture matrix used in most of the material.
  136689. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  136690. */
  136691. getTextureMatrix(): Matrix;
  136692. /**
  136693. * Occurs when the file being loaded is a .3dl LUT file.
  136694. */
  136695. private load3dlTexture;
  136696. /**
  136697. * Starts the loading process of the texture.
  136698. */
  136699. private loadTexture;
  136700. /**
  136701. * Clones the color gradind texture.
  136702. */
  136703. clone(): ColorGradingTexture;
  136704. /**
  136705. * Called during delayed load for textures.
  136706. */
  136707. delayLoad(): void;
  136708. /**
  136709. * Parses a color grading texture serialized by Babylon.
  136710. * @param parsedTexture The texture information being parsedTexture
  136711. * @param scene The scene to load the texture in
  136712. * @param rootUrl The root url of the data assets to load
  136713. * @return A color gradind texture
  136714. */
  136715. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  136716. /**
  136717. * Serializes the LUT texture to json format.
  136718. */
  136719. serialize(): any;
  136720. }
  136721. }
  136722. declare module BABYLON {
  136723. /**
  136724. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  136725. */
  136726. export class EquiRectangularCubeTexture extends BaseTexture {
  136727. /** The six faces of the cube. */
  136728. private static _FacesMapping;
  136729. private _noMipmap;
  136730. private _onLoad;
  136731. private _onError;
  136732. /** The size of the cubemap. */
  136733. private _size;
  136734. /** The buffer of the image. */
  136735. private _buffer;
  136736. /** The width of the input image. */
  136737. private _width;
  136738. /** The height of the input image. */
  136739. private _height;
  136740. /** The URL to the image. */
  136741. url: string;
  136742. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  136743. coordinatesMode: number;
  136744. /**
  136745. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  136746. * @param url The location of the image
  136747. * @param scene The scene the texture will be used in
  136748. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  136749. * @param noMipmap Forces to not generate the mipmap if true
  136750. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  136751. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  136752. * @param onLoad — defines a callback called when texture is loaded
  136753. * @param onError — defines a callback called if there is an error
  136754. */
  136755. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  136756. /**
  136757. * Load the image data, by putting the image on a canvas and extracting its buffer.
  136758. */
  136759. private loadImage;
  136760. /**
  136761. * Convert the image buffer into a cubemap and create a CubeTexture.
  136762. */
  136763. private loadTexture;
  136764. /**
  136765. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  136766. * @param buffer The ArrayBuffer that should be converted.
  136767. * @returns The buffer as Float32Array.
  136768. */
  136769. private getFloat32ArrayFromArrayBuffer;
  136770. /**
  136771. * Get the current class name of the texture useful for serialization or dynamic coding.
  136772. * @returns "EquiRectangularCubeTexture"
  136773. */
  136774. getClassName(): string;
  136775. /**
  136776. * Create a clone of the current EquiRectangularCubeTexture and return it.
  136777. * @returns A clone of the current EquiRectangularCubeTexture.
  136778. */
  136779. clone(): EquiRectangularCubeTexture;
  136780. }
  136781. }
  136782. declare module BABYLON {
  136783. /**
  136784. * Defines the options related to the creation of an HtmlElementTexture
  136785. */
  136786. export interface IHtmlElementTextureOptions {
  136787. /**
  136788. * Defines wether mip maps should be created or not.
  136789. */
  136790. generateMipMaps?: boolean;
  136791. /**
  136792. * Defines the sampling mode of the texture.
  136793. */
  136794. samplingMode?: number;
  136795. /**
  136796. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  136797. */
  136798. engine: Nullable<ThinEngine>;
  136799. /**
  136800. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  136801. */
  136802. scene: Nullable<Scene>;
  136803. }
  136804. /**
  136805. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  136806. * To be as efficient as possible depending on your constraints nothing aside the first upload
  136807. * is automatically managed.
  136808. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  136809. * in your application.
  136810. *
  136811. * As the update is not automatic, you need to call them manually.
  136812. */
  136813. export class HtmlElementTexture extends BaseTexture {
  136814. /**
  136815. * The texture URL.
  136816. */
  136817. element: HTMLVideoElement | HTMLCanvasElement;
  136818. private static readonly DefaultOptions;
  136819. private _textureMatrix;
  136820. private _isVideo;
  136821. private _generateMipMaps;
  136822. private _samplingMode;
  136823. /**
  136824. * Instantiates a HtmlElementTexture from the following parameters.
  136825. *
  136826. * @param name Defines the name of the texture
  136827. * @param element Defines the video or canvas the texture is filled with
  136828. * @param options Defines the other none mandatory texture creation options
  136829. */
  136830. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  136831. private _createInternalTexture;
  136832. /**
  136833. * Returns the texture matrix used in most of the material.
  136834. */
  136835. getTextureMatrix(): Matrix;
  136836. /**
  136837. * Updates the content of the texture.
  136838. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  136839. */
  136840. update(invertY?: Nullable<boolean>): void;
  136841. }
  136842. }
  136843. declare module BABYLON {
  136844. /**
  136845. * Based on jsTGALoader - Javascript loader for TGA file
  136846. * By Vincent Thibault
  136847. * @see http://blog.robrowser.com/javascript-tga-loader.html
  136848. */
  136849. export class TGATools {
  136850. private static _TYPE_INDEXED;
  136851. private static _TYPE_RGB;
  136852. private static _TYPE_GREY;
  136853. private static _TYPE_RLE_INDEXED;
  136854. private static _TYPE_RLE_RGB;
  136855. private static _TYPE_RLE_GREY;
  136856. private static _ORIGIN_MASK;
  136857. private static _ORIGIN_SHIFT;
  136858. private static _ORIGIN_BL;
  136859. private static _ORIGIN_BR;
  136860. private static _ORIGIN_UL;
  136861. private static _ORIGIN_UR;
  136862. /**
  136863. * Gets the header of a TGA file
  136864. * @param data defines the TGA data
  136865. * @returns the header
  136866. */
  136867. static GetTGAHeader(data: Uint8Array): any;
  136868. /**
  136869. * Uploads TGA content to a Babylon Texture
  136870. * @hidden
  136871. */
  136872. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  136873. /** @hidden */
  136874. 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;
  136875. /** @hidden */
  136876. 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;
  136877. /** @hidden */
  136878. 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;
  136879. /** @hidden */
  136880. 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;
  136881. /** @hidden */
  136882. 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;
  136883. /** @hidden */
  136884. 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;
  136885. }
  136886. }
  136887. declare module BABYLON {
  136888. /**
  136889. * Implementation of the TGA Texture Loader.
  136890. * @hidden
  136891. */
  136892. export class _TGATextureLoader implements IInternalTextureLoader {
  136893. /**
  136894. * Defines wether the loader supports cascade loading the different faces.
  136895. */
  136896. readonly supportCascades: boolean;
  136897. /**
  136898. * This returns if the loader support the current file information.
  136899. * @param extension defines the file extension of the file being loaded
  136900. * @returns true if the loader can load the specified file
  136901. */
  136902. canLoad(extension: string): boolean;
  136903. /**
  136904. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  136905. * @param data contains the texture data
  136906. * @param texture defines the BabylonJS internal texture
  136907. * @param createPolynomials will be true if polynomials have been requested
  136908. * @param onLoad defines the callback to trigger once the texture is ready
  136909. * @param onError defines the callback to trigger in case of error
  136910. */
  136911. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  136912. /**
  136913. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  136914. * @param data contains the texture data
  136915. * @param texture defines the BabylonJS internal texture
  136916. * @param callback defines the method to call once ready to upload
  136917. */
  136918. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  136919. }
  136920. }
  136921. declare module BABYLON {
  136922. /**
  136923. * Info about the .basis files
  136924. */
  136925. class BasisFileInfo {
  136926. /**
  136927. * If the file has alpha
  136928. */
  136929. hasAlpha: boolean;
  136930. /**
  136931. * Info about each image of the basis file
  136932. */
  136933. images: Array<{
  136934. levels: Array<{
  136935. width: number;
  136936. height: number;
  136937. transcodedPixels: ArrayBufferView;
  136938. }>;
  136939. }>;
  136940. }
  136941. /**
  136942. * Result of transcoding a basis file
  136943. */
  136944. class TranscodeResult {
  136945. /**
  136946. * Info about the .basis file
  136947. */
  136948. fileInfo: BasisFileInfo;
  136949. /**
  136950. * Format to use when loading the file
  136951. */
  136952. format: number;
  136953. }
  136954. /**
  136955. * Configuration options for the Basis transcoder
  136956. */
  136957. export class BasisTranscodeConfiguration {
  136958. /**
  136959. * Supported compression formats used to determine the supported output format of the transcoder
  136960. */
  136961. supportedCompressionFormats?: {
  136962. /**
  136963. * etc1 compression format
  136964. */
  136965. etc1?: boolean;
  136966. /**
  136967. * s3tc compression format
  136968. */
  136969. s3tc?: boolean;
  136970. /**
  136971. * pvrtc compression format
  136972. */
  136973. pvrtc?: boolean;
  136974. /**
  136975. * etc2 compression format
  136976. */
  136977. etc2?: boolean;
  136978. };
  136979. /**
  136980. * If mipmap levels should be loaded for transcoded images (Default: true)
  136981. */
  136982. loadMipmapLevels?: boolean;
  136983. /**
  136984. * Index of a single image to load (Default: all images)
  136985. */
  136986. loadSingleImage?: number;
  136987. }
  136988. /**
  136989. * Used to load .Basis files
  136990. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  136991. */
  136992. export class BasisTools {
  136993. private static _IgnoreSupportedFormats;
  136994. /**
  136995. * URL to use when loading the basis transcoder
  136996. */
  136997. static JSModuleURL: string;
  136998. /**
  136999. * URL to use when loading the wasm module for the transcoder
  137000. */
  137001. static WasmModuleURL: string;
  137002. /**
  137003. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  137004. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  137005. * @returns internal format corresponding to the Basis format
  137006. */
  137007. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  137008. private static _WorkerPromise;
  137009. private static _Worker;
  137010. private static _actionId;
  137011. private static _CreateWorkerAsync;
  137012. /**
  137013. * Transcodes a loaded image file to compressed pixel data
  137014. * @param data image data to transcode
  137015. * @param config configuration options for the transcoding
  137016. * @returns a promise resulting in the transcoded image
  137017. */
  137018. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  137019. /**
  137020. * Loads a texture from the transcode result
  137021. * @param texture texture load to
  137022. * @param transcodeResult the result of transcoding the basis file to load from
  137023. */
  137024. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  137025. }
  137026. }
  137027. declare module BABYLON {
  137028. /**
  137029. * Loader for .basis file format
  137030. */
  137031. export class _BasisTextureLoader implements IInternalTextureLoader {
  137032. /**
  137033. * Defines whether the loader supports cascade loading the different faces.
  137034. */
  137035. readonly supportCascades: boolean;
  137036. /**
  137037. * This returns if the loader support the current file information.
  137038. * @param extension defines the file extension of the file being loaded
  137039. * @returns true if the loader can load the specified file
  137040. */
  137041. canLoad(extension: string): boolean;
  137042. /**
  137043. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  137044. * @param data contains the texture data
  137045. * @param texture defines the BabylonJS internal texture
  137046. * @param createPolynomials will be true if polynomials have been requested
  137047. * @param onLoad defines the callback to trigger once the texture is ready
  137048. * @param onError defines the callback to trigger in case of error
  137049. */
  137050. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  137051. /**
  137052. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  137053. * @param data contains the texture data
  137054. * @param texture defines the BabylonJS internal texture
  137055. * @param callback defines the method to call once ready to upload
  137056. */
  137057. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  137058. }
  137059. }
  137060. declare module BABYLON {
  137061. /**
  137062. * Defines the basic options interface of a TexturePacker Frame
  137063. */
  137064. export interface ITexturePackerFrame {
  137065. /**
  137066. * The frame ID
  137067. */
  137068. id: number;
  137069. /**
  137070. * The frames Scale
  137071. */
  137072. scale: Vector2;
  137073. /**
  137074. * The Frames offset
  137075. */
  137076. offset: Vector2;
  137077. }
  137078. /**
  137079. * This is a support class for frame Data on texture packer sets.
  137080. */
  137081. export class TexturePackerFrame implements ITexturePackerFrame {
  137082. /**
  137083. * The frame ID
  137084. */
  137085. id: number;
  137086. /**
  137087. * The frames Scale
  137088. */
  137089. scale: Vector2;
  137090. /**
  137091. * The Frames offset
  137092. */
  137093. offset: Vector2;
  137094. /**
  137095. * Initializes a texture package frame.
  137096. * @param id The numerical frame identifier
  137097. * @param scale Scalar Vector2 for UV frame
  137098. * @param offset Vector2 for the frame position in UV units.
  137099. * @returns TexturePackerFrame
  137100. */
  137101. constructor(id: number, scale: Vector2, offset: Vector2);
  137102. }
  137103. }
  137104. declare module BABYLON {
  137105. /**
  137106. * Defines the basic options interface of a TexturePacker
  137107. */
  137108. export interface ITexturePackerOptions {
  137109. /**
  137110. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  137111. */
  137112. map?: string[];
  137113. /**
  137114. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  137115. */
  137116. uvsIn?: string;
  137117. /**
  137118. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  137119. */
  137120. uvsOut?: string;
  137121. /**
  137122. * number representing the layout style. Defaults to LAYOUT_STRIP
  137123. */
  137124. layout?: number;
  137125. /**
  137126. * number of columns if using custom column count layout(2). This defaults to 4.
  137127. */
  137128. colnum?: number;
  137129. /**
  137130. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  137131. */
  137132. updateInputMeshes?: boolean;
  137133. /**
  137134. * boolean flag to dispose all the source textures. Defaults to true.
  137135. */
  137136. disposeSources?: boolean;
  137137. /**
  137138. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  137139. */
  137140. fillBlanks?: boolean;
  137141. /**
  137142. * string value representing the context fill style color. Defaults to 'black'.
  137143. */
  137144. customFillColor?: string;
  137145. /**
  137146. * Width and Height Value of each Frame in the TexturePacker Sets
  137147. */
  137148. frameSize?: number;
  137149. /**
  137150. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  137151. */
  137152. paddingRatio?: number;
  137153. /**
  137154. * Number that declares the fill method for the padding gutter.
  137155. */
  137156. paddingMode?: number;
  137157. /**
  137158. * If in SUBUV_COLOR padding mode what color to use.
  137159. */
  137160. paddingColor?: Color3 | Color4;
  137161. }
  137162. /**
  137163. * Defines the basic interface of a TexturePacker JSON File
  137164. */
  137165. export interface ITexturePackerJSON {
  137166. /**
  137167. * The frame ID
  137168. */
  137169. name: string;
  137170. /**
  137171. * The base64 channel data
  137172. */
  137173. sets: any;
  137174. /**
  137175. * The options of the Packer
  137176. */
  137177. options: ITexturePackerOptions;
  137178. /**
  137179. * The frame data of the Packer
  137180. */
  137181. frames: Array<number>;
  137182. }
  137183. /**
  137184. * This is a support class that generates a series of packed texture sets.
  137185. * @see https://doc.babylonjs.com/babylon101/materials
  137186. */
  137187. export class TexturePacker {
  137188. /** Packer Layout Constant 0 */
  137189. static readonly LAYOUT_STRIP: number;
  137190. /** Packer Layout Constant 1 */
  137191. static readonly LAYOUT_POWER2: number;
  137192. /** Packer Layout Constant 2 */
  137193. static readonly LAYOUT_COLNUM: number;
  137194. /** Packer Layout Constant 0 */
  137195. static readonly SUBUV_WRAP: number;
  137196. /** Packer Layout Constant 1 */
  137197. static readonly SUBUV_EXTEND: number;
  137198. /** Packer Layout Constant 2 */
  137199. static readonly SUBUV_COLOR: number;
  137200. /** The Name of the Texture Package */
  137201. name: string;
  137202. /** The scene scope of the TexturePacker */
  137203. scene: Scene;
  137204. /** The Meshes to target */
  137205. meshes: AbstractMesh[];
  137206. /** Arguments passed with the Constructor */
  137207. options: ITexturePackerOptions;
  137208. /** The promise that is started upon initialization */
  137209. promise: Nullable<Promise<TexturePacker | string>>;
  137210. /** The Container object for the channel sets that are generated */
  137211. sets: object;
  137212. /** The Container array for the frames that are generated */
  137213. frames: TexturePackerFrame[];
  137214. /** The expected number of textures the system is parsing. */
  137215. private _expecting;
  137216. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  137217. private _paddingValue;
  137218. /**
  137219. * Initializes a texture package series from an array of meshes or a single mesh.
  137220. * @param name The name of the package
  137221. * @param meshes The target meshes to compose the package from
  137222. * @param options The arguments that texture packer should follow while building.
  137223. * @param scene The scene which the textures are scoped to.
  137224. * @returns TexturePacker
  137225. */
  137226. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  137227. /**
  137228. * Starts the package process
  137229. * @param resolve The promises resolution function
  137230. * @returns TexturePacker
  137231. */
  137232. private _createFrames;
  137233. /**
  137234. * Calculates the Size of the Channel Sets
  137235. * @returns Vector2
  137236. */
  137237. private _calculateSize;
  137238. /**
  137239. * Calculates the UV data for the frames.
  137240. * @param baseSize the base frameSize
  137241. * @param padding the base frame padding
  137242. * @param dtSize size of the Dynamic Texture for that channel
  137243. * @param dtUnits is 1/dtSize
  137244. * @param update flag to update the input meshes
  137245. */
  137246. private _calculateMeshUVFrames;
  137247. /**
  137248. * Calculates the frames Offset.
  137249. * @param index of the frame
  137250. * @returns Vector2
  137251. */
  137252. private _getFrameOffset;
  137253. /**
  137254. * Updates a Mesh to the frame data
  137255. * @param mesh that is the target
  137256. * @param frameID or the frame index
  137257. */
  137258. private _updateMeshUV;
  137259. /**
  137260. * Updates a Meshes materials to use the texture packer channels
  137261. * @param m is the mesh to target
  137262. * @param force all channels on the packer to be set.
  137263. */
  137264. private _updateTextureReferences;
  137265. /**
  137266. * Public method to set a Mesh to a frame
  137267. * @param m that is the target
  137268. * @param frameID or the frame index
  137269. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  137270. */
  137271. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  137272. /**
  137273. * Starts the async promise to compile the texture packer.
  137274. * @returns Promise<void>
  137275. */
  137276. processAsync(): Promise<void>;
  137277. /**
  137278. * Disposes all textures associated with this packer
  137279. */
  137280. dispose(): void;
  137281. /**
  137282. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  137283. * @param imageType is the image type to use.
  137284. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  137285. */
  137286. download(imageType?: string, quality?: number): void;
  137287. /**
  137288. * Public method to load a texturePacker JSON file.
  137289. * @param data of the JSON file in string format.
  137290. */
  137291. updateFromJSON(data: string): void;
  137292. }
  137293. }
  137294. declare module BABYLON {
  137295. /**
  137296. * 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.
  137297. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  137298. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  137299. */
  137300. export class CustomProceduralTexture extends ProceduralTexture {
  137301. private _animate;
  137302. private _time;
  137303. private _config;
  137304. private _texturePath;
  137305. /**
  137306. * Instantiates a new Custom Procedural Texture.
  137307. * 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.
  137308. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  137309. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  137310. * @param name Define the name of the texture
  137311. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  137312. * @param size Define the size of the texture to create
  137313. * @param scene Define the scene the texture belongs to
  137314. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  137315. * @param generateMipMaps Define if the texture should creates mip maps or not
  137316. */
  137317. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  137318. private _loadJson;
  137319. /**
  137320. * Is the texture ready to be used ? (rendered at least once)
  137321. * @returns true if ready, otherwise, false.
  137322. */
  137323. isReady(): boolean;
  137324. /**
  137325. * Render the texture to its associated render target.
  137326. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  137327. */
  137328. render(useCameraPostProcess?: boolean): void;
  137329. /**
  137330. * Update the list of dependant textures samplers in the shader.
  137331. */
  137332. updateTextures(): void;
  137333. /**
  137334. * Update the uniform values of the procedural texture in the shader.
  137335. */
  137336. updateShaderUniforms(): void;
  137337. /**
  137338. * Define if the texture animates or not.
  137339. */
  137340. get animate(): boolean;
  137341. set animate(value: boolean);
  137342. }
  137343. }
  137344. declare module BABYLON {
  137345. /** @hidden */
  137346. export var noisePixelShader: {
  137347. name: string;
  137348. shader: string;
  137349. };
  137350. }
  137351. declare module BABYLON {
  137352. /**
  137353. * Class used to generate noise procedural textures
  137354. */
  137355. export class NoiseProceduralTexture extends ProceduralTexture {
  137356. private _time;
  137357. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  137358. brightness: number;
  137359. /** Defines the number of octaves to process */
  137360. octaves: number;
  137361. /** Defines the level of persistence (0.8 by default) */
  137362. persistence: number;
  137363. /** Gets or sets animation speed factor (default is 1) */
  137364. animationSpeedFactor: number;
  137365. /**
  137366. * Creates a new NoiseProceduralTexture
  137367. * @param name defines the name fo the texture
  137368. * @param size defines the size of the texture (default is 256)
  137369. * @param scene defines the hosting scene
  137370. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  137371. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  137372. */
  137373. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  137374. private _updateShaderUniforms;
  137375. protected _getDefines(): string;
  137376. /** Generate the current state of the procedural texture */
  137377. render(useCameraPostProcess?: boolean): void;
  137378. /**
  137379. * Serializes this noise procedural texture
  137380. * @returns a serialized noise procedural texture object
  137381. */
  137382. serialize(): any;
  137383. /**
  137384. * Clone the texture.
  137385. * @returns the cloned texture
  137386. */
  137387. clone(): NoiseProceduralTexture;
  137388. /**
  137389. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  137390. * @param parsedTexture defines parsed texture data
  137391. * @param scene defines the current scene
  137392. * @param rootUrl defines the root URL containing noise procedural texture information
  137393. * @returns a parsed NoiseProceduralTexture
  137394. */
  137395. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  137396. }
  137397. }
  137398. declare module BABYLON {
  137399. /**
  137400. * Raw cube texture where the raw buffers are passed in
  137401. */
  137402. export class RawCubeTexture extends CubeTexture {
  137403. /**
  137404. * Creates a cube texture where the raw buffers are passed in.
  137405. * @param scene defines the scene the texture is attached to
  137406. * @param data defines the array of data to use to create each face
  137407. * @param size defines the size of the textures
  137408. * @param format defines the format of the data
  137409. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  137410. * @param generateMipMaps defines if the engine should generate the mip levels
  137411. * @param invertY defines if data must be stored with Y axis inverted
  137412. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  137413. * @param compression defines the compression used (null by default)
  137414. */
  137415. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  137416. /**
  137417. * Updates the raw cube texture.
  137418. * @param data defines the data to store
  137419. * @param format defines the data format
  137420. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  137421. * @param invertY defines if data must be stored with Y axis inverted
  137422. * @param compression defines the compression used (null by default)
  137423. * @param level defines which level of the texture to update
  137424. */
  137425. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  137426. /**
  137427. * Updates a raw cube texture with RGBD encoded data.
  137428. * @param data defines the array of data [mipmap][face] to use to create each face
  137429. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  137430. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  137431. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  137432. * @returns a promsie that resolves when the operation is complete
  137433. */
  137434. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  137435. /**
  137436. * Clones the raw cube texture.
  137437. * @return a new cube texture
  137438. */
  137439. clone(): CubeTexture;
  137440. /** @hidden */
  137441. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  137442. }
  137443. }
  137444. declare module BABYLON {
  137445. /**
  137446. * Class used to store 2D array textures containing user data
  137447. */
  137448. export class RawTexture2DArray extends Texture {
  137449. /** Gets or sets the texture format to use */
  137450. format: number;
  137451. /**
  137452. * Create a new RawTexture2DArray
  137453. * @param data defines the data of the texture
  137454. * @param width defines the width of the texture
  137455. * @param height defines the height of the texture
  137456. * @param depth defines the number of layers of the texture
  137457. * @param format defines the texture format to use
  137458. * @param scene defines the hosting scene
  137459. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  137460. * @param invertY defines if texture must be stored with Y axis inverted
  137461. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  137462. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  137463. */
  137464. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  137465. /** Gets or sets the texture format to use */
  137466. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  137467. /**
  137468. * Update the texture with new data
  137469. * @param data defines the data to store in the texture
  137470. */
  137471. update(data: ArrayBufferView): void;
  137472. }
  137473. }
  137474. declare module BABYLON {
  137475. /**
  137476. * Class used to store 3D textures containing user data
  137477. */
  137478. export class RawTexture3D extends Texture {
  137479. /** Gets or sets the texture format to use */
  137480. format: number;
  137481. /**
  137482. * Create a new RawTexture3D
  137483. * @param data defines the data of the texture
  137484. * @param width defines the width of the texture
  137485. * @param height defines the height of the texture
  137486. * @param depth defines the depth of the texture
  137487. * @param format defines the texture format to use
  137488. * @param scene defines the hosting scene
  137489. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  137490. * @param invertY defines if texture must be stored with Y axis inverted
  137491. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  137492. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  137493. */
  137494. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  137495. /** Gets or sets the texture format to use */
  137496. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  137497. /**
  137498. * Update the texture with new data
  137499. * @param data defines the data to store in the texture
  137500. */
  137501. update(data: ArrayBufferView): void;
  137502. }
  137503. }
  137504. declare module BABYLON {
  137505. /**
  137506. * Creates a refraction texture used by refraction channel of the standard material.
  137507. * It is like a mirror but to see through a material.
  137508. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  137509. */
  137510. export class RefractionTexture extends RenderTargetTexture {
  137511. /**
  137512. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  137513. * 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.
  137514. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  137515. */
  137516. refractionPlane: Plane;
  137517. /**
  137518. * Define how deep under the surface we should see.
  137519. */
  137520. depth: number;
  137521. /**
  137522. * Creates a refraction texture used by refraction channel of the standard material.
  137523. * It is like a mirror but to see through a material.
  137524. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  137525. * @param name Define the texture name
  137526. * @param size Define the size of the underlying texture
  137527. * @param scene Define the scene the refraction belongs to
  137528. * @param generateMipMaps Define if we need to generate mips level for the refraction
  137529. */
  137530. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  137531. /**
  137532. * Clone the refraction texture.
  137533. * @returns the cloned texture
  137534. */
  137535. clone(): RefractionTexture;
  137536. /**
  137537. * Serialize the texture to a JSON representation you could use in Parse later on
  137538. * @returns the serialized JSON representation
  137539. */
  137540. serialize(): any;
  137541. }
  137542. }
  137543. declare module BABYLON {
  137544. /**
  137545. * Block used to add support for vertex skinning (bones)
  137546. */
  137547. export class BonesBlock extends NodeMaterialBlock {
  137548. /**
  137549. * Creates a new BonesBlock
  137550. * @param name defines the block name
  137551. */
  137552. constructor(name: string);
  137553. /**
  137554. * Initialize the block and prepare the context for build
  137555. * @param state defines the state that will be used for the build
  137556. */
  137557. initialize(state: NodeMaterialBuildState): void;
  137558. /**
  137559. * Gets the current class name
  137560. * @returns the class name
  137561. */
  137562. getClassName(): string;
  137563. /**
  137564. * Gets the matrix indices input component
  137565. */
  137566. get matricesIndices(): NodeMaterialConnectionPoint;
  137567. /**
  137568. * Gets the matrix weights input component
  137569. */
  137570. get matricesWeights(): NodeMaterialConnectionPoint;
  137571. /**
  137572. * Gets the extra matrix indices input component
  137573. */
  137574. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  137575. /**
  137576. * Gets the extra matrix weights input component
  137577. */
  137578. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  137579. /**
  137580. * Gets the world input component
  137581. */
  137582. get world(): NodeMaterialConnectionPoint;
  137583. /**
  137584. * Gets the output component
  137585. */
  137586. get output(): NodeMaterialConnectionPoint;
  137587. autoConfigure(material: NodeMaterial): void;
  137588. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  137589. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  137590. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  137591. protected _buildBlock(state: NodeMaterialBuildState): this;
  137592. }
  137593. }
  137594. declare module BABYLON {
  137595. /**
  137596. * Block used to add support for instances
  137597. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  137598. */
  137599. export class InstancesBlock extends NodeMaterialBlock {
  137600. /**
  137601. * Creates a new InstancesBlock
  137602. * @param name defines the block name
  137603. */
  137604. constructor(name: string);
  137605. /**
  137606. * Gets the current class name
  137607. * @returns the class name
  137608. */
  137609. getClassName(): string;
  137610. /**
  137611. * Gets the first world row input component
  137612. */
  137613. get world0(): NodeMaterialConnectionPoint;
  137614. /**
  137615. * Gets the second world row input component
  137616. */
  137617. get world1(): NodeMaterialConnectionPoint;
  137618. /**
  137619. * Gets the third world row input component
  137620. */
  137621. get world2(): NodeMaterialConnectionPoint;
  137622. /**
  137623. * Gets the forth world row input component
  137624. */
  137625. get world3(): NodeMaterialConnectionPoint;
  137626. /**
  137627. * Gets the world input component
  137628. */
  137629. get world(): NodeMaterialConnectionPoint;
  137630. /**
  137631. * Gets the output component
  137632. */
  137633. get output(): NodeMaterialConnectionPoint;
  137634. /**
  137635. * Gets the isntanceID component
  137636. */
  137637. get instanceID(): NodeMaterialConnectionPoint;
  137638. autoConfigure(material: NodeMaterial): void;
  137639. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  137640. protected _buildBlock(state: NodeMaterialBuildState): this;
  137641. }
  137642. }
  137643. declare module BABYLON {
  137644. /**
  137645. * Block used to add morph targets support to vertex shader
  137646. */
  137647. export class MorphTargetsBlock extends NodeMaterialBlock {
  137648. private _repeatableContentAnchor;
  137649. /**
  137650. * Create a new MorphTargetsBlock
  137651. * @param name defines the block name
  137652. */
  137653. constructor(name: string);
  137654. /**
  137655. * Gets the current class name
  137656. * @returns the class name
  137657. */
  137658. getClassName(): string;
  137659. /**
  137660. * Gets the position input component
  137661. */
  137662. get position(): NodeMaterialConnectionPoint;
  137663. /**
  137664. * Gets the normal input component
  137665. */
  137666. get normal(): NodeMaterialConnectionPoint;
  137667. /**
  137668. * Gets the tangent input component
  137669. */
  137670. get tangent(): NodeMaterialConnectionPoint;
  137671. /**
  137672. * Gets the tangent input component
  137673. */
  137674. get uv(): NodeMaterialConnectionPoint;
  137675. /**
  137676. * Gets the position output component
  137677. */
  137678. get positionOutput(): NodeMaterialConnectionPoint;
  137679. /**
  137680. * Gets the normal output component
  137681. */
  137682. get normalOutput(): NodeMaterialConnectionPoint;
  137683. /**
  137684. * Gets the tangent output component
  137685. */
  137686. get tangentOutput(): NodeMaterialConnectionPoint;
  137687. /**
  137688. * Gets the tangent output component
  137689. */
  137690. get uvOutput(): NodeMaterialConnectionPoint;
  137691. initialize(state: NodeMaterialBuildState): void;
  137692. autoConfigure(material: NodeMaterial): void;
  137693. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  137694. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  137695. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  137696. protected _buildBlock(state: NodeMaterialBuildState): this;
  137697. }
  137698. }
  137699. declare module BABYLON {
  137700. /**
  137701. * Block used to get data information from a light
  137702. */
  137703. export class LightInformationBlock extends NodeMaterialBlock {
  137704. private _lightDataUniformName;
  137705. private _lightColorUniformName;
  137706. private _lightTypeDefineName;
  137707. /**
  137708. * Gets or sets the light associated with this block
  137709. */
  137710. light: Nullable<Light>;
  137711. /**
  137712. * Creates a new LightInformationBlock
  137713. * @param name defines the block name
  137714. */
  137715. constructor(name: string);
  137716. /**
  137717. * Gets the current class name
  137718. * @returns the class name
  137719. */
  137720. getClassName(): string;
  137721. /**
  137722. * Gets the world position input component
  137723. */
  137724. get worldPosition(): NodeMaterialConnectionPoint;
  137725. /**
  137726. * Gets the direction output component
  137727. */
  137728. get direction(): NodeMaterialConnectionPoint;
  137729. /**
  137730. * Gets the direction output component
  137731. */
  137732. get color(): NodeMaterialConnectionPoint;
  137733. /**
  137734. * Gets the direction output component
  137735. */
  137736. get intensity(): NodeMaterialConnectionPoint;
  137737. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  137738. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  137739. protected _buildBlock(state: NodeMaterialBuildState): this;
  137740. serialize(): any;
  137741. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  137742. }
  137743. }
  137744. declare module BABYLON {
  137745. /**
  137746. * Block used to add image processing support to fragment shader
  137747. */
  137748. export class ImageProcessingBlock extends NodeMaterialBlock {
  137749. /**
  137750. * Create a new ImageProcessingBlock
  137751. * @param name defines the block name
  137752. */
  137753. constructor(name: string);
  137754. /**
  137755. * Gets the current class name
  137756. * @returns the class name
  137757. */
  137758. getClassName(): string;
  137759. /**
  137760. * Gets the color input component
  137761. */
  137762. get color(): NodeMaterialConnectionPoint;
  137763. /**
  137764. * Gets the output component
  137765. */
  137766. get output(): NodeMaterialConnectionPoint;
  137767. /**
  137768. * Initialize the block and prepare the context for build
  137769. * @param state defines the state that will be used for the build
  137770. */
  137771. initialize(state: NodeMaterialBuildState): void;
  137772. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  137773. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  137774. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  137775. protected _buildBlock(state: NodeMaterialBuildState): this;
  137776. }
  137777. }
  137778. declare module BABYLON {
  137779. /**
  137780. * Block used to pertub normals based on a normal map
  137781. */
  137782. export class PerturbNormalBlock extends NodeMaterialBlock {
  137783. private _tangentSpaceParameterName;
  137784. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  137785. invertX: boolean;
  137786. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  137787. invertY: boolean;
  137788. /**
  137789. * Create a new PerturbNormalBlock
  137790. * @param name defines the block name
  137791. */
  137792. constructor(name: string);
  137793. /**
  137794. * Gets the current class name
  137795. * @returns the class name
  137796. */
  137797. getClassName(): string;
  137798. /**
  137799. * Gets the world position input component
  137800. */
  137801. get worldPosition(): NodeMaterialConnectionPoint;
  137802. /**
  137803. * Gets the world normal input component
  137804. */
  137805. get worldNormal(): NodeMaterialConnectionPoint;
  137806. /**
  137807. * Gets the world tangent input component
  137808. */
  137809. get worldTangent(): NodeMaterialConnectionPoint;
  137810. /**
  137811. * Gets the uv input component
  137812. */
  137813. get uv(): NodeMaterialConnectionPoint;
  137814. /**
  137815. * Gets the normal map color input component
  137816. */
  137817. get normalMapColor(): NodeMaterialConnectionPoint;
  137818. /**
  137819. * Gets the strength input component
  137820. */
  137821. get strength(): NodeMaterialConnectionPoint;
  137822. /**
  137823. * Gets the output component
  137824. */
  137825. get output(): NodeMaterialConnectionPoint;
  137826. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  137827. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  137828. autoConfigure(material: NodeMaterial): void;
  137829. protected _buildBlock(state: NodeMaterialBuildState): this;
  137830. protected _dumpPropertiesCode(): string;
  137831. serialize(): any;
  137832. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  137833. }
  137834. }
  137835. declare module BABYLON {
  137836. /**
  137837. * Block used to discard a pixel if a value is smaller than a cutoff
  137838. */
  137839. export class DiscardBlock extends NodeMaterialBlock {
  137840. /**
  137841. * Create a new DiscardBlock
  137842. * @param name defines the block name
  137843. */
  137844. constructor(name: string);
  137845. /**
  137846. * Gets the current class name
  137847. * @returns the class name
  137848. */
  137849. getClassName(): string;
  137850. /**
  137851. * Gets the color input component
  137852. */
  137853. get value(): NodeMaterialConnectionPoint;
  137854. /**
  137855. * Gets the cutoff input component
  137856. */
  137857. get cutoff(): NodeMaterialConnectionPoint;
  137858. protected _buildBlock(state: NodeMaterialBuildState): this;
  137859. }
  137860. }
  137861. declare module BABYLON {
  137862. /**
  137863. * Block used to test if the fragment shader is front facing
  137864. */
  137865. export class FrontFacingBlock extends NodeMaterialBlock {
  137866. /**
  137867. * Creates a new FrontFacingBlock
  137868. * @param name defines the block name
  137869. */
  137870. constructor(name: string);
  137871. /**
  137872. * Gets the current class name
  137873. * @returns the class name
  137874. */
  137875. getClassName(): string;
  137876. /**
  137877. * Gets the output component
  137878. */
  137879. get output(): NodeMaterialConnectionPoint;
  137880. protected _buildBlock(state: NodeMaterialBuildState): this;
  137881. }
  137882. }
  137883. declare module BABYLON {
  137884. /**
  137885. * Block used to get the derivative value on x and y of a given input
  137886. */
  137887. export class DerivativeBlock extends NodeMaterialBlock {
  137888. /**
  137889. * Create a new DerivativeBlock
  137890. * @param name defines the block name
  137891. */
  137892. constructor(name: string);
  137893. /**
  137894. * Gets the current class name
  137895. * @returns the class name
  137896. */
  137897. getClassName(): string;
  137898. /**
  137899. * Gets the input component
  137900. */
  137901. get input(): NodeMaterialConnectionPoint;
  137902. /**
  137903. * Gets the derivative output on x
  137904. */
  137905. get dx(): NodeMaterialConnectionPoint;
  137906. /**
  137907. * Gets the derivative output on y
  137908. */
  137909. get dy(): NodeMaterialConnectionPoint;
  137910. protected _buildBlock(state: NodeMaterialBuildState): this;
  137911. }
  137912. }
  137913. declare module BABYLON {
  137914. /**
  137915. * Block used to add support for scene fog
  137916. */
  137917. export class FogBlock extends NodeMaterialBlock {
  137918. private _fogDistanceName;
  137919. private _fogParameters;
  137920. /**
  137921. * Create a new FogBlock
  137922. * @param name defines the block name
  137923. */
  137924. constructor(name: string);
  137925. /**
  137926. * Gets the current class name
  137927. * @returns the class name
  137928. */
  137929. getClassName(): string;
  137930. /**
  137931. * Gets the world position input component
  137932. */
  137933. get worldPosition(): NodeMaterialConnectionPoint;
  137934. /**
  137935. * Gets the view input component
  137936. */
  137937. get view(): NodeMaterialConnectionPoint;
  137938. /**
  137939. * Gets the color input component
  137940. */
  137941. get input(): NodeMaterialConnectionPoint;
  137942. /**
  137943. * Gets the fog color input component
  137944. */
  137945. get fogColor(): NodeMaterialConnectionPoint;
  137946. /**
  137947. * Gets the output component
  137948. */
  137949. get output(): NodeMaterialConnectionPoint;
  137950. autoConfigure(material: NodeMaterial): void;
  137951. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  137952. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  137953. protected _buildBlock(state: NodeMaterialBuildState): this;
  137954. }
  137955. }
  137956. declare module BABYLON {
  137957. /**
  137958. * Block used to add light in the fragment shader
  137959. */
  137960. export class LightBlock extends NodeMaterialBlock {
  137961. private _lightId;
  137962. /**
  137963. * Gets or sets the light associated with this block
  137964. */
  137965. light: Nullable<Light>;
  137966. /**
  137967. * Create a new LightBlock
  137968. * @param name defines the block name
  137969. */
  137970. constructor(name: string);
  137971. /**
  137972. * Gets the current class name
  137973. * @returns the class name
  137974. */
  137975. getClassName(): string;
  137976. /**
  137977. * Gets the world position input component
  137978. */
  137979. get worldPosition(): NodeMaterialConnectionPoint;
  137980. /**
  137981. * Gets the world normal input component
  137982. */
  137983. get worldNormal(): NodeMaterialConnectionPoint;
  137984. /**
  137985. * Gets the camera (or eye) position component
  137986. */
  137987. get cameraPosition(): NodeMaterialConnectionPoint;
  137988. /**
  137989. * Gets the glossiness component
  137990. */
  137991. get glossiness(): NodeMaterialConnectionPoint;
  137992. /**
  137993. * Gets the glossinness power component
  137994. */
  137995. get glossPower(): NodeMaterialConnectionPoint;
  137996. /**
  137997. * Gets the diffuse color component
  137998. */
  137999. get diffuseColor(): NodeMaterialConnectionPoint;
  138000. /**
  138001. * Gets the specular color component
  138002. */
  138003. get specularColor(): NodeMaterialConnectionPoint;
  138004. /**
  138005. * Gets the diffuse output component
  138006. */
  138007. get diffuseOutput(): NodeMaterialConnectionPoint;
  138008. /**
  138009. * Gets the specular output component
  138010. */
  138011. get specularOutput(): NodeMaterialConnectionPoint;
  138012. /**
  138013. * Gets the shadow output component
  138014. */
  138015. get shadow(): NodeMaterialConnectionPoint;
  138016. autoConfigure(material: NodeMaterial): void;
  138017. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  138018. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  138019. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  138020. private _injectVertexCode;
  138021. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  138022. serialize(): any;
  138023. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  138024. }
  138025. }
  138026. declare module BABYLON {
  138027. /**
  138028. * Block used to read a reflection texture from a sampler
  138029. */
  138030. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  138031. /**
  138032. * Create a new ReflectionTextureBlock
  138033. * @param name defines the block name
  138034. */
  138035. constructor(name: string);
  138036. /**
  138037. * Gets the current class name
  138038. * @returns the class name
  138039. */
  138040. getClassName(): string;
  138041. /**
  138042. * Gets the world position input component
  138043. */
  138044. get position(): NodeMaterialConnectionPoint;
  138045. /**
  138046. * Gets the world position input component
  138047. */
  138048. get worldPosition(): NodeMaterialConnectionPoint;
  138049. /**
  138050. * Gets the world normal input component
  138051. */
  138052. get worldNormal(): NodeMaterialConnectionPoint;
  138053. /**
  138054. * Gets the world input component
  138055. */
  138056. get world(): NodeMaterialConnectionPoint;
  138057. /**
  138058. * Gets the camera (or eye) position component
  138059. */
  138060. get cameraPosition(): NodeMaterialConnectionPoint;
  138061. /**
  138062. * Gets the view input component
  138063. */
  138064. get view(): NodeMaterialConnectionPoint;
  138065. /**
  138066. * Gets the rgb output component
  138067. */
  138068. get rgb(): NodeMaterialConnectionPoint;
  138069. /**
  138070. * Gets the r output component
  138071. */
  138072. get r(): NodeMaterialConnectionPoint;
  138073. /**
  138074. * Gets the g output component
  138075. */
  138076. get g(): NodeMaterialConnectionPoint;
  138077. /**
  138078. * Gets the b output component
  138079. */
  138080. get b(): NodeMaterialConnectionPoint;
  138081. autoConfigure(material: NodeMaterial): void;
  138082. protected _buildBlock(state: NodeMaterialBuildState): this;
  138083. }
  138084. }
  138085. declare module BABYLON {
  138086. /**
  138087. * Block used to add 2 vectors
  138088. */
  138089. export class AddBlock extends NodeMaterialBlock {
  138090. /**
  138091. * Creates a new AddBlock
  138092. * @param name defines the block name
  138093. */
  138094. constructor(name: string);
  138095. /**
  138096. * Gets the current class name
  138097. * @returns the class name
  138098. */
  138099. getClassName(): string;
  138100. /**
  138101. * Gets the left operand input component
  138102. */
  138103. get left(): NodeMaterialConnectionPoint;
  138104. /**
  138105. * Gets the right operand input component
  138106. */
  138107. get right(): NodeMaterialConnectionPoint;
  138108. /**
  138109. * Gets the output component
  138110. */
  138111. get output(): NodeMaterialConnectionPoint;
  138112. protected _buildBlock(state: NodeMaterialBuildState): this;
  138113. }
  138114. }
  138115. declare module BABYLON {
  138116. /**
  138117. * Block used to scale a vector by a float
  138118. */
  138119. export class ScaleBlock extends NodeMaterialBlock {
  138120. /**
  138121. * Creates a new ScaleBlock
  138122. * @param name defines the block name
  138123. */
  138124. constructor(name: string);
  138125. /**
  138126. * Gets the current class name
  138127. * @returns the class name
  138128. */
  138129. getClassName(): string;
  138130. /**
  138131. * Gets the input component
  138132. */
  138133. get input(): NodeMaterialConnectionPoint;
  138134. /**
  138135. * Gets the factor input component
  138136. */
  138137. get factor(): NodeMaterialConnectionPoint;
  138138. /**
  138139. * Gets the output component
  138140. */
  138141. get output(): NodeMaterialConnectionPoint;
  138142. protected _buildBlock(state: NodeMaterialBuildState): this;
  138143. }
  138144. }
  138145. declare module BABYLON {
  138146. /**
  138147. * Block used to clamp a float
  138148. */
  138149. export class ClampBlock extends NodeMaterialBlock {
  138150. /** Gets or sets the minimum range */
  138151. minimum: number;
  138152. /** Gets or sets the maximum range */
  138153. maximum: number;
  138154. /**
  138155. * Creates a new ClampBlock
  138156. * @param name defines the block name
  138157. */
  138158. constructor(name: string);
  138159. /**
  138160. * Gets the current class name
  138161. * @returns the class name
  138162. */
  138163. getClassName(): string;
  138164. /**
  138165. * Gets the value input component
  138166. */
  138167. get value(): NodeMaterialConnectionPoint;
  138168. /**
  138169. * Gets the output component
  138170. */
  138171. get output(): NodeMaterialConnectionPoint;
  138172. protected _buildBlock(state: NodeMaterialBuildState): this;
  138173. protected _dumpPropertiesCode(): string;
  138174. serialize(): any;
  138175. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  138176. }
  138177. }
  138178. declare module BABYLON {
  138179. /**
  138180. * Block used to apply a cross product between 2 vectors
  138181. */
  138182. export class CrossBlock extends NodeMaterialBlock {
  138183. /**
  138184. * Creates a new CrossBlock
  138185. * @param name defines the block name
  138186. */
  138187. constructor(name: string);
  138188. /**
  138189. * Gets the current class name
  138190. * @returns the class name
  138191. */
  138192. getClassName(): string;
  138193. /**
  138194. * Gets the left operand input component
  138195. */
  138196. get left(): NodeMaterialConnectionPoint;
  138197. /**
  138198. * Gets the right operand input component
  138199. */
  138200. get right(): NodeMaterialConnectionPoint;
  138201. /**
  138202. * Gets the output component
  138203. */
  138204. get output(): NodeMaterialConnectionPoint;
  138205. protected _buildBlock(state: NodeMaterialBuildState): this;
  138206. }
  138207. }
  138208. declare module BABYLON {
  138209. /**
  138210. * Block used to apply a dot product between 2 vectors
  138211. */
  138212. export class DotBlock extends NodeMaterialBlock {
  138213. /**
  138214. * Creates a new DotBlock
  138215. * @param name defines the block name
  138216. */
  138217. constructor(name: string);
  138218. /**
  138219. * Gets the current class name
  138220. * @returns the class name
  138221. */
  138222. getClassName(): string;
  138223. /**
  138224. * Gets the left operand input component
  138225. */
  138226. get left(): NodeMaterialConnectionPoint;
  138227. /**
  138228. * Gets the right operand input component
  138229. */
  138230. get right(): NodeMaterialConnectionPoint;
  138231. /**
  138232. * Gets the output component
  138233. */
  138234. get output(): NodeMaterialConnectionPoint;
  138235. protected _buildBlock(state: NodeMaterialBuildState): this;
  138236. }
  138237. }
  138238. declare module BABYLON {
  138239. /**
  138240. * Block used to normalize a vector
  138241. */
  138242. export class NormalizeBlock extends NodeMaterialBlock {
  138243. /**
  138244. * Creates a new NormalizeBlock
  138245. * @param name defines the block name
  138246. */
  138247. constructor(name: string);
  138248. /**
  138249. * Gets the current class name
  138250. * @returns the class name
  138251. */
  138252. getClassName(): string;
  138253. /**
  138254. * Gets the input component
  138255. */
  138256. get input(): NodeMaterialConnectionPoint;
  138257. /**
  138258. * Gets the output component
  138259. */
  138260. get output(): NodeMaterialConnectionPoint;
  138261. protected _buildBlock(state: NodeMaterialBuildState): this;
  138262. }
  138263. }
  138264. declare module BABYLON {
  138265. /**
  138266. * Operations supported by the Trigonometry block
  138267. */
  138268. export enum TrigonometryBlockOperations {
  138269. /** Cos */
  138270. Cos = 0,
  138271. /** Sin */
  138272. Sin = 1,
  138273. /** Abs */
  138274. Abs = 2,
  138275. /** Exp */
  138276. Exp = 3,
  138277. /** Exp2 */
  138278. Exp2 = 4,
  138279. /** Round */
  138280. Round = 5,
  138281. /** Floor */
  138282. Floor = 6,
  138283. /** Ceiling */
  138284. Ceiling = 7,
  138285. /** Square root */
  138286. Sqrt = 8,
  138287. /** Log */
  138288. Log = 9,
  138289. /** Tangent */
  138290. Tan = 10,
  138291. /** Arc tangent */
  138292. ArcTan = 11,
  138293. /** Arc cosinus */
  138294. ArcCos = 12,
  138295. /** Arc sinus */
  138296. ArcSin = 13,
  138297. /** Fraction */
  138298. Fract = 14,
  138299. /** Sign */
  138300. Sign = 15,
  138301. /** To radians (from degrees) */
  138302. Radians = 16,
  138303. /** To degrees (from radians) */
  138304. Degrees = 17
  138305. }
  138306. /**
  138307. * Block used to apply trigonometry operation to floats
  138308. */
  138309. export class TrigonometryBlock extends NodeMaterialBlock {
  138310. /**
  138311. * Gets or sets the operation applied by the block
  138312. */
  138313. operation: TrigonometryBlockOperations;
  138314. /**
  138315. * Creates a new TrigonometryBlock
  138316. * @param name defines the block name
  138317. */
  138318. constructor(name: string);
  138319. /**
  138320. * Gets the current class name
  138321. * @returns the class name
  138322. */
  138323. getClassName(): string;
  138324. /**
  138325. * Gets the input component
  138326. */
  138327. get input(): NodeMaterialConnectionPoint;
  138328. /**
  138329. * Gets the output component
  138330. */
  138331. get output(): NodeMaterialConnectionPoint;
  138332. protected _buildBlock(state: NodeMaterialBuildState): this;
  138333. serialize(): any;
  138334. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  138335. protected _dumpPropertiesCode(): string;
  138336. }
  138337. }
  138338. declare module BABYLON {
  138339. /**
  138340. * Block used to create a Color3/4 out of individual inputs (one for each component)
  138341. */
  138342. export class ColorMergerBlock extends NodeMaterialBlock {
  138343. /**
  138344. * Create a new ColorMergerBlock
  138345. * @param name defines the block name
  138346. */
  138347. constructor(name: string);
  138348. /**
  138349. * Gets the current class name
  138350. * @returns the class name
  138351. */
  138352. getClassName(): string;
  138353. /**
  138354. * Gets the rgb component (input)
  138355. */
  138356. get rgbIn(): NodeMaterialConnectionPoint;
  138357. /**
  138358. * Gets the r component (input)
  138359. */
  138360. get r(): NodeMaterialConnectionPoint;
  138361. /**
  138362. * Gets the g component (input)
  138363. */
  138364. get g(): NodeMaterialConnectionPoint;
  138365. /**
  138366. * Gets the b component (input)
  138367. */
  138368. get b(): NodeMaterialConnectionPoint;
  138369. /**
  138370. * Gets the a component (input)
  138371. */
  138372. get a(): NodeMaterialConnectionPoint;
  138373. /**
  138374. * Gets the rgba component (output)
  138375. */
  138376. get rgba(): NodeMaterialConnectionPoint;
  138377. /**
  138378. * Gets the rgb component (output)
  138379. */
  138380. get rgbOut(): NodeMaterialConnectionPoint;
  138381. /**
  138382. * Gets the rgb component (output)
  138383. * @deprecated Please use rgbOut instead.
  138384. */
  138385. get rgb(): NodeMaterialConnectionPoint;
  138386. protected _buildBlock(state: NodeMaterialBuildState): this;
  138387. }
  138388. }
  138389. declare module BABYLON {
  138390. /**
  138391. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  138392. */
  138393. export class VectorSplitterBlock extends NodeMaterialBlock {
  138394. /**
  138395. * Create a new VectorSplitterBlock
  138396. * @param name defines the block name
  138397. */
  138398. constructor(name: string);
  138399. /**
  138400. * Gets the current class name
  138401. * @returns the class name
  138402. */
  138403. getClassName(): string;
  138404. /**
  138405. * Gets the xyzw component (input)
  138406. */
  138407. get xyzw(): NodeMaterialConnectionPoint;
  138408. /**
  138409. * Gets the xyz component (input)
  138410. */
  138411. get xyzIn(): NodeMaterialConnectionPoint;
  138412. /**
  138413. * Gets the xy component (input)
  138414. */
  138415. get xyIn(): NodeMaterialConnectionPoint;
  138416. /**
  138417. * Gets the xyz component (output)
  138418. */
  138419. get xyzOut(): NodeMaterialConnectionPoint;
  138420. /**
  138421. * Gets the xy component (output)
  138422. */
  138423. get xyOut(): NodeMaterialConnectionPoint;
  138424. /**
  138425. * Gets the x component (output)
  138426. */
  138427. get x(): NodeMaterialConnectionPoint;
  138428. /**
  138429. * Gets the y component (output)
  138430. */
  138431. get y(): NodeMaterialConnectionPoint;
  138432. /**
  138433. * Gets the z component (output)
  138434. */
  138435. get z(): NodeMaterialConnectionPoint;
  138436. /**
  138437. * Gets the w component (output)
  138438. */
  138439. get w(): NodeMaterialConnectionPoint;
  138440. protected _inputRename(name: string): string;
  138441. protected _outputRename(name: string): string;
  138442. protected _buildBlock(state: NodeMaterialBuildState): this;
  138443. }
  138444. }
  138445. declare module BABYLON {
  138446. /**
  138447. * Block used to lerp between 2 values
  138448. */
  138449. export class LerpBlock extends NodeMaterialBlock {
  138450. /**
  138451. * Creates a new LerpBlock
  138452. * @param name defines the block name
  138453. */
  138454. constructor(name: string);
  138455. /**
  138456. * Gets the current class name
  138457. * @returns the class name
  138458. */
  138459. getClassName(): string;
  138460. /**
  138461. * Gets the left operand input component
  138462. */
  138463. get left(): NodeMaterialConnectionPoint;
  138464. /**
  138465. * Gets the right operand input component
  138466. */
  138467. get right(): NodeMaterialConnectionPoint;
  138468. /**
  138469. * Gets the gradient operand input component
  138470. */
  138471. get gradient(): NodeMaterialConnectionPoint;
  138472. /**
  138473. * Gets the output component
  138474. */
  138475. get output(): NodeMaterialConnectionPoint;
  138476. protected _buildBlock(state: NodeMaterialBuildState): this;
  138477. }
  138478. }
  138479. declare module BABYLON {
  138480. /**
  138481. * Block used to divide 2 vectors
  138482. */
  138483. export class DivideBlock extends NodeMaterialBlock {
  138484. /**
  138485. * Creates a new DivideBlock
  138486. * @param name defines the block name
  138487. */
  138488. constructor(name: string);
  138489. /**
  138490. * Gets the current class name
  138491. * @returns the class name
  138492. */
  138493. getClassName(): string;
  138494. /**
  138495. * Gets the left operand input component
  138496. */
  138497. get left(): NodeMaterialConnectionPoint;
  138498. /**
  138499. * Gets the right operand input component
  138500. */
  138501. get right(): NodeMaterialConnectionPoint;
  138502. /**
  138503. * Gets the output component
  138504. */
  138505. get output(): NodeMaterialConnectionPoint;
  138506. protected _buildBlock(state: NodeMaterialBuildState): this;
  138507. }
  138508. }
  138509. declare module BABYLON {
  138510. /**
  138511. * Block used to subtract 2 vectors
  138512. */
  138513. export class SubtractBlock extends NodeMaterialBlock {
  138514. /**
  138515. * Creates a new SubtractBlock
  138516. * @param name defines the block name
  138517. */
  138518. constructor(name: string);
  138519. /**
  138520. * Gets the current class name
  138521. * @returns the class name
  138522. */
  138523. getClassName(): string;
  138524. /**
  138525. * Gets the left operand input component
  138526. */
  138527. get left(): NodeMaterialConnectionPoint;
  138528. /**
  138529. * Gets the right operand input component
  138530. */
  138531. get right(): NodeMaterialConnectionPoint;
  138532. /**
  138533. * Gets the output component
  138534. */
  138535. get output(): NodeMaterialConnectionPoint;
  138536. protected _buildBlock(state: NodeMaterialBuildState): this;
  138537. }
  138538. }
  138539. declare module BABYLON {
  138540. /**
  138541. * Block used to step a value
  138542. */
  138543. export class StepBlock extends NodeMaterialBlock {
  138544. /**
  138545. * Creates a new StepBlock
  138546. * @param name defines the block name
  138547. */
  138548. constructor(name: string);
  138549. /**
  138550. * Gets the current class name
  138551. * @returns the class name
  138552. */
  138553. getClassName(): string;
  138554. /**
  138555. * Gets the value operand input component
  138556. */
  138557. get value(): NodeMaterialConnectionPoint;
  138558. /**
  138559. * Gets the edge operand input component
  138560. */
  138561. get edge(): NodeMaterialConnectionPoint;
  138562. /**
  138563. * Gets the output component
  138564. */
  138565. get output(): NodeMaterialConnectionPoint;
  138566. protected _buildBlock(state: NodeMaterialBuildState): this;
  138567. }
  138568. }
  138569. declare module BABYLON {
  138570. /**
  138571. * Block used to get the opposite (1 - x) of a value
  138572. */
  138573. export class OneMinusBlock extends NodeMaterialBlock {
  138574. /**
  138575. * Creates a new OneMinusBlock
  138576. * @param name defines the block name
  138577. */
  138578. constructor(name: string);
  138579. /**
  138580. * Gets the current class name
  138581. * @returns the class name
  138582. */
  138583. getClassName(): string;
  138584. /**
  138585. * Gets the input component
  138586. */
  138587. get input(): NodeMaterialConnectionPoint;
  138588. /**
  138589. * Gets the output component
  138590. */
  138591. get output(): NodeMaterialConnectionPoint;
  138592. protected _buildBlock(state: NodeMaterialBuildState): this;
  138593. }
  138594. }
  138595. declare module BABYLON {
  138596. /**
  138597. * Block used to get the view direction
  138598. */
  138599. export class ViewDirectionBlock extends NodeMaterialBlock {
  138600. /**
  138601. * Creates a new ViewDirectionBlock
  138602. * @param name defines the block name
  138603. */
  138604. constructor(name: string);
  138605. /**
  138606. * Gets the current class name
  138607. * @returns the class name
  138608. */
  138609. getClassName(): string;
  138610. /**
  138611. * Gets the world position component
  138612. */
  138613. get worldPosition(): NodeMaterialConnectionPoint;
  138614. /**
  138615. * Gets the camera position component
  138616. */
  138617. get cameraPosition(): NodeMaterialConnectionPoint;
  138618. /**
  138619. * Gets the output component
  138620. */
  138621. get output(): NodeMaterialConnectionPoint;
  138622. autoConfigure(material: NodeMaterial): void;
  138623. protected _buildBlock(state: NodeMaterialBuildState): this;
  138624. }
  138625. }
  138626. declare module BABYLON {
  138627. /**
  138628. * Block used to compute fresnel value
  138629. */
  138630. export class FresnelBlock extends NodeMaterialBlock {
  138631. /**
  138632. * Create a new FresnelBlock
  138633. * @param name defines the block name
  138634. */
  138635. constructor(name: string);
  138636. /**
  138637. * Gets the current class name
  138638. * @returns the class name
  138639. */
  138640. getClassName(): string;
  138641. /**
  138642. * Gets the world normal input component
  138643. */
  138644. get worldNormal(): NodeMaterialConnectionPoint;
  138645. /**
  138646. * Gets the view direction input component
  138647. */
  138648. get viewDirection(): NodeMaterialConnectionPoint;
  138649. /**
  138650. * Gets the bias input component
  138651. */
  138652. get bias(): NodeMaterialConnectionPoint;
  138653. /**
  138654. * Gets the camera (or eye) position component
  138655. */
  138656. get power(): NodeMaterialConnectionPoint;
  138657. /**
  138658. * Gets the fresnel output component
  138659. */
  138660. get fresnel(): NodeMaterialConnectionPoint;
  138661. autoConfigure(material: NodeMaterial): void;
  138662. protected _buildBlock(state: NodeMaterialBuildState): this;
  138663. }
  138664. }
  138665. declare module BABYLON {
  138666. /**
  138667. * Block used to get the max of 2 values
  138668. */
  138669. export class MaxBlock extends NodeMaterialBlock {
  138670. /**
  138671. * Creates a new MaxBlock
  138672. * @param name defines the block name
  138673. */
  138674. constructor(name: string);
  138675. /**
  138676. * Gets the current class name
  138677. * @returns the class name
  138678. */
  138679. getClassName(): string;
  138680. /**
  138681. * Gets the left operand input component
  138682. */
  138683. get left(): NodeMaterialConnectionPoint;
  138684. /**
  138685. * Gets the right operand input component
  138686. */
  138687. get right(): NodeMaterialConnectionPoint;
  138688. /**
  138689. * Gets the output component
  138690. */
  138691. get output(): NodeMaterialConnectionPoint;
  138692. protected _buildBlock(state: NodeMaterialBuildState): this;
  138693. }
  138694. }
  138695. declare module BABYLON {
  138696. /**
  138697. * Block used to get the min of 2 values
  138698. */
  138699. export class MinBlock extends NodeMaterialBlock {
  138700. /**
  138701. * Creates a new MinBlock
  138702. * @param name defines the block name
  138703. */
  138704. constructor(name: string);
  138705. /**
  138706. * Gets the current class name
  138707. * @returns the class name
  138708. */
  138709. getClassName(): string;
  138710. /**
  138711. * Gets the left operand input component
  138712. */
  138713. get left(): NodeMaterialConnectionPoint;
  138714. /**
  138715. * Gets the right operand input component
  138716. */
  138717. get right(): NodeMaterialConnectionPoint;
  138718. /**
  138719. * Gets the output component
  138720. */
  138721. get output(): NodeMaterialConnectionPoint;
  138722. protected _buildBlock(state: NodeMaterialBuildState): this;
  138723. }
  138724. }
  138725. declare module BABYLON {
  138726. /**
  138727. * Block used to get the distance between 2 values
  138728. */
  138729. export class DistanceBlock extends NodeMaterialBlock {
  138730. /**
  138731. * Creates a new DistanceBlock
  138732. * @param name defines the block name
  138733. */
  138734. constructor(name: string);
  138735. /**
  138736. * Gets the current class name
  138737. * @returns the class name
  138738. */
  138739. getClassName(): string;
  138740. /**
  138741. * Gets the left operand input component
  138742. */
  138743. get left(): NodeMaterialConnectionPoint;
  138744. /**
  138745. * Gets the right operand input component
  138746. */
  138747. get right(): NodeMaterialConnectionPoint;
  138748. /**
  138749. * Gets the output component
  138750. */
  138751. get output(): NodeMaterialConnectionPoint;
  138752. protected _buildBlock(state: NodeMaterialBuildState): this;
  138753. }
  138754. }
  138755. declare module BABYLON {
  138756. /**
  138757. * Block used to get the length of a vector
  138758. */
  138759. export class LengthBlock extends NodeMaterialBlock {
  138760. /**
  138761. * Creates a new LengthBlock
  138762. * @param name defines the block name
  138763. */
  138764. constructor(name: string);
  138765. /**
  138766. * Gets the current class name
  138767. * @returns the class name
  138768. */
  138769. getClassName(): string;
  138770. /**
  138771. * Gets the value input component
  138772. */
  138773. get value(): NodeMaterialConnectionPoint;
  138774. /**
  138775. * Gets the output component
  138776. */
  138777. get output(): NodeMaterialConnectionPoint;
  138778. protected _buildBlock(state: NodeMaterialBuildState): this;
  138779. }
  138780. }
  138781. declare module BABYLON {
  138782. /**
  138783. * Block used to get negative version of a value (i.e. x * -1)
  138784. */
  138785. export class NegateBlock extends NodeMaterialBlock {
  138786. /**
  138787. * Creates a new NegateBlock
  138788. * @param name defines the block name
  138789. */
  138790. constructor(name: string);
  138791. /**
  138792. * Gets the current class name
  138793. * @returns the class name
  138794. */
  138795. getClassName(): string;
  138796. /**
  138797. * Gets the value input component
  138798. */
  138799. get value(): NodeMaterialConnectionPoint;
  138800. /**
  138801. * Gets the output component
  138802. */
  138803. get output(): NodeMaterialConnectionPoint;
  138804. protected _buildBlock(state: NodeMaterialBuildState): this;
  138805. }
  138806. }
  138807. declare module BABYLON {
  138808. /**
  138809. * Block used to get the value of the first parameter raised to the power of the second
  138810. */
  138811. export class PowBlock extends NodeMaterialBlock {
  138812. /**
  138813. * Creates a new PowBlock
  138814. * @param name defines the block name
  138815. */
  138816. constructor(name: string);
  138817. /**
  138818. * Gets the current class name
  138819. * @returns the class name
  138820. */
  138821. getClassName(): string;
  138822. /**
  138823. * Gets the value operand input component
  138824. */
  138825. get value(): NodeMaterialConnectionPoint;
  138826. /**
  138827. * Gets the power operand input component
  138828. */
  138829. get power(): NodeMaterialConnectionPoint;
  138830. /**
  138831. * Gets the output component
  138832. */
  138833. get output(): NodeMaterialConnectionPoint;
  138834. protected _buildBlock(state: NodeMaterialBuildState): this;
  138835. }
  138836. }
  138837. declare module BABYLON {
  138838. /**
  138839. * Block used to get a random number
  138840. */
  138841. export class RandomNumberBlock extends NodeMaterialBlock {
  138842. /**
  138843. * Creates a new RandomNumberBlock
  138844. * @param name defines the block name
  138845. */
  138846. constructor(name: string);
  138847. /**
  138848. * Gets the current class name
  138849. * @returns the class name
  138850. */
  138851. getClassName(): string;
  138852. /**
  138853. * Gets the seed input component
  138854. */
  138855. get seed(): NodeMaterialConnectionPoint;
  138856. /**
  138857. * Gets the output component
  138858. */
  138859. get output(): NodeMaterialConnectionPoint;
  138860. protected _buildBlock(state: NodeMaterialBuildState): this;
  138861. }
  138862. }
  138863. declare module BABYLON {
  138864. /**
  138865. * Block used to compute arc tangent of 2 values
  138866. */
  138867. export class ArcTan2Block extends NodeMaterialBlock {
  138868. /**
  138869. * Creates a new ArcTan2Block
  138870. * @param name defines the block name
  138871. */
  138872. constructor(name: string);
  138873. /**
  138874. * Gets the current class name
  138875. * @returns the class name
  138876. */
  138877. getClassName(): string;
  138878. /**
  138879. * Gets the x operand input component
  138880. */
  138881. get x(): NodeMaterialConnectionPoint;
  138882. /**
  138883. * Gets the y operand input component
  138884. */
  138885. get y(): NodeMaterialConnectionPoint;
  138886. /**
  138887. * Gets the output component
  138888. */
  138889. get output(): NodeMaterialConnectionPoint;
  138890. protected _buildBlock(state: NodeMaterialBuildState): this;
  138891. }
  138892. }
  138893. declare module BABYLON {
  138894. /**
  138895. * Block used to smooth step a value
  138896. */
  138897. export class SmoothStepBlock extends NodeMaterialBlock {
  138898. /**
  138899. * Creates a new SmoothStepBlock
  138900. * @param name defines the block name
  138901. */
  138902. constructor(name: string);
  138903. /**
  138904. * Gets the current class name
  138905. * @returns the class name
  138906. */
  138907. getClassName(): string;
  138908. /**
  138909. * Gets the value operand input component
  138910. */
  138911. get value(): NodeMaterialConnectionPoint;
  138912. /**
  138913. * Gets the first edge operand input component
  138914. */
  138915. get edge0(): NodeMaterialConnectionPoint;
  138916. /**
  138917. * Gets the second edge operand input component
  138918. */
  138919. get edge1(): NodeMaterialConnectionPoint;
  138920. /**
  138921. * Gets the output component
  138922. */
  138923. get output(): NodeMaterialConnectionPoint;
  138924. protected _buildBlock(state: NodeMaterialBuildState): this;
  138925. }
  138926. }
  138927. declare module BABYLON {
  138928. /**
  138929. * Block used to get the reciprocal (1 / x) of a value
  138930. */
  138931. export class ReciprocalBlock extends NodeMaterialBlock {
  138932. /**
  138933. * Creates a new ReciprocalBlock
  138934. * @param name defines the block name
  138935. */
  138936. constructor(name: string);
  138937. /**
  138938. * Gets the current class name
  138939. * @returns the class name
  138940. */
  138941. getClassName(): string;
  138942. /**
  138943. * Gets the input component
  138944. */
  138945. get input(): NodeMaterialConnectionPoint;
  138946. /**
  138947. * Gets the output component
  138948. */
  138949. get output(): NodeMaterialConnectionPoint;
  138950. protected _buildBlock(state: NodeMaterialBuildState): this;
  138951. }
  138952. }
  138953. declare module BABYLON {
  138954. /**
  138955. * Block used to replace a color by another one
  138956. */
  138957. export class ReplaceColorBlock extends NodeMaterialBlock {
  138958. /**
  138959. * Creates a new ReplaceColorBlock
  138960. * @param name defines the block name
  138961. */
  138962. constructor(name: string);
  138963. /**
  138964. * Gets the current class name
  138965. * @returns the class name
  138966. */
  138967. getClassName(): string;
  138968. /**
  138969. * Gets the value input component
  138970. */
  138971. get value(): NodeMaterialConnectionPoint;
  138972. /**
  138973. * Gets the reference input component
  138974. */
  138975. get reference(): NodeMaterialConnectionPoint;
  138976. /**
  138977. * Gets the distance input component
  138978. */
  138979. get distance(): NodeMaterialConnectionPoint;
  138980. /**
  138981. * Gets the replacement input component
  138982. */
  138983. get replacement(): NodeMaterialConnectionPoint;
  138984. /**
  138985. * Gets the output component
  138986. */
  138987. get output(): NodeMaterialConnectionPoint;
  138988. protected _buildBlock(state: NodeMaterialBuildState): this;
  138989. }
  138990. }
  138991. declare module BABYLON {
  138992. /**
  138993. * Block used to posterize a value
  138994. * @see https://en.wikipedia.org/wiki/Posterization
  138995. */
  138996. export class PosterizeBlock extends NodeMaterialBlock {
  138997. /**
  138998. * Creates a new PosterizeBlock
  138999. * @param name defines the block name
  139000. */
  139001. constructor(name: string);
  139002. /**
  139003. * Gets the current class name
  139004. * @returns the class name
  139005. */
  139006. getClassName(): string;
  139007. /**
  139008. * Gets the value input component
  139009. */
  139010. get value(): NodeMaterialConnectionPoint;
  139011. /**
  139012. * Gets the steps input component
  139013. */
  139014. get steps(): NodeMaterialConnectionPoint;
  139015. /**
  139016. * Gets the output component
  139017. */
  139018. get output(): NodeMaterialConnectionPoint;
  139019. protected _buildBlock(state: NodeMaterialBuildState): this;
  139020. }
  139021. }
  139022. declare module BABYLON {
  139023. /**
  139024. * Operations supported by the Wave block
  139025. */
  139026. export enum WaveBlockKind {
  139027. /** SawTooth */
  139028. SawTooth = 0,
  139029. /** Square */
  139030. Square = 1,
  139031. /** Triangle */
  139032. Triangle = 2
  139033. }
  139034. /**
  139035. * Block used to apply wave operation to floats
  139036. */
  139037. export class WaveBlock extends NodeMaterialBlock {
  139038. /**
  139039. * Gets or sets the kibnd of wave to be applied by the block
  139040. */
  139041. kind: WaveBlockKind;
  139042. /**
  139043. * Creates a new WaveBlock
  139044. * @param name defines the block name
  139045. */
  139046. constructor(name: string);
  139047. /**
  139048. * Gets the current class name
  139049. * @returns the class name
  139050. */
  139051. getClassName(): string;
  139052. /**
  139053. * Gets the input component
  139054. */
  139055. get input(): NodeMaterialConnectionPoint;
  139056. /**
  139057. * Gets the output component
  139058. */
  139059. get output(): NodeMaterialConnectionPoint;
  139060. protected _buildBlock(state: NodeMaterialBuildState): this;
  139061. serialize(): any;
  139062. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  139063. }
  139064. }
  139065. declare module BABYLON {
  139066. /**
  139067. * Class used to store a color step for the GradientBlock
  139068. */
  139069. export class GradientBlockColorStep {
  139070. /**
  139071. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  139072. */
  139073. step: number;
  139074. /**
  139075. * Gets or sets the color associated with this step
  139076. */
  139077. color: Color3;
  139078. /**
  139079. * Creates a new GradientBlockColorStep
  139080. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  139081. * @param color defines the color associated with this step
  139082. */
  139083. constructor(
  139084. /**
  139085. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  139086. */
  139087. step: number,
  139088. /**
  139089. * Gets or sets the color associated with this step
  139090. */
  139091. color: Color3);
  139092. }
  139093. /**
  139094. * Block used to return a color from a gradient based on an input value between 0 and 1
  139095. */
  139096. export class GradientBlock extends NodeMaterialBlock {
  139097. /**
  139098. * Gets or sets the list of color steps
  139099. */
  139100. colorSteps: GradientBlockColorStep[];
  139101. /**
  139102. * Creates a new GradientBlock
  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 gradient input component
  139113. */
  139114. get gradient(): NodeMaterialConnectionPoint;
  139115. /**
  139116. * Gets the output component
  139117. */
  139118. get output(): NodeMaterialConnectionPoint;
  139119. private _writeColorConstant;
  139120. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  139121. serialize(): any;
  139122. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  139123. protected _dumpPropertiesCode(): string;
  139124. }
  139125. }
  139126. declare module BABYLON {
  139127. /**
  139128. * Block used to normalize lerp between 2 values
  139129. */
  139130. export class NLerpBlock extends NodeMaterialBlock {
  139131. /**
  139132. * Creates a new NLerpBlock
  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 left operand input component
  139143. */
  139144. get left(): NodeMaterialConnectionPoint;
  139145. /**
  139146. * Gets the right operand input component
  139147. */
  139148. get right(): NodeMaterialConnectionPoint;
  139149. /**
  139150. * Gets the gradient operand input component
  139151. */
  139152. get gradient(): NodeMaterialConnectionPoint;
  139153. /**
  139154. * Gets the output component
  139155. */
  139156. get output(): NodeMaterialConnectionPoint;
  139157. protected _buildBlock(state: NodeMaterialBuildState): this;
  139158. }
  139159. }
  139160. declare module BABYLON {
  139161. /**
  139162. * block used to Generate a Worley Noise 3D Noise Pattern
  139163. */
  139164. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  139165. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  139166. manhattanDistance: boolean;
  139167. /**
  139168. * Creates a new WorleyNoise3DBlock
  139169. * @param name defines the block name
  139170. */
  139171. constructor(name: string);
  139172. /**
  139173. * Gets the current class name
  139174. * @returns the class name
  139175. */
  139176. getClassName(): string;
  139177. /**
  139178. * Gets the seed input component
  139179. */
  139180. get seed(): NodeMaterialConnectionPoint;
  139181. /**
  139182. * Gets the jitter input component
  139183. */
  139184. get jitter(): NodeMaterialConnectionPoint;
  139185. /**
  139186. * Gets the output component
  139187. */
  139188. get output(): NodeMaterialConnectionPoint;
  139189. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  139190. /**
  139191. * Exposes the properties to the UI?
  139192. */
  139193. protected _dumpPropertiesCode(): string;
  139194. /**
  139195. * Exposes the properties to the Seralize?
  139196. */
  139197. serialize(): any;
  139198. /**
  139199. * Exposes the properties to the deseralize?
  139200. */
  139201. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  139202. }
  139203. }
  139204. declare module BABYLON {
  139205. /**
  139206. * block used to Generate a Simplex Perlin 3d Noise Pattern
  139207. */
  139208. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  139209. /**
  139210. * Creates a new SimplexPerlin3DBlock
  139211. * @param name defines the block name
  139212. */
  139213. constructor(name: string);
  139214. /**
  139215. * Gets the current class name
  139216. * @returns the class name
  139217. */
  139218. getClassName(): string;
  139219. /**
  139220. * Gets the seed operand input component
  139221. */
  139222. get seed(): NodeMaterialConnectionPoint;
  139223. /**
  139224. * Gets the output component
  139225. */
  139226. get output(): NodeMaterialConnectionPoint;
  139227. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  139228. }
  139229. }
  139230. declare module BABYLON {
  139231. /**
  139232. * Block used to blend normals
  139233. */
  139234. export class NormalBlendBlock extends NodeMaterialBlock {
  139235. /**
  139236. * Creates a new NormalBlendBlock
  139237. * @param name defines the block name
  139238. */
  139239. constructor(name: string);
  139240. /**
  139241. * Gets the current class name
  139242. * @returns the class name
  139243. */
  139244. getClassName(): string;
  139245. /**
  139246. * Gets the first input component
  139247. */
  139248. get normalMap0(): NodeMaterialConnectionPoint;
  139249. /**
  139250. * Gets the second input component
  139251. */
  139252. get normalMap1(): NodeMaterialConnectionPoint;
  139253. /**
  139254. * Gets the output component
  139255. */
  139256. get output(): NodeMaterialConnectionPoint;
  139257. protected _buildBlock(state: NodeMaterialBuildState): this;
  139258. }
  139259. }
  139260. declare module BABYLON {
  139261. /**
  139262. * Block used to rotate a 2d vector by a given angle
  139263. */
  139264. export class Rotate2dBlock extends NodeMaterialBlock {
  139265. /**
  139266. * Creates a new Rotate2dBlock
  139267. * @param name defines the block name
  139268. */
  139269. constructor(name: string);
  139270. /**
  139271. * Gets the current class name
  139272. * @returns the class name
  139273. */
  139274. getClassName(): string;
  139275. /**
  139276. * Gets the input vector
  139277. */
  139278. get input(): NodeMaterialConnectionPoint;
  139279. /**
  139280. * Gets the input angle
  139281. */
  139282. get angle(): NodeMaterialConnectionPoint;
  139283. /**
  139284. * Gets the output component
  139285. */
  139286. get output(): NodeMaterialConnectionPoint;
  139287. autoConfigure(material: NodeMaterial): void;
  139288. protected _buildBlock(state: NodeMaterialBuildState): this;
  139289. }
  139290. }
  139291. declare module BABYLON {
  139292. /**
  139293. * Block used to get the reflected vector from a direction and a normal
  139294. */
  139295. export class ReflectBlock extends NodeMaterialBlock {
  139296. /**
  139297. * Creates a new ReflectBlock
  139298. * @param name defines the block name
  139299. */
  139300. constructor(name: string);
  139301. /**
  139302. * Gets the current class name
  139303. * @returns the class name
  139304. */
  139305. getClassName(): string;
  139306. /**
  139307. * Gets the incident component
  139308. */
  139309. get incident(): NodeMaterialConnectionPoint;
  139310. /**
  139311. * Gets the normal component
  139312. */
  139313. get normal(): NodeMaterialConnectionPoint;
  139314. /**
  139315. * Gets the output component
  139316. */
  139317. get output(): NodeMaterialConnectionPoint;
  139318. protected _buildBlock(state: NodeMaterialBuildState): this;
  139319. }
  139320. }
  139321. declare module BABYLON {
  139322. /**
  139323. * Block used to get the refracted vector from a direction and a normal
  139324. */
  139325. export class RefractBlock extends NodeMaterialBlock {
  139326. /**
  139327. * Creates a new RefractBlock
  139328. * @param name defines the block name
  139329. */
  139330. constructor(name: string);
  139331. /**
  139332. * Gets the current class name
  139333. * @returns the class name
  139334. */
  139335. getClassName(): string;
  139336. /**
  139337. * Gets the incident component
  139338. */
  139339. get incident(): NodeMaterialConnectionPoint;
  139340. /**
  139341. * Gets the normal component
  139342. */
  139343. get normal(): NodeMaterialConnectionPoint;
  139344. /**
  139345. * Gets the index of refraction component
  139346. */
  139347. get ior(): NodeMaterialConnectionPoint;
  139348. /**
  139349. * Gets the output component
  139350. */
  139351. get output(): NodeMaterialConnectionPoint;
  139352. protected _buildBlock(state: NodeMaterialBuildState): this;
  139353. }
  139354. }
  139355. declare module BABYLON {
  139356. /**
  139357. * Block used to desaturate a color
  139358. */
  139359. export class DesaturateBlock extends NodeMaterialBlock {
  139360. /**
  139361. * Creates a new DesaturateBlock
  139362. * @param name defines the block name
  139363. */
  139364. constructor(name: string);
  139365. /**
  139366. * Gets the current class name
  139367. * @returns the class name
  139368. */
  139369. getClassName(): string;
  139370. /**
  139371. * Gets the color operand input component
  139372. */
  139373. get color(): NodeMaterialConnectionPoint;
  139374. /**
  139375. * Gets the level operand input component
  139376. */
  139377. get level(): NodeMaterialConnectionPoint;
  139378. /**
  139379. * Gets the output component
  139380. */
  139381. get output(): NodeMaterialConnectionPoint;
  139382. protected _buildBlock(state: NodeMaterialBuildState): this;
  139383. }
  139384. }
  139385. declare module BABYLON {
  139386. /**
  139387. * Block used to implement the ambient occlusion module of the PBR material
  139388. */
  139389. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  139390. /**
  139391. * Create a new AmbientOcclusionBlock
  139392. * @param name defines the block name
  139393. */
  139394. constructor(name: string);
  139395. /**
  139396. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  139397. */
  139398. useAmbientInGrayScale: boolean;
  139399. /**
  139400. * Initialize the block and prepare the context for build
  139401. * @param state defines the state that will be used for the build
  139402. */
  139403. initialize(state: NodeMaterialBuildState): void;
  139404. /**
  139405. * Gets the current class name
  139406. * @returns the class name
  139407. */
  139408. getClassName(): string;
  139409. /**
  139410. * Gets the texture input component
  139411. */
  139412. get texture(): NodeMaterialConnectionPoint;
  139413. /**
  139414. * Gets the texture intensity component
  139415. */
  139416. get intensity(): NodeMaterialConnectionPoint;
  139417. /**
  139418. * Gets the direct light intensity input component
  139419. */
  139420. get directLightIntensity(): NodeMaterialConnectionPoint;
  139421. /**
  139422. * Gets the ambient occlusion object output component
  139423. */
  139424. get ambientOcclusion(): NodeMaterialConnectionPoint;
  139425. /**
  139426. * Gets the main code of the block (fragment side)
  139427. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  139428. * @returns the shader code
  139429. */
  139430. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  139431. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  139432. protected _buildBlock(state: NodeMaterialBuildState): this;
  139433. protected _dumpPropertiesCode(): string;
  139434. serialize(): any;
  139435. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  139436. }
  139437. }
  139438. declare module BABYLON {
  139439. /**
  139440. * Block used to implement the reflection module of the PBR material
  139441. */
  139442. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  139443. /** @hidden */
  139444. _defineLODReflectionAlpha: string;
  139445. /** @hidden */
  139446. _defineLinearSpecularReflection: string;
  139447. private _vEnvironmentIrradianceName;
  139448. /** @hidden */
  139449. _vReflectionMicrosurfaceInfosName: string;
  139450. /** @hidden */
  139451. _vReflectionInfosName: string;
  139452. private _scene;
  139453. /**
  139454. * The three properties below are set by the main PBR block prior to calling methods of this class.
  139455. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  139456. * It's less burden on the user side in the editor part.
  139457. */
  139458. /** @hidden */
  139459. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  139460. /** @hidden */
  139461. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  139462. /** @hidden */
  139463. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  139464. /**
  139465. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  139466. * diffuse part of the IBL.
  139467. */
  139468. useSphericalHarmonics: boolean;
  139469. /**
  139470. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  139471. */
  139472. forceIrradianceInFragment: boolean;
  139473. /**
  139474. * Create a new ReflectionBlock
  139475. * @param name defines the block name
  139476. */
  139477. constructor(name: string);
  139478. /**
  139479. * Gets the current class name
  139480. * @returns the class name
  139481. */
  139482. getClassName(): string;
  139483. /**
  139484. * Gets the position input component
  139485. */
  139486. get position(): NodeMaterialConnectionPoint;
  139487. /**
  139488. * Gets the world position input component
  139489. */
  139490. get worldPosition(): NodeMaterialConnectionPoint;
  139491. /**
  139492. * Gets the world normal input component
  139493. */
  139494. get worldNormal(): NodeMaterialConnectionPoint;
  139495. /**
  139496. * Gets the world input component
  139497. */
  139498. get world(): NodeMaterialConnectionPoint;
  139499. /**
  139500. * Gets the camera (or eye) position component
  139501. */
  139502. get cameraPosition(): NodeMaterialConnectionPoint;
  139503. /**
  139504. * Gets the view input component
  139505. */
  139506. get view(): NodeMaterialConnectionPoint;
  139507. /**
  139508. * Gets the color input component
  139509. */
  139510. get color(): NodeMaterialConnectionPoint;
  139511. /**
  139512. * Gets the reflection object output component
  139513. */
  139514. get reflection(): NodeMaterialConnectionPoint;
  139515. /**
  139516. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  139517. */
  139518. get hasTexture(): boolean;
  139519. /**
  139520. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  139521. */
  139522. get reflectionColor(): string;
  139523. protected _getTexture(): Nullable<BaseTexture>;
  139524. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  139525. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  139526. /**
  139527. * Gets the code to inject in the vertex shader
  139528. * @param state current state of the node material building
  139529. * @returns the shader code
  139530. */
  139531. handleVertexSide(state: NodeMaterialBuildState): string;
  139532. /**
  139533. * Gets the main code of the block (fragment side)
  139534. * @param state current state of the node material building
  139535. * @param normalVarName name of the existing variable corresponding to the normal
  139536. * @returns the shader code
  139537. */
  139538. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  139539. protected _buildBlock(state: NodeMaterialBuildState): this;
  139540. protected _dumpPropertiesCode(): string;
  139541. serialize(): any;
  139542. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  139543. }
  139544. }
  139545. declare module BABYLON {
  139546. /**
  139547. * Block used to implement the sheen module of the PBR material
  139548. */
  139549. export class SheenBlock extends NodeMaterialBlock {
  139550. /**
  139551. * Create a new SheenBlock
  139552. * @param name defines the block name
  139553. */
  139554. constructor(name: string);
  139555. /**
  139556. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  139557. * It allows the strength of the sheen effect to not depend on the base color of the material,
  139558. * making it easier to setup and tweak the effect
  139559. */
  139560. albedoScaling: boolean;
  139561. /**
  139562. * Defines if the sheen is linked to the sheen color.
  139563. */
  139564. linkSheenWithAlbedo: boolean;
  139565. /**
  139566. * Initialize the block and prepare the context for build
  139567. * @param state defines the state that will be used for the build
  139568. */
  139569. initialize(state: NodeMaterialBuildState): void;
  139570. /**
  139571. * Gets the current class name
  139572. * @returns the class name
  139573. */
  139574. getClassName(): string;
  139575. /**
  139576. * Gets the intensity input component
  139577. */
  139578. get intensity(): NodeMaterialConnectionPoint;
  139579. /**
  139580. * Gets the color input component
  139581. */
  139582. get color(): NodeMaterialConnectionPoint;
  139583. /**
  139584. * Gets the roughness input component
  139585. */
  139586. get roughness(): NodeMaterialConnectionPoint;
  139587. /**
  139588. * Gets the texture input component
  139589. */
  139590. get texture(): NodeMaterialConnectionPoint;
  139591. /**
  139592. * Gets the sheen object output component
  139593. */
  139594. get sheen(): NodeMaterialConnectionPoint;
  139595. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  139596. /**
  139597. * Gets the main code of the block (fragment side)
  139598. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  139599. * @returns the shader code
  139600. */
  139601. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  139602. protected _buildBlock(state: NodeMaterialBuildState): this;
  139603. protected _dumpPropertiesCode(): string;
  139604. serialize(): any;
  139605. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  139606. }
  139607. }
  139608. declare module BABYLON {
  139609. /**
  139610. * Block used to implement the reflectivity module of the PBR material
  139611. */
  139612. export class ReflectivityBlock extends NodeMaterialBlock {
  139613. /**
  139614. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  139615. */
  139616. useAmbientOcclusionFromMetallicTextureRed: boolean;
  139617. /**
  139618. * Specifies if the metallic texture contains the metallness information in its blue channel.
  139619. */
  139620. useMetallnessFromMetallicTextureBlue: boolean;
  139621. /**
  139622. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  139623. */
  139624. useRoughnessFromMetallicTextureAlpha: boolean;
  139625. /**
  139626. * Specifies if the metallic texture contains the roughness information in its green channel.
  139627. */
  139628. useRoughnessFromMetallicTextureGreen: boolean;
  139629. /**
  139630. * Create a new ReflectivityBlock
  139631. * @param name defines the block name
  139632. */
  139633. constructor(name: string);
  139634. /**
  139635. * Initialize the block and prepare the context for build
  139636. * @param state defines the state that will be used for the build
  139637. */
  139638. initialize(state: NodeMaterialBuildState): void;
  139639. /**
  139640. * Gets the current class name
  139641. * @returns the class name
  139642. */
  139643. getClassName(): string;
  139644. /**
  139645. * Gets the metallic input component
  139646. */
  139647. get metallic(): NodeMaterialConnectionPoint;
  139648. /**
  139649. * Gets the roughness input component
  139650. */
  139651. get roughness(): NodeMaterialConnectionPoint;
  139652. /**
  139653. * Gets the texture input component
  139654. */
  139655. get texture(): NodeMaterialConnectionPoint;
  139656. /**
  139657. * Gets the reflectivity object output component
  139658. */
  139659. get reflectivity(): NodeMaterialConnectionPoint;
  139660. /**
  139661. * Gets the main code of the block (fragment side)
  139662. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  139663. * @returns the shader code
  139664. */
  139665. getCode(aoIntensityVarName: string): string;
  139666. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  139667. protected _buildBlock(state: NodeMaterialBuildState): this;
  139668. protected _dumpPropertiesCode(): string;
  139669. serialize(): any;
  139670. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  139671. }
  139672. }
  139673. declare module BABYLON {
  139674. /**
  139675. * Block used to implement the anisotropy module of the PBR material
  139676. */
  139677. export class AnisotropyBlock extends NodeMaterialBlock {
  139678. /**
  139679. * The two properties below are set by the main PBR block prior to calling methods of this class.
  139680. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  139681. * It's less burden on the user side in the editor part.
  139682. */
  139683. /** @hidden */
  139684. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  139685. /** @hidden */
  139686. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  139687. /**
  139688. * Create a new AnisotropyBlock
  139689. * @param name defines the block name
  139690. */
  139691. constructor(name: string);
  139692. /**
  139693. * Initialize the block and prepare the context for build
  139694. * @param state defines the state that will be used for the build
  139695. */
  139696. initialize(state: NodeMaterialBuildState): void;
  139697. /**
  139698. * Gets the current class name
  139699. * @returns the class name
  139700. */
  139701. getClassName(): string;
  139702. /**
  139703. * Gets the intensity input component
  139704. */
  139705. get intensity(): NodeMaterialConnectionPoint;
  139706. /**
  139707. * Gets the direction input component
  139708. */
  139709. get direction(): NodeMaterialConnectionPoint;
  139710. /**
  139711. * Gets the texture input component
  139712. */
  139713. get texture(): NodeMaterialConnectionPoint;
  139714. /**
  139715. * Gets the uv input component
  139716. */
  139717. get uv(): NodeMaterialConnectionPoint;
  139718. /**
  139719. * Gets the worldTangent input component
  139720. */
  139721. get worldTangent(): NodeMaterialConnectionPoint;
  139722. /**
  139723. * Gets the anisotropy object output component
  139724. */
  139725. get anisotropy(): NodeMaterialConnectionPoint;
  139726. private _generateTBNSpace;
  139727. /**
  139728. * Gets the main code of the block (fragment side)
  139729. * @param state current state of the node material building
  139730. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  139731. * @returns the shader code
  139732. */
  139733. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  139734. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  139735. protected _buildBlock(state: NodeMaterialBuildState): this;
  139736. }
  139737. }
  139738. declare module BABYLON {
  139739. /**
  139740. * Block used to implement the clear coat module of the PBR material
  139741. */
  139742. export class ClearCoatBlock extends NodeMaterialBlock {
  139743. private _scene;
  139744. /**
  139745. * Create a new ClearCoatBlock
  139746. * @param name defines the block name
  139747. */
  139748. constructor(name: string);
  139749. /**
  139750. * Initialize the block and prepare the context for build
  139751. * @param state defines the state that will be used for the build
  139752. */
  139753. initialize(state: NodeMaterialBuildState): void;
  139754. /**
  139755. * Gets the current class name
  139756. * @returns the class name
  139757. */
  139758. getClassName(): string;
  139759. /**
  139760. * Gets the intensity input component
  139761. */
  139762. get intensity(): NodeMaterialConnectionPoint;
  139763. /**
  139764. * Gets the roughness input component
  139765. */
  139766. get roughness(): NodeMaterialConnectionPoint;
  139767. /**
  139768. * Gets the ior input component
  139769. */
  139770. get ior(): NodeMaterialConnectionPoint;
  139771. /**
  139772. * Gets the texture input component
  139773. */
  139774. get texture(): NodeMaterialConnectionPoint;
  139775. /**
  139776. * Gets the bump texture input component
  139777. */
  139778. get bumpTexture(): NodeMaterialConnectionPoint;
  139779. /**
  139780. * Gets the uv input component
  139781. */
  139782. get uv(): NodeMaterialConnectionPoint;
  139783. /**
  139784. * Gets the tint color input component
  139785. */
  139786. get tintColor(): NodeMaterialConnectionPoint;
  139787. /**
  139788. * Gets the tint "at distance" input component
  139789. */
  139790. get tintAtDistance(): NodeMaterialConnectionPoint;
  139791. /**
  139792. * Gets the tint thickness input component
  139793. */
  139794. get tintThickness(): NodeMaterialConnectionPoint;
  139795. /**
  139796. * Gets the tint texture input component
  139797. */
  139798. get tintTexture(): NodeMaterialConnectionPoint;
  139799. /**
  139800. * Gets the world tangent input component
  139801. */
  139802. get worldTangent(): NodeMaterialConnectionPoint;
  139803. /**
  139804. * Gets the clear coat object output component
  139805. */
  139806. get clearcoat(): NodeMaterialConnectionPoint;
  139807. autoConfigure(material: NodeMaterial): void;
  139808. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  139809. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  139810. private _generateTBNSpace;
  139811. /**
  139812. * Gets the main code of the block (fragment side)
  139813. * @param state current state of the node material building
  139814. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  139815. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  139816. * @param worldPosVarName name of the variable holding the world position
  139817. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  139818. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  139819. * @param worldNormalVarName name of the variable holding the world normal
  139820. * @returns the shader code
  139821. */
  139822. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  139823. protected _buildBlock(state: NodeMaterialBuildState): this;
  139824. }
  139825. }
  139826. declare module BABYLON {
  139827. /**
  139828. * Block used to implement the sub surface module of the PBR material
  139829. */
  139830. export class SubSurfaceBlock extends NodeMaterialBlock {
  139831. /**
  139832. * Create a new SubSurfaceBlock
  139833. * @param name defines the block name
  139834. */
  139835. constructor(name: string);
  139836. /**
  139837. * Stores the intensity of the different subsurface effects in the thickness texture.
  139838. * * the green channel is the translucency intensity.
  139839. * * the blue channel is the scattering intensity.
  139840. * * the alpha channel is the refraction intensity.
  139841. */
  139842. useMaskFromThicknessTexture: boolean;
  139843. /**
  139844. * Initialize the block and prepare the context for build
  139845. * @param state defines the state that will be used for the build
  139846. */
  139847. initialize(state: NodeMaterialBuildState): void;
  139848. /**
  139849. * Gets the current class name
  139850. * @returns the class name
  139851. */
  139852. getClassName(): string;
  139853. /**
  139854. * Gets the min thickness input component
  139855. */
  139856. get minThickness(): NodeMaterialConnectionPoint;
  139857. /**
  139858. * Gets the max thickness input component
  139859. */
  139860. get maxThickness(): NodeMaterialConnectionPoint;
  139861. /**
  139862. * Gets the thickness texture component
  139863. */
  139864. get thicknessTexture(): NodeMaterialConnectionPoint;
  139865. /**
  139866. * Gets the tint color input component
  139867. */
  139868. get tintColor(): NodeMaterialConnectionPoint;
  139869. /**
  139870. * Gets the translucency intensity input component
  139871. */
  139872. get translucencyIntensity(): NodeMaterialConnectionPoint;
  139873. /**
  139874. * Gets the translucency diffusion distance input component
  139875. */
  139876. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  139877. /**
  139878. * Gets the refraction object parameters
  139879. */
  139880. get refraction(): NodeMaterialConnectionPoint;
  139881. /**
  139882. * Gets the sub surface object output component
  139883. */
  139884. get subsurface(): NodeMaterialConnectionPoint;
  139885. autoConfigure(material: NodeMaterial): void;
  139886. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  139887. /**
  139888. * Gets the main code of the block (fragment side)
  139889. * @param state current state of the node material building
  139890. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  139891. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  139892. * @param worldPosVarName name of the variable holding the world position
  139893. * @returns the shader code
  139894. */
  139895. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  139896. protected _buildBlock(state: NodeMaterialBuildState): this;
  139897. }
  139898. }
  139899. declare module BABYLON {
  139900. /**
  139901. * Block used to implement the PBR metallic/roughness model
  139902. */
  139903. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  139904. /**
  139905. * Gets or sets the light associated with this block
  139906. */
  139907. light: Nullable<Light>;
  139908. private _lightId;
  139909. private _scene;
  139910. private _environmentBRDFTexture;
  139911. private _environmentBrdfSamplerName;
  139912. private _vNormalWName;
  139913. private _invertNormalName;
  139914. /**
  139915. * Create a new ReflectionBlock
  139916. * @param name defines the block name
  139917. */
  139918. constructor(name: string);
  139919. /**
  139920. * Intensity of the direct lights e.g. the four lights available in your scene.
  139921. * This impacts both the direct diffuse and specular highlights.
  139922. */
  139923. directIntensity: number;
  139924. /**
  139925. * Intensity of the environment e.g. how much the environment will light the object
  139926. * either through harmonics for rough material or through the refelction for shiny ones.
  139927. */
  139928. environmentIntensity: number;
  139929. /**
  139930. * This is a special control allowing the reduction of the specular highlights coming from the
  139931. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  139932. */
  139933. specularIntensity: number;
  139934. /**
  139935. * Defines the falloff type used in this material.
  139936. * It by default is Physical.
  139937. */
  139938. lightFalloff: number;
  139939. /**
  139940. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  139941. */
  139942. useAlphaFromAlbedoTexture: boolean;
  139943. /**
  139944. * Specifies that alpha test should be used
  139945. */
  139946. useAlphaTest: boolean;
  139947. /**
  139948. * Defines the alpha limits in alpha test mode.
  139949. */
  139950. alphaTestCutoff: number;
  139951. /**
  139952. * Specifies that alpha blending should be used
  139953. */
  139954. useAlphaBlending: boolean;
  139955. /**
  139956. * Defines if the alpha value should be determined via the rgb values.
  139957. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  139958. */
  139959. opacityRGB: boolean;
  139960. /**
  139961. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  139962. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  139963. */
  139964. useRadianceOverAlpha: boolean;
  139965. /**
  139966. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  139967. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  139968. */
  139969. useSpecularOverAlpha: boolean;
  139970. /**
  139971. * Enables specular anti aliasing in the PBR shader.
  139972. * It will both interacts on the Geometry for analytical and IBL lighting.
  139973. * It also prefilter the roughness map based on the bump values.
  139974. */
  139975. enableSpecularAntiAliasing: boolean;
  139976. /**
  139977. * Defines if the material uses energy conservation.
  139978. */
  139979. useEnergyConservation: boolean;
  139980. /**
  139981. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  139982. * too much the area relying on ambient texture to define their ambient occlusion.
  139983. */
  139984. useRadianceOcclusion: boolean;
  139985. /**
  139986. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  139987. * makes the reflect vector face the model (under horizon).
  139988. */
  139989. useHorizonOcclusion: boolean;
  139990. /**
  139991. * If set to true, no lighting calculations will be applied.
  139992. */
  139993. unlit: boolean;
  139994. /**
  139995. * Force normal to face away from face.
  139996. */
  139997. forceNormalForward: boolean;
  139998. /**
  139999. * Defines the material debug mode.
  140000. * It helps seeing only some components of the material while troubleshooting.
  140001. */
  140002. debugMode: number;
  140003. /**
  140004. * Specify from where on screen the debug mode should start.
  140005. * The value goes from -1 (full screen) to 1 (not visible)
  140006. * It helps with side by side comparison against the final render
  140007. * This defaults to 0
  140008. */
  140009. debugLimit: number;
  140010. /**
  140011. * As the default viewing range might not be enough (if the ambient is really small for instance)
  140012. * You can use the factor to better multiply the final value.
  140013. */
  140014. debugFactor: number;
  140015. /**
  140016. * Initialize the block and prepare the context for build
  140017. * @param state defines the state that will be used for the build
  140018. */
  140019. initialize(state: NodeMaterialBuildState): void;
  140020. /**
  140021. * Gets the current class name
  140022. * @returns the class name
  140023. */
  140024. getClassName(): string;
  140025. /**
  140026. * Gets the world position input component
  140027. */
  140028. get worldPosition(): NodeMaterialConnectionPoint;
  140029. /**
  140030. * Gets the world normal input component
  140031. */
  140032. get worldNormal(): NodeMaterialConnectionPoint;
  140033. /**
  140034. * Gets the perturbed normal input component
  140035. */
  140036. get perturbedNormal(): NodeMaterialConnectionPoint;
  140037. /**
  140038. * Gets the camera position input component
  140039. */
  140040. get cameraPosition(): NodeMaterialConnectionPoint;
  140041. /**
  140042. * Gets the base color input component
  140043. */
  140044. get baseColor(): NodeMaterialConnectionPoint;
  140045. /**
  140046. * Gets the base texture input component
  140047. */
  140048. get baseTexture(): NodeMaterialConnectionPoint;
  140049. /**
  140050. * Gets the opacity texture input component
  140051. */
  140052. get opacityTexture(): NodeMaterialConnectionPoint;
  140053. /**
  140054. * Gets the ambient color input component
  140055. */
  140056. get ambientColor(): NodeMaterialConnectionPoint;
  140057. /**
  140058. * Gets the reflectivity object parameters
  140059. */
  140060. get reflectivity(): NodeMaterialConnectionPoint;
  140061. /**
  140062. * Gets the ambient occlusion object parameters
  140063. */
  140064. get ambientOcclusion(): NodeMaterialConnectionPoint;
  140065. /**
  140066. * Gets the reflection object parameters
  140067. */
  140068. get reflection(): NodeMaterialConnectionPoint;
  140069. /**
  140070. * Gets the sheen object parameters
  140071. */
  140072. get sheen(): NodeMaterialConnectionPoint;
  140073. /**
  140074. * Gets the clear coat object parameters
  140075. */
  140076. get clearcoat(): NodeMaterialConnectionPoint;
  140077. /**
  140078. * Gets the sub surface object parameters
  140079. */
  140080. get subsurface(): NodeMaterialConnectionPoint;
  140081. /**
  140082. * Gets the anisotropy object parameters
  140083. */
  140084. get anisotropy(): NodeMaterialConnectionPoint;
  140085. /**
  140086. * Gets the ambient output component
  140087. */
  140088. get ambient(): NodeMaterialConnectionPoint;
  140089. /**
  140090. * Gets the diffuse output component
  140091. */
  140092. get diffuse(): NodeMaterialConnectionPoint;
  140093. /**
  140094. * Gets the specular output component
  140095. */
  140096. get specular(): NodeMaterialConnectionPoint;
  140097. /**
  140098. * Gets the sheen output component
  140099. */
  140100. get sheenDir(): NodeMaterialConnectionPoint;
  140101. /**
  140102. * Gets the clear coat output component
  140103. */
  140104. get clearcoatDir(): NodeMaterialConnectionPoint;
  140105. /**
  140106. * Gets the indirect diffuse output component
  140107. */
  140108. get diffuseIndirect(): NodeMaterialConnectionPoint;
  140109. /**
  140110. * Gets the indirect specular output component
  140111. */
  140112. get specularIndirect(): NodeMaterialConnectionPoint;
  140113. /**
  140114. * Gets the indirect sheen output component
  140115. */
  140116. get sheenIndirect(): NodeMaterialConnectionPoint;
  140117. /**
  140118. * Gets the indirect clear coat output component
  140119. */
  140120. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  140121. /**
  140122. * Gets the refraction output component
  140123. */
  140124. get refraction(): NodeMaterialConnectionPoint;
  140125. /**
  140126. * Gets the global lighting output component
  140127. */
  140128. get lighting(): NodeMaterialConnectionPoint;
  140129. /**
  140130. * Gets the shadow output component
  140131. */
  140132. get shadow(): NodeMaterialConnectionPoint;
  140133. /**
  140134. * Gets the alpha output component
  140135. */
  140136. get alpha(): NodeMaterialConnectionPoint;
  140137. autoConfigure(material: NodeMaterial): void;
  140138. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  140139. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  140140. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  140141. private _injectVertexCode;
  140142. /**
  140143. * Gets the code corresponding to the albedo/opacity module
  140144. * @returns the shader code
  140145. */
  140146. getAlbedoOpacityCode(): string;
  140147. protected _buildBlock(state: NodeMaterialBuildState): this;
  140148. protected _dumpPropertiesCode(): string;
  140149. serialize(): any;
  140150. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  140151. }
  140152. }
  140153. declare module BABYLON {
  140154. /**
  140155. * Block used to compute value of one parameter modulo another
  140156. */
  140157. export class ModBlock extends NodeMaterialBlock {
  140158. /**
  140159. * Creates a new ModBlock
  140160. * @param name defines the block name
  140161. */
  140162. constructor(name: string);
  140163. /**
  140164. * Gets the current class name
  140165. * @returns the class name
  140166. */
  140167. getClassName(): string;
  140168. /**
  140169. * Gets the left operand input component
  140170. */
  140171. get left(): NodeMaterialConnectionPoint;
  140172. /**
  140173. * Gets the right operand input component
  140174. */
  140175. get right(): NodeMaterialConnectionPoint;
  140176. /**
  140177. * Gets the output component
  140178. */
  140179. get output(): NodeMaterialConnectionPoint;
  140180. protected _buildBlock(state: NodeMaterialBuildState): this;
  140181. }
  140182. }
  140183. declare module BABYLON {
  140184. /**
  140185. * Helper class to push actions to a pool of workers.
  140186. */
  140187. export class WorkerPool implements IDisposable {
  140188. private _workerInfos;
  140189. private _pendingActions;
  140190. /**
  140191. * Constructor
  140192. * @param workers Array of workers to use for actions
  140193. */
  140194. constructor(workers: Array<Worker>);
  140195. /**
  140196. * Terminates all workers and clears any pending actions.
  140197. */
  140198. dispose(): void;
  140199. /**
  140200. * Pushes an action to the worker pool. If all the workers are active, the action will be
  140201. * pended until a worker has completed its action.
  140202. * @param action The action to perform. Call onComplete when the action is complete.
  140203. */
  140204. push(action: (worker: Worker, onComplete: () => void) => void): void;
  140205. private _execute;
  140206. }
  140207. }
  140208. declare module BABYLON {
  140209. /**
  140210. * Configuration for Draco compression
  140211. */
  140212. export interface IDracoCompressionConfiguration {
  140213. /**
  140214. * Configuration for the decoder.
  140215. */
  140216. decoder: {
  140217. /**
  140218. * The url to the WebAssembly module.
  140219. */
  140220. wasmUrl?: string;
  140221. /**
  140222. * The url to the WebAssembly binary.
  140223. */
  140224. wasmBinaryUrl?: string;
  140225. /**
  140226. * The url to the fallback JavaScript module.
  140227. */
  140228. fallbackUrl?: string;
  140229. };
  140230. }
  140231. /**
  140232. * Draco compression (https://google.github.io/draco/)
  140233. *
  140234. * This class wraps the Draco module.
  140235. *
  140236. * **Encoder**
  140237. *
  140238. * The encoder is not currently implemented.
  140239. *
  140240. * **Decoder**
  140241. *
  140242. * 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.
  140243. *
  140244. * To update the configuration, use the following code:
  140245. * ```javascript
  140246. * DracoCompression.Configuration = {
  140247. * decoder: {
  140248. * wasmUrl: "<url to the WebAssembly library>",
  140249. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  140250. * fallbackUrl: "<url to the fallback JavaScript library>",
  140251. * }
  140252. * };
  140253. * ```
  140254. *
  140255. * 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.
  140256. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  140257. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  140258. *
  140259. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  140260. * ```javascript
  140261. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  140262. * ```
  140263. *
  140264. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  140265. */
  140266. export class DracoCompression implements IDisposable {
  140267. private _workerPoolPromise?;
  140268. private _decoderModulePromise?;
  140269. /**
  140270. * The configuration. Defaults to the following urls:
  140271. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  140272. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  140273. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  140274. */
  140275. static Configuration: IDracoCompressionConfiguration;
  140276. /**
  140277. * Returns true if the decoder configuration is available.
  140278. */
  140279. static get DecoderAvailable(): boolean;
  140280. /**
  140281. * Default number of workers to create when creating the draco compression object.
  140282. */
  140283. static DefaultNumWorkers: number;
  140284. private static GetDefaultNumWorkers;
  140285. private static _Default;
  140286. /**
  140287. * Default instance for the draco compression object.
  140288. */
  140289. static get Default(): DracoCompression;
  140290. /**
  140291. * Constructor
  140292. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  140293. */
  140294. constructor(numWorkers?: number);
  140295. /**
  140296. * Stop all async operations and release resources.
  140297. */
  140298. dispose(): void;
  140299. /**
  140300. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  140301. * @returns a promise that resolves when ready
  140302. */
  140303. whenReadyAsync(): Promise<void>;
  140304. /**
  140305. * Decode Draco compressed mesh data to vertex data.
  140306. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  140307. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  140308. * @returns A promise that resolves with the decoded vertex data
  140309. */
  140310. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  140311. [kind: string]: number;
  140312. }): Promise<VertexData>;
  140313. }
  140314. }
  140315. declare module BABYLON {
  140316. /**
  140317. * Class for building Constructive Solid Geometry
  140318. */
  140319. export class CSG {
  140320. private polygons;
  140321. /**
  140322. * The world matrix
  140323. */
  140324. matrix: Matrix;
  140325. /**
  140326. * Stores the position
  140327. */
  140328. position: Vector3;
  140329. /**
  140330. * Stores the rotation
  140331. */
  140332. rotation: Vector3;
  140333. /**
  140334. * Stores the rotation quaternion
  140335. */
  140336. rotationQuaternion: Nullable<Quaternion>;
  140337. /**
  140338. * Stores the scaling vector
  140339. */
  140340. scaling: Vector3;
  140341. /**
  140342. * Convert the Mesh to CSG
  140343. * @param mesh The Mesh to convert to CSG
  140344. * @returns A new CSG from the Mesh
  140345. */
  140346. static FromMesh(mesh: Mesh): CSG;
  140347. /**
  140348. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  140349. * @param polygons Polygons used to construct a CSG solid
  140350. */
  140351. private static FromPolygons;
  140352. /**
  140353. * Clones, or makes a deep copy, of the CSG
  140354. * @returns A new CSG
  140355. */
  140356. clone(): CSG;
  140357. /**
  140358. * Unions this CSG with another CSG
  140359. * @param csg The CSG to union against this CSG
  140360. * @returns The unioned CSG
  140361. */
  140362. union(csg: CSG): CSG;
  140363. /**
  140364. * Unions this CSG with another CSG in place
  140365. * @param csg The CSG to union against this CSG
  140366. */
  140367. unionInPlace(csg: CSG): void;
  140368. /**
  140369. * Subtracts this CSG with another CSG
  140370. * @param csg The CSG to subtract against this CSG
  140371. * @returns A new CSG
  140372. */
  140373. subtract(csg: CSG): CSG;
  140374. /**
  140375. * Subtracts this CSG with another CSG in place
  140376. * @param csg The CSG to subtact against this CSG
  140377. */
  140378. subtractInPlace(csg: CSG): void;
  140379. /**
  140380. * Intersect this CSG with another CSG
  140381. * @param csg The CSG to intersect against this CSG
  140382. * @returns A new CSG
  140383. */
  140384. intersect(csg: CSG): CSG;
  140385. /**
  140386. * Intersects this CSG with another CSG in place
  140387. * @param csg The CSG to intersect against this CSG
  140388. */
  140389. intersectInPlace(csg: CSG): void;
  140390. /**
  140391. * Return a new CSG solid with solid and empty space switched. This solid is
  140392. * not modified.
  140393. * @returns A new CSG solid with solid and empty space switched
  140394. */
  140395. inverse(): CSG;
  140396. /**
  140397. * Inverses the CSG in place
  140398. */
  140399. inverseInPlace(): void;
  140400. /**
  140401. * This is used to keep meshes transformations so they can be restored
  140402. * when we build back a Babylon Mesh
  140403. * NB : All CSG operations are performed in world coordinates
  140404. * @param csg The CSG to copy the transform attributes from
  140405. * @returns This CSG
  140406. */
  140407. copyTransformAttributes(csg: CSG): CSG;
  140408. /**
  140409. * Build Raw mesh from CSG
  140410. * Coordinates here are in world space
  140411. * @param name The name of the mesh geometry
  140412. * @param scene The Scene
  140413. * @param keepSubMeshes Specifies if the submeshes should be kept
  140414. * @returns A new Mesh
  140415. */
  140416. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  140417. /**
  140418. * Build Mesh from CSG taking material and transforms into account
  140419. * @param name The name of the Mesh
  140420. * @param material The material of the Mesh
  140421. * @param scene The Scene
  140422. * @param keepSubMeshes Specifies if submeshes should be kept
  140423. * @returns The new Mesh
  140424. */
  140425. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  140426. }
  140427. }
  140428. declare module BABYLON {
  140429. /**
  140430. * Class used to create a trail following a mesh
  140431. */
  140432. export class TrailMesh extends Mesh {
  140433. private _generator;
  140434. private _autoStart;
  140435. private _running;
  140436. private _diameter;
  140437. private _length;
  140438. private _sectionPolygonPointsCount;
  140439. private _sectionVectors;
  140440. private _sectionNormalVectors;
  140441. private _beforeRenderObserver;
  140442. /**
  140443. * @constructor
  140444. * @param name The value used by scene.getMeshByName() to do a lookup.
  140445. * @param generator The mesh or transform node to generate a trail.
  140446. * @param scene The scene to add this mesh to.
  140447. * @param diameter Diameter of trailing mesh. Default is 1.
  140448. * @param length Length of trailing mesh. Default is 60.
  140449. * @param autoStart Automatically start trailing mesh. Default true.
  140450. */
  140451. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  140452. /**
  140453. * "TrailMesh"
  140454. * @returns "TrailMesh"
  140455. */
  140456. getClassName(): string;
  140457. private _createMesh;
  140458. /**
  140459. * Start trailing mesh.
  140460. */
  140461. start(): void;
  140462. /**
  140463. * Stop trailing mesh.
  140464. */
  140465. stop(): void;
  140466. /**
  140467. * Update trailing mesh geometry.
  140468. */
  140469. update(): void;
  140470. /**
  140471. * Returns a new TrailMesh object.
  140472. * @param name is a string, the name given to the new mesh
  140473. * @param newGenerator use new generator object for cloned trail mesh
  140474. * @returns a new mesh
  140475. */
  140476. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  140477. /**
  140478. * Serializes this trail mesh
  140479. * @param serializationObject object to write serialization to
  140480. */
  140481. serialize(serializationObject: any): void;
  140482. /**
  140483. * Parses a serialized trail mesh
  140484. * @param parsedMesh the serialized mesh
  140485. * @param scene the scene to create the trail mesh in
  140486. * @returns the created trail mesh
  140487. */
  140488. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  140489. }
  140490. }
  140491. declare module BABYLON {
  140492. /**
  140493. * Class containing static functions to help procedurally build meshes
  140494. */
  140495. export class TiledBoxBuilder {
  140496. /**
  140497. * Creates a box mesh
  140498. * 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)
  140499. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  140500. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  140501. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  140502. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  140503. * @param name defines the name of the mesh
  140504. * @param options defines the options used to create the mesh
  140505. * @param scene defines the hosting scene
  140506. * @returns the box mesh
  140507. */
  140508. static CreateTiledBox(name: string, options: {
  140509. pattern?: number;
  140510. width?: number;
  140511. height?: number;
  140512. depth?: number;
  140513. tileSize?: number;
  140514. tileWidth?: number;
  140515. tileHeight?: number;
  140516. alignHorizontal?: number;
  140517. alignVertical?: number;
  140518. faceUV?: Vector4[];
  140519. faceColors?: Color4[];
  140520. sideOrientation?: number;
  140521. updatable?: boolean;
  140522. }, scene?: Nullable<Scene>): Mesh;
  140523. }
  140524. }
  140525. declare module BABYLON {
  140526. /**
  140527. * Class containing static functions to help procedurally build meshes
  140528. */
  140529. export class TorusKnotBuilder {
  140530. /**
  140531. * Creates a torus knot mesh
  140532. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  140533. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  140534. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  140535. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  140536. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  140537. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  140538. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  140539. * @param name defines the name of the mesh
  140540. * @param options defines the options used to create the mesh
  140541. * @param scene defines the hosting scene
  140542. * @returns the torus knot mesh
  140543. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  140544. */
  140545. static CreateTorusKnot(name: string, options: {
  140546. radius?: number;
  140547. tube?: number;
  140548. radialSegments?: number;
  140549. tubularSegments?: number;
  140550. p?: number;
  140551. q?: number;
  140552. updatable?: boolean;
  140553. sideOrientation?: number;
  140554. frontUVs?: Vector4;
  140555. backUVs?: Vector4;
  140556. }, scene: any): Mesh;
  140557. }
  140558. }
  140559. declare module BABYLON {
  140560. /**
  140561. * Polygon
  140562. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  140563. */
  140564. export class Polygon {
  140565. /**
  140566. * Creates a rectangle
  140567. * @param xmin bottom X coord
  140568. * @param ymin bottom Y coord
  140569. * @param xmax top X coord
  140570. * @param ymax top Y coord
  140571. * @returns points that make the resulting rectation
  140572. */
  140573. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  140574. /**
  140575. * Creates a circle
  140576. * @param radius radius of circle
  140577. * @param cx scale in x
  140578. * @param cy scale in y
  140579. * @param numberOfSides number of sides that make up the circle
  140580. * @returns points that make the resulting circle
  140581. */
  140582. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  140583. /**
  140584. * Creates a polygon from input string
  140585. * @param input Input polygon data
  140586. * @returns the parsed points
  140587. */
  140588. static Parse(input: string): Vector2[];
  140589. /**
  140590. * Starts building a polygon from x and y coordinates
  140591. * @param x x coordinate
  140592. * @param y y coordinate
  140593. * @returns the started path2
  140594. */
  140595. static StartingAt(x: number, y: number): Path2;
  140596. }
  140597. /**
  140598. * Builds a polygon
  140599. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  140600. */
  140601. export class PolygonMeshBuilder {
  140602. private _points;
  140603. private _outlinepoints;
  140604. private _holes;
  140605. private _name;
  140606. private _scene;
  140607. private _epoints;
  140608. private _eholes;
  140609. private _addToepoint;
  140610. /**
  140611. * Babylon reference to the earcut plugin.
  140612. */
  140613. bjsEarcut: any;
  140614. /**
  140615. * Creates a PolygonMeshBuilder
  140616. * @param name name of the builder
  140617. * @param contours Path of the polygon
  140618. * @param scene scene to add to when creating the mesh
  140619. * @param earcutInjection can be used to inject your own earcut reference
  140620. */
  140621. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  140622. /**
  140623. * Adds a whole within the polygon
  140624. * @param hole Array of points defining the hole
  140625. * @returns this
  140626. */
  140627. addHole(hole: Vector2[]): PolygonMeshBuilder;
  140628. /**
  140629. * Creates the polygon
  140630. * @param updatable If the mesh should be updatable
  140631. * @param depth The depth of the mesh created
  140632. * @returns the created mesh
  140633. */
  140634. build(updatable?: boolean, depth?: number): Mesh;
  140635. /**
  140636. * Creates the polygon
  140637. * @param depth The depth of the mesh created
  140638. * @returns the created VertexData
  140639. */
  140640. buildVertexData(depth?: number): VertexData;
  140641. /**
  140642. * Adds a side to the polygon
  140643. * @param positions points that make the polygon
  140644. * @param normals normals of the polygon
  140645. * @param uvs uvs of the polygon
  140646. * @param indices indices of the polygon
  140647. * @param bounds bounds of the polygon
  140648. * @param points points of the polygon
  140649. * @param depth depth of the polygon
  140650. * @param flip flip of the polygon
  140651. */
  140652. private addSide;
  140653. }
  140654. }
  140655. declare module BABYLON {
  140656. /**
  140657. * Class containing static functions to help procedurally build meshes
  140658. */
  140659. export class PolygonBuilder {
  140660. /**
  140661. * Creates a polygon mesh
  140662. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  140663. * * 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
  140664. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  140665. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  140666. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  140667. * * Remember you can only change the shape positions, not their number when updating a polygon
  140668. * @param name defines the name of the mesh
  140669. * @param options defines the options used to create the mesh
  140670. * @param scene defines the hosting scene
  140671. * @param earcutInjection can be used to inject your own earcut reference
  140672. * @returns the polygon mesh
  140673. */
  140674. static CreatePolygon(name: string, options: {
  140675. shape: Vector3[];
  140676. holes?: Vector3[][];
  140677. depth?: number;
  140678. faceUV?: Vector4[];
  140679. faceColors?: Color4[];
  140680. updatable?: boolean;
  140681. sideOrientation?: number;
  140682. frontUVs?: Vector4;
  140683. backUVs?: Vector4;
  140684. wrap?: boolean;
  140685. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  140686. /**
  140687. * Creates an extruded polygon mesh, with depth in the Y direction.
  140688. * * 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)
  140689. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  140690. * @param name defines the name of the mesh
  140691. * @param options defines the options used to create the mesh
  140692. * @param scene defines the hosting scene
  140693. * @param earcutInjection can be used to inject your own earcut reference
  140694. * @returns the polygon mesh
  140695. */
  140696. static ExtrudePolygon(name: string, options: {
  140697. shape: Vector3[];
  140698. holes?: Vector3[][];
  140699. depth?: number;
  140700. faceUV?: Vector4[];
  140701. faceColors?: Color4[];
  140702. updatable?: boolean;
  140703. sideOrientation?: number;
  140704. frontUVs?: Vector4;
  140705. backUVs?: Vector4;
  140706. wrap?: boolean;
  140707. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  140708. }
  140709. }
  140710. declare module BABYLON {
  140711. /**
  140712. * Class containing static functions to help procedurally build meshes
  140713. */
  140714. export class LatheBuilder {
  140715. /**
  140716. * Creates lathe mesh.
  140717. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  140718. * * 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
  140719. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  140720. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  140721. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  140722. * * 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
  140723. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  140724. * * 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
  140725. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  140726. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  140727. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  140728. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  140729. * @param name defines the name of the mesh
  140730. * @param options defines the options used to create the mesh
  140731. * @param scene defines the hosting scene
  140732. * @returns the lathe mesh
  140733. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  140734. */
  140735. static CreateLathe(name: string, options: {
  140736. shape: Vector3[];
  140737. radius?: number;
  140738. tessellation?: number;
  140739. clip?: number;
  140740. arc?: number;
  140741. closed?: boolean;
  140742. updatable?: boolean;
  140743. sideOrientation?: number;
  140744. frontUVs?: Vector4;
  140745. backUVs?: Vector4;
  140746. cap?: number;
  140747. invertUV?: boolean;
  140748. }, scene?: Nullable<Scene>): Mesh;
  140749. }
  140750. }
  140751. declare module BABYLON {
  140752. /**
  140753. * Class containing static functions to help procedurally build meshes
  140754. */
  140755. export class TiledPlaneBuilder {
  140756. /**
  140757. * Creates a tiled plane mesh
  140758. * * The parameter `pattern` will, depending on value, do nothing or
  140759. * * * flip (reflect about central vertical) alternate tiles across and up
  140760. * * * flip every tile on alternate rows
  140761. * * * rotate (180 degs) alternate tiles across and up
  140762. * * * rotate every tile on alternate rows
  140763. * * * flip and rotate alternate tiles across and up
  140764. * * * flip and rotate every tile on alternate rows
  140765. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  140766. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  140767. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  140768. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  140769. * * 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)
  140770. * * 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)
  140771. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  140772. * @param name defines the name of the mesh
  140773. * @param options defines the options used to create the mesh
  140774. * @param scene defines the hosting scene
  140775. * @returns the box mesh
  140776. */
  140777. static CreateTiledPlane(name: string, options: {
  140778. pattern?: number;
  140779. tileSize?: number;
  140780. tileWidth?: number;
  140781. tileHeight?: number;
  140782. size?: number;
  140783. width?: number;
  140784. height?: number;
  140785. alignHorizontal?: number;
  140786. alignVertical?: number;
  140787. sideOrientation?: number;
  140788. frontUVs?: Vector4;
  140789. backUVs?: Vector4;
  140790. updatable?: boolean;
  140791. }, scene?: Nullable<Scene>): Mesh;
  140792. }
  140793. }
  140794. declare module BABYLON {
  140795. /**
  140796. * Class containing static functions to help procedurally build meshes
  140797. */
  140798. export class TubeBuilder {
  140799. /**
  140800. * Creates a tube mesh.
  140801. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  140802. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  140803. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  140804. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  140805. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  140806. * * 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)
  140807. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  140808. * * 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
  140809. * * 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
  140810. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  140811. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  140812. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  140813. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  140814. * @param name defines the name of the mesh
  140815. * @param options defines the options used to create the mesh
  140816. * @param scene defines the hosting scene
  140817. * @returns the tube mesh
  140818. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  140819. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  140820. */
  140821. static CreateTube(name: string, options: {
  140822. path: Vector3[];
  140823. radius?: number;
  140824. tessellation?: number;
  140825. radiusFunction?: {
  140826. (i: number, distance: number): number;
  140827. };
  140828. cap?: number;
  140829. arc?: number;
  140830. updatable?: boolean;
  140831. sideOrientation?: number;
  140832. frontUVs?: Vector4;
  140833. backUVs?: Vector4;
  140834. instance?: Mesh;
  140835. invertUV?: boolean;
  140836. }, scene?: Nullable<Scene>): Mesh;
  140837. }
  140838. }
  140839. declare module BABYLON {
  140840. /**
  140841. * Class containing static functions to help procedurally build meshes
  140842. */
  140843. export class IcoSphereBuilder {
  140844. /**
  140845. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  140846. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  140847. * * 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`)
  140848. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  140849. * * 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
  140850. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  140851. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  140852. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  140853. * @param name defines the name of the mesh
  140854. * @param options defines the options used to create the mesh
  140855. * @param scene defines the hosting scene
  140856. * @returns the icosahedron mesh
  140857. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  140858. */
  140859. static CreateIcoSphere(name: string, options: {
  140860. radius?: number;
  140861. radiusX?: number;
  140862. radiusY?: number;
  140863. radiusZ?: number;
  140864. flat?: boolean;
  140865. subdivisions?: number;
  140866. sideOrientation?: number;
  140867. frontUVs?: Vector4;
  140868. backUVs?: Vector4;
  140869. updatable?: boolean;
  140870. }, scene?: Nullable<Scene>): Mesh;
  140871. }
  140872. }
  140873. declare module BABYLON {
  140874. /**
  140875. * Class containing static functions to help procedurally build meshes
  140876. */
  140877. export class DecalBuilder {
  140878. /**
  140879. * Creates a decal mesh.
  140880. * 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
  140881. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  140882. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  140883. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  140884. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  140885. * @param name defines the name of the mesh
  140886. * @param sourceMesh defines the mesh where the decal must be applied
  140887. * @param options defines the options used to create the mesh
  140888. * @param scene defines the hosting scene
  140889. * @returns the decal mesh
  140890. * @see https://doc.babylonjs.com/how_to/decals
  140891. */
  140892. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  140893. position?: Vector3;
  140894. normal?: Vector3;
  140895. size?: Vector3;
  140896. angle?: number;
  140897. }): Mesh;
  140898. }
  140899. }
  140900. declare module BABYLON {
  140901. /**
  140902. * Class containing static functions to help procedurally build meshes
  140903. */
  140904. export class MeshBuilder {
  140905. /**
  140906. * Creates a box mesh
  140907. * * The parameter `size` sets the size (float) of each box side (default 1)
  140908. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  140909. * * 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)
  140910. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  140911. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  140912. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  140913. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  140914. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  140915. * @param name defines the name of the mesh
  140916. * @param options defines the options used to create the mesh
  140917. * @param scene defines the hosting scene
  140918. * @returns the box mesh
  140919. */
  140920. static CreateBox(name: string, options: {
  140921. size?: number;
  140922. width?: number;
  140923. height?: number;
  140924. depth?: number;
  140925. faceUV?: Vector4[];
  140926. faceColors?: Color4[];
  140927. sideOrientation?: number;
  140928. frontUVs?: Vector4;
  140929. backUVs?: Vector4;
  140930. wrap?: boolean;
  140931. topBaseAt?: number;
  140932. bottomBaseAt?: number;
  140933. updatable?: boolean;
  140934. }, scene?: Nullable<Scene>): Mesh;
  140935. /**
  140936. * Creates a tiled box mesh
  140937. * * faceTiles sets the pattern, tile size and number of tiles for a face
  140938. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  140939. * @param name defines the name of the mesh
  140940. * @param options defines the options used to create the mesh
  140941. * @param scene defines the hosting scene
  140942. * @returns the tiled box mesh
  140943. */
  140944. static CreateTiledBox(name: string, options: {
  140945. pattern?: number;
  140946. size?: number;
  140947. width?: number;
  140948. height?: number;
  140949. depth: number;
  140950. tileSize?: number;
  140951. tileWidth?: number;
  140952. tileHeight?: number;
  140953. faceUV?: Vector4[];
  140954. faceColors?: Color4[];
  140955. alignHorizontal?: number;
  140956. alignVertical?: number;
  140957. sideOrientation?: number;
  140958. updatable?: boolean;
  140959. }, scene?: Nullable<Scene>): Mesh;
  140960. /**
  140961. * Creates a sphere mesh
  140962. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  140963. * * 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`)
  140964. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  140965. * * 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
  140966. * * 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)
  140967. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  140968. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  140969. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  140970. * @param name defines the name of the mesh
  140971. * @param options defines the options used to create the mesh
  140972. * @param scene defines the hosting scene
  140973. * @returns the sphere mesh
  140974. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  140975. */
  140976. static CreateSphere(name: string, options: {
  140977. segments?: number;
  140978. diameter?: number;
  140979. diameterX?: number;
  140980. diameterY?: number;
  140981. diameterZ?: number;
  140982. arc?: number;
  140983. slice?: number;
  140984. sideOrientation?: number;
  140985. frontUVs?: Vector4;
  140986. backUVs?: Vector4;
  140987. updatable?: boolean;
  140988. }, scene?: Nullable<Scene>): Mesh;
  140989. /**
  140990. * Creates a plane polygonal mesh. By default, this is a disc
  140991. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  140992. * * 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
  140993. * * 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
  140994. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  140995. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  140996. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  140997. * @param name defines the name of the mesh
  140998. * @param options defines the options used to create the mesh
  140999. * @param scene defines the hosting scene
  141000. * @returns the plane polygonal mesh
  141001. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  141002. */
  141003. static CreateDisc(name: string, options: {
  141004. radius?: number;
  141005. tessellation?: number;
  141006. arc?: number;
  141007. updatable?: boolean;
  141008. sideOrientation?: number;
  141009. frontUVs?: Vector4;
  141010. backUVs?: Vector4;
  141011. }, scene?: Nullable<Scene>): Mesh;
  141012. /**
  141013. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  141014. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  141015. * * 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`)
  141016. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  141017. * * 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
  141018. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  141019. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  141020. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  141021. * @param name defines the name of the mesh
  141022. * @param options defines the options used to create the mesh
  141023. * @param scene defines the hosting scene
  141024. * @returns the icosahedron mesh
  141025. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  141026. */
  141027. static CreateIcoSphere(name: string, options: {
  141028. radius?: number;
  141029. radiusX?: number;
  141030. radiusY?: number;
  141031. radiusZ?: number;
  141032. flat?: boolean;
  141033. subdivisions?: number;
  141034. sideOrientation?: number;
  141035. frontUVs?: Vector4;
  141036. backUVs?: Vector4;
  141037. updatable?: boolean;
  141038. }, scene?: Nullable<Scene>): Mesh;
  141039. /**
  141040. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  141041. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  141042. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  141043. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  141044. * * 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
  141045. * * 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
  141046. * * 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
  141047. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  141048. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  141049. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  141050. * * 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
  141051. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  141052. * * 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
  141053. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  141054. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  141055. * @param name defines the name of the mesh
  141056. * @param options defines the options used to create the mesh
  141057. * @param scene defines the hosting scene
  141058. * @returns the ribbon mesh
  141059. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  141060. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  141061. */
  141062. static CreateRibbon(name: string, options: {
  141063. pathArray: Vector3[][];
  141064. closeArray?: boolean;
  141065. closePath?: boolean;
  141066. offset?: number;
  141067. updatable?: boolean;
  141068. sideOrientation?: number;
  141069. frontUVs?: Vector4;
  141070. backUVs?: Vector4;
  141071. instance?: Mesh;
  141072. invertUV?: boolean;
  141073. uvs?: Vector2[];
  141074. colors?: Color4[];
  141075. }, scene?: Nullable<Scene>): Mesh;
  141076. /**
  141077. * Creates a cylinder or a cone mesh
  141078. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  141079. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  141080. * * 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.
  141081. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  141082. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  141083. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  141084. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  141085. * * 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).
  141086. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  141087. * * 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).
  141088. * * 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
  141089. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  141090. * * 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
  141091. * * 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.
  141092. * * If `enclose` is false, a ring surface is one element.
  141093. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  141094. * * 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
  141095. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  141096. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  141097. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  141098. * @param name defines the name of the mesh
  141099. * @param options defines the options used to create the mesh
  141100. * @param scene defines the hosting scene
  141101. * @returns the cylinder mesh
  141102. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  141103. */
  141104. static CreateCylinder(name: string, options: {
  141105. height?: number;
  141106. diameterTop?: number;
  141107. diameterBottom?: number;
  141108. diameter?: number;
  141109. tessellation?: number;
  141110. subdivisions?: number;
  141111. arc?: number;
  141112. faceColors?: Color4[];
  141113. faceUV?: Vector4[];
  141114. updatable?: boolean;
  141115. hasRings?: boolean;
  141116. enclose?: boolean;
  141117. cap?: number;
  141118. sideOrientation?: number;
  141119. frontUVs?: Vector4;
  141120. backUVs?: Vector4;
  141121. }, scene?: Nullable<Scene>): Mesh;
  141122. /**
  141123. * Creates a torus mesh
  141124. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  141125. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  141126. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  141127. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  141128. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  141129. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  141130. * @param name defines the name of the mesh
  141131. * @param options defines the options used to create the mesh
  141132. * @param scene defines the hosting scene
  141133. * @returns the torus mesh
  141134. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  141135. */
  141136. static CreateTorus(name: string, options: {
  141137. diameter?: number;
  141138. thickness?: number;
  141139. tessellation?: number;
  141140. updatable?: boolean;
  141141. sideOrientation?: number;
  141142. frontUVs?: Vector4;
  141143. backUVs?: Vector4;
  141144. }, scene?: Nullable<Scene>): Mesh;
  141145. /**
  141146. * Creates a torus knot mesh
  141147. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  141148. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  141149. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  141150. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  141151. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  141152. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  141153. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  141154. * @param name defines the name of the mesh
  141155. * @param options defines the options used to create the mesh
  141156. * @param scene defines the hosting scene
  141157. * @returns the torus knot mesh
  141158. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  141159. */
  141160. static CreateTorusKnot(name: string, options: {
  141161. radius?: number;
  141162. tube?: number;
  141163. radialSegments?: number;
  141164. tubularSegments?: number;
  141165. p?: number;
  141166. q?: number;
  141167. updatable?: boolean;
  141168. sideOrientation?: number;
  141169. frontUVs?: Vector4;
  141170. backUVs?: Vector4;
  141171. }, scene?: Nullable<Scene>): Mesh;
  141172. /**
  141173. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  141174. * * 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
  141175. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  141176. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  141177. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  141178. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  141179. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  141180. * * 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
  141181. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  141182. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  141183. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  141184. * @param name defines the name of the new line system
  141185. * @param options defines the options used to create the line system
  141186. * @param scene defines the hosting scene
  141187. * @returns a new line system mesh
  141188. */
  141189. static CreateLineSystem(name: string, options: {
  141190. lines: Vector3[][];
  141191. updatable?: boolean;
  141192. instance?: Nullable<LinesMesh>;
  141193. colors?: Nullable<Color4[][]>;
  141194. useVertexAlpha?: boolean;
  141195. }, scene: Nullable<Scene>): LinesMesh;
  141196. /**
  141197. * Creates a line mesh
  141198. * 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
  141199. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  141200. * * The parameter `points` is an array successive Vector3
  141201. * * 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
  141202. * * The optional parameter `colors` is an array of successive Color4, one per line point
  141203. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  141204. * * When updating an instance, remember that only point positions can change, not the number of points
  141205. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  141206. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  141207. * @param name defines the name of the new line system
  141208. * @param options defines the options used to create the line system
  141209. * @param scene defines the hosting scene
  141210. * @returns a new line mesh
  141211. */
  141212. static CreateLines(name: string, options: {
  141213. points: Vector3[];
  141214. updatable?: boolean;
  141215. instance?: Nullable<LinesMesh>;
  141216. colors?: Color4[];
  141217. useVertexAlpha?: boolean;
  141218. }, scene?: Nullable<Scene>): LinesMesh;
  141219. /**
  141220. * Creates a dashed line mesh
  141221. * * 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
  141222. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  141223. * * The parameter `points` is an array successive Vector3
  141224. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  141225. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  141226. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  141227. * * 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
  141228. * * When updating an instance, remember that only point positions can change, not the number of points
  141229. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  141230. * @param name defines the name of the mesh
  141231. * @param options defines the options used to create the mesh
  141232. * @param scene defines the hosting scene
  141233. * @returns the dashed line mesh
  141234. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  141235. */
  141236. static CreateDashedLines(name: string, options: {
  141237. points: Vector3[];
  141238. dashSize?: number;
  141239. gapSize?: number;
  141240. dashNb?: number;
  141241. updatable?: boolean;
  141242. instance?: LinesMesh;
  141243. }, scene?: Nullable<Scene>): LinesMesh;
  141244. /**
  141245. * 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.
  141246. * * 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.
  141247. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  141248. * * 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.
  141249. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  141250. * * 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
  141251. * * 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
  141252. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  141253. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  141254. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  141255. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  141256. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  141257. * @param name defines the name of the mesh
  141258. * @param options defines the options used to create the mesh
  141259. * @param scene defines the hosting scene
  141260. * @returns the extruded shape mesh
  141261. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  141262. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  141263. */
  141264. static ExtrudeShape(name: string, options: {
  141265. shape: Vector3[];
  141266. path: Vector3[];
  141267. scale?: number;
  141268. rotation?: number;
  141269. cap?: number;
  141270. updatable?: boolean;
  141271. sideOrientation?: number;
  141272. frontUVs?: Vector4;
  141273. backUVs?: Vector4;
  141274. instance?: Mesh;
  141275. invertUV?: boolean;
  141276. }, scene?: Nullable<Scene>): Mesh;
  141277. /**
  141278. * Creates an custom extruded shape mesh.
  141279. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  141280. * * 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.
  141281. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  141282. * * 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
  141283. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  141284. * * 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
  141285. * * It must returns a float value that will be the scale value applied to the shape on each path point
  141286. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  141287. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  141288. * * 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
  141289. * * 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
  141290. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  141291. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  141292. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  141293. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  141294. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  141295. * @param name defines the name of the mesh
  141296. * @param options defines the options used to create the mesh
  141297. * @param scene defines the hosting scene
  141298. * @returns the custom extruded shape mesh
  141299. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  141300. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  141301. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  141302. */
  141303. static ExtrudeShapeCustom(name: string, options: {
  141304. shape: Vector3[];
  141305. path: Vector3[];
  141306. scaleFunction?: any;
  141307. rotationFunction?: any;
  141308. ribbonCloseArray?: boolean;
  141309. ribbonClosePath?: boolean;
  141310. cap?: number;
  141311. updatable?: boolean;
  141312. sideOrientation?: number;
  141313. frontUVs?: Vector4;
  141314. backUVs?: Vector4;
  141315. instance?: Mesh;
  141316. invertUV?: boolean;
  141317. }, scene?: Nullable<Scene>): Mesh;
  141318. /**
  141319. * Creates lathe mesh.
  141320. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  141321. * * 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
  141322. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  141323. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  141324. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  141325. * * 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
  141326. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  141327. * * 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
  141328. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  141329. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  141330. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  141331. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  141332. * @param name defines the name of the mesh
  141333. * @param options defines the options used to create the mesh
  141334. * @param scene defines the hosting scene
  141335. * @returns the lathe mesh
  141336. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  141337. */
  141338. static CreateLathe(name: string, options: {
  141339. shape: Vector3[];
  141340. radius?: number;
  141341. tessellation?: number;
  141342. clip?: number;
  141343. arc?: number;
  141344. closed?: boolean;
  141345. updatable?: boolean;
  141346. sideOrientation?: number;
  141347. frontUVs?: Vector4;
  141348. backUVs?: Vector4;
  141349. cap?: number;
  141350. invertUV?: boolean;
  141351. }, scene?: Nullable<Scene>): Mesh;
  141352. /**
  141353. * Creates a tiled plane mesh
  141354. * * You can set a limited pattern arrangement with the tiles
  141355. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  141356. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  141357. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  141358. * @param name defines the name of the mesh
  141359. * @param options defines the options used to create the mesh
  141360. * @param scene defines the hosting scene
  141361. * @returns the plane mesh
  141362. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  141363. */
  141364. static CreateTiledPlane(name: string, options: {
  141365. pattern?: number;
  141366. tileSize?: number;
  141367. tileWidth?: number;
  141368. tileHeight?: number;
  141369. size?: number;
  141370. width?: number;
  141371. height?: number;
  141372. alignHorizontal?: number;
  141373. alignVertical?: number;
  141374. sideOrientation?: number;
  141375. frontUVs?: Vector4;
  141376. backUVs?: Vector4;
  141377. updatable?: boolean;
  141378. }, scene?: Nullable<Scene>): Mesh;
  141379. /**
  141380. * Creates a plane mesh
  141381. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  141382. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  141383. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  141384. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  141385. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  141386. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  141387. * @param name defines the name of the mesh
  141388. * @param options defines the options used to create the mesh
  141389. * @param scene defines the hosting scene
  141390. * @returns the plane mesh
  141391. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  141392. */
  141393. static CreatePlane(name: string, options: {
  141394. size?: number;
  141395. width?: number;
  141396. height?: number;
  141397. sideOrientation?: number;
  141398. frontUVs?: Vector4;
  141399. backUVs?: Vector4;
  141400. updatable?: boolean;
  141401. sourcePlane?: Plane;
  141402. }, scene?: Nullable<Scene>): Mesh;
  141403. /**
  141404. * Creates a ground mesh
  141405. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  141406. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  141407. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  141408. * @param name defines the name of the mesh
  141409. * @param options defines the options used to create the mesh
  141410. * @param scene defines the hosting scene
  141411. * @returns the ground mesh
  141412. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  141413. */
  141414. static CreateGround(name: string, options: {
  141415. width?: number;
  141416. height?: number;
  141417. subdivisions?: number;
  141418. subdivisionsX?: number;
  141419. subdivisionsY?: number;
  141420. updatable?: boolean;
  141421. }, scene?: Nullable<Scene>): Mesh;
  141422. /**
  141423. * Creates a tiled ground mesh
  141424. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  141425. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  141426. * * 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
  141427. * * 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
  141428. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  141429. * @param name defines the name of the mesh
  141430. * @param options defines the options used to create the mesh
  141431. * @param scene defines the hosting scene
  141432. * @returns the tiled ground mesh
  141433. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  141434. */
  141435. static CreateTiledGround(name: string, options: {
  141436. xmin: number;
  141437. zmin: number;
  141438. xmax: number;
  141439. zmax: number;
  141440. subdivisions?: {
  141441. w: number;
  141442. h: number;
  141443. };
  141444. precision?: {
  141445. w: number;
  141446. h: number;
  141447. };
  141448. updatable?: boolean;
  141449. }, scene?: Nullable<Scene>): Mesh;
  141450. /**
  141451. * Creates a ground mesh from a height map
  141452. * * The parameter `url` sets the URL of the height map image resource.
  141453. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  141454. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  141455. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  141456. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  141457. * * 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.
  141458. * * 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).
  141459. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  141460. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  141461. * @param name defines the name of the mesh
  141462. * @param url defines the url to the height map
  141463. * @param options defines the options used to create the mesh
  141464. * @param scene defines the hosting scene
  141465. * @returns the ground mesh
  141466. * @see https://doc.babylonjs.com/babylon101/height_map
  141467. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  141468. */
  141469. static CreateGroundFromHeightMap(name: string, url: string, options: {
  141470. width?: number;
  141471. height?: number;
  141472. subdivisions?: number;
  141473. minHeight?: number;
  141474. maxHeight?: number;
  141475. colorFilter?: Color3;
  141476. alphaFilter?: number;
  141477. updatable?: boolean;
  141478. onReady?: (mesh: GroundMesh) => void;
  141479. }, scene?: Nullable<Scene>): GroundMesh;
  141480. /**
  141481. * Creates a polygon mesh
  141482. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  141483. * * 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
  141484. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  141485. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  141486. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  141487. * * Remember you can only change the shape positions, not their number when updating a polygon
  141488. * @param name defines the name of the mesh
  141489. * @param options defines the options used to create the mesh
  141490. * @param scene defines the hosting scene
  141491. * @param earcutInjection can be used to inject your own earcut reference
  141492. * @returns the polygon mesh
  141493. */
  141494. static CreatePolygon(name: string, options: {
  141495. shape: Vector3[];
  141496. holes?: Vector3[][];
  141497. depth?: number;
  141498. faceUV?: Vector4[];
  141499. faceColors?: Color4[];
  141500. updatable?: boolean;
  141501. sideOrientation?: number;
  141502. frontUVs?: Vector4;
  141503. backUVs?: Vector4;
  141504. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  141505. /**
  141506. * Creates an extruded polygon mesh, with depth in the Y direction.
  141507. * * 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)
  141508. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  141509. * @param name defines the name of the mesh
  141510. * @param options defines the options used to create the mesh
  141511. * @param scene defines the hosting scene
  141512. * @param earcutInjection can be used to inject your own earcut reference
  141513. * @returns the polygon mesh
  141514. */
  141515. static ExtrudePolygon(name: string, options: {
  141516. shape: Vector3[];
  141517. holes?: Vector3[][];
  141518. depth?: number;
  141519. faceUV?: Vector4[];
  141520. faceColors?: Color4[];
  141521. updatable?: boolean;
  141522. sideOrientation?: number;
  141523. frontUVs?: Vector4;
  141524. backUVs?: Vector4;
  141525. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  141526. /**
  141527. * Creates a tube mesh.
  141528. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  141529. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  141530. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  141531. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  141532. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  141533. * * 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)
  141534. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  141535. * * 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
  141536. * * 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
  141537. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  141538. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  141539. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  141540. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  141541. * @param name defines the name of the mesh
  141542. * @param options defines the options used to create the mesh
  141543. * @param scene defines the hosting scene
  141544. * @returns the tube mesh
  141545. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  141546. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  141547. */
  141548. static CreateTube(name: string, options: {
  141549. path: Vector3[];
  141550. radius?: number;
  141551. tessellation?: number;
  141552. radiusFunction?: {
  141553. (i: number, distance: number): number;
  141554. };
  141555. cap?: number;
  141556. arc?: number;
  141557. updatable?: boolean;
  141558. sideOrientation?: number;
  141559. frontUVs?: Vector4;
  141560. backUVs?: Vector4;
  141561. instance?: Mesh;
  141562. invertUV?: boolean;
  141563. }, scene?: Nullable<Scene>): Mesh;
  141564. /**
  141565. * Creates a polyhedron mesh
  141566. * * 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
  141567. * * The parameter `size` (positive float, default 1) sets the polygon size
  141568. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  141569. * * 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`
  141570. * * 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
  141571. * * 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)`)
  141572. * * 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
  141573. * * 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
  141574. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  141575. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  141576. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  141577. * @param name defines the name of the mesh
  141578. * @param options defines the options used to create the mesh
  141579. * @param scene defines the hosting scene
  141580. * @returns the polyhedron mesh
  141581. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  141582. */
  141583. static CreatePolyhedron(name: string, options: {
  141584. type?: number;
  141585. size?: number;
  141586. sizeX?: number;
  141587. sizeY?: number;
  141588. sizeZ?: number;
  141589. custom?: any;
  141590. faceUV?: Vector4[];
  141591. faceColors?: Color4[];
  141592. flat?: boolean;
  141593. updatable?: boolean;
  141594. sideOrientation?: number;
  141595. frontUVs?: Vector4;
  141596. backUVs?: Vector4;
  141597. }, scene?: Nullable<Scene>): Mesh;
  141598. /**
  141599. * Creates a decal mesh.
  141600. * 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
  141601. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  141602. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  141603. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  141604. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  141605. * @param name defines the name of the mesh
  141606. * @param sourceMesh defines the mesh where the decal must be applied
  141607. * @param options defines the options used to create the mesh
  141608. * @param scene defines the hosting scene
  141609. * @returns the decal mesh
  141610. * @see https://doc.babylonjs.com/how_to/decals
  141611. */
  141612. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  141613. position?: Vector3;
  141614. normal?: Vector3;
  141615. size?: Vector3;
  141616. angle?: number;
  141617. }): Mesh;
  141618. }
  141619. }
  141620. declare module BABYLON {
  141621. /**
  141622. * A simplifier interface for future simplification implementations
  141623. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  141624. */
  141625. export interface ISimplifier {
  141626. /**
  141627. * Simplification of a given mesh according to the given settings.
  141628. * Since this requires computation, it is assumed that the function runs async.
  141629. * @param settings The settings of the simplification, including quality and distance
  141630. * @param successCallback A callback that will be called after the mesh was simplified.
  141631. * @param errorCallback in case of an error, this callback will be called. optional.
  141632. */
  141633. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  141634. }
  141635. /**
  141636. * Expected simplification settings.
  141637. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  141638. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  141639. */
  141640. export interface ISimplificationSettings {
  141641. /**
  141642. * Gets or sets the expected quality
  141643. */
  141644. quality: number;
  141645. /**
  141646. * Gets or sets the distance when this optimized version should be used
  141647. */
  141648. distance: number;
  141649. /**
  141650. * Gets an already optimized mesh
  141651. */
  141652. optimizeMesh?: boolean;
  141653. }
  141654. /**
  141655. * Class used to specify simplification options
  141656. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  141657. */
  141658. export class SimplificationSettings implements ISimplificationSettings {
  141659. /** expected quality */
  141660. quality: number;
  141661. /** distance when this optimized version should be used */
  141662. distance: number;
  141663. /** already optimized mesh */
  141664. optimizeMesh?: boolean | undefined;
  141665. /**
  141666. * Creates a SimplificationSettings
  141667. * @param quality expected quality
  141668. * @param distance distance when this optimized version should be used
  141669. * @param optimizeMesh already optimized mesh
  141670. */
  141671. constructor(
  141672. /** expected quality */
  141673. quality: number,
  141674. /** distance when this optimized version should be used */
  141675. distance: number,
  141676. /** already optimized mesh */
  141677. optimizeMesh?: boolean | undefined);
  141678. }
  141679. /**
  141680. * Interface used to define a simplification task
  141681. */
  141682. export interface ISimplificationTask {
  141683. /**
  141684. * Array of settings
  141685. */
  141686. settings: Array<ISimplificationSettings>;
  141687. /**
  141688. * Simplification type
  141689. */
  141690. simplificationType: SimplificationType;
  141691. /**
  141692. * Mesh to simplify
  141693. */
  141694. mesh: Mesh;
  141695. /**
  141696. * Callback called on success
  141697. */
  141698. successCallback?: () => void;
  141699. /**
  141700. * Defines if parallel processing can be used
  141701. */
  141702. parallelProcessing: boolean;
  141703. }
  141704. /**
  141705. * Queue used to order the simplification tasks
  141706. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  141707. */
  141708. export class SimplificationQueue {
  141709. private _simplificationArray;
  141710. /**
  141711. * Gets a boolean indicating that the process is still running
  141712. */
  141713. running: boolean;
  141714. /**
  141715. * Creates a new queue
  141716. */
  141717. constructor();
  141718. /**
  141719. * Adds a new simplification task
  141720. * @param task defines a task to add
  141721. */
  141722. addTask(task: ISimplificationTask): void;
  141723. /**
  141724. * Execute next task
  141725. */
  141726. executeNext(): void;
  141727. /**
  141728. * Execute a simplification task
  141729. * @param task defines the task to run
  141730. */
  141731. runSimplification(task: ISimplificationTask): void;
  141732. private getSimplifier;
  141733. }
  141734. /**
  141735. * The implemented types of simplification
  141736. * At the moment only Quadratic Error Decimation is implemented
  141737. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  141738. */
  141739. export enum SimplificationType {
  141740. /** Quadratic error decimation */
  141741. QUADRATIC = 0
  141742. }
  141743. /**
  141744. * An implementation of the Quadratic Error simplification algorithm.
  141745. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  141746. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  141747. * @author RaananW
  141748. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  141749. */
  141750. export class QuadraticErrorSimplification implements ISimplifier {
  141751. private _mesh;
  141752. private triangles;
  141753. private vertices;
  141754. private references;
  141755. private _reconstructedMesh;
  141756. /** Gets or sets the number pf sync interations */
  141757. syncIterations: number;
  141758. /** Gets or sets the aggressiveness of the simplifier */
  141759. aggressiveness: number;
  141760. /** Gets or sets the number of allowed iterations for decimation */
  141761. decimationIterations: number;
  141762. /** Gets or sets the espilon to use for bounding box computation */
  141763. boundingBoxEpsilon: number;
  141764. /**
  141765. * Creates a new QuadraticErrorSimplification
  141766. * @param _mesh defines the target mesh
  141767. */
  141768. constructor(_mesh: Mesh);
  141769. /**
  141770. * Simplification of a given mesh according to the given settings.
  141771. * Since this requires computation, it is assumed that the function runs async.
  141772. * @param settings The settings of the simplification, including quality and distance
  141773. * @param successCallback A callback that will be called after the mesh was simplified.
  141774. */
  141775. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  141776. private runDecimation;
  141777. private initWithMesh;
  141778. private init;
  141779. private reconstructMesh;
  141780. private initDecimatedMesh;
  141781. private isFlipped;
  141782. private updateTriangles;
  141783. private identifyBorder;
  141784. private updateMesh;
  141785. private vertexError;
  141786. private calculateError;
  141787. }
  141788. }
  141789. declare module BABYLON {
  141790. interface Scene {
  141791. /** @hidden (Backing field) */
  141792. _simplificationQueue: SimplificationQueue;
  141793. /**
  141794. * Gets or sets the simplification queue attached to the scene
  141795. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  141796. */
  141797. simplificationQueue: SimplificationQueue;
  141798. }
  141799. interface Mesh {
  141800. /**
  141801. * Simplify the mesh according to the given array of settings.
  141802. * Function will return immediately and will simplify async
  141803. * @param settings a collection of simplification settings
  141804. * @param parallelProcessing should all levels calculate parallel or one after the other
  141805. * @param simplificationType the type of simplification to run
  141806. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  141807. * @returns the current mesh
  141808. */
  141809. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  141810. }
  141811. /**
  141812. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  141813. * created in a scene
  141814. */
  141815. export class SimplicationQueueSceneComponent implements ISceneComponent {
  141816. /**
  141817. * The component name helpfull to identify the component in the list of scene components.
  141818. */
  141819. readonly name: string;
  141820. /**
  141821. * The scene the component belongs to.
  141822. */
  141823. scene: Scene;
  141824. /**
  141825. * Creates a new instance of the component for the given scene
  141826. * @param scene Defines the scene to register the component in
  141827. */
  141828. constructor(scene: Scene);
  141829. /**
  141830. * Registers the component in a given scene
  141831. */
  141832. register(): void;
  141833. /**
  141834. * Rebuilds the elements related to this component in case of
  141835. * context lost for instance.
  141836. */
  141837. rebuild(): void;
  141838. /**
  141839. * Disposes the component and the associated ressources
  141840. */
  141841. dispose(): void;
  141842. private _beforeCameraUpdate;
  141843. }
  141844. }
  141845. declare module BABYLON {
  141846. /**
  141847. * Navigation plugin interface to add navigation constrained by a navigation mesh
  141848. */
  141849. export interface INavigationEnginePlugin {
  141850. /**
  141851. * plugin name
  141852. */
  141853. name: string;
  141854. /**
  141855. * Creates a navigation mesh
  141856. * @param meshes array of all the geometry used to compute the navigatio mesh
  141857. * @param parameters bunch of parameters used to filter geometry
  141858. */
  141859. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  141860. /**
  141861. * Create a navigation mesh debug mesh
  141862. * @param scene is where the mesh will be added
  141863. * @returns debug display mesh
  141864. */
  141865. createDebugNavMesh(scene: Scene): Mesh;
  141866. /**
  141867. * Get a navigation mesh constrained position, closest to the parameter position
  141868. * @param position world position
  141869. * @returns the closest point to position constrained by the navigation mesh
  141870. */
  141871. getClosestPoint(position: Vector3): Vector3;
  141872. /**
  141873. * Get a navigation mesh constrained position, closest to the parameter position
  141874. * @param position world position
  141875. * @param result output the closest point to position constrained by the navigation mesh
  141876. */
  141877. getClosestPointToRef(position: Vector3, result: Vector3): void;
  141878. /**
  141879. * Get a navigation mesh constrained position, within a particular radius
  141880. * @param position world position
  141881. * @param maxRadius the maximum distance to the constrained world position
  141882. * @returns the closest point to position constrained by the navigation mesh
  141883. */
  141884. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  141885. /**
  141886. * Get a navigation mesh constrained position, within a particular radius
  141887. * @param position world position
  141888. * @param maxRadius the maximum distance to the constrained world position
  141889. * @param result output the closest point to position constrained by the navigation mesh
  141890. */
  141891. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  141892. /**
  141893. * Compute the final position from a segment made of destination-position
  141894. * @param position world position
  141895. * @param destination world position
  141896. * @returns the resulting point along the navmesh
  141897. */
  141898. moveAlong(position: Vector3, destination: Vector3): Vector3;
  141899. /**
  141900. * Compute the final position from a segment made of destination-position
  141901. * @param position world position
  141902. * @param destination world position
  141903. * @param result output the resulting point along the navmesh
  141904. */
  141905. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  141906. /**
  141907. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  141908. * @param start world position
  141909. * @param end world position
  141910. * @returns array containing world position composing the path
  141911. */
  141912. computePath(start: Vector3, end: Vector3): Vector3[];
  141913. /**
  141914. * If this plugin is supported
  141915. * @returns true if plugin is supported
  141916. */
  141917. isSupported(): boolean;
  141918. /**
  141919. * Create a new Crowd so you can add agents
  141920. * @param maxAgents the maximum agent count in the crowd
  141921. * @param maxAgentRadius the maximum radius an agent can have
  141922. * @param scene to attach the crowd to
  141923. * @returns the crowd you can add agents to
  141924. */
  141925. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  141926. /**
  141927. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  141928. * The queries will try to find a solution within those bounds
  141929. * default is (1,1,1)
  141930. * @param extent x,y,z value that define the extent around the queries point of reference
  141931. */
  141932. setDefaultQueryExtent(extent: Vector3): void;
  141933. /**
  141934. * Get the Bounding box extent specified by setDefaultQueryExtent
  141935. * @returns the box extent values
  141936. */
  141937. getDefaultQueryExtent(): Vector3;
  141938. /**
  141939. * build the navmesh from a previously saved state using getNavmeshData
  141940. * @param data the Uint8Array returned by getNavmeshData
  141941. */
  141942. buildFromNavmeshData(data: Uint8Array): void;
  141943. /**
  141944. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  141945. * @returns data the Uint8Array that can be saved and reused
  141946. */
  141947. getNavmeshData(): Uint8Array;
  141948. /**
  141949. * Get the Bounding box extent result specified by setDefaultQueryExtent
  141950. * @param result output the box extent values
  141951. */
  141952. getDefaultQueryExtentToRef(result: Vector3): void;
  141953. /**
  141954. * Release all resources
  141955. */
  141956. dispose(): void;
  141957. }
  141958. /**
  141959. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  141960. */
  141961. export interface ICrowd {
  141962. /**
  141963. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  141964. * You can attach anything to that node. The node position is updated in the scene update tick.
  141965. * @param pos world position that will be constrained by the navigation mesh
  141966. * @param parameters agent parameters
  141967. * @param transform hooked to the agent that will be update by the scene
  141968. * @returns agent index
  141969. */
  141970. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  141971. /**
  141972. * Returns the agent position in world space
  141973. * @param index agent index returned by addAgent
  141974. * @returns world space position
  141975. */
  141976. getAgentPosition(index: number): Vector3;
  141977. /**
  141978. * Gets the agent position result in world space
  141979. * @param index agent index returned by addAgent
  141980. * @param result output world space position
  141981. */
  141982. getAgentPositionToRef(index: number, result: Vector3): void;
  141983. /**
  141984. * Gets the agent velocity in world space
  141985. * @param index agent index returned by addAgent
  141986. * @returns world space velocity
  141987. */
  141988. getAgentVelocity(index: number): Vector3;
  141989. /**
  141990. * Gets the agent velocity result in world space
  141991. * @param index agent index returned by addAgent
  141992. * @param result output world space velocity
  141993. */
  141994. getAgentVelocityToRef(index: number, result: Vector3): void;
  141995. /**
  141996. * remove a particular agent previously created
  141997. * @param index agent index returned by addAgent
  141998. */
  141999. removeAgent(index: number): void;
  142000. /**
  142001. * get the list of all agents attached to this crowd
  142002. * @returns list of agent indices
  142003. */
  142004. getAgents(): number[];
  142005. /**
  142006. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  142007. * @param deltaTime in seconds
  142008. */
  142009. update(deltaTime: number): void;
  142010. /**
  142011. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  142012. * @param index agent index returned by addAgent
  142013. * @param destination targeted world position
  142014. */
  142015. agentGoto(index: number, destination: Vector3): void;
  142016. /**
  142017. * Teleport the agent to a new position
  142018. * @param index agent index returned by addAgent
  142019. * @param destination targeted world position
  142020. */
  142021. agentTeleport(index: number, destination: Vector3): void;
  142022. /**
  142023. * Update agent parameters
  142024. * @param index agent index returned by addAgent
  142025. * @param parameters agent parameters
  142026. */
  142027. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  142028. /**
  142029. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  142030. * The queries will try to find a solution within those bounds
  142031. * default is (1,1,1)
  142032. * @param extent x,y,z value that define the extent around the queries point of reference
  142033. */
  142034. setDefaultQueryExtent(extent: Vector3): void;
  142035. /**
  142036. * Get the Bounding box extent specified by setDefaultQueryExtent
  142037. * @returns the box extent values
  142038. */
  142039. getDefaultQueryExtent(): Vector3;
  142040. /**
  142041. * Get the Bounding box extent result specified by setDefaultQueryExtent
  142042. * @param result output the box extent values
  142043. */
  142044. getDefaultQueryExtentToRef(result: Vector3): void;
  142045. /**
  142046. * Release all resources
  142047. */
  142048. dispose(): void;
  142049. }
  142050. /**
  142051. * Configures an agent
  142052. */
  142053. export interface IAgentParameters {
  142054. /**
  142055. * Agent radius. [Limit: >= 0]
  142056. */
  142057. radius: number;
  142058. /**
  142059. * Agent height. [Limit: > 0]
  142060. */
  142061. height: number;
  142062. /**
  142063. * Maximum allowed acceleration. [Limit: >= 0]
  142064. */
  142065. maxAcceleration: number;
  142066. /**
  142067. * Maximum allowed speed. [Limit: >= 0]
  142068. */
  142069. maxSpeed: number;
  142070. /**
  142071. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  142072. */
  142073. collisionQueryRange: number;
  142074. /**
  142075. * The path visibility optimization range. [Limit: > 0]
  142076. */
  142077. pathOptimizationRange: number;
  142078. /**
  142079. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  142080. */
  142081. separationWeight: number;
  142082. }
  142083. /**
  142084. * Configures the navigation mesh creation
  142085. */
  142086. export interface INavMeshParameters {
  142087. /**
  142088. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  142089. */
  142090. cs: number;
  142091. /**
  142092. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  142093. */
  142094. ch: number;
  142095. /**
  142096. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  142097. */
  142098. walkableSlopeAngle: number;
  142099. /**
  142100. * Minimum floor to 'ceiling' height that will still allow the floor area to
  142101. * be considered walkable. [Limit: >= 3] [Units: vx]
  142102. */
  142103. walkableHeight: number;
  142104. /**
  142105. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  142106. */
  142107. walkableClimb: number;
  142108. /**
  142109. * The distance to erode/shrink the walkable area of the heightfield away from
  142110. * obstructions. [Limit: >=0] [Units: vx]
  142111. */
  142112. walkableRadius: number;
  142113. /**
  142114. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  142115. */
  142116. maxEdgeLen: number;
  142117. /**
  142118. * The maximum distance a simplfied contour's border edges should deviate
  142119. * the original raw contour. [Limit: >=0] [Units: vx]
  142120. */
  142121. maxSimplificationError: number;
  142122. /**
  142123. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  142124. */
  142125. minRegionArea: number;
  142126. /**
  142127. * Any regions with a span count smaller than this value will, if possible,
  142128. * be merged with larger regions. [Limit: >=0] [Units: vx]
  142129. */
  142130. mergeRegionArea: number;
  142131. /**
  142132. * The maximum number of vertices allowed for polygons generated during the
  142133. * contour to polygon conversion process. [Limit: >= 3]
  142134. */
  142135. maxVertsPerPoly: number;
  142136. /**
  142137. * Sets the sampling distance to use when generating the detail mesh.
  142138. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  142139. */
  142140. detailSampleDist: number;
  142141. /**
  142142. * The maximum distance the detail mesh surface should deviate from heightfield
  142143. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  142144. */
  142145. detailSampleMaxError: number;
  142146. }
  142147. }
  142148. declare module BABYLON {
  142149. /**
  142150. * RecastJS navigation plugin
  142151. */
  142152. export class RecastJSPlugin implements INavigationEnginePlugin {
  142153. /**
  142154. * Reference to the Recast library
  142155. */
  142156. bjsRECAST: any;
  142157. /**
  142158. * plugin name
  142159. */
  142160. name: string;
  142161. /**
  142162. * the first navmesh created. We might extend this to support multiple navmeshes
  142163. */
  142164. navMesh: any;
  142165. /**
  142166. * Initializes the recastJS plugin
  142167. * @param recastInjection can be used to inject your own recast reference
  142168. */
  142169. constructor(recastInjection?: any);
  142170. /**
  142171. * Creates a navigation mesh
  142172. * @param meshes array of all the geometry used to compute the navigatio mesh
  142173. * @param parameters bunch of parameters used to filter geometry
  142174. */
  142175. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  142176. /**
  142177. * Create a navigation mesh debug mesh
  142178. * @param scene is where the mesh will be added
  142179. * @returns debug display mesh
  142180. */
  142181. createDebugNavMesh(scene: Scene): Mesh;
  142182. /**
  142183. * Get a navigation mesh constrained position, closest to the parameter position
  142184. * @param position world position
  142185. * @returns the closest point to position constrained by the navigation mesh
  142186. */
  142187. getClosestPoint(position: Vector3): Vector3;
  142188. /**
  142189. * Get a navigation mesh constrained position, closest to the parameter position
  142190. * @param position world position
  142191. * @param result output the closest point to position constrained by the navigation mesh
  142192. */
  142193. getClosestPointToRef(position: Vector3, result: Vector3): void;
  142194. /**
  142195. * Get a navigation mesh constrained position, within a particular radius
  142196. * @param position world position
  142197. * @param maxRadius the maximum distance to the constrained world position
  142198. * @returns the closest point to position constrained by the navigation mesh
  142199. */
  142200. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  142201. /**
  142202. * Get a navigation mesh constrained position, within a particular radius
  142203. * @param position world position
  142204. * @param maxRadius the maximum distance to the constrained world position
  142205. * @param result output the closest point to position constrained by the navigation mesh
  142206. */
  142207. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  142208. /**
  142209. * Compute the final position from a segment made of destination-position
  142210. * @param position world position
  142211. * @param destination world position
  142212. * @returns the resulting point along the navmesh
  142213. */
  142214. moveAlong(position: Vector3, destination: Vector3): Vector3;
  142215. /**
  142216. * Compute the final position from a segment made of destination-position
  142217. * @param position world position
  142218. * @param destination world position
  142219. * @param result output the resulting point along the navmesh
  142220. */
  142221. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  142222. /**
  142223. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  142224. * @param start world position
  142225. * @param end world position
  142226. * @returns array containing world position composing the path
  142227. */
  142228. computePath(start: Vector3, end: Vector3): Vector3[];
  142229. /**
  142230. * Create a new Crowd so you can add agents
  142231. * @param maxAgents the maximum agent count in the crowd
  142232. * @param maxAgentRadius the maximum radius an agent can have
  142233. * @param scene to attach the crowd to
  142234. * @returns the crowd you can add agents to
  142235. */
  142236. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  142237. /**
  142238. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  142239. * The queries will try to find a solution within those bounds
  142240. * default is (1,1,1)
  142241. * @param extent x,y,z value that define the extent around the queries point of reference
  142242. */
  142243. setDefaultQueryExtent(extent: Vector3): void;
  142244. /**
  142245. * Get the Bounding box extent specified by setDefaultQueryExtent
  142246. * @returns the box extent values
  142247. */
  142248. getDefaultQueryExtent(): Vector3;
  142249. /**
  142250. * build the navmesh from a previously saved state using getNavmeshData
  142251. * @param data the Uint8Array returned by getNavmeshData
  142252. */
  142253. buildFromNavmeshData(data: Uint8Array): void;
  142254. /**
  142255. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  142256. * @returns data the Uint8Array that can be saved and reused
  142257. */
  142258. getNavmeshData(): Uint8Array;
  142259. /**
  142260. * Get the Bounding box extent result specified by setDefaultQueryExtent
  142261. * @param result output the box extent values
  142262. */
  142263. getDefaultQueryExtentToRef(result: Vector3): void;
  142264. /**
  142265. * Disposes
  142266. */
  142267. dispose(): void;
  142268. /**
  142269. * If this plugin is supported
  142270. * @returns true if plugin is supported
  142271. */
  142272. isSupported(): boolean;
  142273. }
  142274. /**
  142275. * Recast detour crowd implementation
  142276. */
  142277. export class RecastJSCrowd implements ICrowd {
  142278. /**
  142279. * Recast/detour plugin
  142280. */
  142281. bjsRECASTPlugin: RecastJSPlugin;
  142282. /**
  142283. * Link to the detour crowd
  142284. */
  142285. recastCrowd: any;
  142286. /**
  142287. * One transform per agent
  142288. */
  142289. transforms: TransformNode[];
  142290. /**
  142291. * All agents created
  142292. */
  142293. agents: number[];
  142294. /**
  142295. * Link to the scene is kept to unregister the crowd from the scene
  142296. */
  142297. private _scene;
  142298. /**
  142299. * Observer for crowd updates
  142300. */
  142301. private _onBeforeAnimationsObserver;
  142302. /**
  142303. * Constructor
  142304. * @param plugin recastJS plugin
  142305. * @param maxAgents the maximum agent count in the crowd
  142306. * @param maxAgentRadius the maximum radius an agent can have
  142307. * @param scene to attach the crowd to
  142308. * @returns the crowd you can add agents to
  142309. */
  142310. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  142311. /**
  142312. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  142313. * You can attach anything to that node. The node position is updated in the scene update tick.
  142314. * @param pos world position that will be constrained by the navigation mesh
  142315. * @param parameters agent parameters
  142316. * @param transform hooked to the agent that will be update by the scene
  142317. * @returns agent index
  142318. */
  142319. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  142320. /**
  142321. * Returns the agent position in world space
  142322. * @param index agent index returned by addAgent
  142323. * @returns world space position
  142324. */
  142325. getAgentPosition(index: number): Vector3;
  142326. /**
  142327. * Returns the agent position result in world space
  142328. * @param index agent index returned by addAgent
  142329. * @param result output world space position
  142330. */
  142331. getAgentPositionToRef(index: number, result: Vector3): void;
  142332. /**
  142333. * Returns the agent velocity in world space
  142334. * @param index agent index returned by addAgent
  142335. * @returns world space velocity
  142336. */
  142337. getAgentVelocity(index: number): Vector3;
  142338. /**
  142339. * Returns the agent velocity result in world space
  142340. * @param index agent index returned by addAgent
  142341. * @param result output world space velocity
  142342. */
  142343. getAgentVelocityToRef(index: number, result: Vector3): void;
  142344. /**
  142345. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  142346. * @param index agent index returned by addAgent
  142347. * @param destination targeted world position
  142348. */
  142349. agentGoto(index: number, destination: Vector3): void;
  142350. /**
  142351. * Teleport the agent to a new position
  142352. * @param index agent index returned by addAgent
  142353. * @param destination targeted world position
  142354. */
  142355. agentTeleport(index: number, destination: Vector3): void;
  142356. /**
  142357. * Update agent parameters
  142358. * @param index agent index returned by addAgent
  142359. * @param parameters agent parameters
  142360. */
  142361. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  142362. /**
  142363. * remove a particular agent previously created
  142364. * @param index agent index returned by addAgent
  142365. */
  142366. removeAgent(index: number): void;
  142367. /**
  142368. * get the list of all agents attached to this crowd
  142369. * @returns list of agent indices
  142370. */
  142371. getAgents(): number[];
  142372. /**
  142373. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  142374. * @param deltaTime in seconds
  142375. */
  142376. update(deltaTime: number): void;
  142377. /**
  142378. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  142379. * The queries will try to find a solution within those bounds
  142380. * default is (1,1,1)
  142381. * @param extent x,y,z value that define the extent around the queries point of reference
  142382. */
  142383. setDefaultQueryExtent(extent: Vector3): void;
  142384. /**
  142385. * Get the Bounding box extent specified by setDefaultQueryExtent
  142386. * @returns the box extent values
  142387. */
  142388. getDefaultQueryExtent(): Vector3;
  142389. /**
  142390. * Get the Bounding box extent result specified by setDefaultQueryExtent
  142391. * @param result output the box extent values
  142392. */
  142393. getDefaultQueryExtentToRef(result: Vector3): void;
  142394. /**
  142395. * Release all resources
  142396. */
  142397. dispose(): void;
  142398. }
  142399. }
  142400. declare module BABYLON {
  142401. /**
  142402. * Class used to enable access to IndexedDB
  142403. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  142404. */
  142405. export class Database implements IOfflineProvider {
  142406. private _callbackManifestChecked;
  142407. private _currentSceneUrl;
  142408. private _db;
  142409. private _enableSceneOffline;
  142410. private _enableTexturesOffline;
  142411. private _manifestVersionFound;
  142412. private _mustUpdateRessources;
  142413. private _hasReachedQuota;
  142414. private _isSupported;
  142415. private _idbFactory;
  142416. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  142417. private static IsUASupportingBlobStorage;
  142418. /**
  142419. * Gets a boolean indicating if Database storate is enabled (off by default)
  142420. */
  142421. static IDBStorageEnabled: boolean;
  142422. /**
  142423. * Gets a boolean indicating if scene must be saved in the database
  142424. */
  142425. get enableSceneOffline(): boolean;
  142426. /**
  142427. * Gets a boolean indicating if textures must be saved in the database
  142428. */
  142429. get enableTexturesOffline(): boolean;
  142430. /**
  142431. * Creates a new Database
  142432. * @param urlToScene defines the url to load the scene
  142433. * @param callbackManifestChecked defines the callback to use when manifest is checked
  142434. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  142435. */
  142436. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  142437. private static _ParseURL;
  142438. private static _ReturnFullUrlLocation;
  142439. private _checkManifestFile;
  142440. /**
  142441. * Open the database and make it available
  142442. * @param successCallback defines the callback to call on success
  142443. * @param errorCallback defines the callback to call on error
  142444. */
  142445. open(successCallback: () => void, errorCallback: () => void): void;
  142446. /**
  142447. * Loads an image from the database
  142448. * @param url defines the url to load from
  142449. * @param image defines the target DOM image
  142450. */
  142451. loadImage(url: string, image: HTMLImageElement): void;
  142452. private _loadImageFromDBAsync;
  142453. private _saveImageIntoDBAsync;
  142454. private _checkVersionFromDB;
  142455. private _loadVersionFromDBAsync;
  142456. private _saveVersionIntoDBAsync;
  142457. /**
  142458. * Loads a file from database
  142459. * @param url defines the URL to load from
  142460. * @param sceneLoaded defines a callback to call on success
  142461. * @param progressCallBack defines a callback to call when progress changed
  142462. * @param errorCallback defines a callback to call on error
  142463. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  142464. */
  142465. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  142466. private _loadFileAsync;
  142467. private _saveFileAsync;
  142468. /**
  142469. * Validates if xhr data is correct
  142470. * @param xhr defines the request to validate
  142471. * @param dataType defines the expected data type
  142472. * @returns true if data is correct
  142473. */
  142474. private static _ValidateXHRData;
  142475. }
  142476. }
  142477. declare module BABYLON {
  142478. /** @hidden */
  142479. export var gpuUpdateParticlesPixelShader: {
  142480. name: string;
  142481. shader: string;
  142482. };
  142483. }
  142484. declare module BABYLON {
  142485. /** @hidden */
  142486. export var gpuUpdateParticlesVertexShader: {
  142487. name: string;
  142488. shader: string;
  142489. };
  142490. }
  142491. declare module BABYLON {
  142492. /** @hidden */
  142493. export var clipPlaneFragmentDeclaration2: {
  142494. name: string;
  142495. shader: string;
  142496. };
  142497. }
  142498. declare module BABYLON {
  142499. /** @hidden */
  142500. export var gpuRenderParticlesPixelShader: {
  142501. name: string;
  142502. shader: string;
  142503. };
  142504. }
  142505. declare module BABYLON {
  142506. /** @hidden */
  142507. export var clipPlaneVertexDeclaration2: {
  142508. name: string;
  142509. shader: string;
  142510. };
  142511. }
  142512. declare module BABYLON {
  142513. /** @hidden */
  142514. export var gpuRenderParticlesVertexShader: {
  142515. name: string;
  142516. shader: string;
  142517. };
  142518. }
  142519. declare module BABYLON {
  142520. /**
  142521. * This represents a GPU particle system in Babylon
  142522. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  142523. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  142524. */
  142525. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  142526. /**
  142527. * The layer mask we are rendering the particles through.
  142528. */
  142529. layerMask: number;
  142530. private _capacity;
  142531. private _activeCount;
  142532. private _currentActiveCount;
  142533. private _accumulatedCount;
  142534. private _renderEffect;
  142535. private _updateEffect;
  142536. private _buffer0;
  142537. private _buffer1;
  142538. private _spriteBuffer;
  142539. private _updateVAO;
  142540. private _renderVAO;
  142541. private _targetIndex;
  142542. private _sourceBuffer;
  142543. private _targetBuffer;
  142544. private _engine;
  142545. private _currentRenderId;
  142546. private _started;
  142547. private _stopped;
  142548. private _timeDelta;
  142549. private _randomTexture;
  142550. private _randomTexture2;
  142551. private _attributesStrideSize;
  142552. private _updateEffectOptions;
  142553. private _randomTextureSize;
  142554. private _actualFrame;
  142555. private _customEffect;
  142556. private readonly _rawTextureWidth;
  142557. /**
  142558. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  142559. */
  142560. static get IsSupported(): boolean;
  142561. /**
  142562. * An event triggered when the system is disposed.
  142563. */
  142564. onDisposeObservable: Observable<IParticleSystem>;
  142565. /**
  142566. * Gets the maximum number of particles active at the same time.
  142567. * @returns The max number of active particles.
  142568. */
  142569. getCapacity(): number;
  142570. /**
  142571. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  142572. * to override the particles.
  142573. */
  142574. forceDepthWrite: boolean;
  142575. /**
  142576. * Gets or set the number of active particles
  142577. */
  142578. get activeParticleCount(): number;
  142579. set activeParticleCount(value: number);
  142580. private _preWarmDone;
  142581. /**
  142582. * Specifies if the particles are updated in emitter local space or world space.
  142583. */
  142584. isLocal: boolean;
  142585. /**
  142586. * Is this system ready to be used/rendered
  142587. * @return true if the system is ready
  142588. */
  142589. isReady(): boolean;
  142590. /**
  142591. * Gets if the system has been started. (Note: this will still be true after stop is called)
  142592. * @returns True if it has been started, otherwise false.
  142593. */
  142594. isStarted(): boolean;
  142595. /**
  142596. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  142597. * @returns True if it has been stopped, otherwise false.
  142598. */
  142599. isStopped(): boolean;
  142600. /**
  142601. * Gets a boolean indicating that the system is stopping
  142602. * @returns true if the system is currently stopping
  142603. */
  142604. isStopping(): boolean;
  142605. /**
  142606. * Gets the number of particles active at the same time.
  142607. * @returns The number of active particles.
  142608. */
  142609. getActiveCount(): number;
  142610. /**
  142611. * Starts the particle system and begins to emit
  142612. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  142613. */
  142614. start(delay?: number): void;
  142615. /**
  142616. * Stops the particle system.
  142617. */
  142618. stop(): void;
  142619. /**
  142620. * Remove all active particles
  142621. */
  142622. reset(): void;
  142623. /**
  142624. * Returns the string "GPUParticleSystem"
  142625. * @returns a string containing the class name
  142626. */
  142627. getClassName(): string;
  142628. /**
  142629. * Gets the custom effect used to render the particles
  142630. * @param blendMode Blend mode for which the effect should be retrieved
  142631. * @returns The effect
  142632. */
  142633. getCustomEffect(blendMode?: number): Nullable<Effect>;
  142634. /**
  142635. * Sets the custom effect used to render the particles
  142636. * @param effect The effect to set
  142637. * @param blendMode Blend mode for which the effect should be set
  142638. */
  142639. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  142640. /** @hidden */
  142641. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  142642. /**
  142643. * Observable that will be called just before the particles are drawn
  142644. */
  142645. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  142646. /**
  142647. * Gets the name of the particle vertex shader
  142648. */
  142649. get vertexShaderName(): string;
  142650. private _colorGradientsTexture;
  142651. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  142652. /**
  142653. * Adds a new color gradient
  142654. * @param gradient defines the gradient to use (between 0 and 1)
  142655. * @param color1 defines the color to affect to the specified gradient
  142656. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  142657. * @returns the current particle system
  142658. */
  142659. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  142660. private _refreshColorGradient;
  142661. /** Force the system to rebuild all gradients that need to be resync */
  142662. forceRefreshGradients(): void;
  142663. /**
  142664. * Remove a specific color gradient
  142665. * @param gradient defines the gradient to remove
  142666. * @returns the current particle system
  142667. */
  142668. removeColorGradient(gradient: number): GPUParticleSystem;
  142669. private _angularSpeedGradientsTexture;
  142670. private _sizeGradientsTexture;
  142671. private _velocityGradientsTexture;
  142672. private _limitVelocityGradientsTexture;
  142673. private _dragGradientsTexture;
  142674. private _addFactorGradient;
  142675. /**
  142676. * Adds a new size gradient
  142677. * @param gradient defines the gradient to use (between 0 and 1)
  142678. * @param factor defines the size factor to affect to the specified gradient
  142679. * @returns the current particle system
  142680. */
  142681. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  142682. /**
  142683. * Remove a specific size gradient
  142684. * @param gradient defines the gradient to remove
  142685. * @returns the current particle system
  142686. */
  142687. removeSizeGradient(gradient: number): GPUParticleSystem;
  142688. private _refreshFactorGradient;
  142689. /**
  142690. * Adds a new angular speed gradient
  142691. * @param gradient defines the gradient to use (between 0 and 1)
  142692. * @param factor defines the angular speed to affect to the specified gradient
  142693. * @returns the current particle system
  142694. */
  142695. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  142696. /**
  142697. * Remove a specific angular speed gradient
  142698. * @param gradient defines the gradient to remove
  142699. * @returns the current particle system
  142700. */
  142701. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  142702. /**
  142703. * Adds a new velocity gradient
  142704. * @param gradient defines the gradient to use (between 0 and 1)
  142705. * @param factor defines the velocity to affect to the specified gradient
  142706. * @returns the current particle system
  142707. */
  142708. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  142709. /**
  142710. * Remove a specific velocity gradient
  142711. * @param gradient defines the gradient to remove
  142712. * @returns the current particle system
  142713. */
  142714. removeVelocityGradient(gradient: number): GPUParticleSystem;
  142715. /**
  142716. * Adds a new limit velocity gradient
  142717. * @param gradient defines the gradient to use (between 0 and 1)
  142718. * @param factor defines the limit velocity value to affect to the specified gradient
  142719. * @returns the current particle system
  142720. */
  142721. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  142722. /**
  142723. * Remove a specific limit velocity gradient
  142724. * @param gradient defines the gradient to remove
  142725. * @returns the current particle system
  142726. */
  142727. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  142728. /**
  142729. * Adds a new drag gradient
  142730. * @param gradient defines the gradient to use (between 0 and 1)
  142731. * @param factor defines the drag value to affect to the specified gradient
  142732. * @returns the current particle system
  142733. */
  142734. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  142735. /**
  142736. * Remove a specific drag gradient
  142737. * @param gradient defines the gradient to remove
  142738. * @returns the current particle system
  142739. */
  142740. removeDragGradient(gradient: number): GPUParticleSystem;
  142741. /**
  142742. * Not supported by GPUParticleSystem
  142743. * @param gradient defines the gradient to use (between 0 and 1)
  142744. * @param factor defines the emit rate value to affect to the specified gradient
  142745. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  142746. * @returns the current particle system
  142747. */
  142748. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  142749. /**
  142750. * Not supported by GPUParticleSystem
  142751. * @param gradient defines the gradient to remove
  142752. * @returns the current particle system
  142753. */
  142754. removeEmitRateGradient(gradient: number): IParticleSystem;
  142755. /**
  142756. * Not supported by GPUParticleSystem
  142757. * @param gradient defines the gradient to use (between 0 and 1)
  142758. * @param factor defines the start size value to affect to the specified gradient
  142759. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  142760. * @returns the current particle system
  142761. */
  142762. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  142763. /**
  142764. * Not supported by GPUParticleSystem
  142765. * @param gradient defines the gradient to remove
  142766. * @returns the current particle system
  142767. */
  142768. removeStartSizeGradient(gradient: number): IParticleSystem;
  142769. /**
  142770. * Not supported by GPUParticleSystem
  142771. * @param gradient defines the gradient to use (between 0 and 1)
  142772. * @param min defines the color remap minimal range
  142773. * @param max defines the color remap maximal range
  142774. * @returns the current particle system
  142775. */
  142776. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  142777. /**
  142778. * Not supported by GPUParticleSystem
  142779. * @param gradient defines the gradient to remove
  142780. * @returns the current particle system
  142781. */
  142782. removeColorRemapGradient(): IParticleSystem;
  142783. /**
  142784. * Not supported by GPUParticleSystem
  142785. * @param gradient defines the gradient to use (between 0 and 1)
  142786. * @param min defines the alpha remap minimal range
  142787. * @param max defines the alpha remap maximal range
  142788. * @returns the current particle system
  142789. */
  142790. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  142791. /**
  142792. * Not supported by GPUParticleSystem
  142793. * @param gradient defines the gradient to remove
  142794. * @returns the current particle system
  142795. */
  142796. removeAlphaRemapGradient(): IParticleSystem;
  142797. /**
  142798. * Not supported by GPUParticleSystem
  142799. * @param gradient defines the gradient to use (between 0 and 1)
  142800. * @param color defines the color to affect to the specified gradient
  142801. * @returns the current particle system
  142802. */
  142803. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  142804. /**
  142805. * Not supported by GPUParticleSystem
  142806. * @param gradient defines the gradient to remove
  142807. * @returns the current particle system
  142808. */
  142809. removeRampGradient(): IParticleSystem;
  142810. /**
  142811. * Not supported by GPUParticleSystem
  142812. * @returns the list of ramp gradients
  142813. */
  142814. getRampGradients(): Nullable<Array<Color3Gradient>>;
  142815. /**
  142816. * Not supported by GPUParticleSystem
  142817. * Gets or sets a boolean indicating that ramp gradients must be used
  142818. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  142819. */
  142820. get useRampGradients(): boolean;
  142821. set useRampGradients(value: boolean);
  142822. /**
  142823. * Not supported by GPUParticleSystem
  142824. * @param gradient defines the gradient to use (between 0 and 1)
  142825. * @param factor defines the life time factor to affect to the specified gradient
  142826. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  142827. * @returns the current particle system
  142828. */
  142829. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  142830. /**
  142831. * Not supported by GPUParticleSystem
  142832. * @param gradient defines the gradient to remove
  142833. * @returns the current particle system
  142834. */
  142835. removeLifeTimeGradient(gradient: number): IParticleSystem;
  142836. /**
  142837. * Instantiates a GPU particle system.
  142838. * 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.
  142839. * @param name The name of the particle system
  142840. * @param options The options used to create the system
  142841. * @param scene The scene the particle system belongs to
  142842. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  142843. * @param customEffect a custom effect used to change the way particles are rendered by default
  142844. */
  142845. constructor(name: string, options: Partial<{
  142846. capacity: number;
  142847. randomTextureSize: number;
  142848. }>, scene: Scene, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  142849. protected _reset(): void;
  142850. private _createUpdateVAO;
  142851. private _createRenderVAO;
  142852. private _initialize;
  142853. /** @hidden */
  142854. _recreateUpdateEffect(): void;
  142855. private _getEffect;
  142856. /**
  142857. * Fill the defines array according to the current settings of the particle system
  142858. * @param defines Array to be updated
  142859. * @param blendMode blend mode to take into account when updating the array
  142860. */
  142861. fillDefines(defines: Array<string>, blendMode?: number): void;
  142862. /**
  142863. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  142864. * @param uniforms Uniforms array to fill
  142865. * @param attributes Attributes array to fill
  142866. * @param samplers Samplers array to fill
  142867. */
  142868. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  142869. /** @hidden */
  142870. _recreateRenderEffect(): Effect;
  142871. /**
  142872. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  142873. * @param preWarm defines if we are in the pre-warmimg phase
  142874. */
  142875. animate(preWarm?: boolean): void;
  142876. private _createFactorGradientTexture;
  142877. private _createSizeGradientTexture;
  142878. private _createAngularSpeedGradientTexture;
  142879. private _createVelocityGradientTexture;
  142880. private _createLimitVelocityGradientTexture;
  142881. private _createDragGradientTexture;
  142882. private _createColorGradientTexture;
  142883. /**
  142884. * Renders the particle system in its current state
  142885. * @param preWarm defines if the system should only update the particles but not render them
  142886. * @returns the current number of particles
  142887. */
  142888. render(preWarm?: boolean): number;
  142889. /**
  142890. * Rebuilds the particle system
  142891. */
  142892. rebuild(): void;
  142893. private _releaseBuffers;
  142894. private _releaseVAOs;
  142895. /**
  142896. * Disposes the particle system and free the associated resources
  142897. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  142898. */
  142899. dispose(disposeTexture?: boolean): void;
  142900. /**
  142901. * Clones the particle system.
  142902. * @param name The name of the cloned object
  142903. * @param newEmitter The new emitter to use
  142904. * @returns the cloned particle system
  142905. */
  142906. clone(name: string, newEmitter: any): GPUParticleSystem;
  142907. /**
  142908. * Serializes the particle system to a JSON object
  142909. * @param serializeTexture defines if the texture must be serialized as well
  142910. * @returns the JSON object
  142911. */
  142912. serialize(serializeTexture?: boolean): any;
  142913. /**
  142914. * Parses a JSON object to create a GPU particle system.
  142915. * @param parsedParticleSystem The JSON object to parse
  142916. * @param scene The scene to create the particle system in
  142917. * @param rootUrl The root url to use to load external dependencies like texture
  142918. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  142919. * @returns the parsed GPU particle system
  142920. */
  142921. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  142922. }
  142923. }
  142924. declare module BABYLON {
  142925. /**
  142926. * Represents a set of particle systems working together to create a specific effect
  142927. */
  142928. export class ParticleSystemSet implements IDisposable {
  142929. /**
  142930. * Gets or sets base Assets URL
  142931. */
  142932. static BaseAssetsUrl: string;
  142933. private _emitterCreationOptions;
  142934. private _emitterNode;
  142935. /**
  142936. * Gets the particle system list
  142937. */
  142938. systems: IParticleSystem[];
  142939. /**
  142940. * Gets the emitter node used with this set
  142941. */
  142942. get emitterNode(): Nullable<TransformNode>;
  142943. /**
  142944. * Creates a new emitter mesh as a sphere
  142945. * @param options defines the options used to create the sphere
  142946. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  142947. * @param scene defines the hosting scene
  142948. */
  142949. setEmitterAsSphere(options: {
  142950. diameter: number;
  142951. segments: number;
  142952. color: Color3;
  142953. }, renderingGroupId: number, scene: Scene): void;
  142954. /**
  142955. * Starts all particle systems of the set
  142956. * @param emitter defines an optional mesh to use as emitter for the particle systems
  142957. */
  142958. start(emitter?: AbstractMesh): void;
  142959. /**
  142960. * Release all associated resources
  142961. */
  142962. dispose(): void;
  142963. /**
  142964. * Serialize the set into a JSON compatible object
  142965. * @param serializeTexture defines if the texture must be serialized as well
  142966. * @returns a JSON compatible representation of the set
  142967. */
  142968. serialize(serializeTexture?: boolean): any;
  142969. /**
  142970. * Parse a new ParticleSystemSet from a serialized source
  142971. * @param data defines a JSON compatible representation of the set
  142972. * @param scene defines the hosting scene
  142973. * @param gpu defines if we want GPU particles or CPU particles
  142974. * @returns a new ParticleSystemSet
  142975. */
  142976. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  142977. }
  142978. }
  142979. declare module BABYLON {
  142980. /**
  142981. * This class is made for on one-liner static method to help creating particle system set.
  142982. */
  142983. export class ParticleHelper {
  142984. /**
  142985. * Gets or sets base Assets URL
  142986. */
  142987. static BaseAssetsUrl: string;
  142988. /** Define the Url to load snippets */
  142989. static SnippetUrl: string;
  142990. /**
  142991. * Create a default particle system that you can tweak
  142992. * @param emitter defines the emitter to use
  142993. * @param capacity defines the system capacity (default is 500 particles)
  142994. * @param scene defines the hosting scene
  142995. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  142996. * @returns the new Particle system
  142997. */
  142998. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  142999. /**
  143000. * This is the main static method (one-liner) of this helper to create different particle systems
  143001. * @param type This string represents the type to the particle system to create
  143002. * @param scene The scene where the particle system should live
  143003. * @param gpu If the system will use gpu
  143004. * @returns the ParticleSystemSet created
  143005. */
  143006. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  143007. /**
  143008. * Static function used to export a particle system to a ParticleSystemSet variable.
  143009. * Please note that the emitter shape is not exported
  143010. * @param systems defines the particle systems to export
  143011. * @returns the created particle system set
  143012. */
  143013. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  143014. /**
  143015. * Creates a particle system from a snippet saved in a remote file
  143016. * @param name defines the name of the particle system to create
  143017. * @param url defines the url to load from
  143018. * @param scene defines the hosting scene
  143019. * @param gpu If the system will use gpu
  143020. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  143021. * @returns a promise that will resolve to the new particle system
  143022. */
  143023. static ParseFromFileAsync(name: string, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  143024. /**
  143025. * Creates a particle system from a snippet saved by the particle system editor
  143026. * @param snippetId defines the snippet to load
  143027. * @param scene defines the hosting scene
  143028. * @param gpu If the system will use gpu
  143029. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  143030. * @returns a promise that will resolve to the new particle system
  143031. */
  143032. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  143033. }
  143034. }
  143035. declare module BABYLON {
  143036. interface Engine {
  143037. /**
  143038. * Create an effect to use with particle systems.
  143039. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  143040. * the particle system for which you want to create a custom effect in the last parameter
  143041. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  143042. * @param uniformsNames defines a list of attribute names
  143043. * @param samplers defines an array of string used to represent textures
  143044. * @param defines defines the string containing the defines to use to compile the shaders
  143045. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  143046. * @param onCompiled defines a function to call when the effect creation is successful
  143047. * @param onError defines a function to call when the effect creation has failed
  143048. * @param particleSystem the particle system you want to create the effect for
  143049. * @returns the new Effect
  143050. */
  143051. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  143052. }
  143053. interface Mesh {
  143054. /**
  143055. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  143056. * @returns an array of IParticleSystem
  143057. */
  143058. getEmittedParticleSystems(): IParticleSystem[];
  143059. /**
  143060. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  143061. * @returns an array of IParticleSystem
  143062. */
  143063. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  143064. }
  143065. /**
  143066. * @hidden
  143067. */
  143068. export var _IDoNeedToBeInTheBuild: number;
  143069. }
  143070. declare module BABYLON {
  143071. /** Defines the 4 color options */
  143072. export enum PointColor {
  143073. /** color value */
  143074. Color = 2,
  143075. /** uv value */
  143076. UV = 1,
  143077. /** random value */
  143078. Random = 0,
  143079. /** stated value */
  143080. Stated = 3
  143081. }
  143082. /**
  143083. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  143084. * 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.
  143085. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  143086. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  143087. *
  143088. * Full documentation here : TO BE ENTERED
  143089. */
  143090. export class PointsCloudSystem implements IDisposable {
  143091. /**
  143092. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  143093. * Example : var p = SPS.particles[i];
  143094. */
  143095. particles: CloudPoint[];
  143096. /**
  143097. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  143098. */
  143099. nbParticles: number;
  143100. /**
  143101. * This a counter for your own usage. It's not set by any SPS functions.
  143102. */
  143103. counter: number;
  143104. /**
  143105. * The PCS name. This name is also given to the underlying mesh.
  143106. */
  143107. name: string;
  143108. /**
  143109. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  143110. */
  143111. mesh: Mesh;
  143112. /**
  143113. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  143114. * Please read :
  143115. */
  143116. vars: any;
  143117. /**
  143118. * @hidden
  143119. */
  143120. _size: number;
  143121. private _scene;
  143122. private _promises;
  143123. private _positions;
  143124. private _indices;
  143125. private _normals;
  143126. private _colors;
  143127. private _uvs;
  143128. private _indices32;
  143129. private _positions32;
  143130. private _colors32;
  143131. private _uvs32;
  143132. private _updatable;
  143133. private _isVisibilityBoxLocked;
  143134. private _alwaysVisible;
  143135. private _groups;
  143136. private _groupCounter;
  143137. private _computeParticleColor;
  143138. private _computeParticleTexture;
  143139. private _computeParticleRotation;
  143140. private _computeBoundingBox;
  143141. private _isReady;
  143142. /**
  143143. * Creates a PCS (Points Cloud System) object
  143144. * @param name (String) is the PCS name, this will be the underlying mesh name
  143145. * @param pointSize (number) is the size for each point
  143146. * @param scene (Scene) is the scene in which the PCS is added
  143147. * @param options defines the options of the PCS e.g.
  143148. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  143149. */
  143150. constructor(name: string, pointSize: number, scene: Scene, options?: {
  143151. updatable?: boolean;
  143152. });
  143153. /**
  143154. * Builds the PCS underlying mesh. Returns a standard Mesh.
  143155. * If no points were added to the PCS, the returned mesh is just a single point.
  143156. * @returns a promise for the created mesh
  143157. */
  143158. buildMeshAsync(): Promise<Mesh>;
  143159. /**
  143160. * @hidden
  143161. */
  143162. private _buildMesh;
  143163. private _addParticle;
  143164. private _randomUnitVector;
  143165. private _getColorIndicesForCoord;
  143166. private _setPointsColorOrUV;
  143167. private _colorFromTexture;
  143168. private _calculateDensity;
  143169. /**
  143170. * Adds points to the PCS in random positions within a unit sphere
  143171. * @param nb (positive integer) the number of particles to be created from this model
  143172. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  143173. * @returns the number of groups in the system
  143174. */
  143175. addPoints(nb: number, pointFunction?: any): number;
  143176. /**
  143177. * Adds points to the PCS from the surface of the model shape
  143178. * @param mesh is any Mesh object that will be used as a surface model for the points
  143179. * @param nb (positive integer) the number of particles to be created from this model
  143180. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  143181. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  143182. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  143183. * @returns the number of groups in the system
  143184. */
  143185. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  143186. /**
  143187. * Adds points to the PCS inside the model shape
  143188. * @param mesh is any Mesh object that will be used as a surface model for the points
  143189. * @param nb (positive integer) the number of particles to be created from this model
  143190. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  143191. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  143192. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  143193. * @returns the number of groups in the system
  143194. */
  143195. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  143196. /**
  143197. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  143198. * This method calls `updateParticle()` for each particle of the SPS.
  143199. * For an animated SPS, it is usually called within the render loop.
  143200. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  143201. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  143202. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  143203. * @returns the PCS.
  143204. */
  143205. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  143206. /**
  143207. * Disposes the PCS.
  143208. */
  143209. dispose(): void;
  143210. /**
  143211. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  143212. * doc :
  143213. * @returns the PCS.
  143214. */
  143215. refreshVisibleSize(): PointsCloudSystem;
  143216. /**
  143217. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  143218. * @param size the size (float) of the visibility box
  143219. * note : this doesn't lock the PCS mesh bounding box.
  143220. * doc :
  143221. */
  143222. setVisibilityBox(size: number): void;
  143223. /**
  143224. * Gets whether the PCS is always visible or not
  143225. * doc :
  143226. */
  143227. get isAlwaysVisible(): boolean;
  143228. /**
  143229. * Sets the PCS as always visible or not
  143230. * doc :
  143231. */
  143232. set isAlwaysVisible(val: boolean);
  143233. /**
  143234. * Tells to `setParticles()` to compute the particle rotations or not
  143235. * Default value : false. The PCS is faster when it's set to false
  143236. * Note : particle rotations are only applied to parent particles
  143237. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  143238. */
  143239. set computeParticleRotation(val: boolean);
  143240. /**
  143241. * Tells to `setParticles()` to compute the particle colors or not.
  143242. * Default value : true. The PCS is faster when it's set to false.
  143243. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  143244. */
  143245. set computeParticleColor(val: boolean);
  143246. set computeParticleTexture(val: boolean);
  143247. /**
  143248. * Gets if `setParticles()` computes the particle colors or not.
  143249. * Default value : false. The PCS is faster when it's set to false.
  143250. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  143251. */
  143252. get computeParticleColor(): boolean;
  143253. /**
  143254. * Gets if `setParticles()` computes the particle textures or not.
  143255. * Default value : false. The PCS is faster when it's set to false.
  143256. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  143257. */
  143258. get computeParticleTexture(): boolean;
  143259. /**
  143260. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  143261. */
  143262. set computeBoundingBox(val: boolean);
  143263. /**
  143264. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  143265. */
  143266. get computeBoundingBox(): boolean;
  143267. /**
  143268. * This function does nothing. It may be overwritten to set all the particle first values.
  143269. * The PCS doesn't call this function, you may have to call it by your own.
  143270. * doc :
  143271. */
  143272. initParticles(): void;
  143273. /**
  143274. * This function does nothing. It may be overwritten to recycle a particle
  143275. * The PCS doesn't call this function, you can to call it
  143276. * doc :
  143277. * @param particle The particle to recycle
  143278. * @returns the recycled particle
  143279. */
  143280. recycleParticle(particle: CloudPoint): CloudPoint;
  143281. /**
  143282. * Updates a particle : this function should be overwritten by the user.
  143283. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  143284. * doc :
  143285. * @example : just set a particle position or velocity and recycle conditions
  143286. * @param particle The particle to update
  143287. * @returns the updated particle
  143288. */
  143289. updateParticle(particle: CloudPoint): CloudPoint;
  143290. /**
  143291. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  143292. * This does nothing and may be overwritten by the user.
  143293. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  143294. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  143295. * @param update the boolean update value actually passed to setParticles()
  143296. */
  143297. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  143298. /**
  143299. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  143300. * This will be passed three parameters.
  143301. * This does nothing and may be overwritten by the user.
  143302. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  143303. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  143304. * @param update the boolean update value actually passed to setParticles()
  143305. */
  143306. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  143307. }
  143308. }
  143309. declare module BABYLON {
  143310. /**
  143311. * Represents one particle of a points cloud system.
  143312. */
  143313. export class CloudPoint {
  143314. /**
  143315. * particle global index
  143316. */
  143317. idx: number;
  143318. /**
  143319. * The color of the particle
  143320. */
  143321. color: Nullable<Color4>;
  143322. /**
  143323. * The world space position of the particle.
  143324. */
  143325. position: Vector3;
  143326. /**
  143327. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  143328. */
  143329. rotation: Vector3;
  143330. /**
  143331. * The world space rotation quaternion of the particle.
  143332. */
  143333. rotationQuaternion: Nullable<Quaternion>;
  143334. /**
  143335. * The uv of the particle.
  143336. */
  143337. uv: Nullable<Vector2>;
  143338. /**
  143339. * The current speed of the particle.
  143340. */
  143341. velocity: Vector3;
  143342. /**
  143343. * The pivot point in the particle local space.
  143344. */
  143345. pivot: Vector3;
  143346. /**
  143347. * Must the particle be translated from its pivot point in its local space ?
  143348. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  143349. * Default : false
  143350. */
  143351. translateFromPivot: boolean;
  143352. /**
  143353. * Index of this particle in the global "positions" array (Internal use)
  143354. * @hidden
  143355. */
  143356. _pos: number;
  143357. /**
  143358. * @hidden Index of this particle in the global "indices" array (Internal use)
  143359. */
  143360. _ind: number;
  143361. /**
  143362. * Group this particle belongs to
  143363. */
  143364. _group: PointsGroup;
  143365. /**
  143366. * Group id of this particle
  143367. */
  143368. groupId: number;
  143369. /**
  143370. * Index of the particle in its group id (Internal use)
  143371. */
  143372. idxInGroup: number;
  143373. /**
  143374. * @hidden Particle BoundingInfo object (Internal use)
  143375. */
  143376. _boundingInfo: BoundingInfo;
  143377. /**
  143378. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  143379. */
  143380. _pcs: PointsCloudSystem;
  143381. /**
  143382. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  143383. */
  143384. _stillInvisible: boolean;
  143385. /**
  143386. * @hidden Last computed particle rotation matrix
  143387. */
  143388. _rotationMatrix: number[];
  143389. /**
  143390. * Parent particle Id, if any.
  143391. * Default null.
  143392. */
  143393. parentId: Nullable<number>;
  143394. /**
  143395. * @hidden Internal global position in the PCS.
  143396. */
  143397. _globalPosition: Vector3;
  143398. /**
  143399. * Creates a Point Cloud object.
  143400. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  143401. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  143402. * @param group (PointsGroup) is the group the particle belongs to
  143403. * @param groupId (integer) is the group identifier in the PCS.
  143404. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  143405. * @param pcs defines the PCS it is associated to
  143406. */
  143407. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  143408. /**
  143409. * get point size
  143410. */
  143411. get size(): Vector3;
  143412. /**
  143413. * Set point size
  143414. */
  143415. set size(scale: Vector3);
  143416. /**
  143417. * Legacy support, changed quaternion to rotationQuaternion
  143418. */
  143419. get quaternion(): Nullable<Quaternion>;
  143420. /**
  143421. * Legacy support, changed quaternion to rotationQuaternion
  143422. */
  143423. set quaternion(q: Nullable<Quaternion>);
  143424. /**
  143425. * Returns a boolean. True if the particle intersects a mesh, else false
  143426. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  143427. * @param target is the object (point or mesh) what the intersection is computed against
  143428. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  143429. * @returns true if it intersects
  143430. */
  143431. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  143432. /**
  143433. * get the rotation matrix of the particle
  143434. * @hidden
  143435. */
  143436. getRotationMatrix(m: Matrix): void;
  143437. }
  143438. /**
  143439. * Represents a group of points in a points cloud system
  143440. * * PCS internal tool, don't use it manually.
  143441. */
  143442. export class PointsGroup {
  143443. /**
  143444. * The group id
  143445. * @hidden
  143446. */
  143447. groupID: number;
  143448. /**
  143449. * image data for group (internal use)
  143450. * @hidden
  143451. */
  143452. _groupImageData: Nullable<ArrayBufferView>;
  143453. /**
  143454. * Image Width (internal use)
  143455. * @hidden
  143456. */
  143457. _groupImgWidth: number;
  143458. /**
  143459. * Image Height (internal use)
  143460. * @hidden
  143461. */
  143462. _groupImgHeight: number;
  143463. /**
  143464. * Custom position function (internal use)
  143465. * @hidden
  143466. */
  143467. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  143468. /**
  143469. * density per facet for surface points
  143470. * @hidden
  143471. */
  143472. _groupDensity: number[];
  143473. /**
  143474. * Only when points are colored by texture carries pointer to texture list array
  143475. * @hidden
  143476. */
  143477. _textureNb: number;
  143478. /**
  143479. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  143480. * PCS internal tool, don't use it manually.
  143481. * @hidden
  143482. */
  143483. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  143484. }
  143485. }
  143486. declare module BABYLON {
  143487. interface Scene {
  143488. /** @hidden (Backing field) */
  143489. _physicsEngine: Nullable<IPhysicsEngine>;
  143490. /** @hidden */
  143491. _physicsTimeAccumulator: number;
  143492. /**
  143493. * Gets the current physics engine
  143494. * @returns a IPhysicsEngine or null if none attached
  143495. */
  143496. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  143497. /**
  143498. * Enables physics to the current scene
  143499. * @param gravity defines the scene's gravity for the physics engine
  143500. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  143501. * @return a boolean indicating if the physics engine was initialized
  143502. */
  143503. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  143504. /**
  143505. * Disables and disposes the physics engine associated with the scene
  143506. */
  143507. disablePhysicsEngine(): void;
  143508. /**
  143509. * Gets a boolean indicating if there is an active physics engine
  143510. * @returns a boolean indicating if there is an active physics engine
  143511. */
  143512. isPhysicsEnabled(): boolean;
  143513. /**
  143514. * Deletes a physics compound impostor
  143515. * @param compound defines the compound to delete
  143516. */
  143517. deleteCompoundImpostor(compound: any): void;
  143518. /**
  143519. * An event triggered when physic simulation is about to be run
  143520. */
  143521. onBeforePhysicsObservable: Observable<Scene>;
  143522. /**
  143523. * An event triggered when physic simulation has been done
  143524. */
  143525. onAfterPhysicsObservable: Observable<Scene>;
  143526. }
  143527. interface AbstractMesh {
  143528. /** @hidden */
  143529. _physicsImpostor: Nullable<PhysicsImpostor>;
  143530. /**
  143531. * Gets or sets impostor used for physic simulation
  143532. * @see http://doc.babylonjs.com/features/physics_engine
  143533. */
  143534. physicsImpostor: Nullable<PhysicsImpostor>;
  143535. /**
  143536. * Gets the current physics impostor
  143537. * @see http://doc.babylonjs.com/features/physics_engine
  143538. * @returns a physics impostor or null
  143539. */
  143540. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  143541. /** Apply a physic impulse to the mesh
  143542. * @param force defines the force to apply
  143543. * @param contactPoint defines where to apply the force
  143544. * @returns the current mesh
  143545. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  143546. */
  143547. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  143548. /**
  143549. * Creates a physic joint between two meshes
  143550. * @param otherMesh defines the other mesh to use
  143551. * @param pivot1 defines the pivot to use on this mesh
  143552. * @param pivot2 defines the pivot to use on the other mesh
  143553. * @param options defines additional options (can be plugin dependent)
  143554. * @returns the current mesh
  143555. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  143556. */
  143557. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  143558. /** @hidden */
  143559. _disposePhysicsObserver: Nullable<Observer<Node>>;
  143560. }
  143561. /**
  143562. * Defines the physics engine scene component responsible to manage a physics engine
  143563. */
  143564. export class PhysicsEngineSceneComponent implements ISceneComponent {
  143565. /**
  143566. * The component name helpful to identify the component in the list of scene components.
  143567. */
  143568. readonly name: string;
  143569. /**
  143570. * The scene the component belongs to.
  143571. */
  143572. scene: Scene;
  143573. /**
  143574. * Creates a new instance of the component for the given scene
  143575. * @param scene Defines the scene to register the component in
  143576. */
  143577. constructor(scene: Scene);
  143578. /**
  143579. * Registers the component in a given scene
  143580. */
  143581. register(): void;
  143582. /**
  143583. * Rebuilds the elements related to this component in case of
  143584. * context lost for instance.
  143585. */
  143586. rebuild(): void;
  143587. /**
  143588. * Disposes the component and the associated ressources
  143589. */
  143590. dispose(): void;
  143591. }
  143592. }
  143593. declare module BABYLON {
  143594. /**
  143595. * A helper for physics simulations
  143596. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  143597. */
  143598. export class PhysicsHelper {
  143599. private _scene;
  143600. private _physicsEngine;
  143601. /**
  143602. * Initializes the Physics helper
  143603. * @param scene Babylon.js scene
  143604. */
  143605. constructor(scene: Scene);
  143606. /**
  143607. * Applies a radial explosion impulse
  143608. * @param origin the origin of the explosion
  143609. * @param radiusOrEventOptions the radius or the options of radial explosion
  143610. * @param strength the explosion strength
  143611. * @param falloff possible options: Constant & Linear. Defaults to Constant
  143612. * @returns A physics radial explosion event, or null
  143613. */
  143614. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  143615. /**
  143616. * Applies a radial explosion force
  143617. * @param origin the origin of the explosion
  143618. * @param radiusOrEventOptions the radius or the options of radial explosion
  143619. * @param strength the explosion strength
  143620. * @param falloff possible options: Constant & Linear. Defaults to Constant
  143621. * @returns A physics radial explosion event, or null
  143622. */
  143623. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  143624. /**
  143625. * Creates a gravitational field
  143626. * @param origin the origin of the explosion
  143627. * @param radiusOrEventOptions the radius or the options of radial explosion
  143628. * @param strength the explosion strength
  143629. * @param falloff possible options: Constant & Linear. Defaults to Constant
  143630. * @returns A physics gravitational field event, or null
  143631. */
  143632. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  143633. /**
  143634. * Creates a physics updraft event
  143635. * @param origin the origin of the updraft
  143636. * @param radiusOrEventOptions the radius or the options of the updraft
  143637. * @param strength the strength of the updraft
  143638. * @param height the height of the updraft
  143639. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  143640. * @returns A physics updraft event, or null
  143641. */
  143642. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  143643. /**
  143644. * Creates a physics vortex event
  143645. * @param origin the of the vortex
  143646. * @param radiusOrEventOptions the radius or the options of the vortex
  143647. * @param strength the strength of the vortex
  143648. * @param height the height of the vortex
  143649. * @returns a Physics vortex event, or null
  143650. * A physics vortex event or null
  143651. */
  143652. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  143653. }
  143654. /**
  143655. * Represents a physics radial explosion event
  143656. */
  143657. class PhysicsRadialExplosionEvent {
  143658. private _scene;
  143659. private _options;
  143660. private _sphere;
  143661. private _dataFetched;
  143662. /**
  143663. * Initializes a radial explosioin event
  143664. * @param _scene BabylonJS scene
  143665. * @param _options The options for the vortex event
  143666. */
  143667. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  143668. /**
  143669. * Returns the data related to the radial explosion event (sphere).
  143670. * @returns The radial explosion event data
  143671. */
  143672. getData(): PhysicsRadialExplosionEventData;
  143673. /**
  143674. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  143675. * @param impostor A physics imposter
  143676. * @param origin the origin of the explosion
  143677. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  143678. */
  143679. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  143680. /**
  143681. * Triggers affecterd impostors callbacks
  143682. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  143683. */
  143684. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  143685. /**
  143686. * Disposes the sphere.
  143687. * @param force Specifies if the sphere should be disposed by force
  143688. */
  143689. dispose(force?: boolean): void;
  143690. /*** Helpers ***/
  143691. private _prepareSphere;
  143692. private _intersectsWithSphere;
  143693. }
  143694. /**
  143695. * Represents a gravitational field event
  143696. */
  143697. class PhysicsGravitationalFieldEvent {
  143698. private _physicsHelper;
  143699. private _scene;
  143700. private _origin;
  143701. private _options;
  143702. private _tickCallback;
  143703. private _sphere;
  143704. private _dataFetched;
  143705. /**
  143706. * Initializes the physics gravitational field event
  143707. * @param _physicsHelper A physics helper
  143708. * @param _scene BabylonJS scene
  143709. * @param _origin The origin position of the gravitational field event
  143710. * @param _options The options for the vortex event
  143711. */
  143712. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  143713. /**
  143714. * Returns the data related to the gravitational field event (sphere).
  143715. * @returns A gravitational field event
  143716. */
  143717. getData(): PhysicsGravitationalFieldEventData;
  143718. /**
  143719. * Enables the gravitational field.
  143720. */
  143721. enable(): void;
  143722. /**
  143723. * Disables the gravitational field.
  143724. */
  143725. disable(): void;
  143726. /**
  143727. * Disposes the sphere.
  143728. * @param force The force to dispose from the gravitational field event
  143729. */
  143730. dispose(force?: boolean): void;
  143731. private _tick;
  143732. }
  143733. /**
  143734. * Represents a physics updraft event
  143735. */
  143736. class PhysicsUpdraftEvent {
  143737. private _scene;
  143738. private _origin;
  143739. private _options;
  143740. private _physicsEngine;
  143741. private _originTop;
  143742. private _originDirection;
  143743. private _tickCallback;
  143744. private _cylinder;
  143745. private _cylinderPosition;
  143746. private _dataFetched;
  143747. /**
  143748. * Initializes the physics updraft event
  143749. * @param _scene BabylonJS scene
  143750. * @param _origin The origin position of the updraft
  143751. * @param _options The options for the updraft event
  143752. */
  143753. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  143754. /**
  143755. * Returns the data related to the updraft event (cylinder).
  143756. * @returns A physics updraft event
  143757. */
  143758. getData(): PhysicsUpdraftEventData;
  143759. /**
  143760. * Enables the updraft.
  143761. */
  143762. enable(): void;
  143763. /**
  143764. * Disables the updraft.
  143765. */
  143766. disable(): void;
  143767. /**
  143768. * Disposes the cylinder.
  143769. * @param force Specifies if the updraft should be disposed by force
  143770. */
  143771. dispose(force?: boolean): void;
  143772. private getImpostorHitData;
  143773. private _tick;
  143774. /*** Helpers ***/
  143775. private _prepareCylinder;
  143776. private _intersectsWithCylinder;
  143777. }
  143778. /**
  143779. * Represents a physics vortex event
  143780. */
  143781. class PhysicsVortexEvent {
  143782. private _scene;
  143783. private _origin;
  143784. private _options;
  143785. private _physicsEngine;
  143786. private _originTop;
  143787. private _tickCallback;
  143788. private _cylinder;
  143789. private _cylinderPosition;
  143790. private _dataFetched;
  143791. /**
  143792. * Initializes the physics vortex event
  143793. * @param _scene The BabylonJS scene
  143794. * @param _origin The origin position of the vortex
  143795. * @param _options The options for the vortex event
  143796. */
  143797. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  143798. /**
  143799. * Returns the data related to the vortex event (cylinder).
  143800. * @returns The physics vortex event data
  143801. */
  143802. getData(): PhysicsVortexEventData;
  143803. /**
  143804. * Enables the vortex.
  143805. */
  143806. enable(): void;
  143807. /**
  143808. * Disables the cortex.
  143809. */
  143810. disable(): void;
  143811. /**
  143812. * Disposes the sphere.
  143813. * @param force
  143814. */
  143815. dispose(force?: boolean): void;
  143816. private getImpostorHitData;
  143817. private _tick;
  143818. /*** Helpers ***/
  143819. private _prepareCylinder;
  143820. private _intersectsWithCylinder;
  143821. }
  143822. /**
  143823. * Options fot the radial explosion event
  143824. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  143825. */
  143826. export class PhysicsRadialExplosionEventOptions {
  143827. /**
  143828. * The radius of the sphere for the radial explosion.
  143829. */
  143830. radius: number;
  143831. /**
  143832. * The strenth of the explosion.
  143833. */
  143834. strength: number;
  143835. /**
  143836. * The strenght of the force in correspondence to the distance of the affected object
  143837. */
  143838. falloff: PhysicsRadialImpulseFalloff;
  143839. /**
  143840. * Sphere options for the radial explosion.
  143841. */
  143842. sphere: {
  143843. segments: number;
  143844. diameter: number;
  143845. };
  143846. /**
  143847. * Sphere options for the radial explosion.
  143848. */
  143849. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  143850. }
  143851. /**
  143852. * Options fot the updraft event
  143853. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  143854. */
  143855. export class PhysicsUpdraftEventOptions {
  143856. /**
  143857. * The radius of the cylinder for the vortex
  143858. */
  143859. radius: number;
  143860. /**
  143861. * The strenth of the updraft.
  143862. */
  143863. strength: number;
  143864. /**
  143865. * The height of the cylinder for the updraft.
  143866. */
  143867. height: number;
  143868. /**
  143869. * The mode for the the updraft.
  143870. */
  143871. updraftMode: PhysicsUpdraftMode;
  143872. }
  143873. /**
  143874. * Options fot the vortex event
  143875. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  143876. */
  143877. export class PhysicsVortexEventOptions {
  143878. /**
  143879. * The radius of the cylinder for the vortex
  143880. */
  143881. radius: number;
  143882. /**
  143883. * The strenth of the vortex.
  143884. */
  143885. strength: number;
  143886. /**
  143887. * The height of the cylinder for the vortex.
  143888. */
  143889. height: number;
  143890. /**
  143891. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  143892. */
  143893. centripetalForceThreshold: number;
  143894. /**
  143895. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  143896. */
  143897. centripetalForceMultiplier: number;
  143898. /**
  143899. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  143900. */
  143901. centrifugalForceMultiplier: number;
  143902. /**
  143903. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  143904. */
  143905. updraftForceMultiplier: number;
  143906. }
  143907. /**
  143908. * The strenght of the force in correspondence to the distance of the affected object
  143909. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  143910. */
  143911. export enum PhysicsRadialImpulseFalloff {
  143912. /** Defines that impulse is constant in strength across it's whole radius */
  143913. Constant = 0,
  143914. /** Defines that impulse gets weaker if it's further from the origin */
  143915. Linear = 1
  143916. }
  143917. /**
  143918. * The strength of the force in correspondence to the distance of the affected object
  143919. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  143920. */
  143921. export enum PhysicsUpdraftMode {
  143922. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  143923. Center = 0,
  143924. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  143925. Perpendicular = 1
  143926. }
  143927. /**
  143928. * Interface for a physics hit data
  143929. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  143930. */
  143931. export interface PhysicsHitData {
  143932. /**
  143933. * The force applied at the contact point
  143934. */
  143935. force: Vector3;
  143936. /**
  143937. * The contact point
  143938. */
  143939. contactPoint: Vector3;
  143940. /**
  143941. * The distance from the origin to the contact point
  143942. */
  143943. distanceFromOrigin: number;
  143944. }
  143945. /**
  143946. * Interface for radial explosion event data
  143947. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  143948. */
  143949. export interface PhysicsRadialExplosionEventData {
  143950. /**
  143951. * A sphere used for the radial explosion event
  143952. */
  143953. sphere: Mesh;
  143954. }
  143955. /**
  143956. * Interface for gravitational field event data
  143957. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  143958. */
  143959. export interface PhysicsGravitationalFieldEventData {
  143960. /**
  143961. * A sphere mesh used for the gravitational field event
  143962. */
  143963. sphere: Mesh;
  143964. }
  143965. /**
  143966. * Interface for updraft event data
  143967. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  143968. */
  143969. export interface PhysicsUpdraftEventData {
  143970. /**
  143971. * A cylinder used for the updraft event
  143972. */
  143973. cylinder: Mesh;
  143974. }
  143975. /**
  143976. * Interface for vortex event data
  143977. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  143978. */
  143979. export interface PhysicsVortexEventData {
  143980. /**
  143981. * A cylinder used for the vortex event
  143982. */
  143983. cylinder: Mesh;
  143984. }
  143985. /**
  143986. * Interface for an affected physics impostor
  143987. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  143988. */
  143989. export interface PhysicsAffectedImpostorWithData {
  143990. /**
  143991. * The impostor affected by the effect
  143992. */
  143993. impostor: PhysicsImpostor;
  143994. /**
  143995. * The data about the hit/horce from the explosion
  143996. */
  143997. hitData: PhysicsHitData;
  143998. }
  143999. }
  144000. declare module BABYLON {
  144001. /** @hidden */
  144002. export var blackAndWhitePixelShader: {
  144003. name: string;
  144004. shader: string;
  144005. };
  144006. }
  144007. declare module BABYLON {
  144008. /**
  144009. * Post process used to render in black and white
  144010. */
  144011. export class BlackAndWhitePostProcess extends PostProcess {
  144012. /**
  144013. * Linear about to convert he result to black and white (default: 1)
  144014. */
  144015. degree: number;
  144016. /**
  144017. * Creates a black and white post process
  144018. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  144019. * @param name The name of the effect.
  144020. * @param options The required width/height ratio to downsize to before computing the render pass.
  144021. * @param camera The camera to apply the render pass to.
  144022. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  144023. * @param engine The engine which the post process will be applied. (default: current engine)
  144024. * @param reusable If the post process can be reused on the same frame. (default: false)
  144025. */
  144026. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  144027. }
  144028. }
  144029. declare module BABYLON {
  144030. /**
  144031. * This represents a set of one or more post processes in Babylon.
  144032. * A post process can be used to apply a shader to a texture after it is rendered.
  144033. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  144034. */
  144035. export class PostProcessRenderEffect {
  144036. private _postProcesses;
  144037. private _getPostProcesses;
  144038. private _singleInstance;
  144039. private _cameras;
  144040. private _indicesForCamera;
  144041. /**
  144042. * Name of the effect
  144043. * @hidden
  144044. */
  144045. _name: string;
  144046. /**
  144047. * Instantiates a post process render effect.
  144048. * A post process can be used to apply a shader to a texture after it is rendered.
  144049. * @param engine The engine the effect is tied to
  144050. * @param name The name of the effect
  144051. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  144052. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  144053. */
  144054. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  144055. /**
  144056. * Checks if all the post processes in the effect are supported.
  144057. */
  144058. get isSupported(): boolean;
  144059. /**
  144060. * Updates the current state of the effect
  144061. * @hidden
  144062. */
  144063. _update(): void;
  144064. /**
  144065. * Attaches the effect on cameras
  144066. * @param cameras The camera to attach to.
  144067. * @hidden
  144068. */
  144069. _attachCameras(cameras: Camera): void;
  144070. /**
  144071. * Attaches the effect on cameras
  144072. * @param cameras The camera to attach to.
  144073. * @hidden
  144074. */
  144075. _attachCameras(cameras: Camera[]): void;
  144076. /**
  144077. * Detaches the effect on cameras
  144078. * @param cameras The camera to detatch from.
  144079. * @hidden
  144080. */
  144081. _detachCameras(cameras: Camera): void;
  144082. /**
  144083. * Detatches the effect on cameras
  144084. * @param cameras The camera to detatch from.
  144085. * @hidden
  144086. */
  144087. _detachCameras(cameras: Camera[]): void;
  144088. /**
  144089. * Enables the effect on given cameras
  144090. * @param cameras The camera to enable.
  144091. * @hidden
  144092. */
  144093. _enable(cameras: Camera): void;
  144094. /**
  144095. * Enables the effect on given cameras
  144096. * @param cameras The camera to enable.
  144097. * @hidden
  144098. */
  144099. _enable(cameras: Nullable<Camera[]>): void;
  144100. /**
  144101. * Disables the effect on the given cameras
  144102. * @param cameras The camera to disable.
  144103. * @hidden
  144104. */
  144105. _disable(cameras: Camera): void;
  144106. /**
  144107. * Disables the effect on the given cameras
  144108. * @param cameras The camera to disable.
  144109. * @hidden
  144110. */
  144111. _disable(cameras: Nullable<Camera[]>): void;
  144112. /**
  144113. * Gets a list of the post processes contained in the effect.
  144114. * @param camera The camera to get the post processes on.
  144115. * @returns The list of the post processes in the effect.
  144116. */
  144117. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  144118. }
  144119. }
  144120. declare module BABYLON {
  144121. /** @hidden */
  144122. export var extractHighlightsPixelShader: {
  144123. name: string;
  144124. shader: string;
  144125. };
  144126. }
  144127. declare module BABYLON {
  144128. /**
  144129. * 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.
  144130. */
  144131. export class ExtractHighlightsPostProcess extends PostProcess {
  144132. /**
  144133. * The luminance threshold, pixels below this value will be set to black.
  144134. */
  144135. threshold: number;
  144136. /** @hidden */
  144137. _exposure: number;
  144138. /**
  144139. * Post process which has the input texture to be used when performing highlight extraction
  144140. * @hidden
  144141. */
  144142. _inputPostProcess: Nullable<PostProcess>;
  144143. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  144144. }
  144145. }
  144146. declare module BABYLON {
  144147. /** @hidden */
  144148. export var bloomMergePixelShader: {
  144149. name: string;
  144150. shader: string;
  144151. };
  144152. }
  144153. declare module BABYLON {
  144154. /**
  144155. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  144156. */
  144157. export class BloomMergePostProcess extends PostProcess {
  144158. /** Weight of the bloom to be added to the original input. */
  144159. weight: number;
  144160. /**
  144161. * Creates a new instance of @see BloomMergePostProcess
  144162. * @param name The name of the effect.
  144163. * @param originalFromInput Post process which's input will be used for the merge.
  144164. * @param blurred Blurred highlights post process which's output will be used.
  144165. * @param weight Weight of the bloom to be added to the original input.
  144166. * @param options The required width/height ratio to downsize to before computing the render pass.
  144167. * @param camera The camera to apply the render pass to.
  144168. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  144169. * @param engine The engine which the post process will be applied. (default: current engine)
  144170. * @param reusable If the post process can be reused on the same frame. (default: false)
  144171. * @param textureType Type of textures used when performing the post process. (default: 0)
  144172. * @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)
  144173. */
  144174. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  144175. /** Weight of the bloom to be added to the original input. */
  144176. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  144177. }
  144178. }
  144179. declare module BABYLON {
  144180. /**
  144181. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  144182. */
  144183. export class BloomEffect extends PostProcessRenderEffect {
  144184. private bloomScale;
  144185. /**
  144186. * @hidden Internal
  144187. */
  144188. _effects: Array<PostProcess>;
  144189. /**
  144190. * @hidden Internal
  144191. */
  144192. _downscale: ExtractHighlightsPostProcess;
  144193. private _blurX;
  144194. private _blurY;
  144195. private _merge;
  144196. /**
  144197. * The luminance threshold to find bright areas of the image to bloom.
  144198. */
  144199. get threshold(): number;
  144200. set threshold(value: number);
  144201. /**
  144202. * The strength of the bloom.
  144203. */
  144204. get weight(): number;
  144205. set weight(value: number);
  144206. /**
  144207. * Specifies the size of the bloom blur kernel, relative to the final output size
  144208. */
  144209. get kernel(): number;
  144210. set kernel(value: number);
  144211. /**
  144212. * Creates a new instance of @see BloomEffect
  144213. * @param scene The scene the effect belongs to.
  144214. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  144215. * @param bloomKernel The size of the kernel to be used when applying the blur.
  144216. * @param bloomWeight The the strength of bloom.
  144217. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  144218. * @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)
  144219. */
  144220. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  144221. /**
  144222. * Disposes each of the internal effects for a given camera.
  144223. * @param camera The camera to dispose the effect on.
  144224. */
  144225. disposeEffects(camera: Camera): void;
  144226. /**
  144227. * @hidden Internal
  144228. */
  144229. _updateEffects(): void;
  144230. /**
  144231. * Internal
  144232. * @returns if all the contained post processes are ready.
  144233. * @hidden
  144234. */
  144235. _isReady(): boolean;
  144236. }
  144237. }
  144238. declare module BABYLON {
  144239. /** @hidden */
  144240. export var chromaticAberrationPixelShader: {
  144241. name: string;
  144242. shader: string;
  144243. };
  144244. }
  144245. declare module BABYLON {
  144246. /**
  144247. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  144248. */
  144249. export class ChromaticAberrationPostProcess extends PostProcess {
  144250. /**
  144251. * The amount of seperation of rgb channels (default: 30)
  144252. */
  144253. aberrationAmount: number;
  144254. /**
  144255. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  144256. */
  144257. radialIntensity: number;
  144258. /**
  144259. * 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))
  144260. */
  144261. direction: Vector2;
  144262. /**
  144263. * 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))
  144264. */
  144265. centerPosition: Vector2;
  144266. /**
  144267. * Creates a new instance ChromaticAberrationPostProcess
  144268. * @param name The name of the effect.
  144269. * @param screenWidth The width of the screen to apply the effect on.
  144270. * @param screenHeight The height of the screen to apply the effect on.
  144271. * @param options The required width/height ratio to downsize to before computing the render pass.
  144272. * @param camera The camera to apply the render pass to.
  144273. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  144274. * @param engine The engine which the post process will be applied. (default: current engine)
  144275. * @param reusable If the post process can be reused on the same frame. (default: false)
  144276. * @param textureType Type of textures used when performing the post process. (default: 0)
  144277. * @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)
  144278. */
  144279. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  144280. }
  144281. }
  144282. declare module BABYLON {
  144283. /** @hidden */
  144284. export var circleOfConfusionPixelShader: {
  144285. name: string;
  144286. shader: string;
  144287. };
  144288. }
  144289. declare module BABYLON {
  144290. /**
  144291. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  144292. */
  144293. export class CircleOfConfusionPostProcess extends PostProcess {
  144294. /**
  144295. * 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.
  144296. */
  144297. lensSize: number;
  144298. /**
  144299. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  144300. */
  144301. fStop: number;
  144302. /**
  144303. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  144304. */
  144305. focusDistance: number;
  144306. /**
  144307. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  144308. */
  144309. focalLength: number;
  144310. private _depthTexture;
  144311. /**
  144312. * Creates a new instance CircleOfConfusionPostProcess
  144313. * @param name The name of the effect.
  144314. * @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.
  144315. * @param options The required width/height ratio to downsize to before computing the render pass.
  144316. * @param camera The camera to apply the render pass to.
  144317. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  144318. * @param engine The engine which the post process will be applied. (default: current engine)
  144319. * @param reusable If the post process can be reused on the same frame. (default: false)
  144320. * @param textureType Type of textures used when performing the post process. (default: 0)
  144321. * @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)
  144322. */
  144323. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  144324. /**
  144325. * 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.
  144326. */
  144327. set depthTexture(value: RenderTargetTexture);
  144328. }
  144329. }
  144330. declare module BABYLON {
  144331. /** @hidden */
  144332. export var colorCorrectionPixelShader: {
  144333. name: string;
  144334. shader: string;
  144335. };
  144336. }
  144337. declare module BABYLON {
  144338. /**
  144339. *
  144340. * This post-process allows the modification of rendered colors by using
  144341. * a 'look-up table' (LUT). This effect is also called Color Grading.
  144342. *
  144343. * The object needs to be provided an url to a texture containing the color
  144344. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  144345. * Use an image editing software to tweak the LUT to match your needs.
  144346. *
  144347. * For an example of a color LUT, see here:
  144348. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  144349. * For explanations on color grading, see here:
  144350. * @see http://udn.epicgames.com/Three/ColorGrading.html
  144351. *
  144352. */
  144353. export class ColorCorrectionPostProcess extends PostProcess {
  144354. private _colorTableTexture;
  144355. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  144356. }
  144357. }
  144358. declare module BABYLON {
  144359. /** @hidden */
  144360. export var convolutionPixelShader: {
  144361. name: string;
  144362. shader: string;
  144363. };
  144364. }
  144365. declare module BABYLON {
  144366. /**
  144367. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  144368. * input texture to perform effects such as edge detection or sharpening
  144369. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  144370. */
  144371. export class ConvolutionPostProcess extends PostProcess {
  144372. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  144373. kernel: number[];
  144374. /**
  144375. * Creates a new instance ConvolutionPostProcess
  144376. * @param name The name of the effect.
  144377. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  144378. * @param options The required width/height ratio to downsize to before computing the render pass.
  144379. * @param camera The camera to apply the render pass to.
  144380. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  144381. * @param engine The engine which the post process will be applied. (default: current engine)
  144382. * @param reusable If the post process can be reused on the same frame. (default: false)
  144383. * @param textureType Type of textures used when performing the post process. (default: 0)
  144384. */
  144385. constructor(name: string,
  144386. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  144387. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  144388. /**
  144389. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  144390. */
  144391. static EdgeDetect0Kernel: number[];
  144392. /**
  144393. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  144394. */
  144395. static EdgeDetect1Kernel: number[];
  144396. /**
  144397. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  144398. */
  144399. static EdgeDetect2Kernel: number[];
  144400. /**
  144401. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  144402. */
  144403. static SharpenKernel: number[];
  144404. /**
  144405. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  144406. */
  144407. static EmbossKernel: number[];
  144408. /**
  144409. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  144410. */
  144411. static GaussianKernel: number[];
  144412. }
  144413. }
  144414. declare module BABYLON {
  144415. /**
  144416. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  144417. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  144418. * based on samples that have a large difference in distance than the center pixel.
  144419. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  144420. */
  144421. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  144422. direction: Vector2;
  144423. /**
  144424. * Creates a new instance CircleOfConfusionPostProcess
  144425. * @param name The name of the effect.
  144426. * @param scene The scene the effect belongs to.
  144427. * @param direction The direction the blur should be applied.
  144428. * @param kernel The size of the kernel used to blur.
  144429. * @param options The required width/height ratio to downsize to before computing the render pass.
  144430. * @param camera The camera to apply the render pass to.
  144431. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  144432. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  144433. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  144434. * @param engine The engine which the post process will be applied. (default: current engine)
  144435. * @param reusable If the post process can be reused on the same frame. (default: false)
  144436. * @param textureType Type of textures used when performing the post process. (default: 0)
  144437. * @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)
  144438. */
  144439. 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);
  144440. }
  144441. }
  144442. declare module BABYLON {
  144443. /** @hidden */
  144444. export var depthOfFieldMergePixelShader: {
  144445. name: string;
  144446. shader: string;
  144447. };
  144448. }
  144449. declare module BABYLON {
  144450. /**
  144451. * Options to be set when merging outputs from the default pipeline.
  144452. */
  144453. export class DepthOfFieldMergePostProcessOptions {
  144454. /**
  144455. * The original image to merge on top of
  144456. */
  144457. originalFromInput: PostProcess;
  144458. /**
  144459. * Parameters to perform the merge of the depth of field effect
  144460. */
  144461. depthOfField?: {
  144462. circleOfConfusion: PostProcess;
  144463. blurSteps: Array<PostProcess>;
  144464. };
  144465. /**
  144466. * Parameters to perform the merge of bloom effect
  144467. */
  144468. bloom?: {
  144469. blurred: PostProcess;
  144470. weight: number;
  144471. };
  144472. }
  144473. /**
  144474. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  144475. */
  144476. export class DepthOfFieldMergePostProcess extends PostProcess {
  144477. private blurSteps;
  144478. /**
  144479. * Creates a new instance of DepthOfFieldMergePostProcess
  144480. * @param name The name of the effect.
  144481. * @param originalFromInput Post process which's input will be used for the merge.
  144482. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  144483. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  144484. * @param options The required width/height ratio to downsize to before computing the render pass.
  144485. * @param camera The camera to apply the render pass to.
  144486. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  144487. * @param engine The engine which the post process will be applied. (default: current engine)
  144488. * @param reusable If the post process can be reused on the same frame. (default: false)
  144489. * @param textureType Type of textures used when performing the post process. (default: 0)
  144490. * @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)
  144491. */
  144492. 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);
  144493. /**
  144494. * Updates the effect with the current post process compile time values and recompiles the shader.
  144495. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  144496. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  144497. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  144498. * @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
  144499. * @param onCompiled Called when the shader has been compiled.
  144500. * @param onError Called if there is an error when compiling a shader.
  144501. */
  144502. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  144503. }
  144504. }
  144505. declare module BABYLON {
  144506. /**
  144507. * Specifies the level of max blur that should be applied when using the depth of field effect
  144508. */
  144509. export enum DepthOfFieldEffectBlurLevel {
  144510. /**
  144511. * Subtle blur
  144512. */
  144513. Low = 0,
  144514. /**
  144515. * Medium blur
  144516. */
  144517. Medium = 1,
  144518. /**
  144519. * Large blur
  144520. */
  144521. High = 2
  144522. }
  144523. /**
  144524. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  144525. */
  144526. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  144527. private _circleOfConfusion;
  144528. /**
  144529. * @hidden Internal, blurs from high to low
  144530. */
  144531. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  144532. private _depthOfFieldBlurY;
  144533. private _dofMerge;
  144534. /**
  144535. * @hidden Internal post processes in depth of field effect
  144536. */
  144537. _effects: Array<PostProcess>;
  144538. /**
  144539. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  144540. */
  144541. set focalLength(value: number);
  144542. get focalLength(): number;
  144543. /**
  144544. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  144545. */
  144546. set fStop(value: number);
  144547. get fStop(): number;
  144548. /**
  144549. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  144550. */
  144551. set focusDistance(value: number);
  144552. get focusDistance(): number;
  144553. /**
  144554. * 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.
  144555. */
  144556. set lensSize(value: number);
  144557. get lensSize(): number;
  144558. /**
  144559. * Creates a new instance DepthOfFieldEffect
  144560. * @param scene The scene the effect belongs to.
  144561. * @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.
  144562. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  144563. * @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)
  144564. */
  144565. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  144566. /**
  144567. * Get the current class name of the current effet
  144568. * @returns "DepthOfFieldEffect"
  144569. */
  144570. getClassName(): string;
  144571. /**
  144572. * 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.
  144573. */
  144574. set depthTexture(value: RenderTargetTexture);
  144575. /**
  144576. * Disposes each of the internal effects for a given camera.
  144577. * @param camera The camera to dispose the effect on.
  144578. */
  144579. disposeEffects(camera: Camera): void;
  144580. /**
  144581. * @hidden Internal
  144582. */
  144583. _updateEffects(): void;
  144584. /**
  144585. * Internal
  144586. * @returns if all the contained post processes are ready.
  144587. * @hidden
  144588. */
  144589. _isReady(): boolean;
  144590. }
  144591. }
  144592. declare module BABYLON {
  144593. /** @hidden */
  144594. export var displayPassPixelShader: {
  144595. name: string;
  144596. shader: string;
  144597. };
  144598. }
  144599. declare module BABYLON {
  144600. /**
  144601. * DisplayPassPostProcess which produces an output the same as it's input
  144602. */
  144603. export class DisplayPassPostProcess extends PostProcess {
  144604. /**
  144605. * Creates the DisplayPassPostProcess
  144606. * @param name The name of the effect.
  144607. * @param options The required width/height ratio to downsize to before computing the render pass.
  144608. * @param camera The camera to apply the render pass to.
  144609. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  144610. * @param engine The engine which the post process will be applied. (default: current engine)
  144611. * @param reusable If the post process can be reused on the same frame. (default: false)
  144612. */
  144613. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  144614. }
  144615. }
  144616. declare module BABYLON {
  144617. /** @hidden */
  144618. export var filterPixelShader: {
  144619. name: string;
  144620. shader: string;
  144621. };
  144622. }
  144623. declare module BABYLON {
  144624. /**
  144625. * Applies a kernel filter to the image
  144626. */
  144627. export class FilterPostProcess extends PostProcess {
  144628. /** The matrix to be applied to the image */
  144629. kernelMatrix: Matrix;
  144630. /**
  144631. *
  144632. * @param name The name of the effect.
  144633. * @param kernelMatrix The matrix to be applied to the image
  144634. * @param options The required width/height ratio to downsize to before computing the render pass.
  144635. * @param camera The camera to apply the render pass to.
  144636. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  144637. * @param engine The engine which the post process will be applied. (default: current engine)
  144638. * @param reusable If the post process can be reused on the same frame. (default: false)
  144639. */
  144640. constructor(name: string,
  144641. /** The matrix to be applied to the image */
  144642. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  144643. }
  144644. }
  144645. declare module BABYLON {
  144646. /** @hidden */
  144647. export var fxaaPixelShader: {
  144648. name: string;
  144649. shader: string;
  144650. };
  144651. }
  144652. declare module BABYLON {
  144653. /** @hidden */
  144654. export var fxaaVertexShader: {
  144655. name: string;
  144656. shader: string;
  144657. };
  144658. }
  144659. declare module BABYLON {
  144660. /**
  144661. * Fxaa post process
  144662. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  144663. */
  144664. export class FxaaPostProcess extends PostProcess {
  144665. /** @hidden */
  144666. texelWidth: number;
  144667. /** @hidden */
  144668. texelHeight: number;
  144669. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  144670. private _getDefines;
  144671. }
  144672. }
  144673. declare module BABYLON {
  144674. /** @hidden */
  144675. export var grainPixelShader: {
  144676. name: string;
  144677. shader: string;
  144678. };
  144679. }
  144680. declare module BABYLON {
  144681. /**
  144682. * The GrainPostProcess adds noise to the image at mid luminance levels
  144683. */
  144684. export class GrainPostProcess extends PostProcess {
  144685. /**
  144686. * The intensity of the grain added (default: 30)
  144687. */
  144688. intensity: number;
  144689. /**
  144690. * If the grain should be randomized on every frame
  144691. */
  144692. animated: boolean;
  144693. /**
  144694. * Creates a new instance of @see GrainPostProcess
  144695. * @param name The name of the effect.
  144696. * @param options The required width/height ratio to downsize to before computing the render pass.
  144697. * @param camera The camera to apply the render pass to.
  144698. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  144699. * @param engine The engine which the post process will be applied. (default: current engine)
  144700. * @param reusable If the post process can be reused on the same frame. (default: false)
  144701. * @param textureType Type of textures used when performing the post process. (default: 0)
  144702. * @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)
  144703. */
  144704. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  144705. }
  144706. }
  144707. declare module BABYLON {
  144708. /** @hidden */
  144709. export var highlightsPixelShader: {
  144710. name: string;
  144711. shader: string;
  144712. };
  144713. }
  144714. declare module BABYLON {
  144715. /**
  144716. * Extracts highlights from the image
  144717. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  144718. */
  144719. export class HighlightsPostProcess extends PostProcess {
  144720. /**
  144721. * Extracts highlights from the image
  144722. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  144723. * @param name The name of the effect.
  144724. * @param options The required width/height ratio to downsize to before computing the render pass.
  144725. * @param camera The camera to apply the render pass to.
  144726. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  144727. * @param engine The engine which the post process will be applied. (default: current engine)
  144728. * @param reusable If the post process can be reused on the same frame. (default: false)
  144729. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  144730. */
  144731. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  144732. }
  144733. }
  144734. declare module BABYLON {
  144735. /** @hidden */
  144736. export var mrtFragmentDeclaration: {
  144737. name: string;
  144738. shader: string;
  144739. };
  144740. }
  144741. declare module BABYLON {
  144742. /** @hidden */
  144743. export var geometryPixelShader: {
  144744. name: string;
  144745. shader: string;
  144746. };
  144747. }
  144748. declare module BABYLON {
  144749. /** @hidden */
  144750. export var geometryVertexShader: {
  144751. name: string;
  144752. shader: string;
  144753. };
  144754. }
  144755. declare module BABYLON {
  144756. /** @hidden */
  144757. interface ISavedTransformationMatrix {
  144758. world: Matrix;
  144759. viewProjection: Matrix;
  144760. }
  144761. /**
  144762. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  144763. */
  144764. export class GeometryBufferRenderer {
  144765. /**
  144766. * Constant used to retrieve the position texture index in the G-Buffer textures array
  144767. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  144768. */
  144769. static readonly POSITION_TEXTURE_TYPE: number;
  144770. /**
  144771. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  144772. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  144773. */
  144774. static readonly VELOCITY_TEXTURE_TYPE: number;
  144775. /**
  144776. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  144777. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  144778. */
  144779. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  144780. /**
  144781. * Dictionary used to store the previous transformation matrices of each rendered mesh
  144782. * in order to compute objects velocities when enableVelocity is set to "true"
  144783. * @hidden
  144784. */
  144785. _previousTransformationMatrices: {
  144786. [index: number]: ISavedTransformationMatrix;
  144787. };
  144788. /**
  144789. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  144790. * in order to compute objects velocities when enableVelocity is set to "true"
  144791. * @hidden
  144792. */
  144793. _previousBonesTransformationMatrices: {
  144794. [index: number]: Float32Array;
  144795. };
  144796. /**
  144797. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  144798. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  144799. */
  144800. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  144801. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  144802. renderTransparentMeshes: boolean;
  144803. private _scene;
  144804. private _multiRenderTarget;
  144805. private _ratio;
  144806. private _enablePosition;
  144807. private _enableVelocity;
  144808. private _enableReflectivity;
  144809. private _positionIndex;
  144810. private _velocityIndex;
  144811. private _reflectivityIndex;
  144812. protected _effect: Effect;
  144813. protected _cachedDefines: string;
  144814. /**
  144815. * Set the render list (meshes to be rendered) used in the G buffer.
  144816. */
  144817. set renderList(meshes: Mesh[]);
  144818. /**
  144819. * Gets wether or not G buffer are supported by the running hardware.
  144820. * This requires draw buffer supports
  144821. */
  144822. get isSupported(): boolean;
  144823. /**
  144824. * Returns the index of the given texture type in the G-Buffer textures array
  144825. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  144826. * @returns the index of the given texture type in the G-Buffer textures array
  144827. */
  144828. getTextureIndex(textureType: number): number;
  144829. /**
  144830. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  144831. */
  144832. get enablePosition(): boolean;
  144833. /**
  144834. * Sets whether or not objects positions are enabled for the G buffer.
  144835. */
  144836. set enablePosition(enable: boolean);
  144837. /**
  144838. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  144839. */
  144840. get enableVelocity(): boolean;
  144841. /**
  144842. * Sets wether or not objects velocities are enabled for the G buffer.
  144843. */
  144844. set enableVelocity(enable: boolean);
  144845. /**
  144846. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  144847. */
  144848. get enableReflectivity(): boolean;
  144849. /**
  144850. * Sets wether or not objects roughness are enabled for the G buffer.
  144851. */
  144852. set enableReflectivity(enable: boolean);
  144853. /**
  144854. * Gets the scene associated with the buffer.
  144855. */
  144856. get scene(): Scene;
  144857. /**
  144858. * Gets the ratio used by the buffer during its creation.
  144859. * How big is the buffer related to the main canvas.
  144860. */
  144861. get ratio(): number;
  144862. /** @hidden */
  144863. static _SceneComponentInitialization: (scene: Scene) => void;
  144864. /**
  144865. * Creates a new G Buffer for the scene
  144866. * @param scene The scene the buffer belongs to
  144867. * @param ratio How big is the buffer related to the main canvas.
  144868. */
  144869. constructor(scene: Scene, ratio?: number);
  144870. /**
  144871. * Checks wether everything is ready to render a submesh to the G buffer.
  144872. * @param subMesh the submesh to check readiness for
  144873. * @param useInstances is the mesh drawn using instance or not
  144874. * @returns true if ready otherwise false
  144875. */
  144876. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  144877. /**
  144878. * Gets the current underlying G Buffer.
  144879. * @returns the buffer
  144880. */
  144881. getGBuffer(): MultiRenderTarget;
  144882. /**
  144883. * Gets the number of samples used to render the buffer (anti aliasing).
  144884. */
  144885. get samples(): number;
  144886. /**
  144887. * Sets the number of samples used to render the buffer (anti aliasing).
  144888. */
  144889. set samples(value: number);
  144890. /**
  144891. * Disposes the renderer and frees up associated resources.
  144892. */
  144893. dispose(): void;
  144894. protected _createRenderTargets(): void;
  144895. private _copyBonesTransformationMatrices;
  144896. }
  144897. }
  144898. declare module BABYLON {
  144899. interface Scene {
  144900. /** @hidden (Backing field) */
  144901. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  144902. /**
  144903. * Gets or Sets the current geometry buffer associated to the scene.
  144904. */
  144905. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  144906. /**
  144907. * Enables a GeometryBufferRender and associates it with the scene
  144908. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  144909. * @returns the GeometryBufferRenderer
  144910. */
  144911. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  144912. /**
  144913. * Disables the GeometryBufferRender associated with the scene
  144914. */
  144915. disableGeometryBufferRenderer(): void;
  144916. }
  144917. /**
  144918. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  144919. * in several rendering techniques.
  144920. */
  144921. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  144922. /**
  144923. * The component name helpful to identify the component in the list of scene components.
  144924. */
  144925. readonly name: string;
  144926. /**
  144927. * The scene the component belongs to.
  144928. */
  144929. scene: Scene;
  144930. /**
  144931. * Creates a new instance of the component for the given scene
  144932. * @param scene Defines the scene to register the component in
  144933. */
  144934. constructor(scene: Scene);
  144935. /**
  144936. * Registers the component in a given scene
  144937. */
  144938. register(): void;
  144939. /**
  144940. * Rebuilds the elements related to this component in case of
  144941. * context lost for instance.
  144942. */
  144943. rebuild(): void;
  144944. /**
  144945. * Disposes the component and the associated ressources
  144946. */
  144947. dispose(): void;
  144948. private _gatherRenderTargets;
  144949. }
  144950. }
  144951. declare module BABYLON {
  144952. /** @hidden */
  144953. export var motionBlurPixelShader: {
  144954. name: string;
  144955. shader: string;
  144956. };
  144957. }
  144958. declare module BABYLON {
  144959. /**
  144960. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  144961. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  144962. * As an example, all you have to do is to create the post-process:
  144963. * var mb = new BABYLON.MotionBlurPostProcess(
  144964. * 'mb', // The name of the effect.
  144965. * scene, // The scene containing the objects to blur according to their velocity.
  144966. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  144967. * camera // The camera to apply the render pass to.
  144968. * );
  144969. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  144970. */
  144971. export class MotionBlurPostProcess extends PostProcess {
  144972. /**
  144973. * Defines how much the image is blurred by the movement. Default value is equal to 1
  144974. */
  144975. motionStrength: number;
  144976. /**
  144977. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  144978. */
  144979. get motionBlurSamples(): number;
  144980. /**
  144981. * Sets the number of iterations to be used for motion blur quality
  144982. */
  144983. set motionBlurSamples(samples: number);
  144984. private _motionBlurSamples;
  144985. private _geometryBufferRenderer;
  144986. /**
  144987. * Creates a new instance MotionBlurPostProcess
  144988. * @param name The name of the effect.
  144989. * @param scene The scene containing the objects to blur according to their velocity.
  144990. * @param options The required width/height ratio to downsize to before computing the render pass.
  144991. * @param camera The camera to apply the render pass to.
  144992. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  144993. * @param engine The engine which the post process will be applied. (default: current engine)
  144994. * @param reusable If the post process can be reused on the same frame. (default: false)
  144995. * @param textureType Type of textures used when performing the post process. (default: 0)
  144996. * @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)
  144997. */
  144998. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  144999. /**
  145000. * Excludes the given skinned mesh from computing bones velocities.
  145001. * 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.
  145002. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  145003. */
  145004. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  145005. /**
  145006. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  145007. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  145008. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  145009. */
  145010. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  145011. /**
  145012. * Disposes the post process.
  145013. * @param camera The camera to dispose the post process on.
  145014. */
  145015. dispose(camera?: Camera): void;
  145016. }
  145017. }
  145018. declare module BABYLON {
  145019. /** @hidden */
  145020. export var refractionPixelShader: {
  145021. name: string;
  145022. shader: string;
  145023. };
  145024. }
  145025. declare module BABYLON {
  145026. /**
  145027. * Post process which applies a refractin texture
  145028. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  145029. */
  145030. export class RefractionPostProcess extends PostProcess {
  145031. /** the base color of the refraction (used to taint the rendering) */
  145032. color: Color3;
  145033. /** simulated refraction depth */
  145034. depth: number;
  145035. /** the coefficient of the base color (0 to remove base color tainting) */
  145036. colorLevel: number;
  145037. private _refTexture;
  145038. private _ownRefractionTexture;
  145039. /**
  145040. * Gets or sets the refraction texture
  145041. * Please note that you are responsible for disposing the texture if you set it manually
  145042. */
  145043. get refractionTexture(): Texture;
  145044. set refractionTexture(value: Texture);
  145045. /**
  145046. * Initializes the RefractionPostProcess
  145047. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  145048. * @param name The name of the effect.
  145049. * @param refractionTextureUrl Url of the refraction texture to use
  145050. * @param color the base color of the refraction (used to taint the rendering)
  145051. * @param depth simulated refraction depth
  145052. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  145053. * @param camera The camera to apply the render pass to.
  145054. * @param options The required width/height ratio to downsize to before computing the render pass.
  145055. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  145056. * @param engine The engine which the post process will be applied. (default: current engine)
  145057. * @param reusable If the post process can be reused on the same frame. (default: false)
  145058. */
  145059. constructor(name: string, refractionTextureUrl: string,
  145060. /** the base color of the refraction (used to taint the rendering) */
  145061. color: Color3,
  145062. /** simulated refraction depth */
  145063. depth: number,
  145064. /** the coefficient of the base color (0 to remove base color tainting) */
  145065. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  145066. /**
  145067. * Disposes of the post process
  145068. * @param camera Camera to dispose post process on
  145069. */
  145070. dispose(camera: Camera): void;
  145071. }
  145072. }
  145073. declare module BABYLON {
  145074. /** @hidden */
  145075. export var sharpenPixelShader: {
  145076. name: string;
  145077. shader: string;
  145078. };
  145079. }
  145080. declare module BABYLON {
  145081. /**
  145082. * The SharpenPostProcess applies a sharpen kernel to every pixel
  145083. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  145084. */
  145085. export class SharpenPostProcess extends PostProcess {
  145086. /**
  145087. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  145088. */
  145089. colorAmount: number;
  145090. /**
  145091. * How much sharpness should be applied (default: 0.3)
  145092. */
  145093. edgeAmount: number;
  145094. /**
  145095. * Creates a new instance ConvolutionPostProcess
  145096. * @param name The name of the effect.
  145097. * @param options The required width/height ratio to downsize to before computing the render pass.
  145098. * @param camera The camera to apply the render pass to.
  145099. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  145100. * @param engine The engine which the post process will be applied. (default: current engine)
  145101. * @param reusable If the post process can be reused on the same frame. (default: false)
  145102. * @param textureType Type of textures used when performing the post process. (default: 0)
  145103. * @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)
  145104. */
  145105. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  145106. }
  145107. }
  145108. declare module BABYLON {
  145109. /**
  145110. * PostProcessRenderPipeline
  145111. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  145112. */
  145113. export class PostProcessRenderPipeline {
  145114. private engine;
  145115. private _renderEffects;
  145116. private _renderEffectsForIsolatedPass;
  145117. /**
  145118. * List of inspectable custom properties (used by the Inspector)
  145119. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  145120. */
  145121. inspectableCustomProperties: IInspectable[];
  145122. /**
  145123. * @hidden
  145124. */
  145125. protected _cameras: Camera[];
  145126. /** @hidden */
  145127. _name: string;
  145128. /**
  145129. * Gets pipeline name
  145130. */
  145131. get name(): string;
  145132. /** Gets the list of attached cameras */
  145133. get cameras(): Camera[];
  145134. /**
  145135. * Initializes a PostProcessRenderPipeline
  145136. * @param engine engine to add the pipeline to
  145137. * @param name name of the pipeline
  145138. */
  145139. constructor(engine: Engine, name: string);
  145140. /**
  145141. * Gets the class name
  145142. * @returns "PostProcessRenderPipeline"
  145143. */
  145144. getClassName(): string;
  145145. /**
  145146. * If all the render effects in the pipeline are supported
  145147. */
  145148. get isSupported(): boolean;
  145149. /**
  145150. * Adds an effect to the pipeline
  145151. * @param renderEffect the effect to add
  145152. */
  145153. addEffect(renderEffect: PostProcessRenderEffect): void;
  145154. /** @hidden */
  145155. _rebuild(): void;
  145156. /** @hidden */
  145157. _enableEffect(renderEffectName: string, cameras: Camera): void;
  145158. /** @hidden */
  145159. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  145160. /** @hidden */
  145161. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  145162. /** @hidden */
  145163. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  145164. /** @hidden */
  145165. _attachCameras(cameras: Camera, unique: boolean): void;
  145166. /** @hidden */
  145167. _attachCameras(cameras: Camera[], unique: boolean): void;
  145168. /** @hidden */
  145169. _detachCameras(cameras: Camera): void;
  145170. /** @hidden */
  145171. _detachCameras(cameras: Nullable<Camera[]>): void;
  145172. /** @hidden */
  145173. _update(): void;
  145174. /** @hidden */
  145175. _reset(): void;
  145176. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  145177. /**
  145178. * Disposes of the pipeline
  145179. */
  145180. dispose(): void;
  145181. }
  145182. }
  145183. declare module BABYLON {
  145184. /**
  145185. * PostProcessRenderPipelineManager class
  145186. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  145187. */
  145188. export class PostProcessRenderPipelineManager {
  145189. private _renderPipelines;
  145190. /**
  145191. * Initializes a PostProcessRenderPipelineManager
  145192. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  145193. */
  145194. constructor();
  145195. /**
  145196. * Gets the list of supported render pipelines
  145197. */
  145198. get supportedPipelines(): PostProcessRenderPipeline[];
  145199. /**
  145200. * Adds a pipeline to the manager
  145201. * @param renderPipeline The pipeline to add
  145202. */
  145203. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  145204. /**
  145205. * Attaches a camera to the pipeline
  145206. * @param renderPipelineName The name of the pipeline to attach to
  145207. * @param cameras the camera to attach
  145208. * @param unique if the camera can be attached multiple times to the pipeline
  145209. */
  145210. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  145211. /**
  145212. * Detaches a camera from the pipeline
  145213. * @param renderPipelineName The name of the pipeline to detach from
  145214. * @param cameras the camera to detach
  145215. */
  145216. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  145217. /**
  145218. * Enables an effect by name on a pipeline
  145219. * @param renderPipelineName the name of the pipeline to enable the effect in
  145220. * @param renderEffectName the name of the effect to enable
  145221. * @param cameras the cameras that the effect should be enabled on
  145222. */
  145223. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  145224. /**
  145225. * Disables an effect by name on a pipeline
  145226. * @param renderPipelineName the name of the pipeline to disable the effect in
  145227. * @param renderEffectName the name of the effect to disable
  145228. * @param cameras the cameras that the effect should be disabled on
  145229. */
  145230. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  145231. /**
  145232. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  145233. */
  145234. update(): void;
  145235. /** @hidden */
  145236. _rebuild(): void;
  145237. /**
  145238. * Disposes of the manager and pipelines
  145239. */
  145240. dispose(): void;
  145241. }
  145242. }
  145243. declare module BABYLON {
  145244. interface Scene {
  145245. /** @hidden (Backing field) */
  145246. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  145247. /**
  145248. * Gets the postprocess render pipeline manager
  145249. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  145250. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  145251. */
  145252. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  145253. }
  145254. /**
  145255. * Defines the Render Pipeline scene component responsible to rendering pipelines
  145256. */
  145257. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  145258. /**
  145259. * The component name helpfull to identify the component in the list of scene components.
  145260. */
  145261. readonly name: string;
  145262. /**
  145263. * The scene the component belongs to.
  145264. */
  145265. scene: Scene;
  145266. /**
  145267. * Creates a new instance of the component for the given scene
  145268. * @param scene Defines the scene to register the component in
  145269. */
  145270. constructor(scene: Scene);
  145271. /**
  145272. * Registers the component in a given scene
  145273. */
  145274. register(): void;
  145275. /**
  145276. * Rebuilds the elements related to this component in case of
  145277. * context lost for instance.
  145278. */
  145279. rebuild(): void;
  145280. /**
  145281. * Disposes the component and the associated ressources
  145282. */
  145283. dispose(): void;
  145284. private _gatherRenderTargets;
  145285. }
  145286. }
  145287. declare module BABYLON {
  145288. /**
  145289. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  145290. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  145291. */
  145292. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  145293. private _scene;
  145294. private _camerasToBeAttached;
  145295. /**
  145296. * ID of the sharpen post process,
  145297. */
  145298. private readonly SharpenPostProcessId;
  145299. /**
  145300. * @ignore
  145301. * ID of the image processing post process;
  145302. */
  145303. readonly ImageProcessingPostProcessId: string;
  145304. /**
  145305. * @ignore
  145306. * ID of the Fast Approximate Anti-Aliasing post process;
  145307. */
  145308. readonly FxaaPostProcessId: string;
  145309. /**
  145310. * ID of the chromatic aberration post process,
  145311. */
  145312. private readonly ChromaticAberrationPostProcessId;
  145313. /**
  145314. * ID of the grain post process
  145315. */
  145316. private readonly GrainPostProcessId;
  145317. /**
  145318. * Sharpen post process which will apply a sharpen convolution to enhance edges
  145319. */
  145320. sharpen: SharpenPostProcess;
  145321. private _sharpenEffect;
  145322. private bloom;
  145323. /**
  145324. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  145325. */
  145326. depthOfField: DepthOfFieldEffect;
  145327. /**
  145328. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  145329. */
  145330. fxaa: FxaaPostProcess;
  145331. /**
  145332. * Image post processing pass used to perform operations such as tone mapping or color grading.
  145333. */
  145334. imageProcessing: ImageProcessingPostProcess;
  145335. /**
  145336. * Chromatic aberration post process which will shift rgb colors in the image
  145337. */
  145338. chromaticAberration: ChromaticAberrationPostProcess;
  145339. private _chromaticAberrationEffect;
  145340. /**
  145341. * Grain post process which add noise to the image
  145342. */
  145343. grain: GrainPostProcess;
  145344. private _grainEffect;
  145345. /**
  145346. * Glow post process which adds a glow to emissive areas of the image
  145347. */
  145348. private _glowLayer;
  145349. /**
  145350. * Animations which can be used to tweak settings over a period of time
  145351. */
  145352. animations: Animation[];
  145353. private _imageProcessingConfigurationObserver;
  145354. private _sharpenEnabled;
  145355. private _bloomEnabled;
  145356. private _depthOfFieldEnabled;
  145357. private _depthOfFieldBlurLevel;
  145358. private _fxaaEnabled;
  145359. private _imageProcessingEnabled;
  145360. private _defaultPipelineTextureType;
  145361. private _bloomScale;
  145362. private _chromaticAberrationEnabled;
  145363. private _grainEnabled;
  145364. private _buildAllowed;
  145365. /**
  145366. * Gets active scene
  145367. */
  145368. get scene(): Scene;
  145369. /**
  145370. * Enable or disable the sharpen process from the pipeline
  145371. */
  145372. set sharpenEnabled(enabled: boolean);
  145373. get sharpenEnabled(): boolean;
  145374. private _resizeObserver;
  145375. private _hardwareScaleLevel;
  145376. private _bloomKernel;
  145377. /**
  145378. * Specifies the size of the bloom blur kernel, relative to the final output size
  145379. */
  145380. get bloomKernel(): number;
  145381. set bloomKernel(value: number);
  145382. /**
  145383. * Specifies the weight of the bloom in the final rendering
  145384. */
  145385. private _bloomWeight;
  145386. /**
  145387. * Specifies the luma threshold for the area that will be blurred by the bloom
  145388. */
  145389. private _bloomThreshold;
  145390. private _hdr;
  145391. /**
  145392. * The strength of the bloom.
  145393. */
  145394. set bloomWeight(value: number);
  145395. get bloomWeight(): number;
  145396. /**
  145397. * The strength of the bloom.
  145398. */
  145399. set bloomThreshold(value: number);
  145400. get bloomThreshold(): number;
  145401. /**
  145402. * The scale of the bloom, lower value will provide better performance.
  145403. */
  145404. set bloomScale(value: number);
  145405. get bloomScale(): number;
  145406. /**
  145407. * Enable or disable the bloom from the pipeline
  145408. */
  145409. set bloomEnabled(enabled: boolean);
  145410. get bloomEnabled(): boolean;
  145411. private _rebuildBloom;
  145412. /**
  145413. * If the depth of field is enabled.
  145414. */
  145415. get depthOfFieldEnabled(): boolean;
  145416. set depthOfFieldEnabled(enabled: boolean);
  145417. /**
  145418. * Blur level of the depth of field effect. (Higher blur will effect performance)
  145419. */
  145420. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  145421. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  145422. /**
  145423. * If the anti aliasing is enabled.
  145424. */
  145425. set fxaaEnabled(enabled: boolean);
  145426. get fxaaEnabled(): boolean;
  145427. private _samples;
  145428. /**
  145429. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  145430. */
  145431. set samples(sampleCount: number);
  145432. get samples(): number;
  145433. /**
  145434. * If image processing is enabled.
  145435. */
  145436. set imageProcessingEnabled(enabled: boolean);
  145437. get imageProcessingEnabled(): boolean;
  145438. /**
  145439. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  145440. */
  145441. set glowLayerEnabled(enabled: boolean);
  145442. get glowLayerEnabled(): boolean;
  145443. /**
  145444. * Gets the glow layer (or null if not defined)
  145445. */
  145446. get glowLayer(): Nullable<GlowLayer>;
  145447. /**
  145448. * Enable or disable the chromaticAberration process from the pipeline
  145449. */
  145450. set chromaticAberrationEnabled(enabled: boolean);
  145451. get chromaticAberrationEnabled(): boolean;
  145452. /**
  145453. * Enable or disable the grain process from the pipeline
  145454. */
  145455. set grainEnabled(enabled: boolean);
  145456. get grainEnabled(): boolean;
  145457. /**
  145458. * @constructor
  145459. * @param name - The rendering pipeline name (default: "")
  145460. * @param hdr - If high dynamic range textures should be used (default: true)
  145461. * @param scene - The scene linked to this pipeline (default: the last created scene)
  145462. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  145463. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  145464. */
  145465. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  145466. /**
  145467. * Get the class name
  145468. * @returns "DefaultRenderingPipeline"
  145469. */
  145470. getClassName(): string;
  145471. /**
  145472. * Force the compilation of the entire pipeline.
  145473. */
  145474. prepare(): void;
  145475. private _hasCleared;
  145476. private _prevPostProcess;
  145477. private _prevPrevPostProcess;
  145478. private _setAutoClearAndTextureSharing;
  145479. private _depthOfFieldSceneObserver;
  145480. private _buildPipeline;
  145481. private _disposePostProcesses;
  145482. /**
  145483. * Adds a camera to the pipeline
  145484. * @param camera the camera to be added
  145485. */
  145486. addCamera(camera: Camera): void;
  145487. /**
  145488. * Removes a camera from the pipeline
  145489. * @param camera the camera to remove
  145490. */
  145491. removeCamera(camera: Camera): void;
  145492. /**
  145493. * Dispose of the pipeline and stop all post processes
  145494. */
  145495. dispose(): void;
  145496. /**
  145497. * Serialize the rendering pipeline (Used when exporting)
  145498. * @returns the serialized object
  145499. */
  145500. serialize(): any;
  145501. /**
  145502. * Parse the serialized pipeline
  145503. * @param source Source pipeline.
  145504. * @param scene The scene to load the pipeline to.
  145505. * @param rootUrl The URL of the serialized pipeline.
  145506. * @returns An instantiated pipeline from the serialized object.
  145507. */
  145508. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  145509. }
  145510. }
  145511. declare module BABYLON {
  145512. /** @hidden */
  145513. export var lensHighlightsPixelShader: {
  145514. name: string;
  145515. shader: string;
  145516. };
  145517. }
  145518. declare module BABYLON {
  145519. /** @hidden */
  145520. export var depthOfFieldPixelShader: {
  145521. name: string;
  145522. shader: string;
  145523. };
  145524. }
  145525. declare module BABYLON {
  145526. /**
  145527. * BABYLON.JS Chromatic Aberration GLSL Shader
  145528. * Author: Olivier Guyot
  145529. * Separates very slightly R, G and B colors on the edges of the screen
  145530. * Inspired by Francois Tarlier & Martins Upitis
  145531. */
  145532. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  145533. /**
  145534. * @ignore
  145535. * The chromatic aberration PostProcess id in the pipeline
  145536. */
  145537. LensChromaticAberrationEffect: string;
  145538. /**
  145539. * @ignore
  145540. * The highlights enhancing PostProcess id in the pipeline
  145541. */
  145542. HighlightsEnhancingEffect: string;
  145543. /**
  145544. * @ignore
  145545. * The depth-of-field PostProcess id in the pipeline
  145546. */
  145547. LensDepthOfFieldEffect: string;
  145548. private _scene;
  145549. private _depthTexture;
  145550. private _grainTexture;
  145551. private _chromaticAberrationPostProcess;
  145552. private _highlightsPostProcess;
  145553. private _depthOfFieldPostProcess;
  145554. private _edgeBlur;
  145555. private _grainAmount;
  145556. private _chromaticAberration;
  145557. private _distortion;
  145558. private _highlightsGain;
  145559. private _highlightsThreshold;
  145560. private _dofDistance;
  145561. private _dofAperture;
  145562. private _dofDarken;
  145563. private _dofPentagon;
  145564. private _blurNoise;
  145565. /**
  145566. * @constructor
  145567. *
  145568. * Effect parameters are as follow:
  145569. * {
  145570. * chromatic_aberration: number; // from 0 to x (1 for realism)
  145571. * edge_blur: number; // from 0 to x (1 for realism)
  145572. * distortion: number; // from 0 to x (1 for realism)
  145573. * grain_amount: number; // from 0 to 1
  145574. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  145575. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  145576. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  145577. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  145578. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  145579. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  145580. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  145581. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  145582. * }
  145583. * Note: if an effect parameter is unset, effect is disabled
  145584. *
  145585. * @param name The rendering pipeline name
  145586. * @param parameters - An object containing all parameters (see above)
  145587. * @param scene The scene linked to this pipeline
  145588. * @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)
  145589. * @param cameras The array of cameras that the rendering pipeline will be attached to
  145590. */
  145591. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  145592. /**
  145593. * Get the class name
  145594. * @returns "LensRenderingPipeline"
  145595. */
  145596. getClassName(): string;
  145597. /**
  145598. * Gets associated scene
  145599. */
  145600. get scene(): Scene;
  145601. /**
  145602. * Gets or sets the edge blur
  145603. */
  145604. get edgeBlur(): number;
  145605. set edgeBlur(value: number);
  145606. /**
  145607. * Gets or sets the grain amount
  145608. */
  145609. get grainAmount(): number;
  145610. set grainAmount(value: number);
  145611. /**
  145612. * Gets or sets the chromatic aberration amount
  145613. */
  145614. get chromaticAberration(): number;
  145615. set chromaticAberration(value: number);
  145616. /**
  145617. * Gets or sets the depth of field aperture
  145618. */
  145619. get dofAperture(): number;
  145620. set dofAperture(value: number);
  145621. /**
  145622. * Gets or sets the edge distortion
  145623. */
  145624. get edgeDistortion(): number;
  145625. set edgeDistortion(value: number);
  145626. /**
  145627. * Gets or sets the depth of field distortion
  145628. */
  145629. get dofDistortion(): number;
  145630. set dofDistortion(value: number);
  145631. /**
  145632. * Gets or sets the darken out of focus amount
  145633. */
  145634. get darkenOutOfFocus(): number;
  145635. set darkenOutOfFocus(value: number);
  145636. /**
  145637. * Gets or sets a boolean indicating if blur noise is enabled
  145638. */
  145639. get blurNoise(): boolean;
  145640. set blurNoise(value: boolean);
  145641. /**
  145642. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  145643. */
  145644. get pentagonBokeh(): boolean;
  145645. set pentagonBokeh(value: boolean);
  145646. /**
  145647. * Gets or sets the highlight grain amount
  145648. */
  145649. get highlightsGain(): number;
  145650. set highlightsGain(value: number);
  145651. /**
  145652. * Gets or sets the highlight threshold
  145653. */
  145654. get highlightsThreshold(): number;
  145655. set highlightsThreshold(value: number);
  145656. /**
  145657. * Sets the amount of blur at the edges
  145658. * @param amount blur amount
  145659. */
  145660. setEdgeBlur(amount: number): void;
  145661. /**
  145662. * Sets edge blur to 0
  145663. */
  145664. disableEdgeBlur(): void;
  145665. /**
  145666. * Sets the amout of grain
  145667. * @param amount Amount of grain
  145668. */
  145669. setGrainAmount(amount: number): void;
  145670. /**
  145671. * Set grain amount to 0
  145672. */
  145673. disableGrain(): void;
  145674. /**
  145675. * Sets the chromatic aberration amount
  145676. * @param amount amount of chromatic aberration
  145677. */
  145678. setChromaticAberration(amount: number): void;
  145679. /**
  145680. * Sets chromatic aberration amount to 0
  145681. */
  145682. disableChromaticAberration(): void;
  145683. /**
  145684. * Sets the EdgeDistortion amount
  145685. * @param amount amount of EdgeDistortion
  145686. */
  145687. setEdgeDistortion(amount: number): void;
  145688. /**
  145689. * Sets edge distortion to 0
  145690. */
  145691. disableEdgeDistortion(): void;
  145692. /**
  145693. * Sets the FocusDistance amount
  145694. * @param amount amount of FocusDistance
  145695. */
  145696. setFocusDistance(amount: number): void;
  145697. /**
  145698. * Disables depth of field
  145699. */
  145700. disableDepthOfField(): void;
  145701. /**
  145702. * Sets the Aperture amount
  145703. * @param amount amount of Aperture
  145704. */
  145705. setAperture(amount: number): void;
  145706. /**
  145707. * Sets the DarkenOutOfFocus amount
  145708. * @param amount amount of DarkenOutOfFocus
  145709. */
  145710. setDarkenOutOfFocus(amount: number): void;
  145711. private _pentagonBokehIsEnabled;
  145712. /**
  145713. * Creates a pentagon bokeh effect
  145714. */
  145715. enablePentagonBokeh(): void;
  145716. /**
  145717. * Disables the pentagon bokeh effect
  145718. */
  145719. disablePentagonBokeh(): void;
  145720. /**
  145721. * Enables noise blur
  145722. */
  145723. enableNoiseBlur(): void;
  145724. /**
  145725. * Disables noise blur
  145726. */
  145727. disableNoiseBlur(): void;
  145728. /**
  145729. * Sets the HighlightsGain amount
  145730. * @param amount amount of HighlightsGain
  145731. */
  145732. setHighlightsGain(amount: number): void;
  145733. /**
  145734. * Sets the HighlightsThreshold amount
  145735. * @param amount amount of HighlightsThreshold
  145736. */
  145737. setHighlightsThreshold(amount: number): void;
  145738. /**
  145739. * Disables highlights
  145740. */
  145741. disableHighlights(): void;
  145742. /**
  145743. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  145744. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  145745. */
  145746. dispose(disableDepthRender?: boolean): void;
  145747. private _createChromaticAberrationPostProcess;
  145748. private _createHighlightsPostProcess;
  145749. private _createDepthOfFieldPostProcess;
  145750. private _createGrainTexture;
  145751. }
  145752. }
  145753. declare module BABYLON {
  145754. /** @hidden */
  145755. export var ssao2PixelShader: {
  145756. name: string;
  145757. shader: string;
  145758. };
  145759. }
  145760. declare module BABYLON {
  145761. /** @hidden */
  145762. export var ssaoCombinePixelShader: {
  145763. name: string;
  145764. shader: string;
  145765. };
  145766. }
  145767. declare module BABYLON {
  145768. /**
  145769. * Render pipeline to produce ssao effect
  145770. */
  145771. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  145772. /**
  145773. * @ignore
  145774. * The PassPostProcess id in the pipeline that contains the original scene color
  145775. */
  145776. SSAOOriginalSceneColorEffect: string;
  145777. /**
  145778. * @ignore
  145779. * The SSAO PostProcess id in the pipeline
  145780. */
  145781. SSAORenderEffect: string;
  145782. /**
  145783. * @ignore
  145784. * The horizontal blur PostProcess id in the pipeline
  145785. */
  145786. SSAOBlurHRenderEffect: string;
  145787. /**
  145788. * @ignore
  145789. * The vertical blur PostProcess id in the pipeline
  145790. */
  145791. SSAOBlurVRenderEffect: string;
  145792. /**
  145793. * @ignore
  145794. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  145795. */
  145796. SSAOCombineRenderEffect: string;
  145797. /**
  145798. * The output strength of the SSAO post-process. Default value is 1.0.
  145799. */
  145800. totalStrength: number;
  145801. /**
  145802. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  145803. */
  145804. maxZ: number;
  145805. /**
  145806. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  145807. */
  145808. minZAspect: number;
  145809. private _samples;
  145810. /**
  145811. * Number of samples used for the SSAO calculations. Default value is 8
  145812. */
  145813. set samples(n: number);
  145814. get samples(): number;
  145815. private _textureSamples;
  145816. /**
  145817. * Number of samples to use for antialiasing
  145818. */
  145819. set textureSamples(n: number);
  145820. get textureSamples(): number;
  145821. /**
  145822. * Ratio object used for SSAO ratio and blur ratio
  145823. */
  145824. private _ratio;
  145825. /**
  145826. * Dynamically generated sphere sampler.
  145827. */
  145828. private _sampleSphere;
  145829. /**
  145830. * Blur filter offsets
  145831. */
  145832. private _samplerOffsets;
  145833. private _expensiveBlur;
  145834. /**
  145835. * If bilateral blur should be used
  145836. */
  145837. set expensiveBlur(b: boolean);
  145838. get expensiveBlur(): boolean;
  145839. /**
  145840. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  145841. */
  145842. radius: number;
  145843. /**
  145844. * The base color of the SSAO post-process
  145845. * The final result is "base + ssao" between [0, 1]
  145846. */
  145847. base: number;
  145848. /**
  145849. * Support test.
  145850. */
  145851. static get IsSupported(): boolean;
  145852. private _scene;
  145853. private _depthTexture;
  145854. private _normalTexture;
  145855. private _randomTexture;
  145856. private _originalColorPostProcess;
  145857. private _ssaoPostProcess;
  145858. private _blurHPostProcess;
  145859. private _blurVPostProcess;
  145860. private _ssaoCombinePostProcess;
  145861. /**
  145862. * Gets active scene
  145863. */
  145864. get scene(): Scene;
  145865. /**
  145866. * @constructor
  145867. * @param name The rendering pipeline name
  145868. * @param scene The scene linked to this pipeline
  145869. * @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 }
  145870. * @param cameras The array of cameras that the rendering pipeline will be attached to
  145871. */
  145872. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  145873. /**
  145874. * Get the class name
  145875. * @returns "SSAO2RenderingPipeline"
  145876. */
  145877. getClassName(): string;
  145878. /**
  145879. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  145880. */
  145881. dispose(disableGeometryBufferRenderer?: boolean): void;
  145882. private _createBlurPostProcess;
  145883. /** @hidden */
  145884. _rebuild(): void;
  145885. private _bits;
  145886. private _radicalInverse_VdC;
  145887. private _hammersley;
  145888. private _hemisphereSample_uniform;
  145889. private _generateHemisphere;
  145890. private _createSSAOPostProcess;
  145891. private _createSSAOCombinePostProcess;
  145892. private _createRandomTexture;
  145893. /**
  145894. * Serialize the rendering pipeline (Used when exporting)
  145895. * @returns the serialized object
  145896. */
  145897. serialize(): any;
  145898. /**
  145899. * Parse the serialized pipeline
  145900. * @param source Source pipeline.
  145901. * @param scene The scene to load the pipeline to.
  145902. * @param rootUrl The URL of the serialized pipeline.
  145903. * @returns An instantiated pipeline from the serialized object.
  145904. */
  145905. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  145906. }
  145907. }
  145908. declare module BABYLON {
  145909. /** @hidden */
  145910. export var ssaoPixelShader: {
  145911. name: string;
  145912. shader: string;
  145913. };
  145914. }
  145915. declare module BABYLON {
  145916. /**
  145917. * Render pipeline to produce ssao effect
  145918. */
  145919. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  145920. /**
  145921. * @ignore
  145922. * The PassPostProcess id in the pipeline that contains the original scene color
  145923. */
  145924. SSAOOriginalSceneColorEffect: string;
  145925. /**
  145926. * @ignore
  145927. * The SSAO PostProcess id in the pipeline
  145928. */
  145929. SSAORenderEffect: string;
  145930. /**
  145931. * @ignore
  145932. * The horizontal blur PostProcess id in the pipeline
  145933. */
  145934. SSAOBlurHRenderEffect: string;
  145935. /**
  145936. * @ignore
  145937. * The vertical blur PostProcess id in the pipeline
  145938. */
  145939. SSAOBlurVRenderEffect: string;
  145940. /**
  145941. * @ignore
  145942. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  145943. */
  145944. SSAOCombineRenderEffect: string;
  145945. /**
  145946. * The output strength of the SSAO post-process. Default value is 1.0.
  145947. */
  145948. totalStrength: number;
  145949. /**
  145950. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  145951. */
  145952. radius: number;
  145953. /**
  145954. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  145955. * Must not be equal to fallOff and superior to fallOff.
  145956. * Default value is 0.0075
  145957. */
  145958. area: number;
  145959. /**
  145960. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  145961. * Must not be equal to area and inferior to area.
  145962. * Default value is 0.000001
  145963. */
  145964. fallOff: number;
  145965. /**
  145966. * The base color of the SSAO post-process
  145967. * The final result is "base + ssao" between [0, 1]
  145968. */
  145969. base: number;
  145970. private _scene;
  145971. private _depthTexture;
  145972. private _randomTexture;
  145973. private _originalColorPostProcess;
  145974. private _ssaoPostProcess;
  145975. private _blurHPostProcess;
  145976. private _blurVPostProcess;
  145977. private _ssaoCombinePostProcess;
  145978. private _firstUpdate;
  145979. /**
  145980. * Gets active scene
  145981. */
  145982. get scene(): Scene;
  145983. /**
  145984. * @constructor
  145985. * @param name - The rendering pipeline name
  145986. * @param scene - The scene linked to this pipeline
  145987. * @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 }
  145988. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  145989. */
  145990. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  145991. /**
  145992. * Get the class name
  145993. * @returns "SSAORenderingPipeline"
  145994. */
  145995. getClassName(): string;
  145996. /**
  145997. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  145998. */
  145999. dispose(disableDepthRender?: boolean): void;
  146000. private _createBlurPostProcess;
  146001. /** @hidden */
  146002. _rebuild(): void;
  146003. private _createSSAOPostProcess;
  146004. private _createSSAOCombinePostProcess;
  146005. private _createRandomTexture;
  146006. }
  146007. }
  146008. declare module BABYLON {
  146009. /** @hidden */
  146010. export var screenSpaceReflectionPixelShader: {
  146011. name: string;
  146012. shader: string;
  146013. };
  146014. }
  146015. declare module BABYLON {
  146016. /**
  146017. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  146018. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  146019. */
  146020. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  146021. /**
  146022. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  146023. */
  146024. threshold: number;
  146025. /**
  146026. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  146027. */
  146028. strength: number;
  146029. /**
  146030. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  146031. */
  146032. reflectionSpecularFalloffExponent: number;
  146033. /**
  146034. * 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]
  146035. */
  146036. step: number;
  146037. /**
  146038. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  146039. */
  146040. roughnessFactor: number;
  146041. private _geometryBufferRenderer;
  146042. private _enableSmoothReflections;
  146043. private _reflectionSamples;
  146044. private _smoothSteps;
  146045. /**
  146046. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  146047. * @param name The name of the effect.
  146048. * @param scene The scene containing the objects to calculate reflections.
  146049. * @param options The required width/height ratio to downsize to before computing the render pass.
  146050. * @param camera The camera to apply the render pass to.
  146051. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  146052. * @param engine The engine which the post process will be applied. (default: current engine)
  146053. * @param reusable If the post process can be reused on the same frame. (default: false)
  146054. * @param textureType Type of textures used when performing the post process. (default: 0)
  146055. * @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)
  146056. */
  146057. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  146058. /**
  146059. * Gets wether or not smoothing reflections is enabled.
  146060. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  146061. */
  146062. get enableSmoothReflections(): boolean;
  146063. /**
  146064. * Sets wether or not smoothing reflections is enabled.
  146065. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  146066. */
  146067. set enableSmoothReflections(enabled: boolean);
  146068. /**
  146069. * Gets the number of samples taken while computing reflections. More samples count is high,
  146070. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  146071. */
  146072. get reflectionSamples(): number;
  146073. /**
  146074. * Sets the number of samples taken while computing reflections. More samples count is high,
  146075. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  146076. */
  146077. set reflectionSamples(samples: number);
  146078. /**
  146079. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  146080. * more the post-process will require GPU power and can generate a drop in FPS.
  146081. * Default value (5.0) work pretty well in all cases but can be adjusted.
  146082. */
  146083. get smoothSteps(): number;
  146084. set smoothSteps(steps: number);
  146085. private _updateEffectDefines;
  146086. }
  146087. }
  146088. declare module BABYLON {
  146089. /** @hidden */
  146090. export var standardPixelShader: {
  146091. name: string;
  146092. shader: string;
  146093. };
  146094. }
  146095. declare module BABYLON {
  146096. /**
  146097. * Standard rendering pipeline
  146098. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  146099. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  146100. */
  146101. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  146102. /**
  146103. * Public members
  146104. */
  146105. /**
  146106. * Post-process which contains the original scene color before the pipeline applies all the effects
  146107. */
  146108. originalPostProcess: Nullable<PostProcess>;
  146109. /**
  146110. * Post-process used to down scale an image x4
  146111. */
  146112. downSampleX4PostProcess: Nullable<PostProcess>;
  146113. /**
  146114. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  146115. */
  146116. brightPassPostProcess: Nullable<PostProcess>;
  146117. /**
  146118. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  146119. */
  146120. blurHPostProcesses: PostProcess[];
  146121. /**
  146122. * Post-process array storing all the vertical blur post-processes used by the pipeline
  146123. */
  146124. blurVPostProcesses: PostProcess[];
  146125. /**
  146126. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  146127. */
  146128. textureAdderPostProcess: Nullable<PostProcess>;
  146129. /**
  146130. * Post-process used to create volumetric lighting effect
  146131. */
  146132. volumetricLightPostProcess: Nullable<PostProcess>;
  146133. /**
  146134. * Post-process used to smooth the previous volumetric light post-process on the X axis
  146135. */
  146136. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  146137. /**
  146138. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  146139. */
  146140. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  146141. /**
  146142. * Post-process used to merge the volumetric light effect and the real scene color
  146143. */
  146144. volumetricLightMergePostProces: Nullable<PostProcess>;
  146145. /**
  146146. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  146147. */
  146148. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  146149. /**
  146150. * Base post-process used to calculate the average luminance of the final image for HDR
  146151. */
  146152. luminancePostProcess: Nullable<PostProcess>;
  146153. /**
  146154. * Post-processes used to create down sample post-processes in order to get
  146155. * the average luminance of the final image for HDR
  146156. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  146157. */
  146158. luminanceDownSamplePostProcesses: PostProcess[];
  146159. /**
  146160. * Post-process used to create a HDR effect (light adaptation)
  146161. */
  146162. hdrPostProcess: Nullable<PostProcess>;
  146163. /**
  146164. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  146165. */
  146166. textureAdderFinalPostProcess: Nullable<PostProcess>;
  146167. /**
  146168. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  146169. */
  146170. lensFlareFinalPostProcess: Nullable<PostProcess>;
  146171. /**
  146172. * Post-process used to merge the final HDR post-process and the real scene color
  146173. */
  146174. hdrFinalPostProcess: Nullable<PostProcess>;
  146175. /**
  146176. * Post-process used to create a lens flare effect
  146177. */
  146178. lensFlarePostProcess: Nullable<PostProcess>;
  146179. /**
  146180. * Post-process that merges the result of the lens flare post-process and the real scene color
  146181. */
  146182. lensFlareComposePostProcess: Nullable<PostProcess>;
  146183. /**
  146184. * Post-process used to create a motion blur effect
  146185. */
  146186. motionBlurPostProcess: Nullable<PostProcess>;
  146187. /**
  146188. * Post-process used to create a depth of field effect
  146189. */
  146190. depthOfFieldPostProcess: Nullable<PostProcess>;
  146191. /**
  146192. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  146193. */
  146194. fxaaPostProcess: Nullable<FxaaPostProcess>;
  146195. /**
  146196. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  146197. */
  146198. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  146199. /**
  146200. * Represents the brightness threshold in order to configure the illuminated surfaces
  146201. */
  146202. brightThreshold: number;
  146203. /**
  146204. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  146205. */
  146206. blurWidth: number;
  146207. /**
  146208. * Sets if the blur for highlighted surfaces must be only horizontal
  146209. */
  146210. horizontalBlur: boolean;
  146211. /**
  146212. * Gets the overall exposure used by the pipeline
  146213. */
  146214. get exposure(): number;
  146215. /**
  146216. * Sets the overall exposure used by the pipeline
  146217. */
  146218. set exposure(value: number);
  146219. /**
  146220. * Texture used typically to simulate "dirty" on camera lens
  146221. */
  146222. lensTexture: Nullable<Texture>;
  146223. /**
  146224. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  146225. */
  146226. volumetricLightCoefficient: number;
  146227. /**
  146228. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  146229. */
  146230. volumetricLightPower: number;
  146231. /**
  146232. * Used the set the blur intensity to smooth the volumetric lights
  146233. */
  146234. volumetricLightBlurScale: number;
  146235. /**
  146236. * Light (spot or directional) used to generate the volumetric lights rays
  146237. * The source light must have a shadow generate so the pipeline can get its
  146238. * depth map
  146239. */
  146240. sourceLight: Nullable<SpotLight | DirectionalLight>;
  146241. /**
  146242. * For eye adaptation, represents the minimum luminance the eye can see
  146243. */
  146244. hdrMinimumLuminance: number;
  146245. /**
  146246. * For eye adaptation, represents the decrease luminance speed
  146247. */
  146248. hdrDecreaseRate: number;
  146249. /**
  146250. * For eye adaptation, represents the increase luminance speed
  146251. */
  146252. hdrIncreaseRate: number;
  146253. /**
  146254. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  146255. */
  146256. get hdrAutoExposure(): boolean;
  146257. /**
  146258. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  146259. */
  146260. set hdrAutoExposure(value: boolean);
  146261. /**
  146262. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  146263. */
  146264. lensColorTexture: Nullable<Texture>;
  146265. /**
  146266. * The overall strengh for the lens flare effect
  146267. */
  146268. lensFlareStrength: number;
  146269. /**
  146270. * Dispersion coefficient for lens flare ghosts
  146271. */
  146272. lensFlareGhostDispersal: number;
  146273. /**
  146274. * Main lens flare halo width
  146275. */
  146276. lensFlareHaloWidth: number;
  146277. /**
  146278. * Based on the lens distortion effect, defines how much the lens flare result
  146279. * is distorted
  146280. */
  146281. lensFlareDistortionStrength: number;
  146282. /**
  146283. * Configures the blur intensity used for for lens flare (halo)
  146284. */
  146285. lensFlareBlurWidth: number;
  146286. /**
  146287. * Lens star texture must be used to simulate rays on the flares and is available
  146288. * in the documentation
  146289. */
  146290. lensStarTexture: Nullable<Texture>;
  146291. /**
  146292. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  146293. * flare effect by taking account of the dirt texture
  146294. */
  146295. lensFlareDirtTexture: Nullable<Texture>;
  146296. /**
  146297. * Represents the focal length for the depth of field effect
  146298. */
  146299. depthOfFieldDistance: number;
  146300. /**
  146301. * Represents the blur intensity for the blurred part of the depth of field effect
  146302. */
  146303. depthOfFieldBlurWidth: number;
  146304. /**
  146305. * Gets how much the image is blurred by the movement while using the motion blur post-process
  146306. */
  146307. get motionStrength(): number;
  146308. /**
  146309. * Sets how much the image is blurred by the movement while using the motion blur post-process
  146310. */
  146311. set motionStrength(strength: number);
  146312. /**
  146313. * Gets wether or not the motion blur post-process is object based or screen based.
  146314. */
  146315. get objectBasedMotionBlur(): boolean;
  146316. /**
  146317. * Sets wether or not the motion blur post-process should be object based or screen based
  146318. */
  146319. set objectBasedMotionBlur(value: boolean);
  146320. /**
  146321. * List of animations for the pipeline (IAnimatable implementation)
  146322. */
  146323. animations: Animation[];
  146324. /**
  146325. * Private members
  146326. */
  146327. private _scene;
  146328. private _currentDepthOfFieldSource;
  146329. private _basePostProcess;
  146330. private _fixedExposure;
  146331. private _currentExposure;
  146332. private _hdrAutoExposure;
  146333. private _hdrCurrentLuminance;
  146334. private _motionStrength;
  146335. private _isObjectBasedMotionBlur;
  146336. private _floatTextureType;
  146337. private _camerasToBeAttached;
  146338. private _ratio;
  146339. private _bloomEnabled;
  146340. private _depthOfFieldEnabled;
  146341. private _vlsEnabled;
  146342. private _lensFlareEnabled;
  146343. private _hdrEnabled;
  146344. private _motionBlurEnabled;
  146345. private _fxaaEnabled;
  146346. private _screenSpaceReflectionsEnabled;
  146347. private _motionBlurSamples;
  146348. private _volumetricLightStepsCount;
  146349. private _samples;
  146350. /**
  146351. * @ignore
  146352. * Specifies if the bloom pipeline is enabled
  146353. */
  146354. get BloomEnabled(): boolean;
  146355. set BloomEnabled(enabled: boolean);
  146356. /**
  146357. * @ignore
  146358. * Specifies if the depth of field pipeline is enabed
  146359. */
  146360. get DepthOfFieldEnabled(): boolean;
  146361. set DepthOfFieldEnabled(enabled: boolean);
  146362. /**
  146363. * @ignore
  146364. * Specifies if the lens flare pipeline is enabed
  146365. */
  146366. get LensFlareEnabled(): boolean;
  146367. set LensFlareEnabled(enabled: boolean);
  146368. /**
  146369. * @ignore
  146370. * Specifies if the HDR pipeline is enabled
  146371. */
  146372. get HDREnabled(): boolean;
  146373. set HDREnabled(enabled: boolean);
  146374. /**
  146375. * @ignore
  146376. * Specifies if the volumetric lights scattering effect is enabled
  146377. */
  146378. get VLSEnabled(): boolean;
  146379. set VLSEnabled(enabled: boolean);
  146380. /**
  146381. * @ignore
  146382. * Specifies if the motion blur effect is enabled
  146383. */
  146384. get MotionBlurEnabled(): boolean;
  146385. set MotionBlurEnabled(enabled: boolean);
  146386. /**
  146387. * Specifies if anti-aliasing is enabled
  146388. */
  146389. get fxaaEnabled(): boolean;
  146390. set fxaaEnabled(enabled: boolean);
  146391. /**
  146392. * Specifies if screen space reflections are enabled.
  146393. */
  146394. get screenSpaceReflectionsEnabled(): boolean;
  146395. set screenSpaceReflectionsEnabled(enabled: boolean);
  146396. /**
  146397. * Specifies the number of steps used to calculate the volumetric lights
  146398. * Typically in interval [50, 200]
  146399. */
  146400. get volumetricLightStepsCount(): number;
  146401. set volumetricLightStepsCount(count: number);
  146402. /**
  146403. * Specifies the number of samples used for the motion blur effect
  146404. * Typically in interval [16, 64]
  146405. */
  146406. get motionBlurSamples(): number;
  146407. set motionBlurSamples(samples: number);
  146408. /**
  146409. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  146410. */
  146411. get samples(): number;
  146412. set samples(sampleCount: number);
  146413. /**
  146414. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  146415. * @constructor
  146416. * @param name The rendering pipeline name
  146417. * @param scene The scene linked to this pipeline
  146418. * @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)
  146419. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  146420. * @param cameras The array of cameras that the rendering pipeline will be attached to
  146421. */
  146422. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  146423. private _buildPipeline;
  146424. private _createDownSampleX4PostProcess;
  146425. private _createBrightPassPostProcess;
  146426. private _createBlurPostProcesses;
  146427. private _createTextureAdderPostProcess;
  146428. private _createVolumetricLightPostProcess;
  146429. private _createLuminancePostProcesses;
  146430. private _createHdrPostProcess;
  146431. private _createLensFlarePostProcess;
  146432. private _createDepthOfFieldPostProcess;
  146433. private _createMotionBlurPostProcess;
  146434. private _getDepthTexture;
  146435. private _disposePostProcesses;
  146436. /**
  146437. * Dispose of the pipeline and stop all post processes
  146438. */
  146439. dispose(): void;
  146440. /**
  146441. * Serialize the rendering pipeline (Used when exporting)
  146442. * @returns the serialized object
  146443. */
  146444. serialize(): any;
  146445. /**
  146446. * Parse the serialized pipeline
  146447. * @param source Source pipeline.
  146448. * @param scene The scene to load the pipeline to.
  146449. * @param rootUrl The URL of the serialized pipeline.
  146450. * @returns An instantiated pipeline from the serialized object.
  146451. */
  146452. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  146453. /**
  146454. * Luminance steps
  146455. */
  146456. static LuminanceSteps: number;
  146457. }
  146458. }
  146459. declare module BABYLON {
  146460. /** @hidden */
  146461. export var stereoscopicInterlacePixelShader: {
  146462. name: string;
  146463. shader: string;
  146464. };
  146465. }
  146466. declare module BABYLON {
  146467. /**
  146468. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  146469. */
  146470. export class StereoscopicInterlacePostProcessI extends PostProcess {
  146471. private _stepSize;
  146472. private _passedProcess;
  146473. /**
  146474. * Initializes a StereoscopicInterlacePostProcessI
  146475. * @param name The name of the effect.
  146476. * @param rigCameras The rig cameras to be appled to the post process
  146477. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  146478. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  146479. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  146480. * @param engine The engine which the post process will be applied. (default: current engine)
  146481. * @param reusable If the post process can be reused on the same frame. (default: false)
  146482. */
  146483. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  146484. }
  146485. /**
  146486. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  146487. */
  146488. export class StereoscopicInterlacePostProcess extends PostProcess {
  146489. private _stepSize;
  146490. private _passedProcess;
  146491. /**
  146492. * Initializes a StereoscopicInterlacePostProcess
  146493. * @param name The name of the effect.
  146494. * @param rigCameras The rig cameras to be appled to the post process
  146495. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  146496. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  146497. * @param engine The engine which the post process will be applied. (default: current engine)
  146498. * @param reusable If the post process can be reused on the same frame. (default: false)
  146499. */
  146500. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  146501. }
  146502. }
  146503. declare module BABYLON {
  146504. /** @hidden */
  146505. export var tonemapPixelShader: {
  146506. name: string;
  146507. shader: string;
  146508. };
  146509. }
  146510. declare module BABYLON {
  146511. /** Defines operator used for tonemapping */
  146512. export enum TonemappingOperator {
  146513. /** Hable */
  146514. Hable = 0,
  146515. /** Reinhard */
  146516. Reinhard = 1,
  146517. /** HejiDawson */
  146518. HejiDawson = 2,
  146519. /** Photographic */
  146520. Photographic = 3
  146521. }
  146522. /**
  146523. * Defines a post process to apply tone mapping
  146524. */
  146525. export class TonemapPostProcess extends PostProcess {
  146526. private _operator;
  146527. /** Defines the required exposure adjustement */
  146528. exposureAdjustment: number;
  146529. /**
  146530. * Creates a new TonemapPostProcess
  146531. * @param name defines the name of the postprocess
  146532. * @param _operator defines the operator to use
  146533. * @param exposureAdjustment defines the required exposure adjustement
  146534. * @param camera defines the camera to use (can be null)
  146535. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  146536. * @param engine defines the hosting engine (can be ignore if camera is set)
  146537. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  146538. */
  146539. constructor(name: string, _operator: TonemappingOperator,
  146540. /** Defines the required exposure adjustement */
  146541. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  146542. }
  146543. }
  146544. declare module BABYLON {
  146545. /** @hidden */
  146546. export var volumetricLightScatteringPixelShader: {
  146547. name: string;
  146548. shader: string;
  146549. };
  146550. }
  146551. declare module BABYLON {
  146552. /** @hidden */
  146553. export var volumetricLightScatteringPassVertexShader: {
  146554. name: string;
  146555. shader: string;
  146556. };
  146557. }
  146558. declare module BABYLON {
  146559. /** @hidden */
  146560. export var volumetricLightScatteringPassPixelShader: {
  146561. name: string;
  146562. shader: string;
  146563. };
  146564. }
  146565. declare module BABYLON {
  146566. /**
  146567. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  146568. */
  146569. export class VolumetricLightScatteringPostProcess extends PostProcess {
  146570. private _volumetricLightScatteringPass;
  146571. private _volumetricLightScatteringRTT;
  146572. private _viewPort;
  146573. private _screenCoordinates;
  146574. private _cachedDefines;
  146575. /**
  146576. * If not undefined, the mesh position is computed from the attached node position
  146577. */
  146578. attachedNode: {
  146579. position: Vector3;
  146580. };
  146581. /**
  146582. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  146583. */
  146584. customMeshPosition: Vector3;
  146585. /**
  146586. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  146587. */
  146588. useCustomMeshPosition: boolean;
  146589. /**
  146590. * If the post-process should inverse the light scattering direction
  146591. */
  146592. invert: boolean;
  146593. /**
  146594. * The internal mesh used by the post-process
  146595. */
  146596. mesh: Mesh;
  146597. /**
  146598. * @hidden
  146599. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  146600. */
  146601. get useDiffuseColor(): boolean;
  146602. set useDiffuseColor(useDiffuseColor: boolean);
  146603. /**
  146604. * Array containing the excluded meshes not rendered in the internal pass
  146605. */
  146606. excludedMeshes: AbstractMesh[];
  146607. /**
  146608. * Controls the overall intensity of the post-process
  146609. */
  146610. exposure: number;
  146611. /**
  146612. * Dissipates each sample's contribution in range [0, 1]
  146613. */
  146614. decay: number;
  146615. /**
  146616. * Controls the overall intensity of each sample
  146617. */
  146618. weight: number;
  146619. /**
  146620. * Controls the density of each sample
  146621. */
  146622. density: number;
  146623. /**
  146624. * @constructor
  146625. * @param name The post-process name
  146626. * @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)
  146627. * @param camera The camera that the post-process will be attached to
  146628. * @param mesh The mesh used to create the light scattering
  146629. * @param samples The post-process quality, default 100
  146630. * @param samplingModeThe post-process filtering mode
  146631. * @param engine The babylon engine
  146632. * @param reusable If the post-process is reusable
  146633. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  146634. */
  146635. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  146636. /**
  146637. * Returns the string "VolumetricLightScatteringPostProcess"
  146638. * @returns "VolumetricLightScatteringPostProcess"
  146639. */
  146640. getClassName(): string;
  146641. private _isReady;
  146642. /**
  146643. * Sets the new light position for light scattering effect
  146644. * @param position The new custom light position
  146645. */
  146646. setCustomMeshPosition(position: Vector3): void;
  146647. /**
  146648. * Returns the light position for light scattering effect
  146649. * @return Vector3 The custom light position
  146650. */
  146651. getCustomMeshPosition(): Vector3;
  146652. /**
  146653. * Disposes the internal assets and detaches the post-process from the camera
  146654. */
  146655. dispose(camera: Camera): void;
  146656. /**
  146657. * Returns the render target texture used by the post-process
  146658. * @return the render target texture used by the post-process
  146659. */
  146660. getPass(): RenderTargetTexture;
  146661. private _meshExcluded;
  146662. private _createPass;
  146663. private _updateMeshScreenCoordinates;
  146664. /**
  146665. * Creates a default mesh for the Volumeric Light Scattering post-process
  146666. * @param name The mesh name
  146667. * @param scene The scene where to create the mesh
  146668. * @return the default mesh
  146669. */
  146670. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  146671. }
  146672. }
  146673. declare module BABYLON {
  146674. interface Scene {
  146675. /** @hidden (Backing field) */
  146676. _boundingBoxRenderer: BoundingBoxRenderer;
  146677. /** @hidden (Backing field) */
  146678. _forceShowBoundingBoxes: boolean;
  146679. /**
  146680. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  146681. */
  146682. forceShowBoundingBoxes: boolean;
  146683. /**
  146684. * Gets the bounding box renderer associated with the scene
  146685. * @returns a BoundingBoxRenderer
  146686. */
  146687. getBoundingBoxRenderer(): BoundingBoxRenderer;
  146688. }
  146689. interface AbstractMesh {
  146690. /** @hidden (Backing field) */
  146691. _showBoundingBox: boolean;
  146692. /**
  146693. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  146694. */
  146695. showBoundingBox: boolean;
  146696. }
  146697. /**
  146698. * Component responsible of rendering the bounding box of the meshes in a scene.
  146699. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  146700. */
  146701. export class BoundingBoxRenderer implements ISceneComponent {
  146702. /**
  146703. * The component name helpfull to identify the component in the list of scene components.
  146704. */
  146705. readonly name: string;
  146706. /**
  146707. * The scene the component belongs to.
  146708. */
  146709. scene: Scene;
  146710. /**
  146711. * Color of the bounding box lines placed in front of an object
  146712. */
  146713. frontColor: Color3;
  146714. /**
  146715. * Color of the bounding box lines placed behind an object
  146716. */
  146717. backColor: Color3;
  146718. /**
  146719. * Defines if the renderer should show the back lines or not
  146720. */
  146721. showBackLines: boolean;
  146722. /**
  146723. * Observable raised before rendering a bounding box
  146724. */
  146725. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  146726. /**
  146727. * Observable raised after rendering a bounding box
  146728. */
  146729. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  146730. /**
  146731. * @hidden
  146732. */
  146733. renderList: SmartArray<BoundingBox>;
  146734. private _colorShader;
  146735. private _vertexBuffers;
  146736. private _indexBuffer;
  146737. private _fillIndexBuffer;
  146738. private _fillIndexData;
  146739. /**
  146740. * Instantiates a new bounding box renderer in a scene.
  146741. * @param scene the scene the renderer renders in
  146742. */
  146743. constructor(scene: Scene);
  146744. /**
  146745. * Registers the component in a given scene
  146746. */
  146747. register(): void;
  146748. private _evaluateSubMesh;
  146749. private _activeMesh;
  146750. private _prepareRessources;
  146751. private _createIndexBuffer;
  146752. /**
  146753. * Rebuilds the elements related to this component in case of
  146754. * context lost for instance.
  146755. */
  146756. rebuild(): void;
  146757. /**
  146758. * @hidden
  146759. */
  146760. reset(): void;
  146761. /**
  146762. * Render the bounding boxes of a specific rendering group
  146763. * @param renderingGroupId defines the rendering group to render
  146764. */
  146765. render(renderingGroupId: number): void;
  146766. /**
  146767. * In case of occlusion queries, we can render the occlusion bounding box through this method
  146768. * @param mesh Define the mesh to render the occlusion bounding box for
  146769. */
  146770. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  146771. /**
  146772. * Dispose and release the resources attached to this renderer.
  146773. */
  146774. dispose(): void;
  146775. }
  146776. }
  146777. declare module BABYLON {
  146778. interface Scene {
  146779. /** @hidden (Backing field) */
  146780. _depthRenderer: {
  146781. [id: string]: DepthRenderer;
  146782. };
  146783. /**
  146784. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  146785. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  146786. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  146787. * @returns the created depth renderer
  146788. */
  146789. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  146790. /**
  146791. * Disables a depth renderer for a given camera
  146792. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  146793. */
  146794. disableDepthRenderer(camera?: Nullable<Camera>): void;
  146795. }
  146796. /**
  146797. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  146798. * in several rendering techniques.
  146799. */
  146800. export class DepthRendererSceneComponent implements ISceneComponent {
  146801. /**
  146802. * The component name helpfull to identify the component in the list of scene components.
  146803. */
  146804. readonly name: string;
  146805. /**
  146806. * The scene the component belongs to.
  146807. */
  146808. scene: Scene;
  146809. /**
  146810. * Creates a new instance of the component for the given scene
  146811. * @param scene Defines the scene to register the component in
  146812. */
  146813. constructor(scene: Scene);
  146814. /**
  146815. * Registers the component in a given scene
  146816. */
  146817. register(): void;
  146818. /**
  146819. * Rebuilds the elements related to this component in case of
  146820. * context lost for instance.
  146821. */
  146822. rebuild(): void;
  146823. /**
  146824. * Disposes the component and the associated ressources
  146825. */
  146826. dispose(): void;
  146827. private _gatherRenderTargets;
  146828. private _gatherActiveCameraRenderTargets;
  146829. }
  146830. }
  146831. declare module BABYLON {
  146832. /** @hidden */
  146833. export var outlinePixelShader: {
  146834. name: string;
  146835. shader: string;
  146836. };
  146837. }
  146838. declare module BABYLON {
  146839. /** @hidden */
  146840. export var outlineVertexShader: {
  146841. name: string;
  146842. shader: string;
  146843. };
  146844. }
  146845. declare module BABYLON {
  146846. interface Scene {
  146847. /** @hidden */
  146848. _outlineRenderer: OutlineRenderer;
  146849. /**
  146850. * Gets the outline renderer associated with the scene
  146851. * @returns a OutlineRenderer
  146852. */
  146853. getOutlineRenderer(): OutlineRenderer;
  146854. }
  146855. interface AbstractMesh {
  146856. /** @hidden (Backing field) */
  146857. _renderOutline: boolean;
  146858. /**
  146859. * Gets or sets a boolean indicating if the outline must be rendered as well
  146860. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  146861. */
  146862. renderOutline: boolean;
  146863. /** @hidden (Backing field) */
  146864. _renderOverlay: boolean;
  146865. /**
  146866. * Gets or sets a boolean indicating if the overlay must be rendered as well
  146867. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  146868. */
  146869. renderOverlay: boolean;
  146870. }
  146871. /**
  146872. * This class is responsible to draw bothe outline/overlay of meshes.
  146873. * It should not be used directly but through the available method on mesh.
  146874. */
  146875. export class OutlineRenderer implements ISceneComponent {
  146876. /**
  146877. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  146878. */
  146879. private static _StencilReference;
  146880. /**
  146881. * The name of the component. Each component must have a unique name.
  146882. */
  146883. name: string;
  146884. /**
  146885. * The scene the component belongs to.
  146886. */
  146887. scene: Scene;
  146888. /**
  146889. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  146890. */
  146891. zOffset: number;
  146892. private _engine;
  146893. private _effect;
  146894. private _cachedDefines;
  146895. private _savedDepthWrite;
  146896. /**
  146897. * Instantiates a new outline renderer. (There could be only one per scene).
  146898. * @param scene Defines the scene it belongs to
  146899. */
  146900. constructor(scene: Scene);
  146901. /**
  146902. * Register the component to one instance of a scene.
  146903. */
  146904. register(): void;
  146905. /**
  146906. * Rebuilds the elements related to this component in case of
  146907. * context lost for instance.
  146908. */
  146909. rebuild(): void;
  146910. /**
  146911. * Disposes the component and the associated ressources.
  146912. */
  146913. dispose(): void;
  146914. /**
  146915. * Renders the outline in the canvas.
  146916. * @param subMesh Defines the sumesh to render
  146917. * @param batch Defines the batch of meshes in case of instances
  146918. * @param useOverlay Defines if the rendering is for the overlay or the outline
  146919. */
  146920. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  146921. /**
  146922. * Returns whether or not the outline renderer is ready for a given submesh.
  146923. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  146924. * @param subMesh Defines the submesh to check readyness for
  146925. * @param useInstances Defines wheter wee are trying to render instances or not
  146926. * @returns true if ready otherwise false
  146927. */
  146928. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  146929. private _beforeRenderingMesh;
  146930. private _afterRenderingMesh;
  146931. }
  146932. }
  146933. declare module BABYLON {
  146934. /**
  146935. * Defines the basic options interface of a Sprite Frame Source Size.
  146936. */
  146937. export interface ISpriteJSONSpriteSourceSize {
  146938. /**
  146939. * number of the original width of the Frame
  146940. */
  146941. w: number;
  146942. /**
  146943. * number of the original height of the Frame
  146944. */
  146945. h: number;
  146946. }
  146947. /**
  146948. * Defines the basic options interface of a Sprite Frame Data.
  146949. */
  146950. export interface ISpriteJSONSpriteFrameData {
  146951. /**
  146952. * number of the x offset of the Frame
  146953. */
  146954. x: number;
  146955. /**
  146956. * number of the y offset of the Frame
  146957. */
  146958. y: number;
  146959. /**
  146960. * number of the width of the Frame
  146961. */
  146962. w: number;
  146963. /**
  146964. * number of the height of the Frame
  146965. */
  146966. h: number;
  146967. }
  146968. /**
  146969. * Defines the basic options interface of a JSON Sprite.
  146970. */
  146971. export interface ISpriteJSONSprite {
  146972. /**
  146973. * string name of the Frame
  146974. */
  146975. filename: string;
  146976. /**
  146977. * ISpriteJSONSpriteFrame basic object of the frame data
  146978. */
  146979. frame: ISpriteJSONSpriteFrameData;
  146980. /**
  146981. * boolean to flag is the frame was rotated.
  146982. */
  146983. rotated: boolean;
  146984. /**
  146985. * boolean to flag is the frame was trimmed.
  146986. */
  146987. trimmed: boolean;
  146988. /**
  146989. * ISpriteJSONSpriteFrame basic object of the source data
  146990. */
  146991. spriteSourceSize: ISpriteJSONSpriteFrameData;
  146992. /**
  146993. * ISpriteJSONSpriteFrame basic object of the source data
  146994. */
  146995. sourceSize: ISpriteJSONSpriteSourceSize;
  146996. }
  146997. /**
  146998. * Defines the basic options interface of a JSON atlas.
  146999. */
  147000. export interface ISpriteJSONAtlas {
  147001. /**
  147002. * Array of objects that contain the frame data.
  147003. */
  147004. frames: Array<ISpriteJSONSprite>;
  147005. /**
  147006. * object basic object containing the sprite meta data.
  147007. */
  147008. meta?: object;
  147009. }
  147010. }
  147011. declare module BABYLON {
  147012. /** @hidden */
  147013. export var spriteMapPixelShader: {
  147014. name: string;
  147015. shader: string;
  147016. };
  147017. }
  147018. declare module BABYLON {
  147019. /** @hidden */
  147020. export var spriteMapVertexShader: {
  147021. name: string;
  147022. shader: string;
  147023. };
  147024. }
  147025. declare module BABYLON {
  147026. /**
  147027. * Defines the basic options interface of a SpriteMap
  147028. */
  147029. export interface ISpriteMapOptions {
  147030. /**
  147031. * Vector2 of the number of cells in the grid.
  147032. */
  147033. stageSize?: Vector2;
  147034. /**
  147035. * Vector2 of the size of the output plane in World Units.
  147036. */
  147037. outputSize?: Vector2;
  147038. /**
  147039. * Vector3 of the position of the output plane in World Units.
  147040. */
  147041. outputPosition?: Vector3;
  147042. /**
  147043. * Vector3 of the rotation of the output plane.
  147044. */
  147045. outputRotation?: Vector3;
  147046. /**
  147047. * number of layers that the system will reserve in resources.
  147048. */
  147049. layerCount?: number;
  147050. /**
  147051. * number of max animation frames a single cell will reserve in resources.
  147052. */
  147053. maxAnimationFrames?: number;
  147054. /**
  147055. * number cell index of the base tile when the system compiles.
  147056. */
  147057. baseTile?: number;
  147058. /**
  147059. * boolean flip the sprite after its been repositioned by the framing data.
  147060. */
  147061. flipU?: boolean;
  147062. /**
  147063. * Vector3 scalar of the global RGB values of the SpriteMap.
  147064. */
  147065. colorMultiply?: Vector3;
  147066. }
  147067. /**
  147068. * Defines the IDisposable interface in order to be cleanable from resources.
  147069. */
  147070. export interface ISpriteMap extends IDisposable {
  147071. /**
  147072. * String name of the SpriteMap.
  147073. */
  147074. name: string;
  147075. /**
  147076. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  147077. */
  147078. atlasJSON: ISpriteJSONAtlas;
  147079. /**
  147080. * Texture of the SpriteMap.
  147081. */
  147082. spriteSheet: Texture;
  147083. /**
  147084. * The parameters to initialize the SpriteMap with.
  147085. */
  147086. options: ISpriteMapOptions;
  147087. }
  147088. /**
  147089. * Class used to manage a grid restricted sprite deployment on an Output plane.
  147090. */
  147091. export class SpriteMap implements ISpriteMap {
  147092. /** The Name of the spriteMap */
  147093. name: string;
  147094. /** The JSON file with the frame and meta data */
  147095. atlasJSON: ISpriteJSONAtlas;
  147096. /** The systems Sprite Sheet Texture */
  147097. spriteSheet: Texture;
  147098. /** Arguments passed with the Constructor */
  147099. options: ISpriteMapOptions;
  147100. /** Public Sprite Storage array, parsed from atlasJSON */
  147101. sprites: Array<ISpriteJSONSprite>;
  147102. /** Returns the Number of Sprites in the System */
  147103. get spriteCount(): number;
  147104. /** Returns the Position of Output Plane*/
  147105. get position(): Vector3;
  147106. /** Returns the Position of Output Plane*/
  147107. set position(v: Vector3);
  147108. /** Returns the Rotation of Output Plane*/
  147109. get rotation(): Vector3;
  147110. /** Returns the Rotation of Output Plane*/
  147111. set rotation(v: Vector3);
  147112. /** Sets the AnimationMap*/
  147113. get animationMap(): RawTexture;
  147114. /** Sets the AnimationMap*/
  147115. set animationMap(v: RawTexture);
  147116. /** Scene that the SpriteMap was created in */
  147117. private _scene;
  147118. /** Texture Buffer of Float32 that holds tile frame data*/
  147119. private _frameMap;
  147120. /** Texture Buffers of Float32 that holds tileMap data*/
  147121. private _tileMaps;
  147122. /** Texture Buffer of Float32 that holds Animation Data*/
  147123. private _animationMap;
  147124. /** Custom ShaderMaterial Central to the System*/
  147125. private _material;
  147126. /** Custom ShaderMaterial Central to the System*/
  147127. private _output;
  147128. /** Systems Time Ticker*/
  147129. private _time;
  147130. /**
  147131. * Creates a new SpriteMap
  147132. * @param name defines the SpriteMaps Name
  147133. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  147134. * @param spriteSheet is the Texture that the Sprites are on.
  147135. * @param options a basic deployment configuration
  147136. * @param scene The Scene that the map is deployed on
  147137. */
  147138. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  147139. /**
  147140. * Returns tileID location
  147141. * @returns Vector2 the cell position ID
  147142. */
  147143. getTileID(): Vector2;
  147144. /**
  147145. * Gets the UV location of the mouse over the SpriteMap.
  147146. * @returns Vector2 the UV position of the mouse interaction
  147147. */
  147148. getMousePosition(): Vector2;
  147149. /**
  147150. * Creates the "frame" texture Buffer
  147151. * -------------------------------------
  147152. * Structure of frames
  147153. * "filename": "Falling-Water-2.png",
  147154. * "frame": {"x":69,"y":103,"w":24,"h":32},
  147155. * "rotated": true,
  147156. * "trimmed": true,
  147157. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  147158. * "sourceSize": {"w":32,"h":32}
  147159. * @returns RawTexture of the frameMap
  147160. */
  147161. private _createFrameBuffer;
  147162. /**
  147163. * Creates the tileMap texture Buffer
  147164. * @param buffer normally and array of numbers, or a false to generate from scratch
  147165. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  147166. * @returns RawTexture of the tileMap
  147167. */
  147168. private _createTileBuffer;
  147169. /**
  147170. * Modifies the data of the tileMaps
  147171. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  147172. * @param pos is the iVector2 Coordinates of the Tile
  147173. * @param tile The SpriteIndex of the new Tile
  147174. */
  147175. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  147176. /**
  147177. * Creates the animationMap texture Buffer
  147178. * @param buffer normally and array of numbers, or a false to generate from scratch
  147179. * @returns RawTexture of the animationMap
  147180. */
  147181. private _createTileAnimationBuffer;
  147182. /**
  147183. * Modifies the data of the animationMap
  147184. * @param cellID is the Index of the Sprite
  147185. * @param _frame is the target Animation frame
  147186. * @param toCell is the Target Index of the next frame of the animation
  147187. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  147188. * @param speed is a global scalar of the time variable on the map.
  147189. */
  147190. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  147191. /**
  147192. * Exports the .tilemaps file
  147193. */
  147194. saveTileMaps(): void;
  147195. /**
  147196. * Imports the .tilemaps file
  147197. * @param url of the .tilemaps file
  147198. */
  147199. loadTileMaps(url: string): void;
  147200. /**
  147201. * Release associated resources
  147202. */
  147203. dispose(): void;
  147204. }
  147205. }
  147206. declare module BABYLON {
  147207. /**
  147208. * Class used to manage multiple sprites of different sizes on the same spritesheet
  147209. * @see http://doc.babylonjs.com/babylon101/sprites
  147210. */
  147211. export class SpritePackedManager extends SpriteManager {
  147212. /** defines the packed manager's name */
  147213. name: string;
  147214. /**
  147215. * Creates a new sprite manager from a packed sprite sheet
  147216. * @param name defines the manager's name
  147217. * @param imgUrl defines the sprite sheet url
  147218. * @param capacity defines the maximum allowed number of sprites
  147219. * @param scene defines the hosting scene
  147220. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  147221. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  147222. * @param samplingMode defines the smapling mode to use with spritesheet
  147223. * @param fromPacked set to true; do not alter
  147224. */
  147225. constructor(
  147226. /** defines the packed manager's name */
  147227. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  147228. }
  147229. }
  147230. declare module BABYLON {
  147231. /**
  147232. * Defines the list of states available for a task inside a AssetsManager
  147233. */
  147234. export enum AssetTaskState {
  147235. /**
  147236. * Initialization
  147237. */
  147238. INIT = 0,
  147239. /**
  147240. * Running
  147241. */
  147242. RUNNING = 1,
  147243. /**
  147244. * Done
  147245. */
  147246. DONE = 2,
  147247. /**
  147248. * Error
  147249. */
  147250. ERROR = 3
  147251. }
  147252. /**
  147253. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  147254. */
  147255. export abstract class AbstractAssetTask {
  147256. /**
  147257. * Task name
  147258. */ name: string;
  147259. /**
  147260. * Callback called when the task is successful
  147261. */
  147262. onSuccess: (task: any) => void;
  147263. /**
  147264. * Callback called when the task is not successful
  147265. */
  147266. onError: (task: any, message?: string, exception?: any) => void;
  147267. /**
  147268. * Creates a new AssetsManager
  147269. * @param name defines the name of the task
  147270. */
  147271. constructor(
  147272. /**
  147273. * Task name
  147274. */ name: string);
  147275. private _isCompleted;
  147276. private _taskState;
  147277. private _errorObject;
  147278. /**
  147279. * Get if the task is completed
  147280. */
  147281. get isCompleted(): boolean;
  147282. /**
  147283. * Gets the current state of the task
  147284. */
  147285. get taskState(): AssetTaskState;
  147286. /**
  147287. * Gets the current error object (if task is in error)
  147288. */
  147289. get errorObject(): {
  147290. message?: string;
  147291. exception?: any;
  147292. };
  147293. /**
  147294. * Internal only
  147295. * @hidden
  147296. */
  147297. _setErrorObject(message?: string, exception?: any): void;
  147298. /**
  147299. * Execute the current task
  147300. * @param scene defines the scene where you want your assets to be loaded
  147301. * @param onSuccess is a callback called when the task is successfully executed
  147302. * @param onError is a callback called if an error occurs
  147303. */
  147304. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  147305. /**
  147306. * Execute the current task
  147307. * @param scene defines the scene where you want your assets to be loaded
  147308. * @param onSuccess is a callback called when the task is successfully executed
  147309. * @param onError is a callback called if an error occurs
  147310. */
  147311. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  147312. /**
  147313. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  147314. * This can be used with failed tasks that have the reason for failure fixed.
  147315. */
  147316. reset(): void;
  147317. private onErrorCallback;
  147318. private onDoneCallback;
  147319. }
  147320. /**
  147321. * Define the interface used by progress events raised during assets loading
  147322. */
  147323. export interface IAssetsProgressEvent {
  147324. /**
  147325. * Defines the number of remaining tasks to process
  147326. */
  147327. remainingCount: number;
  147328. /**
  147329. * Defines the total number of tasks
  147330. */
  147331. totalCount: number;
  147332. /**
  147333. * Defines the task that was just processed
  147334. */
  147335. task: AbstractAssetTask;
  147336. }
  147337. /**
  147338. * Class used to share progress information about assets loading
  147339. */
  147340. export class AssetsProgressEvent implements IAssetsProgressEvent {
  147341. /**
  147342. * Defines the number of remaining tasks to process
  147343. */
  147344. remainingCount: number;
  147345. /**
  147346. * Defines the total number of tasks
  147347. */
  147348. totalCount: number;
  147349. /**
  147350. * Defines the task that was just processed
  147351. */
  147352. task: AbstractAssetTask;
  147353. /**
  147354. * Creates a AssetsProgressEvent
  147355. * @param remainingCount defines the number of remaining tasks to process
  147356. * @param totalCount defines the total number of tasks
  147357. * @param task defines the task that was just processed
  147358. */
  147359. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  147360. }
  147361. /**
  147362. * Define a task used by AssetsManager to load meshes
  147363. */
  147364. export class MeshAssetTask extends AbstractAssetTask {
  147365. /**
  147366. * Defines the name of the task
  147367. */
  147368. name: string;
  147369. /**
  147370. * Defines the list of mesh's names you want to load
  147371. */
  147372. meshesNames: any;
  147373. /**
  147374. * Defines the root url to use as a base to load your meshes and associated resources
  147375. */
  147376. rootUrl: string;
  147377. /**
  147378. * Defines the filename or File of the scene to load from
  147379. */
  147380. sceneFilename: string | File;
  147381. /**
  147382. * Gets the list of loaded meshes
  147383. */
  147384. loadedMeshes: Array<AbstractMesh>;
  147385. /**
  147386. * Gets the list of loaded particle systems
  147387. */
  147388. loadedParticleSystems: Array<IParticleSystem>;
  147389. /**
  147390. * Gets the list of loaded skeletons
  147391. */
  147392. loadedSkeletons: Array<Skeleton>;
  147393. /**
  147394. * Gets the list of loaded animation groups
  147395. */
  147396. loadedAnimationGroups: Array<AnimationGroup>;
  147397. /**
  147398. * Callback called when the task is successful
  147399. */
  147400. onSuccess: (task: MeshAssetTask) => void;
  147401. /**
  147402. * Callback called when the task is successful
  147403. */
  147404. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  147405. /**
  147406. * Creates a new MeshAssetTask
  147407. * @param name defines the name of the task
  147408. * @param meshesNames defines the list of mesh's names you want to load
  147409. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  147410. * @param sceneFilename defines the filename or File of the scene to load from
  147411. */
  147412. constructor(
  147413. /**
  147414. * Defines the name of the task
  147415. */
  147416. name: string,
  147417. /**
  147418. * Defines the list of mesh's names you want to load
  147419. */
  147420. meshesNames: any,
  147421. /**
  147422. * Defines the root url to use as a base to load your meshes and associated resources
  147423. */
  147424. rootUrl: string,
  147425. /**
  147426. * Defines the filename or File of the scene to load from
  147427. */
  147428. sceneFilename: string | File);
  147429. /**
  147430. * Execute the current task
  147431. * @param scene defines the scene where you want your assets to be loaded
  147432. * @param onSuccess is a callback called when the task is successfully executed
  147433. * @param onError is a callback called if an error occurs
  147434. */
  147435. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  147436. }
  147437. /**
  147438. * Define a task used by AssetsManager to load text content
  147439. */
  147440. export class TextFileAssetTask extends AbstractAssetTask {
  147441. /**
  147442. * Defines the name of the task
  147443. */
  147444. name: string;
  147445. /**
  147446. * Defines the location of the file to load
  147447. */
  147448. url: string;
  147449. /**
  147450. * Gets the loaded text string
  147451. */
  147452. text: string;
  147453. /**
  147454. * Callback called when the task is successful
  147455. */
  147456. onSuccess: (task: TextFileAssetTask) => void;
  147457. /**
  147458. * Callback called when the task is successful
  147459. */
  147460. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  147461. /**
  147462. * Creates a new TextFileAssetTask object
  147463. * @param name defines the name of the task
  147464. * @param url defines the location of the file to load
  147465. */
  147466. constructor(
  147467. /**
  147468. * Defines the name of the task
  147469. */
  147470. name: string,
  147471. /**
  147472. * Defines the location of the file to load
  147473. */
  147474. url: string);
  147475. /**
  147476. * Execute the current task
  147477. * @param scene defines the scene where you want your assets to be loaded
  147478. * @param onSuccess is a callback called when the task is successfully executed
  147479. * @param onError is a callback called if an error occurs
  147480. */
  147481. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  147482. }
  147483. /**
  147484. * Define a task used by AssetsManager to load binary data
  147485. */
  147486. export class BinaryFileAssetTask extends AbstractAssetTask {
  147487. /**
  147488. * Defines the name of the task
  147489. */
  147490. name: string;
  147491. /**
  147492. * Defines the location of the file to load
  147493. */
  147494. url: string;
  147495. /**
  147496. * Gets the lodaded data (as an array buffer)
  147497. */
  147498. data: ArrayBuffer;
  147499. /**
  147500. * Callback called when the task is successful
  147501. */
  147502. onSuccess: (task: BinaryFileAssetTask) => void;
  147503. /**
  147504. * Callback called when the task is successful
  147505. */
  147506. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  147507. /**
  147508. * Creates a new BinaryFileAssetTask object
  147509. * @param name defines the name of the new task
  147510. * @param url defines the location of the file to load
  147511. */
  147512. constructor(
  147513. /**
  147514. * Defines the name of the task
  147515. */
  147516. name: string,
  147517. /**
  147518. * Defines the location of the file to load
  147519. */
  147520. url: string);
  147521. /**
  147522. * Execute the current task
  147523. * @param scene defines the scene where you want your assets to be loaded
  147524. * @param onSuccess is a callback called when the task is successfully executed
  147525. * @param onError is a callback called if an error occurs
  147526. */
  147527. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  147528. }
  147529. /**
  147530. * Define a task used by AssetsManager to load images
  147531. */
  147532. export class ImageAssetTask extends AbstractAssetTask {
  147533. /**
  147534. * Defines the name of the task
  147535. */
  147536. name: string;
  147537. /**
  147538. * Defines the location of the image to load
  147539. */
  147540. url: string;
  147541. /**
  147542. * Gets the loaded images
  147543. */
  147544. image: HTMLImageElement;
  147545. /**
  147546. * Callback called when the task is successful
  147547. */
  147548. onSuccess: (task: ImageAssetTask) => void;
  147549. /**
  147550. * Callback called when the task is successful
  147551. */
  147552. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  147553. /**
  147554. * Creates a new ImageAssetTask
  147555. * @param name defines the name of the task
  147556. * @param url defines the location of the image to load
  147557. */
  147558. constructor(
  147559. /**
  147560. * Defines the name of the task
  147561. */
  147562. name: string,
  147563. /**
  147564. * Defines the location of the image to load
  147565. */
  147566. url: string);
  147567. /**
  147568. * Execute the current task
  147569. * @param scene defines the scene where you want your assets to be loaded
  147570. * @param onSuccess is a callback called when the task is successfully executed
  147571. * @param onError is a callback called if an error occurs
  147572. */
  147573. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  147574. }
  147575. /**
  147576. * Defines the interface used by texture loading tasks
  147577. */
  147578. export interface ITextureAssetTask<TEX extends BaseTexture> {
  147579. /**
  147580. * Gets the loaded texture
  147581. */
  147582. texture: TEX;
  147583. }
  147584. /**
  147585. * Define a task used by AssetsManager to load 2D textures
  147586. */
  147587. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  147588. /**
  147589. * Defines the name of the task
  147590. */
  147591. name: string;
  147592. /**
  147593. * Defines the location of the file to load
  147594. */
  147595. url: string;
  147596. /**
  147597. * Defines if mipmap should not be generated (default is false)
  147598. */
  147599. noMipmap?: boolean | undefined;
  147600. /**
  147601. * Defines if texture must be inverted on Y axis (default is true)
  147602. */
  147603. invertY: boolean;
  147604. /**
  147605. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  147606. */
  147607. samplingMode: number;
  147608. /**
  147609. * Gets the loaded texture
  147610. */
  147611. texture: Texture;
  147612. /**
  147613. * Callback called when the task is successful
  147614. */
  147615. onSuccess: (task: TextureAssetTask) => void;
  147616. /**
  147617. * Callback called when the task is successful
  147618. */
  147619. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  147620. /**
  147621. * Creates a new TextureAssetTask object
  147622. * @param name defines the name of the task
  147623. * @param url defines the location of the file to load
  147624. * @param noMipmap defines if mipmap should not be generated (default is false)
  147625. * @param invertY defines if texture must be inverted on Y axis (default is true)
  147626. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  147627. */
  147628. constructor(
  147629. /**
  147630. * Defines the name of the task
  147631. */
  147632. name: string,
  147633. /**
  147634. * Defines the location of the file to load
  147635. */
  147636. url: string,
  147637. /**
  147638. * Defines if mipmap should not be generated (default is false)
  147639. */
  147640. noMipmap?: boolean | undefined,
  147641. /**
  147642. * Defines if texture must be inverted on Y axis (default is true)
  147643. */
  147644. invertY?: boolean,
  147645. /**
  147646. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  147647. */
  147648. samplingMode?: number);
  147649. /**
  147650. * Execute the current task
  147651. * @param scene defines the scene where you want your assets to be loaded
  147652. * @param onSuccess is a callback called when the task is successfully executed
  147653. * @param onError is a callback called if an error occurs
  147654. */
  147655. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  147656. }
  147657. /**
  147658. * Define a task used by AssetsManager to load cube textures
  147659. */
  147660. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  147661. /**
  147662. * Defines the name of the task
  147663. */
  147664. name: string;
  147665. /**
  147666. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  147667. */
  147668. url: string;
  147669. /**
  147670. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  147671. */
  147672. extensions?: string[] | undefined;
  147673. /**
  147674. * Defines if mipmaps should not be generated (default is false)
  147675. */
  147676. noMipmap?: boolean | undefined;
  147677. /**
  147678. * Defines the explicit list of files (undefined by default)
  147679. */
  147680. files?: string[] | undefined;
  147681. /**
  147682. * Gets the loaded texture
  147683. */
  147684. texture: CubeTexture;
  147685. /**
  147686. * Callback called when the task is successful
  147687. */
  147688. onSuccess: (task: CubeTextureAssetTask) => void;
  147689. /**
  147690. * Callback called when the task is successful
  147691. */
  147692. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  147693. /**
  147694. * Creates a new CubeTextureAssetTask
  147695. * @param name defines the name of the task
  147696. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  147697. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  147698. * @param noMipmap defines if mipmaps should not be generated (default is false)
  147699. * @param files defines the explicit list of files (undefined by default)
  147700. */
  147701. constructor(
  147702. /**
  147703. * Defines the name of the task
  147704. */
  147705. name: string,
  147706. /**
  147707. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  147708. */
  147709. url: string,
  147710. /**
  147711. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  147712. */
  147713. extensions?: string[] | undefined,
  147714. /**
  147715. * Defines if mipmaps should not be generated (default is false)
  147716. */
  147717. noMipmap?: boolean | undefined,
  147718. /**
  147719. * Defines the explicit list of files (undefined by default)
  147720. */
  147721. files?: string[] | undefined);
  147722. /**
  147723. * Execute the current task
  147724. * @param scene defines the scene where you want your assets to be loaded
  147725. * @param onSuccess is a callback called when the task is successfully executed
  147726. * @param onError is a callback called if an error occurs
  147727. */
  147728. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  147729. }
  147730. /**
  147731. * Define a task used by AssetsManager to load HDR cube textures
  147732. */
  147733. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  147734. /**
  147735. * Defines the name of the task
  147736. */
  147737. name: string;
  147738. /**
  147739. * Defines the location of the file to load
  147740. */
  147741. url: string;
  147742. /**
  147743. * Defines the desired size (the more it increases the longer the generation will be)
  147744. */
  147745. size: number;
  147746. /**
  147747. * Defines if mipmaps should not be generated (default is false)
  147748. */
  147749. noMipmap: boolean;
  147750. /**
  147751. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  147752. */
  147753. generateHarmonics: boolean;
  147754. /**
  147755. * 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)
  147756. */
  147757. gammaSpace: boolean;
  147758. /**
  147759. * Internal Use Only
  147760. */
  147761. reserved: boolean;
  147762. /**
  147763. * Gets the loaded texture
  147764. */
  147765. texture: HDRCubeTexture;
  147766. /**
  147767. * Callback called when the task is successful
  147768. */
  147769. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  147770. /**
  147771. * Callback called when the task is successful
  147772. */
  147773. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  147774. /**
  147775. * Creates a new HDRCubeTextureAssetTask object
  147776. * @param name defines the name of the task
  147777. * @param url defines the location of the file to load
  147778. * @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.
  147779. * @param noMipmap defines if mipmaps should not be generated (default is false)
  147780. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  147781. * @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)
  147782. * @param reserved Internal use only
  147783. */
  147784. constructor(
  147785. /**
  147786. * Defines the name of the task
  147787. */
  147788. name: string,
  147789. /**
  147790. * Defines the location of the file to load
  147791. */
  147792. url: string,
  147793. /**
  147794. * Defines the desired size (the more it increases the longer the generation will be)
  147795. */
  147796. size: number,
  147797. /**
  147798. * Defines if mipmaps should not be generated (default is false)
  147799. */
  147800. noMipmap?: boolean,
  147801. /**
  147802. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  147803. */
  147804. generateHarmonics?: boolean,
  147805. /**
  147806. * 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)
  147807. */
  147808. gammaSpace?: boolean,
  147809. /**
  147810. * Internal Use Only
  147811. */
  147812. reserved?: boolean);
  147813. /**
  147814. * Execute the current task
  147815. * @param scene defines the scene where you want your assets to be loaded
  147816. * @param onSuccess is a callback called when the task is successfully executed
  147817. * @param onError is a callback called if an error occurs
  147818. */
  147819. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  147820. }
  147821. /**
  147822. * Define a task used by AssetsManager to load Equirectangular cube textures
  147823. */
  147824. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  147825. /**
  147826. * Defines the name of the task
  147827. */
  147828. name: string;
  147829. /**
  147830. * Defines the location of the file to load
  147831. */
  147832. url: string;
  147833. /**
  147834. * Defines the desired size (the more it increases the longer the generation will be)
  147835. */
  147836. size: number;
  147837. /**
  147838. * Defines if mipmaps should not be generated (default is false)
  147839. */
  147840. noMipmap: boolean;
  147841. /**
  147842. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  147843. * but the standard material would require them in Gamma space) (default is true)
  147844. */
  147845. gammaSpace: boolean;
  147846. /**
  147847. * Gets the loaded texture
  147848. */
  147849. texture: EquiRectangularCubeTexture;
  147850. /**
  147851. * Callback called when the task is successful
  147852. */
  147853. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  147854. /**
  147855. * Callback called when the task is successful
  147856. */
  147857. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  147858. /**
  147859. * Creates a new EquiRectangularCubeTextureAssetTask object
  147860. * @param name defines the name of the task
  147861. * @param url defines the location of the file to load
  147862. * @param size defines the desired size (the more it increases the longer the generation will be)
  147863. * If the size is omitted this implies you are using a preprocessed cubemap.
  147864. * @param noMipmap defines if mipmaps should not be generated (default is false)
  147865. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  147866. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  147867. * (default is true)
  147868. */
  147869. constructor(
  147870. /**
  147871. * Defines the name of the task
  147872. */
  147873. name: string,
  147874. /**
  147875. * Defines the location of the file to load
  147876. */
  147877. url: string,
  147878. /**
  147879. * Defines the desired size (the more it increases the longer the generation will be)
  147880. */
  147881. size: number,
  147882. /**
  147883. * Defines if mipmaps should not be generated (default is false)
  147884. */
  147885. noMipmap?: boolean,
  147886. /**
  147887. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  147888. * but the standard material would require them in Gamma space) (default is true)
  147889. */
  147890. gammaSpace?: boolean);
  147891. /**
  147892. * Execute the current task
  147893. * @param scene defines the scene where you want your assets to be loaded
  147894. * @param onSuccess is a callback called when the task is successfully executed
  147895. * @param onError is a callback called if an error occurs
  147896. */
  147897. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  147898. }
  147899. /**
  147900. * This class can be used to easily import assets into a scene
  147901. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  147902. */
  147903. export class AssetsManager {
  147904. private _scene;
  147905. private _isLoading;
  147906. protected _tasks: AbstractAssetTask[];
  147907. protected _waitingTasksCount: number;
  147908. protected _totalTasksCount: number;
  147909. /**
  147910. * Callback called when all tasks are processed
  147911. */
  147912. onFinish: (tasks: AbstractAssetTask[]) => void;
  147913. /**
  147914. * Callback called when a task is successful
  147915. */
  147916. onTaskSuccess: (task: AbstractAssetTask) => void;
  147917. /**
  147918. * Callback called when a task had an error
  147919. */
  147920. onTaskError: (task: AbstractAssetTask) => void;
  147921. /**
  147922. * Callback called when a task is done (whatever the result is)
  147923. */
  147924. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  147925. /**
  147926. * Observable called when all tasks are processed
  147927. */
  147928. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  147929. /**
  147930. * Observable called when a task had an error
  147931. */
  147932. onTaskErrorObservable: Observable<AbstractAssetTask>;
  147933. /**
  147934. * Observable called when all tasks were executed
  147935. */
  147936. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  147937. /**
  147938. * Observable called when a task is done (whatever the result is)
  147939. */
  147940. onProgressObservable: Observable<IAssetsProgressEvent>;
  147941. /**
  147942. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  147943. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  147944. */
  147945. useDefaultLoadingScreen: boolean;
  147946. /**
  147947. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  147948. * when all assets have been downloaded.
  147949. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  147950. */
  147951. autoHideLoadingUI: boolean;
  147952. /**
  147953. * Creates a new AssetsManager
  147954. * @param scene defines the scene to work on
  147955. */
  147956. constructor(scene: Scene);
  147957. /**
  147958. * Add a MeshAssetTask to the list of active tasks
  147959. * @param taskName defines the name of the new task
  147960. * @param meshesNames defines the name of meshes to load
  147961. * @param rootUrl defines the root url to use to locate files
  147962. * @param sceneFilename defines the filename of the scene file
  147963. * @returns a new MeshAssetTask object
  147964. */
  147965. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  147966. /**
  147967. * Add a TextFileAssetTask to the list of active tasks
  147968. * @param taskName defines the name of the new task
  147969. * @param url defines the url of the file to load
  147970. * @returns a new TextFileAssetTask object
  147971. */
  147972. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  147973. /**
  147974. * Add a BinaryFileAssetTask to the list of active tasks
  147975. * @param taskName defines the name of the new task
  147976. * @param url defines the url of the file to load
  147977. * @returns a new BinaryFileAssetTask object
  147978. */
  147979. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  147980. /**
  147981. * Add a ImageAssetTask to the list of active tasks
  147982. * @param taskName defines the name of the new task
  147983. * @param url defines the url of the file to load
  147984. * @returns a new ImageAssetTask object
  147985. */
  147986. addImageTask(taskName: string, url: string): ImageAssetTask;
  147987. /**
  147988. * Add a TextureAssetTask to the list of active tasks
  147989. * @param taskName defines the name of the new task
  147990. * @param url defines the url of the file to load
  147991. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  147992. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  147993. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  147994. * @returns a new TextureAssetTask object
  147995. */
  147996. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  147997. /**
  147998. * Add a CubeTextureAssetTask to the list of active tasks
  147999. * @param taskName defines the name of the new task
  148000. * @param url defines the url of the file to load
  148001. * @param extensions defines the extension to use to load the cube map (can be null)
  148002. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  148003. * @param files defines the list of files to load (can be null)
  148004. * @returns a new CubeTextureAssetTask object
  148005. */
  148006. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  148007. /**
  148008. *
  148009. * Add a HDRCubeTextureAssetTask to the list of active tasks
  148010. * @param taskName defines the name of the new task
  148011. * @param url defines the url of the file to load
  148012. * @param size defines the size you want for the cubemap (can be null)
  148013. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  148014. * @param generateHarmonics defines if you want to automatically generate (true by default)
  148015. * @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)
  148016. * @param reserved Internal use only
  148017. * @returns a new HDRCubeTextureAssetTask object
  148018. */
  148019. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  148020. /**
  148021. *
  148022. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  148023. * @param taskName defines the name of the new task
  148024. * @param url defines the url of the file to load
  148025. * @param size defines the size you want for the cubemap (can be null)
  148026. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  148027. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  148028. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  148029. * @returns a new EquiRectangularCubeTextureAssetTask object
  148030. */
  148031. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  148032. /**
  148033. * Remove a task from the assets manager.
  148034. * @param task the task to remove
  148035. */
  148036. removeTask(task: AbstractAssetTask): void;
  148037. private _decreaseWaitingTasksCount;
  148038. private _runTask;
  148039. /**
  148040. * Reset the AssetsManager and remove all tasks
  148041. * @return the current instance of the AssetsManager
  148042. */
  148043. reset(): AssetsManager;
  148044. /**
  148045. * Start the loading process
  148046. * @return the current instance of the AssetsManager
  148047. */
  148048. load(): AssetsManager;
  148049. /**
  148050. * Start the loading process as an async operation
  148051. * @return a promise returning the list of failed tasks
  148052. */
  148053. loadAsync(): Promise<void>;
  148054. }
  148055. }
  148056. declare module BABYLON {
  148057. /**
  148058. * Wrapper class for promise with external resolve and reject.
  148059. */
  148060. export class Deferred<T> {
  148061. /**
  148062. * The promise associated with this deferred object.
  148063. */
  148064. readonly promise: Promise<T>;
  148065. private _resolve;
  148066. private _reject;
  148067. /**
  148068. * The resolve method of the promise associated with this deferred object.
  148069. */
  148070. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  148071. /**
  148072. * The reject method of the promise associated with this deferred object.
  148073. */
  148074. get reject(): (reason?: any) => void;
  148075. /**
  148076. * Constructor for this deferred object.
  148077. */
  148078. constructor();
  148079. }
  148080. }
  148081. declare module BABYLON {
  148082. /**
  148083. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  148084. */
  148085. export class MeshExploder {
  148086. private _centerMesh;
  148087. private _meshes;
  148088. private _meshesOrigins;
  148089. private _toCenterVectors;
  148090. private _scaledDirection;
  148091. private _newPosition;
  148092. private _centerPosition;
  148093. /**
  148094. * Explodes meshes from a center mesh.
  148095. * @param meshes The meshes to explode.
  148096. * @param centerMesh The mesh to be center of explosion.
  148097. */
  148098. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  148099. private _setCenterMesh;
  148100. /**
  148101. * Get class name
  148102. * @returns "MeshExploder"
  148103. */
  148104. getClassName(): string;
  148105. /**
  148106. * "Exploded meshes"
  148107. * @returns Array of meshes with the centerMesh at index 0.
  148108. */
  148109. getMeshes(): Array<Mesh>;
  148110. /**
  148111. * Explodes meshes giving a specific direction
  148112. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  148113. */
  148114. explode(direction?: number): void;
  148115. }
  148116. }
  148117. declare module BABYLON {
  148118. /**
  148119. * Class used to help managing file picking and drag'n'drop
  148120. */
  148121. export class FilesInput {
  148122. /**
  148123. * List of files ready to be loaded
  148124. */
  148125. static get FilesToLoad(): {
  148126. [key: string]: File;
  148127. };
  148128. /**
  148129. * Callback called when a file is processed
  148130. */
  148131. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  148132. private _engine;
  148133. private _currentScene;
  148134. private _sceneLoadedCallback;
  148135. private _progressCallback;
  148136. private _additionalRenderLoopLogicCallback;
  148137. private _textureLoadingCallback;
  148138. private _startingProcessingFilesCallback;
  148139. private _onReloadCallback;
  148140. private _errorCallback;
  148141. private _elementToMonitor;
  148142. private _sceneFileToLoad;
  148143. private _filesToLoad;
  148144. /**
  148145. * Creates a new FilesInput
  148146. * @param engine defines the rendering engine
  148147. * @param scene defines the hosting scene
  148148. * @param sceneLoadedCallback callback called when scene is loaded
  148149. * @param progressCallback callback called to track progress
  148150. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  148151. * @param textureLoadingCallback callback called when a texture is loading
  148152. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  148153. * @param onReloadCallback callback called when a reload is requested
  148154. * @param errorCallback callback call if an error occurs
  148155. */
  148156. 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);
  148157. private _dragEnterHandler;
  148158. private _dragOverHandler;
  148159. private _dropHandler;
  148160. /**
  148161. * Calls this function to listen to drag'n'drop events on a specific DOM element
  148162. * @param elementToMonitor defines the DOM element to track
  148163. */
  148164. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  148165. /**
  148166. * Release all associated resources
  148167. */
  148168. dispose(): void;
  148169. private renderFunction;
  148170. private drag;
  148171. private drop;
  148172. private _traverseFolder;
  148173. private _processFiles;
  148174. /**
  148175. * Load files from a drop event
  148176. * @param event defines the drop event to use as source
  148177. */
  148178. loadFiles(event: any): void;
  148179. private _processReload;
  148180. /**
  148181. * Reload the current scene from the loaded files
  148182. */
  148183. reload(): void;
  148184. }
  148185. }
  148186. declare module BABYLON {
  148187. /**
  148188. * Defines the root class used to create scene optimization to use with SceneOptimizer
  148189. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  148190. */
  148191. export class SceneOptimization {
  148192. /**
  148193. * Defines the priority of this optimization (0 by default which means first in the list)
  148194. */
  148195. priority: number;
  148196. /**
  148197. * Gets a string describing the action executed by the current optimization
  148198. * @returns description string
  148199. */
  148200. getDescription(): string;
  148201. /**
  148202. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  148203. * @param scene defines the current scene where to apply this optimization
  148204. * @param optimizer defines the current optimizer
  148205. * @returns true if everything that can be done was applied
  148206. */
  148207. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  148208. /**
  148209. * Creates the SceneOptimization object
  148210. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  148211. * @param desc defines the description associated with the optimization
  148212. */
  148213. constructor(
  148214. /**
  148215. * Defines the priority of this optimization (0 by default which means first in the list)
  148216. */
  148217. priority?: number);
  148218. }
  148219. /**
  148220. * Defines an optimization used to reduce the size of render target textures
  148221. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  148222. */
  148223. export class TextureOptimization extends SceneOptimization {
  148224. /**
  148225. * Defines the priority of this optimization (0 by default which means first in the list)
  148226. */
  148227. priority: number;
  148228. /**
  148229. * 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
  148230. */
  148231. maximumSize: number;
  148232. /**
  148233. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  148234. */
  148235. step: number;
  148236. /**
  148237. * Gets a string describing the action executed by the current optimization
  148238. * @returns description string
  148239. */
  148240. getDescription(): string;
  148241. /**
  148242. * Creates the TextureOptimization object
  148243. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  148244. * @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
  148245. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  148246. */
  148247. constructor(
  148248. /**
  148249. * Defines the priority of this optimization (0 by default which means first in the list)
  148250. */
  148251. priority?: number,
  148252. /**
  148253. * 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
  148254. */
  148255. maximumSize?: number,
  148256. /**
  148257. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  148258. */
  148259. step?: number);
  148260. /**
  148261. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  148262. * @param scene defines the current scene where to apply this optimization
  148263. * @param optimizer defines the current optimizer
  148264. * @returns true if everything that can be done was applied
  148265. */
  148266. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  148267. }
  148268. /**
  148269. * Defines an optimization used to increase or decrease the rendering resolution
  148270. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  148271. */
  148272. export class HardwareScalingOptimization extends SceneOptimization {
  148273. /**
  148274. * Defines the priority of this optimization (0 by default which means first in the list)
  148275. */
  148276. priority: number;
  148277. /**
  148278. * Defines the maximum scale to use (2 by default)
  148279. */
  148280. maximumScale: number;
  148281. /**
  148282. * Defines the step to use between two passes (0.5 by default)
  148283. */
  148284. step: number;
  148285. private _currentScale;
  148286. private _directionOffset;
  148287. /**
  148288. * Gets a string describing the action executed by the current optimization
  148289. * @return description string
  148290. */
  148291. getDescription(): string;
  148292. /**
  148293. * Creates the HardwareScalingOptimization object
  148294. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  148295. * @param maximumScale defines the maximum scale to use (2 by default)
  148296. * @param step defines the step to use between two passes (0.5 by default)
  148297. */
  148298. constructor(
  148299. /**
  148300. * Defines the priority of this optimization (0 by default which means first in the list)
  148301. */
  148302. priority?: number,
  148303. /**
  148304. * Defines the maximum scale to use (2 by default)
  148305. */
  148306. maximumScale?: number,
  148307. /**
  148308. * Defines the step to use between two passes (0.5 by default)
  148309. */
  148310. step?: number);
  148311. /**
  148312. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  148313. * @param scene defines the current scene where to apply this optimization
  148314. * @param optimizer defines the current optimizer
  148315. * @returns true if everything that can be done was applied
  148316. */
  148317. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  148318. }
  148319. /**
  148320. * Defines an optimization used to remove shadows
  148321. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  148322. */
  148323. export class ShadowsOptimization extends SceneOptimization {
  148324. /**
  148325. * Gets a string describing the action executed by the current optimization
  148326. * @return description string
  148327. */
  148328. getDescription(): string;
  148329. /**
  148330. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  148331. * @param scene defines the current scene where to apply this optimization
  148332. * @param optimizer defines the current optimizer
  148333. * @returns true if everything that can be done was applied
  148334. */
  148335. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  148336. }
  148337. /**
  148338. * Defines an optimization used to turn post-processes off
  148339. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  148340. */
  148341. export class PostProcessesOptimization extends SceneOptimization {
  148342. /**
  148343. * Gets a string describing the action executed by the current optimization
  148344. * @return description string
  148345. */
  148346. getDescription(): string;
  148347. /**
  148348. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  148349. * @param scene defines the current scene where to apply this optimization
  148350. * @param optimizer defines the current optimizer
  148351. * @returns true if everything that can be done was applied
  148352. */
  148353. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  148354. }
  148355. /**
  148356. * Defines an optimization used to turn lens flares off
  148357. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  148358. */
  148359. export class LensFlaresOptimization extends SceneOptimization {
  148360. /**
  148361. * Gets a string describing the action executed by the current optimization
  148362. * @return description string
  148363. */
  148364. getDescription(): string;
  148365. /**
  148366. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  148367. * @param scene defines the current scene where to apply this optimization
  148368. * @param optimizer defines the current optimizer
  148369. * @returns true if everything that can be done was applied
  148370. */
  148371. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  148372. }
  148373. /**
  148374. * Defines an optimization based on user defined callback.
  148375. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  148376. */
  148377. export class CustomOptimization extends SceneOptimization {
  148378. /**
  148379. * Callback called to apply the custom optimization.
  148380. */
  148381. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  148382. /**
  148383. * Callback called to get custom description
  148384. */
  148385. onGetDescription: () => string;
  148386. /**
  148387. * Gets a string describing the action executed by the current optimization
  148388. * @returns description string
  148389. */
  148390. getDescription(): string;
  148391. /**
  148392. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  148393. * @param scene defines the current scene where to apply this optimization
  148394. * @param optimizer defines the current optimizer
  148395. * @returns true if everything that can be done was applied
  148396. */
  148397. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  148398. }
  148399. /**
  148400. * Defines an optimization used to turn particles off
  148401. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  148402. */
  148403. export class ParticlesOptimization extends SceneOptimization {
  148404. /**
  148405. * Gets a string describing the action executed by the current optimization
  148406. * @return description string
  148407. */
  148408. getDescription(): string;
  148409. /**
  148410. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  148411. * @param scene defines the current scene where to apply this optimization
  148412. * @param optimizer defines the current optimizer
  148413. * @returns true if everything that can be done was applied
  148414. */
  148415. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  148416. }
  148417. /**
  148418. * Defines an optimization used to turn render targets off
  148419. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  148420. */
  148421. export class RenderTargetsOptimization extends SceneOptimization {
  148422. /**
  148423. * Gets a string describing the action executed by the current optimization
  148424. * @return description string
  148425. */
  148426. getDescription(): string;
  148427. /**
  148428. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  148429. * @param scene defines the current scene where to apply this optimization
  148430. * @param optimizer defines the current optimizer
  148431. * @returns true if everything that can be done was applied
  148432. */
  148433. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  148434. }
  148435. /**
  148436. * Defines an optimization used to merge meshes with compatible materials
  148437. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  148438. */
  148439. export class MergeMeshesOptimization extends SceneOptimization {
  148440. private static _UpdateSelectionTree;
  148441. /**
  148442. * Gets or sets a boolean which defines if optimization octree has to be updated
  148443. */
  148444. static get UpdateSelectionTree(): boolean;
  148445. /**
  148446. * Gets or sets a boolean which defines if optimization octree has to be updated
  148447. */
  148448. static set UpdateSelectionTree(value: boolean);
  148449. /**
  148450. * Gets a string describing the action executed by the current optimization
  148451. * @return description string
  148452. */
  148453. getDescription(): string;
  148454. private _canBeMerged;
  148455. /**
  148456. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  148457. * @param scene defines the current scene where to apply this optimization
  148458. * @param optimizer defines the current optimizer
  148459. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  148460. * @returns true if everything that can be done was applied
  148461. */
  148462. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  148463. }
  148464. /**
  148465. * Defines a list of options used by SceneOptimizer
  148466. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  148467. */
  148468. export class SceneOptimizerOptions {
  148469. /**
  148470. * Defines the target frame rate to reach (60 by default)
  148471. */
  148472. targetFrameRate: number;
  148473. /**
  148474. * Defines the interval between two checkes (2000ms by default)
  148475. */
  148476. trackerDuration: number;
  148477. /**
  148478. * Gets the list of optimizations to apply
  148479. */
  148480. optimizations: SceneOptimization[];
  148481. /**
  148482. * Creates a new list of options used by SceneOptimizer
  148483. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  148484. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  148485. */
  148486. constructor(
  148487. /**
  148488. * Defines the target frame rate to reach (60 by default)
  148489. */
  148490. targetFrameRate?: number,
  148491. /**
  148492. * Defines the interval between two checkes (2000ms by default)
  148493. */
  148494. trackerDuration?: number);
  148495. /**
  148496. * Add a new optimization
  148497. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  148498. * @returns the current SceneOptimizerOptions
  148499. */
  148500. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  148501. /**
  148502. * Add a new custom optimization
  148503. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  148504. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  148505. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  148506. * @returns the current SceneOptimizerOptions
  148507. */
  148508. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  148509. /**
  148510. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  148511. * @param targetFrameRate defines the target frame rate (60 by default)
  148512. * @returns a SceneOptimizerOptions object
  148513. */
  148514. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  148515. /**
  148516. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  148517. * @param targetFrameRate defines the target frame rate (60 by default)
  148518. * @returns a SceneOptimizerOptions object
  148519. */
  148520. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  148521. /**
  148522. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  148523. * @param targetFrameRate defines the target frame rate (60 by default)
  148524. * @returns a SceneOptimizerOptions object
  148525. */
  148526. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  148527. }
  148528. /**
  148529. * Class used to run optimizations in order to reach a target frame rate
  148530. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  148531. */
  148532. export class SceneOptimizer implements IDisposable {
  148533. private _isRunning;
  148534. private _options;
  148535. private _scene;
  148536. private _currentPriorityLevel;
  148537. private _targetFrameRate;
  148538. private _trackerDuration;
  148539. private _currentFrameRate;
  148540. private _sceneDisposeObserver;
  148541. private _improvementMode;
  148542. /**
  148543. * Defines an observable called when the optimizer reaches the target frame rate
  148544. */
  148545. onSuccessObservable: Observable<SceneOptimizer>;
  148546. /**
  148547. * Defines an observable called when the optimizer enables an optimization
  148548. */
  148549. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  148550. /**
  148551. * Defines an observable called when the optimizer is not able to reach the target frame rate
  148552. */
  148553. onFailureObservable: Observable<SceneOptimizer>;
  148554. /**
  148555. * Gets a boolean indicating if the optimizer is in improvement mode
  148556. */
  148557. get isInImprovementMode(): boolean;
  148558. /**
  148559. * Gets the current priority level (0 at start)
  148560. */
  148561. get currentPriorityLevel(): number;
  148562. /**
  148563. * Gets the current frame rate checked by the SceneOptimizer
  148564. */
  148565. get currentFrameRate(): number;
  148566. /**
  148567. * Gets or sets the current target frame rate (60 by default)
  148568. */
  148569. get targetFrameRate(): number;
  148570. /**
  148571. * Gets or sets the current target frame rate (60 by default)
  148572. */
  148573. set targetFrameRate(value: number);
  148574. /**
  148575. * Gets or sets the current interval between two checks (every 2000ms by default)
  148576. */
  148577. get trackerDuration(): number;
  148578. /**
  148579. * Gets or sets the current interval between two checks (every 2000ms by default)
  148580. */
  148581. set trackerDuration(value: number);
  148582. /**
  148583. * Gets the list of active optimizations
  148584. */
  148585. get optimizations(): SceneOptimization[];
  148586. /**
  148587. * Creates a new SceneOptimizer
  148588. * @param scene defines the scene to work on
  148589. * @param options defines the options to use with the SceneOptimizer
  148590. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  148591. * @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)
  148592. */
  148593. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  148594. /**
  148595. * Stops the current optimizer
  148596. */
  148597. stop(): void;
  148598. /**
  148599. * Reset the optimizer to initial step (current priority level = 0)
  148600. */
  148601. reset(): void;
  148602. /**
  148603. * Start the optimizer. By default it will try to reach a specific framerate
  148604. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  148605. */
  148606. start(): void;
  148607. private _checkCurrentState;
  148608. /**
  148609. * Release all resources
  148610. */
  148611. dispose(): void;
  148612. /**
  148613. * Helper function to create a SceneOptimizer with one single line of code
  148614. * @param scene defines the scene to work on
  148615. * @param options defines the options to use with the SceneOptimizer
  148616. * @param onSuccess defines a callback to call on success
  148617. * @param onFailure defines a callback to call on failure
  148618. * @returns the new SceneOptimizer object
  148619. */
  148620. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  148621. }
  148622. }
  148623. declare module BABYLON {
  148624. /**
  148625. * Class used to serialize a scene into a string
  148626. */
  148627. export class SceneSerializer {
  148628. /**
  148629. * Clear cache used by a previous serialization
  148630. */
  148631. static ClearCache(): void;
  148632. /**
  148633. * Serialize a scene into a JSON compatible object
  148634. * @param scene defines the scene to serialize
  148635. * @returns a JSON compatible object
  148636. */
  148637. static Serialize(scene: Scene): any;
  148638. /**
  148639. * Serialize a mesh into a JSON compatible object
  148640. * @param toSerialize defines the mesh to serialize
  148641. * @param withParents defines if parents must be serialized as well
  148642. * @param withChildren defines if children must be serialized as well
  148643. * @returns a JSON compatible object
  148644. */
  148645. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  148646. }
  148647. }
  148648. declare module BABYLON {
  148649. /**
  148650. * Class used to host texture specific utilities
  148651. */
  148652. export class TextureTools {
  148653. /**
  148654. * Uses the GPU to create a copy texture rescaled at a given size
  148655. * @param texture Texture to copy from
  148656. * @param width defines the desired width
  148657. * @param height defines the desired height
  148658. * @param useBilinearMode defines if bilinear mode has to be used
  148659. * @return the generated texture
  148660. */
  148661. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  148662. }
  148663. }
  148664. declare module BABYLON {
  148665. /**
  148666. * This represents the different options available for the video capture.
  148667. */
  148668. export interface VideoRecorderOptions {
  148669. /** Defines the mime type of the video. */
  148670. mimeType: string;
  148671. /** Defines the FPS the video should be recorded at. */
  148672. fps: number;
  148673. /** Defines the chunk size for the recording data. */
  148674. recordChunckSize: number;
  148675. /** The audio tracks to attach to the recording. */
  148676. audioTracks?: MediaStreamTrack[];
  148677. }
  148678. /**
  148679. * This can help with recording videos from BabylonJS.
  148680. * This is based on the available WebRTC functionalities of the browser.
  148681. *
  148682. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  148683. */
  148684. export class VideoRecorder {
  148685. private static readonly _defaultOptions;
  148686. /**
  148687. * Returns whether or not the VideoRecorder is available in your browser.
  148688. * @param engine Defines the Babylon Engine.
  148689. * @returns true if supported otherwise false.
  148690. */
  148691. static IsSupported(engine: Engine): boolean;
  148692. private readonly _options;
  148693. private _canvas;
  148694. private _mediaRecorder;
  148695. private _recordedChunks;
  148696. private _fileName;
  148697. private _resolve;
  148698. private _reject;
  148699. /**
  148700. * True when a recording is already in progress.
  148701. */
  148702. get isRecording(): boolean;
  148703. /**
  148704. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  148705. * @param engine Defines the BabylonJS Engine you wish to record.
  148706. * @param options Defines options that can be used to customize the capture.
  148707. */
  148708. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  148709. /**
  148710. * Stops the current recording before the default capture timeout passed in the startRecording function.
  148711. */
  148712. stopRecording(): void;
  148713. /**
  148714. * Starts recording the canvas for a max duration specified in parameters.
  148715. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  148716. * If null no automatic download will start and you can rely on the promise to get the data back.
  148717. * @param maxDuration Defines the maximum recording time in seconds.
  148718. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  148719. * @return A promise callback at the end of the recording with the video data in Blob.
  148720. */
  148721. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  148722. /**
  148723. * Releases internal resources used during the recording.
  148724. */
  148725. dispose(): void;
  148726. private _handleDataAvailable;
  148727. private _handleError;
  148728. private _handleStop;
  148729. }
  148730. }
  148731. declare module BABYLON {
  148732. /**
  148733. * Class containing a set of static utilities functions for screenshots
  148734. */
  148735. export class ScreenshotTools {
  148736. /**
  148737. * Captures a screenshot of the current rendering
  148738. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  148739. * @param engine defines the rendering engine
  148740. * @param camera defines the source camera
  148741. * @param size This parameter can be set to a single number or to an object with the
  148742. * following (optional) properties: precision, width, height. If a single number is passed,
  148743. * it will be used for both width and height. If an object is passed, the screenshot size
  148744. * will be derived from the parameters. The precision property is a multiplier allowing
  148745. * rendering at a higher or lower resolution
  148746. * @param successCallback defines the callback receives a single parameter which contains the
  148747. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  148748. * src parameter of an <img> to display it
  148749. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  148750. * Check your browser for supported MIME types
  148751. */
  148752. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  148753. /**
  148754. * Captures a screenshot of the current rendering
  148755. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  148756. * @param engine defines the rendering engine
  148757. * @param camera defines the source camera
  148758. * @param size This parameter can be set to a single number or to an object with the
  148759. * following (optional) properties: precision, width, height. If a single number is passed,
  148760. * it will be used for both width and height. If an object is passed, the screenshot size
  148761. * will be derived from the parameters. The precision property is a multiplier allowing
  148762. * rendering at a higher or lower resolution
  148763. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  148764. * Check your browser for supported MIME types
  148765. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  148766. * to the src parameter of an <img> to display it
  148767. */
  148768. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  148769. /**
  148770. * Generates an image screenshot from the specified camera.
  148771. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  148772. * @param engine The engine to use for rendering
  148773. * @param camera The camera to use for rendering
  148774. * @param size This parameter can be set to a single number or to an object with the
  148775. * following (optional) properties: precision, width, height. If a single number is passed,
  148776. * it will be used for both width and height. If an object is passed, the screenshot size
  148777. * will be derived from the parameters. The precision property is a multiplier allowing
  148778. * rendering at a higher or lower resolution
  148779. * @param successCallback The callback receives a single parameter which contains the
  148780. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  148781. * src parameter of an <img> to display it
  148782. * @param mimeType The MIME type of the screenshot image (default: image/png).
  148783. * Check your browser for supported MIME types
  148784. * @param samples Texture samples (default: 1)
  148785. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  148786. * @param fileName A name for for the downloaded file.
  148787. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  148788. */
  148789. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  148790. /**
  148791. * Generates an image screenshot from the specified camera.
  148792. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  148793. * @param engine The engine to use for rendering
  148794. * @param camera The camera to use for rendering
  148795. * @param size This parameter can be set to a single number or to an object with the
  148796. * following (optional) properties: precision, width, height. If a single number is passed,
  148797. * it will be used for both width and height. If an object is passed, the screenshot size
  148798. * will be derived from the parameters. The precision property is a multiplier allowing
  148799. * rendering at a higher or lower resolution
  148800. * @param mimeType The MIME type of the screenshot image (default: image/png).
  148801. * Check your browser for supported MIME types
  148802. * @param samples Texture samples (default: 1)
  148803. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  148804. * @param fileName A name for for the downloaded file.
  148805. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  148806. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  148807. * to the src parameter of an <img> to display it
  148808. */
  148809. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  148810. /**
  148811. * Gets height and width for screenshot size
  148812. * @private
  148813. */
  148814. private static _getScreenshotSize;
  148815. }
  148816. }
  148817. declare module BABYLON {
  148818. /**
  148819. * Interface for a data buffer
  148820. */
  148821. export interface IDataBuffer {
  148822. /**
  148823. * Reads bytes from the data buffer.
  148824. * @param byteOffset The byte offset to read
  148825. * @param byteLength The byte length to read
  148826. * @returns A promise that resolves when the bytes are read
  148827. */
  148828. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  148829. /**
  148830. * The byte length of the buffer.
  148831. */
  148832. readonly byteLength: number;
  148833. }
  148834. /**
  148835. * Utility class for reading from a data buffer
  148836. */
  148837. export class DataReader {
  148838. /**
  148839. * The data buffer associated with this data reader.
  148840. */
  148841. readonly buffer: IDataBuffer;
  148842. /**
  148843. * The current byte offset from the beginning of the data buffer.
  148844. */
  148845. byteOffset: number;
  148846. private _dataView;
  148847. private _dataByteOffset;
  148848. /**
  148849. * Constructor
  148850. * @param buffer The buffer to read
  148851. */
  148852. constructor(buffer: IDataBuffer);
  148853. /**
  148854. * Loads the given byte length.
  148855. * @param byteLength The byte length to load
  148856. * @returns A promise that resolves when the load is complete
  148857. */
  148858. loadAsync(byteLength: number): Promise<void>;
  148859. /**
  148860. * Read a unsigned 32-bit integer from the currently loaded data range.
  148861. * @returns The 32-bit integer read
  148862. */
  148863. readUint32(): number;
  148864. /**
  148865. * Read a byte array from the currently loaded data range.
  148866. * @param byteLength The byte length to read
  148867. * @returns The byte array read
  148868. */
  148869. readUint8Array(byteLength: number): Uint8Array;
  148870. /**
  148871. * Read a string from the currently loaded data range.
  148872. * @param byteLength The byte length to read
  148873. * @returns The string read
  148874. */
  148875. readString(byteLength: number): string;
  148876. /**
  148877. * Skips the given byte length the currently loaded data range.
  148878. * @param byteLength The byte length to skip
  148879. */
  148880. skipBytes(byteLength: number): void;
  148881. }
  148882. }
  148883. declare module BABYLON {
  148884. /**
  148885. * Class for storing data to local storage if available or in-memory storage otherwise
  148886. */
  148887. export class DataStorage {
  148888. private static _Storage;
  148889. private static _GetStorage;
  148890. /**
  148891. * Reads a string from the data storage
  148892. * @param key The key to read
  148893. * @param defaultValue The value if the key doesn't exist
  148894. * @returns The string value
  148895. */
  148896. static ReadString(key: string, defaultValue: string): string;
  148897. /**
  148898. * Writes a string to the data storage
  148899. * @param key The key to write
  148900. * @param value The value to write
  148901. */
  148902. static WriteString(key: string, value: string): void;
  148903. /**
  148904. * Reads a boolean from the data storage
  148905. * @param key The key to read
  148906. * @param defaultValue The value if the key doesn't exist
  148907. * @returns The boolean value
  148908. */
  148909. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  148910. /**
  148911. * Writes a boolean to the data storage
  148912. * @param key The key to write
  148913. * @param value The value to write
  148914. */
  148915. static WriteBoolean(key: string, value: boolean): void;
  148916. /**
  148917. * Reads a number from the data storage
  148918. * @param key The key to read
  148919. * @param defaultValue The value if the key doesn't exist
  148920. * @returns The number value
  148921. */
  148922. static ReadNumber(key: string, defaultValue: number): number;
  148923. /**
  148924. * Writes a number to the data storage
  148925. * @param key The key to write
  148926. * @param value The value to write
  148927. */
  148928. static WriteNumber(key: string, value: number): void;
  148929. }
  148930. }
  148931. declare module BABYLON {
  148932. /**
  148933. * Options used for hit testing
  148934. */
  148935. export interface IWebXRLegacyHitTestOptions {
  148936. /**
  148937. * Only test when user interacted with the scene. Default - hit test every frame
  148938. */
  148939. testOnPointerDownOnly?: boolean;
  148940. /**
  148941. * The node to use to transform the local results to world coordinates
  148942. */
  148943. worldParentNode?: TransformNode;
  148944. }
  148945. /**
  148946. * Interface defining the babylon result of raycasting/hit-test
  148947. */
  148948. export interface IWebXRLegacyHitResult {
  148949. /**
  148950. * Transformation matrix that can be applied to a node that will put it in the hit point location
  148951. */
  148952. transformationMatrix: Matrix;
  148953. /**
  148954. * The native hit test result
  148955. */
  148956. xrHitResult: XRHitResult | XRHitTestResult;
  148957. }
  148958. /**
  148959. * The currently-working hit-test module.
  148960. * Hit test (or Ray-casting) is used to interact with the real world.
  148961. * For further information read here - https://github.com/immersive-web/hit-test
  148962. */
  148963. export class WebXRHitTestLegacy extends WebXRAbstractFeature {
  148964. /**
  148965. * options to use when constructing this feature
  148966. */
  148967. readonly options: IWebXRLegacyHitTestOptions;
  148968. private _direction;
  148969. private _mat;
  148970. private _onSelectEnabled;
  148971. private _origin;
  148972. /**
  148973. * The module's name
  148974. */
  148975. static readonly Name: string;
  148976. /**
  148977. * The (Babylon) version of this module.
  148978. * This is an integer representing the implementation version.
  148979. * This number does not correspond to the WebXR specs version
  148980. */
  148981. static readonly Version: number;
  148982. /**
  148983. * Populated with the last native XR Hit Results
  148984. */
  148985. lastNativeXRHitResults: XRHitResult[];
  148986. /**
  148987. * Triggered when new babylon (transformed) hit test results are available
  148988. */
  148989. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  148990. /**
  148991. * Creates a new instance of the (legacy version) hit test feature
  148992. * @param _xrSessionManager an instance of WebXRSessionManager
  148993. * @param options options to use when constructing this feature
  148994. */
  148995. constructor(_xrSessionManager: WebXRSessionManager,
  148996. /**
  148997. * options to use when constructing this feature
  148998. */
  148999. options?: IWebXRLegacyHitTestOptions);
  149000. /**
  149001. * execute a hit test with an XR Ray
  149002. *
  149003. * @param xrSession a native xrSession that will execute this hit test
  149004. * @param xrRay the ray (position and direction) to use for ray-casting
  149005. * @param referenceSpace native XR reference space to use for the hit-test
  149006. * @param filter filter function that will filter the results
  149007. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  149008. */
  149009. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  149010. /**
  149011. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  149012. * @param event the (select) event to use to select with
  149013. * @param referenceSpace the reference space to use for this hit test
  149014. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  149015. */
  149016. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  149017. /**
  149018. * attach this feature
  149019. * Will usually be called by the features manager
  149020. *
  149021. * @returns true if successful.
  149022. */
  149023. attach(): boolean;
  149024. /**
  149025. * detach this feature.
  149026. * Will usually be called by the features manager
  149027. *
  149028. * @returns true if successful.
  149029. */
  149030. detach(): boolean;
  149031. /**
  149032. * Dispose this feature and all of the resources attached
  149033. */
  149034. dispose(): void;
  149035. protected _onXRFrame(frame: XRFrame): void;
  149036. private _onHitTestResults;
  149037. private _onSelect;
  149038. }
  149039. }
  149040. declare module BABYLON {
  149041. /**
  149042. * Options used in the plane detector module
  149043. */
  149044. export interface IWebXRPlaneDetectorOptions {
  149045. /**
  149046. * The node to use to transform the local results to world coordinates
  149047. */
  149048. worldParentNode?: TransformNode;
  149049. }
  149050. /**
  149051. * A babylon interface for a WebXR plane.
  149052. * A Plane is actually a polygon, built from N points in space
  149053. *
  149054. * Supported in chrome 79, not supported in canary 81 ATM
  149055. */
  149056. export interface IWebXRPlane {
  149057. /**
  149058. * a babylon-assigned ID for this polygon
  149059. */
  149060. id: number;
  149061. /**
  149062. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  149063. */
  149064. polygonDefinition: Array<Vector3>;
  149065. /**
  149066. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  149067. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  149068. */
  149069. transformationMatrix: Matrix;
  149070. /**
  149071. * the native xr-plane object
  149072. */
  149073. xrPlane: XRPlane;
  149074. }
  149075. /**
  149076. * The plane detector is used to detect planes in the real world when in AR
  149077. * For more information see https://github.com/immersive-web/real-world-geometry/
  149078. */
  149079. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  149080. private _options;
  149081. private _detectedPlanes;
  149082. private _enabled;
  149083. private _lastFrameDetected;
  149084. /**
  149085. * The module's name
  149086. */
  149087. static readonly Name: string;
  149088. /**
  149089. * The (Babylon) version of this module.
  149090. * This is an integer representing the implementation version.
  149091. * This number does not correspond to the WebXR specs version
  149092. */
  149093. static readonly Version: number;
  149094. /**
  149095. * Observers registered here will be executed when a new plane was added to the session
  149096. */
  149097. onPlaneAddedObservable: Observable<IWebXRPlane>;
  149098. /**
  149099. * Observers registered here will be executed when a plane is no longer detected in the session
  149100. */
  149101. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  149102. /**
  149103. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  149104. * This can execute N times every frame
  149105. */
  149106. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  149107. /**
  149108. * construct a new Plane Detector
  149109. * @param _xrSessionManager an instance of xr Session manager
  149110. * @param _options configuration to use when constructing this feature
  149111. */
  149112. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  149113. /**
  149114. * Dispose this feature and all of the resources attached
  149115. */
  149116. dispose(): void;
  149117. protected _onXRFrame(frame: XRFrame): void;
  149118. private _init;
  149119. private _updatePlaneWithXRPlane;
  149120. /**
  149121. * avoiding using Array.find for global support.
  149122. * @param xrPlane the plane to find in the array
  149123. */
  149124. private findIndexInPlaneArray;
  149125. }
  149126. }
  149127. declare module BABYLON {
  149128. /**
  149129. * Configuration options of the anchor system
  149130. */
  149131. export interface IWebXRAnchorSystemOptions {
  149132. /**
  149133. * Should a new anchor be added every time a select event is triggered
  149134. */
  149135. addAnchorOnSelect?: boolean;
  149136. /**
  149137. * should the anchor system use plane detection.
  149138. * If set to true, the plane-detection feature should be set using setPlaneDetector
  149139. */
  149140. usePlaneDetection?: boolean;
  149141. /**
  149142. * a node that will be used to convert local to world coordinates
  149143. */
  149144. worldParentNode?: TransformNode;
  149145. }
  149146. /**
  149147. * A babylon container for an XR Anchor
  149148. */
  149149. export interface IWebXRAnchor {
  149150. /**
  149151. * A babylon-assigned ID for this anchor
  149152. */
  149153. id: number;
  149154. /**
  149155. * Transformation matrix to apply to an object attached to this anchor
  149156. */
  149157. transformationMatrix: Matrix;
  149158. /**
  149159. * The native anchor object
  149160. */
  149161. xrAnchor: XRAnchor;
  149162. }
  149163. /**
  149164. * An implementation of the anchor system of WebXR.
  149165. * Note that the current documented implementation is not available in any browser. Future implementations
  149166. * will use the frame to create an anchor and not the session or a detected plane
  149167. * For further information see https://github.com/immersive-web/anchors/
  149168. */
  149169. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  149170. private _options;
  149171. private _enabled;
  149172. private _hitTestModule;
  149173. private _lastFrameDetected;
  149174. private _onSelect;
  149175. private _planeDetector;
  149176. private _trackedAnchors;
  149177. /**
  149178. * The module's name
  149179. */
  149180. static readonly Name: string;
  149181. /**
  149182. * The (Babylon) version of this module.
  149183. * This is an integer representing the implementation version.
  149184. * This number does not correspond to the WebXR specs version
  149185. */
  149186. static readonly Version: number;
  149187. /**
  149188. * Observers registered here will be executed when a new anchor was added to the session
  149189. */
  149190. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  149191. /**
  149192. * Observers registered here will be executed when an anchor was removed from the session
  149193. */
  149194. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  149195. /**
  149196. * Observers registered here will be executed when an existing anchor updates
  149197. * This can execute N times every frame
  149198. */
  149199. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  149200. /**
  149201. * constructs a new anchor system
  149202. * @param _xrSessionManager an instance of WebXRSessionManager
  149203. * @param _options configuration object for this feature
  149204. */
  149205. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  149206. /**
  149207. * Add anchor at a specific XR point.
  149208. *
  149209. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  149210. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  149211. * @returns a promise the fulfills when the anchor was created
  149212. */
  149213. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  149214. /**
  149215. * attach this feature
  149216. * Will usually be called by the features manager
  149217. *
  149218. * @returns true if successful.
  149219. */
  149220. attach(): boolean;
  149221. /**
  149222. * detach this feature.
  149223. * Will usually be called by the features manager
  149224. *
  149225. * @returns true if successful.
  149226. */
  149227. detach(): boolean;
  149228. /**
  149229. * Dispose this feature and all of the resources attached
  149230. */
  149231. dispose(): void;
  149232. /**
  149233. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  149234. * @param hitTestModule the hit-test module to use.
  149235. */
  149236. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  149237. /**
  149238. * set the plane detector to use in order to create anchors from frames
  149239. * @param planeDetector the plane-detector module to use
  149240. * @param enable enable plane-anchors. default is true
  149241. */
  149242. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  149243. protected _onXRFrame(frame: XRFrame): void;
  149244. /**
  149245. * avoiding using Array.find for global support.
  149246. * @param xrAnchor the plane to find in the array
  149247. */
  149248. private _findIndexInAnchorArray;
  149249. private _updateAnchorWithXRFrame;
  149250. }
  149251. }
  149252. declare module BABYLON {
  149253. /**
  149254. * Options interface for the background remover plugin
  149255. */
  149256. export interface IWebXRBackgroundRemoverOptions {
  149257. /**
  149258. * Further background meshes to disable when entering AR
  149259. */
  149260. backgroundMeshes?: AbstractMesh[];
  149261. /**
  149262. * flags to configure the removal of the environment helper.
  149263. * If not set, the entire background will be removed. If set, flags should be set as well.
  149264. */
  149265. environmentHelperRemovalFlags?: {
  149266. /**
  149267. * Should the skybox be removed (default false)
  149268. */
  149269. skyBox?: boolean;
  149270. /**
  149271. * Should the ground be removed (default false)
  149272. */
  149273. ground?: boolean;
  149274. };
  149275. /**
  149276. * don't disable the environment helper
  149277. */
  149278. ignoreEnvironmentHelper?: boolean;
  149279. }
  149280. /**
  149281. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  149282. */
  149283. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  149284. /**
  149285. * read-only options to be used in this module
  149286. */
  149287. readonly options: IWebXRBackgroundRemoverOptions;
  149288. /**
  149289. * The module's name
  149290. */
  149291. static readonly Name: string;
  149292. /**
  149293. * The (Babylon) version of this module.
  149294. * This is an integer representing the implementation version.
  149295. * This number does not correspond to the WebXR specs version
  149296. */
  149297. static readonly Version: number;
  149298. /**
  149299. * registered observers will be triggered when the background state changes
  149300. */
  149301. onBackgroundStateChangedObservable: Observable<boolean>;
  149302. /**
  149303. * constructs a new background remover module
  149304. * @param _xrSessionManager the session manager for this module
  149305. * @param options read-only options to be used in this module
  149306. */
  149307. constructor(_xrSessionManager: WebXRSessionManager,
  149308. /**
  149309. * read-only options to be used in this module
  149310. */
  149311. options?: IWebXRBackgroundRemoverOptions);
  149312. /**
  149313. * attach this feature
  149314. * Will usually be called by the features manager
  149315. *
  149316. * @returns true if successful.
  149317. */
  149318. attach(): boolean;
  149319. /**
  149320. * detach this feature.
  149321. * Will usually be called by the features manager
  149322. *
  149323. * @returns true if successful.
  149324. */
  149325. detach(): boolean;
  149326. /**
  149327. * Dispose this feature and all of the resources attached
  149328. */
  149329. dispose(): void;
  149330. protected _onXRFrame(_xrFrame: XRFrame): void;
  149331. private _setBackgroundState;
  149332. }
  149333. }
  149334. declare module BABYLON {
  149335. /**
  149336. * Options for the controller physics feature
  149337. */
  149338. export class IWebXRControllerPhysicsOptions {
  149339. /**
  149340. * Should the headset get its own impostor
  149341. */
  149342. enableHeadsetImpostor?: boolean;
  149343. /**
  149344. * Optional parameters for the headset impostor
  149345. */
  149346. headsetImpostorParams?: {
  149347. /**
  149348. * The type of impostor to create. Default is sphere
  149349. */
  149350. impostorType: number;
  149351. /**
  149352. * the size of the impostor. Defaults to 10cm
  149353. */
  149354. impostorSize?: number | {
  149355. width: number;
  149356. height: number;
  149357. depth: number;
  149358. };
  149359. /**
  149360. * Friction definitions
  149361. */
  149362. friction?: number;
  149363. /**
  149364. * Restitution
  149365. */
  149366. restitution?: number;
  149367. };
  149368. /**
  149369. * The physics properties of the future impostors
  149370. */
  149371. physicsProperties?: {
  149372. /**
  149373. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  149374. * Note that this requires a physics engine that supports mesh impostors!
  149375. */
  149376. useControllerMesh?: boolean;
  149377. /**
  149378. * The type of impostor to create. Default is sphere
  149379. */
  149380. impostorType?: number;
  149381. /**
  149382. * the size of the impostor. Defaults to 10cm
  149383. */
  149384. impostorSize?: number | {
  149385. width: number;
  149386. height: number;
  149387. depth: number;
  149388. };
  149389. /**
  149390. * Friction definitions
  149391. */
  149392. friction?: number;
  149393. /**
  149394. * Restitution
  149395. */
  149396. restitution?: number;
  149397. };
  149398. /**
  149399. * the xr input to use with this pointer selection
  149400. */
  149401. xrInput: WebXRInput;
  149402. }
  149403. /**
  149404. * Add physics impostor to your webxr controllers,
  149405. * including naive calculation of their linear and angular velocity
  149406. */
  149407. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  149408. private readonly _options;
  149409. private _attachController;
  149410. private _controllers;
  149411. private _debugMode;
  149412. private _delta;
  149413. private _headsetImpostor?;
  149414. private _headsetMesh?;
  149415. private _lastTimestamp;
  149416. private _tmpQuaternion;
  149417. private _tmpVector;
  149418. /**
  149419. * The module's name
  149420. */
  149421. static readonly Name: string;
  149422. /**
  149423. * The (Babylon) version of this module.
  149424. * This is an integer representing the implementation version.
  149425. * This number does not correspond to the webxr specs version
  149426. */
  149427. static readonly Version: number;
  149428. /**
  149429. * Construct a new Controller Physics Feature
  149430. * @param _xrSessionManager the corresponding xr session manager
  149431. * @param _options options to create this feature with
  149432. */
  149433. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  149434. /**
  149435. * @hidden
  149436. * enable debugging - will show console outputs and the impostor mesh
  149437. */
  149438. _enablePhysicsDebug(): void;
  149439. /**
  149440. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  149441. * @param xrController the controller to add
  149442. */
  149443. addController(xrController: WebXRInputSource): void;
  149444. /**
  149445. * attach this feature
  149446. * Will usually be called by the features manager
  149447. *
  149448. * @returns true if successful.
  149449. */
  149450. attach(): boolean;
  149451. /**
  149452. * detach this feature.
  149453. * Will usually be called by the features manager
  149454. *
  149455. * @returns true if successful.
  149456. */
  149457. detach(): boolean;
  149458. /**
  149459. * Get the headset impostor, if enabled
  149460. * @returns the impostor
  149461. */
  149462. getHeadsetImpostor(): PhysicsImpostor | undefined;
  149463. /**
  149464. * Get the physics impostor of a specific controller.
  149465. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  149466. * @param controller the controller or the controller id of which to get the impostor
  149467. * @returns the impostor or null
  149468. */
  149469. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  149470. /**
  149471. * Update the physics properties provided in the constructor
  149472. * @param newProperties the new properties object
  149473. */
  149474. setPhysicsProperties(newProperties: {
  149475. impostorType?: number;
  149476. impostorSize?: number | {
  149477. width: number;
  149478. height: number;
  149479. depth: number;
  149480. };
  149481. friction?: number;
  149482. restitution?: number;
  149483. }): void;
  149484. protected _onXRFrame(_xrFrame: any): void;
  149485. private _detachController;
  149486. }
  149487. }
  149488. declare module BABYLON {
  149489. /**
  149490. * Options used for hit testing (version 2)
  149491. */
  149492. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  149493. /**
  149494. * Do not create a permanent hit test. Will usually be used when only
  149495. * transient inputs are needed.
  149496. */
  149497. disablePermanentHitTest?: boolean;
  149498. /**
  149499. * Enable transient (for example touch-based) hit test inspections
  149500. */
  149501. enableTransientHitTest?: boolean;
  149502. /**
  149503. * Offset ray for the permanent hit test
  149504. */
  149505. offsetRay?: Vector3;
  149506. /**
  149507. * Offset ray for the transient hit test
  149508. */
  149509. transientOffsetRay?: Vector3;
  149510. /**
  149511. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  149512. */
  149513. useReferenceSpace?: boolean;
  149514. }
  149515. /**
  149516. * Interface defining the babylon result of hit-test
  149517. */
  149518. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  149519. /**
  149520. * The input source that generated this hit test (if transient)
  149521. */
  149522. inputSource?: XRInputSource;
  149523. /**
  149524. * Is this a transient hit test
  149525. */
  149526. isTransient?: boolean;
  149527. /**
  149528. * Position of the hit test result
  149529. */
  149530. position: Vector3;
  149531. /**
  149532. * Rotation of the hit test result
  149533. */
  149534. rotationQuaternion: Quaternion;
  149535. }
  149536. /**
  149537. * The currently-working hit-test module.
  149538. * Hit test (or Ray-casting) is used to interact with the real world.
  149539. * For further information read here - https://github.com/immersive-web/hit-test
  149540. *
  149541. * Tested on chrome (mobile) 80.
  149542. */
  149543. export class WebXRHitTest extends WebXRAbstractFeature {
  149544. /**
  149545. * options to use when constructing this feature
  149546. */
  149547. readonly options: IWebXRHitTestOptions;
  149548. private _tmpMat;
  149549. private _tmpPos;
  149550. private _tmpQuat;
  149551. private _transientXrHitTestSource;
  149552. private _xrHitTestSource;
  149553. private initHitTestSource;
  149554. /**
  149555. * The module's name
  149556. */
  149557. static readonly Name: string;
  149558. /**
  149559. * The (Babylon) version of this module.
  149560. * This is an integer representing the implementation version.
  149561. * This number does not correspond to the WebXR specs version
  149562. */
  149563. static readonly Version: number;
  149564. /**
  149565. * When set to true, each hit test will have its own position/rotation objects
  149566. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  149567. * the developers will clone them or copy them as they see fit.
  149568. */
  149569. autoCloneTransformation: boolean;
  149570. /**
  149571. * Populated with the last native XR Hit Results
  149572. */
  149573. lastNativeXRHitResults: XRHitResult[];
  149574. /**
  149575. * Triggered when new babylon (transformed) hit test results are available
  149576. */
  149577. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  149578. /**
  149579. * Use this to temporarily pause hit test checks.
  149580. */
  149581. paused: boolean;
  149582. /**
  149583. * Creates a new instance of the hit test feature
  149584. * @param _xrSessionManager an instance of WebXRSessionManager
  149585. * @param options options to use when constructing this feature
  149586. */
  149587. constructor(_xrSessionManager: WebXRSessionManager,
  149588. /**
  149589. * options to use when constructing this feature
  149590. */
  149591. options?: IWebXRHitTestOptions);
  149592. /**
  149593. * attach this feature
  149594. * Will usually be called by the features manager
  149595. *
  149596. * @returns true if successful.
  149597. */
  149598. attach(): boolean;
  149599. /**
  149600. * detach this feature.
  149601. * Will usually be called by the features manager
  149602. *
  149603. * @returns true if successful.
  149604. */
  149605. detach(): boolean;
  149606. /**
  149607. * Dispose this feature and all of the resources attached
  149608. */
  149609. dispose(): void;
  149610. protected _onXRFrame(frame: XRFrame): void;
  149611. private _processWebXRHitTestResult;
  149612. }
  149613. }
  149614. declare module BABYLON {
  149615. /**
  149616. * The motion controller class for all microsoft mixed reality controllers
  149617. */
  149618. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  149619. protected readonly _mapping: {
  149620. defaultButton: {
  149621. valueNodeName: string;
  149622. unpressedNodeName: string;
  149623. pressedNodeName: string;
  149624. };
  149625. defaultAxis: {
  149626. valueNodeName: string;
  149627. minNodeName: string;
  149628. maxNodeName: string;
  149629. };
  149630. buttons: {
  149631. "xr-standard-trigger": {
  149632. rootNodeName: string;
  149633. componentProperty: string;
  149634. states: string[];
  149635. };
  149636. "xr-standard-squeeze": {
  149637. rootNodeName: string;
  149638. componentProperty: string;
  149639. states: string[];
  149640. };
  149641. "xr-standard-touchpad": {
  149642. rootNodeName: string;
  149643. labelAnchorNodeName: string;
  149644. touchPointNodeName: string;
  149645. };
  149646. "xr-standard-thumbstick": {
  149647. rootNodeName: string;
  149648. componentProperty: string;
  149649. states: string[];
  149650. };
  149651. };
  149652. axes: {
  149653. "xr-standard-touchpad": {
  149654. "x-axis": {
  149655. rootNodeName: string;
  149656. };
  149657. "y-axis": {
  149658. rootNodeName: string;
  149659. };
  149660. };
  149661. "xr-standard-thumbstick": {
  149662. "x-axis": {
  149663. rootNodeName: string;
  149664. };
  149665. "y-axis": {
  149666. rootNodeName: string;
  149667. };
  149668. };
  149669. };
  149670. };
  149671. /**
  149672. * The base url used to load the left and right controller models
  149673. */
  149674. static MODEL_BASE_URL: string;
  149675. /**
  149676. * The name of the left controller model file
  149677. */
  149678. static MODEL_LEFT_FILENAME: string;
  149679. /**
  149680. * The name of the right controller model file
  149681. */
  149682. static MODEL_RIGHT_FILENAME: string;
  149683. profileId: string;
  149684. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  149685. protected _getFilenameAndPath(): {
  149686. filename: string;
  149687. path: string;
  149688. };
  149689. protected _getModelLoadingConstraints(): boolean;
  149690. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  149691. protected _setRootMesh(meshes: AbstractMesh[]): void;
  149692. protected _updateModel(): void;
  149693. }
  149694. }
  149695. declare module BABYLON {
  149696. /**
  149697. * The motion controller class for oculus touch (quest, rift).
  149698. * This class supports legacy mapping as well the standard xr mapping
  149699. */
  149700. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  149701. private _forceLegacyControllers;
  149702. private _modelRootNode;
  149703. /**
  149704. * The base url used to load the left and right controller models
  149705. */
  149706. static MODEL_BASE_URL: string;
  149707. /**
  149708. * The name of the left controller model file
  149709. */
  149710. static MODEL_LEFT_FILENAME: string;
  149711. /**
  149712. * The name of the right controller model file
  149713. */
  149714. static MODEL_RIGHT_FILENAME: string;
  149715. /**
  149716. * Base Url for the Quest controller model.
  149717. */
  149718. static QUEST_MODEL_BASE_URL: string;
  149719. profileId: string;
  149720. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  149721. protected _getFilenameAndPath(): {
  149722. filename: string;
  149723. path: string;
  149724. };
  149725. protected _getModelLoadingConstraints(): boolean;
  149726. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  149727. protected _setRootMesh(meshes: AbstractMesh[]): void;
  149728. protected _updateModel(): void;
  149729. /**
  149730. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  149731. * between the touch and touch 2.
  149732. */
  149733. private _isQuest;
  149734. }
  149735. }
  149736. declare module BABYLON {
  149737. /**
  149738. * The motion controller class for the standard HTC-Vive controllers
  149739. */
  149740. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  149741. private _modelRootNode;
  149742. /**
  149743. * The base url used to load the left and right controller models
  149744. */
  149745. static MODEL_BASE_URL: string;
  149746. /**
  149747. * File name for the controller model.
  149748. */
  149749. static MODEL_FILENAME: string;
  149750. profileId: string;
  149751. /**
  149752. * Create a new Vive motion controller object
  149753. * @param scene the scene to use to create this controller
  149754. * @param gamepadObject the corresponding gamepad object
  149755. * @param handedness the handedness of the controller
  149756. */
  149757. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  149758. protected _getFilenameAndPath(): {
  149759. filename: string;
  149760. path: string;
  149761. };
  149762. protected _getModelLoadingConstraints(): boolean;
  149763. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  149764. protected _setRootMesh(meshes: AbstractMesh[]): void;
  149765. protected _updateModel(): void;
  149766. }
  149767. }
  149768. declare module BABYLON {
  149769. /**
  149770. * A cursor which tracks a point on a path
  149771. */
  149772. export class PathCursor {
  149773. private path;
  149774. /**
  149775. * Stores path cursor callbacks for when an onchange event is triggered
  149776. */
  149777. private _onchange;
  149778. /**
  149779. * The value of the path cursor
  149780. */
  149781. value: number;
  149782. /**
  149783. * The animation array of the path cursor
  149784. */
  149785. animations: Animation[];
  149786. /**
  149787. * Initializes the path cursor
  149788. * @param path The path to track
  149789. */
  149790. constructor(path: Path2);
  149791. /**
  149792. * Gets the cursor point on the path
  149793. * @returns A point on the path cursor at the cursor location
  149794. */
  149795. getPoint(): Vector3;
  149796. /**
  149797. * Moves the cursor ahead by the step amount
  149798. * @param step The amount to move the cursor forward
  149799. * @returns This path cursor
  149800. */
  149801. moveAhead(step?: number): PathCursor;
  149802. /**
  149803. * Moves the cursor behind by the step amount
  149804. * @param step The amount to move the cursor back
  149805. * @returns This path cursor
  149806. */
  149807. moveBack(step?: number): PathCursor;
  149808. /**
  149809. * Moves the cursor by the step amount
  149810. * If the step amount is greater than one, an exception is thrown
  149811. * @param step The amount to move the cursor
  149812. * @returns This path cursor
  149813. */
  149814. move(step: number): PathCursor;
  149815. /**
  149816. * Ensures that the value is limited between zero and one
  149817. * @returns This path cursor
  149818. */
  149819. private ensureLimits;
  149820. /**
  149821. * Runs onchange callbacks on change (used by the animation engine)
  149822. * @returns This path cursor
  149823. */
  149824. private raiseOnChange;
  149825. /**
  149826. * Executes a function on change
  149827. * @param f A path cursor onchange callback
  149828. * @returns This path cursor
  149829. */
  149830. onchange(f: (cursor: PathCursor) => void): PathCursor;
  149831. }
  149832. }
  149833. declare module BABYLON {
  149834. /** @hidden */
  149835. export var blurPixelShader: {
  149836. name: string;
  149837. shader: string;
  149838. };
  149839. }
  149840. declare module BABYLON {
  149841. /** @hidden */
  149842. export var pointCloudVertexDeclaration: {
  149843. name: string;
  149844. shader: string;
  149845. };
  149846. }
  149847. // Mixins
  149848. interface Window {
  149849. mozIndexedDB: IDBFactory;
  149850. webkitIndexedDB: IDBFactory;
  149851. msIndexedDB: IDBFactory;
  149852. webkitURL: typeof URL;
  149853. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  149854. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  149855. WebGLRenderingContext: WebGLRenderingContext;
  149856. MSGesture: MSGesture;
  149857. CANNON: any;
  149858. AudioContext: AudioContext;
  149859. webkitAudioContext: AudioContext;
  149860. PointerEvent: any;
  149861. Math: Math;
  149862. Uint8Array: Uint8ArrayConstructor;
  149863. Float32Array: Float32ArrayConstructor;
  149864. mozURL: typeof URL;
  149865. msURL: typeof URL;
  149866. VRFrameData: any; // WebVR, from specs 1.1
  149867. DracoDecoderModule: any;
  149868. setImmediate(handler: (...args: any[]) => void): number;
  149869. }
  149870. interface HTMLCanvasElement {
  149871. requestPointerLock(): void;
  149872. msRequestPointerLock?(): void;
  149873. mozRequestPointerLock?(): void;
  149874. webkitRequestPointerLock?(): void;
  149875. /** Track wether a record is in progress */
  149876. isRecording: boolean;
  149877. /** Capture Stream method defined by some browsers */
  149878. captureStream(fps?: number): MediaStream;
  149879. }
  149880. interface CanvasRenderingContext2D {
  149881. msImageSmoothingEnabled: boolean;
  149882. }
  149883. interface MouseEvent {
  149884. mozMovementX: number;
  149885. mozMovementY: number;
  149886. webkitMovementX: number;
  149887. webkitMovementY: number;
  149888. msMovementX: number;
  149889. msMovementY: number;
  149890. }
  149891. interface Navigator {
  149892. mozGetVRDevices: (any: any) => any;
  149893. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  149894. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  149895. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  149896. webkitGetGamepads(): Gamepad[];
  149897. msGetGamepads(): Gamepad[];
  149898. webkitGamepads(): Gamepad[];
  149899. }
  149900. interface HTMLVideoElement {
  149901. mozSrcObject: any;
  149902. }
  149903. interface Math {
  149904. fround(x: number): number;
  149905. imul(a: number, b: number): number;
  149906. }
  149907. interface WebGLRenderingContext {
  149908. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  149909. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  149910. vertexAttribDivisor(index: number, divisor: number): void;
  149911. createVertexArray(): any;
  149912. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  149913. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  149914. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  149915. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  149916. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  149917. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  149918. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  149919. // Queries
  149920. createQuery(): WebGLQuery;
  149921. deleteQuery(query: WebGLQuery): void;
  149922. beginQuery(target: number, query: WebGLQuery): void;
  149923. endQuery(target: number): void;
  149924. getQueryParameter(query: WebGLQuery, pname: number): any;
  149925. getQuery(target: number, pname: number): any;
  149926. MAX_SAMPLES: number;
  149927. RGBA8: number;
  149928. READ_FRAMEBUFFER: number;
  149929. DRAW_FRAMEBUFFER: number;
  149930. UNIFORM_BUFFER: number;
  149931. HALF_FLOAT_OES: number;
  149932. RGBA16F: number;
  149933. RGBA32F: number;
  149934. R32F: number;
  149935. RG32F: number;
  149936. RGB32F: number;
  149937. R16F: number;
  149938. RG16F: number;
  149939. RGB16F: number;
  149940. RED: number;
  149941. RG: number;
  149942. R8: number;
  149943. RG8: number;
  149944. UNSIGNED_INT_24_8: number;
  149945. DEPTH24_STENCIL8: number;
  149946. MIN: number;
  149947. MAX: number;
  149948. /* Multiple Render Targets */
  149949. drawBuffers(buffers: number[]): void;
  149950. readBuffer(src: number): void;
  149951. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  149952. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  149953. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  149954. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  149955. // Occlusion Query
  149956. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  149957. ANY_SAMPLES_PASSED: number;
  149958. QUERY_RESULT_AVAILABLE: number;
  149959. QUERY_RESULT: number;
  149960. }
  149961. interface WebGLProgram {
  149962. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  149963. }
  149964. interface EXT_disjoint_timer_query {
  149965. QUERY_COUNTER_BITS_EXT: number;
  149966. TIME_ELAPSED_EXT: number;
  149967. TIMESTAMP_EXT: number;
  149968. GPU_DISJOINT_EXT: number;
  149969. QUERY_RESULT_EXT: number;
  149970. QUERY_RESULT_AVAILABLE_EXT: number;
  149971. queryCounterEXT(query: WebGLQuery, target: number): void;
  149972. createQueryEXT(): WebGLQuery;
  149973. beginQueryEXT(target: number, query: WebGLQuery): void;
  149974. endQueryEXT(target: number): void;
  149975. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  149976. deleteQueryEXT(query: WebGLQuery): void;
  149977. }
  149978. interface WebGLUniformLocation {
  149979. _currentState: any;
  149980. }
  149981. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  149982. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  149983. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  149984. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  149985. interface WebGLRenderingContext {
  149986. readonly RASTERIZER_DISCARD: number;
  149987. readonly DEPTH_COMPONENT24: number;
  149988. readonly TEXTURE_3D: number;
  149989. readonly TEXTURE_2D_ARRAY: number;
  149990. readonly TEXTURE_COMPARE_FUNC: number;
  149991. readonly TEXTURE_COMPARE_MODE: number;
  149992. readonly COMPARE_REF_TO_TEXTURE: number;
  149993. readonly TEXTURE_WRAP_R: number;
  149994. readonly HALF_FLOAT: number;
  149995. readonly RGB8: number;
  149996. readonly RED_INTEGER: number;
  149997. readonly RG_INTEGER: number;
  149998. readonly RGB_INTEGER: number;
  149999. readonly RGBA_INTEGER: number;
  150000. readonly R8_SNORM: number;
  150001. readonly RG8_SNORM: number;
  150002. readonly RGB8_SNORM: number;
  150003. readonly RGBA8_SNORM: number;
  150004. readonly R8I: number;
  150005. readonly RG8I: number;
  150006. readonly RGB8I: number;
  150007. readonly RGBA8I: number;
  150008. readonly R8UI: number;
  150009. readonly RG8UI: number;
  150010. readonly RGB8UI: number;
  150011. readonly RGBA8UI: number;
  150012. readonly R16I: number;
  150013. readonly RG16I: number;
  150014. readonly RGB16I: number;
  150015. readonly RGBA16I: number;
  150016. readonly R16UI: number;
  150017. readonly RG16UI: number;
  150018. readonly RGB16UI: number;
  150019. readonly RGBA16UI: number;
  150020. readonly R32I: number;
  150021. readonly RG32I: number;
  150022. readonly RGB32I: number;
  150023. readonly RGBA32I: number;
  150024. readonly R32UI: number;
  150025. readonly RG32UI: number;
  150026. readonly RGB32UI: number;
  150027. readonly RGBA32UI: number;
  150028. readonly RGB10_A2UI: number;
  150029. readonly R11F_G11F_B10F: number;
  150030. readonly RGB9_E5: number;
  150031. readonly RGB10_A2: number;
  150032. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  150033. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  150034. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  150035. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  150036. readonly DEPTH_COMPONENT32F: number;
  150037. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  150038. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  150039. 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;
  150040. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  150041. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  150042. readonly TRANSFORM_FEEDBACK: number;
  150043. readonly INTERLEAVED_ATTRIBS: number;
  150044. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  150045. createTransformFeedback(): WebGLTransformFeedback;
  150046. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  150047. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  150048. beginTransformFeedback(primitiveMode: number): void;
  150049. endTransformFeedback(): void;
  150050. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  150051. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  150052. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  150053. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  150054. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  150055. }
  150056. interface ImageBitmap {
  150057. readonly width: number;
  150058. readonly height: number;
  150059. close(): void;
  150060. }
  150061. interface WebGLQuery extends WebGLObject {
  150062. }
  150063. declare var WebGLQuery: {
  150064. prototype: WebGLQuery;
  150065. new(): WebGLQuery;
  150066. };
  150067. interface WebGLSampler extends WebGLObject {
  150068. }
  150069. declare var WebGLSampler: {
  150070. prototype: WebGLSampler;
  150071. new(): WebGLSampler;
  150072. };
  150073. interface WebGLSync extends WebGLObject {
  150074. }
  150075. declare var WebGLSync: {
  150076. prototype: WebGLSync;
  150077. new(): WebGLSync;
  150078. };
  150079. interface WebGLTransformFeedback extends WebGLObject {
  150080. }
  150081. declare var WebGLTransformFeedback: {
  150082. prototype: WebGLTransformFeedback;
  150083. new(): WebGLTransformFeedback;
  150084. };
  150085. interface WebGLVertexArrayObject extends WebGLObject {
  150086. }
  150087. declare var WebGLVertexArrayObject: {
  150088. prototype: WebGLVertexArrayObject;
  150089. new(): WebGLVertexArrayObject;
  150090. };
  150091. // Type definitions for WebVR API
  150092. // Project: https://w3c.github.io/webvr/
  150093. // Definitions by: six a <https://github.com/lostfictions>
  150094. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  150095. interface VRDisplay extends EventTarget {
  150096. /**
  150097. * Dictionary of capabilities describing the VRDisplay.
  150098. */
  150099. readonly capabilities: VRDisplayCapabilities;
  150100. /**
  150101. * z-depth defining the far plane of the eye view frustum
  150102. * enables mapping of values in the render target depth
  150103. * attachment to scene coordinates. Initially set to 10000.0.
  150104. */
  150105. depthFar: number;
  150106. /**
  150107. * z-depth defining the near plane of the eye view frustum
  150108. * enables mapping of values in the render target depth
  150109. * attachment to scene coordinates. Initially set to 0.01.
  150110. */
  150111. depthNear: number;
  150112. /**
  150113. * An identifier for this distinct VRDisplay. Used as an
  150114. * association point in the Gamepad API.
  150115. */
  150116. readonly displayId: number;
  150117. /**
  150118. * A display name, a user-readable name identifying it.
  150119. */
  150120. readonly displayName: string;
  150121. readonly isConnected: boolean;
  150122. readonly isPresenting: boolean;
  150123. /**
  150124. * If this VRDisplay supports room-scale experiences, the optional
  150125. * stage attribute contains details on the room-scale parameters.
  150126. */
  150127. readonly stageParameters: VRStageParameters | null;
  150128. /**
  150129. * Passing the value returned by `requestAnimationFrame` to
  150130. * `cancelAnimationFrame` will unregister the callback.
  150131. * @param handle Define the hanle of the request to cancel
  150132. */
  150133. cancelAnimationFrame(handle: number): void;
  150134. /**
  150135. * Stops presenting to the VRDisplay.
  150136. * @returns a promise to know when it stopped
  150137. */
  150138. exitPresent(): Promise<void>;
  150139. /**
  150140. * Return the current VREyeParameters for the given eye.
  150141. * @param whichEye Define the eye we want the parameter for
  150142. * @returns the eye parameters
  150143. */
  150144. getEyeParameters(whichEye: string): VREyeParameters;
  150145. /**
  150146. * Populates the passed VRFrameData with the information required to render
  150147. * the current frame.
  150148. * @param frameData Define the data structure to populate
  150149. * @returns true if ok otherwise false
  150150. */
  150151. getFrameData(frameData: VRFrameData): boolean;
  150152. /**
  150153. * Get the layers currently being presented.
  150154. * @returns the list of VR layers
  150155. */
  150156. getLayers(): VRLayer[];
  150157. /**
  150158. * Return a VRPose containing the future predicted pose of the VRDisplay
  150159. * when the current frame will be presented. The value returned will not
  150160. * change until JavaScript has returned control to the browser.
  150161. *
  150162. * The VRPose will contain the position, orientation, velocity,
  150163. * and acceleration of each of these properties.
  150164. * @returns the pose object
  150165. */
  150166. getPose(): VRPose;
  150167. /**
  150168. * Return the current instantaneous pose of the VRDisplay, with no
  150169. * prediction applied.
  150170. * @returns the current instantaneous pose
  150171. */
  150172. getImmediatePose(): VRPose;
  150173. /**
  150174. * The callback passed to `requestAnimationFrame` will be called
  150175. * any time a new frame should be rendered. When the VRDisplay is
  150176. * presenting the callback will be called at the native refresh
  150177. * rate of the HMD. When not presenting this function acts
  150178. * identically to how window.requestAnimationFrame acts. Content should
  150179. * make no assumptions of frame rate or vsync behavior as the HMD runs
  150180. * asynchronously from other displays and at differing refresh rates.
  150181. * @param callback Define the eaction to run next frame
  150182. * @returns the request handle it
  150183. */
  150184. requestAnimationFrame(callback: FrameRequestCallback): number;
  150185. /**
  150186. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  150187. * Repeat calls while already presenting will update the VRLayers being displayed.
  150188. * @param layers Define the list of layer to present
  150189. * @returns a promise to know when the request has been fulfilled
  150190. */
  150191. requestPresent(layers: VRLayer[]): Promise<void>;
  150192. /**
  150193. * Reset the pose for this display, treating its current position and
  150194. * orientation as the "origin/zero" values. VRPose.position,
  150195. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  150196. * updated when calling resetPose(). This should be called in only
  150197. * sitting-space experiences.
  150198. */
  150199. resetPose(): void;
  150200. /**
  150201. * The VRLayer provided to the VRDisplay will be captured and presented
  150202. * in the HMD. Calling this function has the same effect on the source
  150203. * canvas as any other operation that uses its source image, and canvases
  150204. * created without preserveDrawingBuffer set to true will be cleared.
  150205. * @param pose Define the pose to submit
  150206. */
  150207. submitFrame(pose?: VRPose): void;
  150208. }
  150209. declare var VRDisplay: {
  150210. prototype: VRDisplay;
  150211. new(): VRDisplay;
  150212. };
  150213. interface VRLayer {
  150214. leftBounds?: number[] | Float32Array | null;
  150215. rightBounds?: number[] | Float32Array | null;
  150216. source?: HTMLCanvasElement | null;
  150217. }
  150218. interface VRDisplayCapabilities {
  150219. readonly canPresent: boolean;
  150220. readonly hasExternalDisplay: boolean;
  150221. readonly hasOrientation: boolean;
  150222. readonly hasPosition: boolean;
  150223. readonly maxLayers: number;
  150224. }
  150225. interface VREyeParameters {
  150226. /** @deprecated */
  150227. readonly fieldOfView: VRFieldOfView;
  150228. readonly offset: Float32Array;
  150229. readonly renderHeight: number;
  150230. readonly renderWidth: number;
  150231. }
  150232. interface VRFieldOfView {
  150233. readonly downDegrees: number;
  150234. readonly leftDegrees: number;
  150235. readonly rightDegrees: number;
  150236. readonly upDegrees: number;
  150237. }
  150238. interface VRFrameData {
  150239. readonly leftProjectionMatrix: Float32Array;
  150240. readonly leftViewMatrix: Float32Array;
  150241. readonly pose: VRPose;
  150242. readonly rightProjectionMatrix: Float32Array;
  150243. readonly rightViewMatrix: Float32Array;
  150244. readonly timestamp: number;
  150245. }
  150246. interface VRPose {
  150247. readonly angularAcceleration: Float32Array | null;
  150248. readonly angularVelocity: Float32Array | null;
  150249. readonly linearAcceleration: Float32Array | null;
  150250. readonly linearVelocity: Float32Array | null;
  150251. readonly orientation: Float32Array | null;
  150252. readonly position: Float32Array | null;
  150253. readonly timestamp: number;
  150254. }
  150255. interface VRStageParameters {
  150256. sittingToStandingTransform?: Float32Array;
  150257. sizeX?: number;
  150258. sizeY?: number;
  150259. }
  150260. interface Navigator {
  150261. getVRDisplays(): Promise<VRDisplay[]>;
  150262. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  150263. }
  150264. interface Window {
  150265. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  150266. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  150267. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  150268. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  150269. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  150270. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  150271. }
  150272. interface Gamepad {
  150273. readonly displayId: number;
  150274. }
  150275. type XRSessionMode =
  150276. | "inline"
  150277. | "immersive-vr"
  150278. | "immersive-ar";
  150279. type XRReferenceSpaceType =
  150280. | "viewer"
  150281. | "local"
  150282. | "local-floor"
  150283. | "bounded-floor"
  150284. | "unbounded";
  150285. type XREnvironmentBlendMode =
  150286. | "opaque"
  150287. | "additive"
  150288. | "alpha-blend";
  150289. type XRVisibilityState =
  150290. | "visible"
  150291. | "visible-blurred"
  150292. | "hidden";
  150293. type XRHandedness =
  150294. | "none"
  150295. | "left"
  150296. | "right";
  150297. type XRTargetRayMode =
  150298. | "gaze"
  150299. | "tracked-pointer"
  150300. | "screen";
  150301. type XREye =
  150302. | "none"
  150303. | "left"
  150304. | "right";
  150305. type XREventType =
  150306. | "devicechange"
  150307. | "visibilitychange"
  150308. | "end"
  150309. | "inputsourceschange"
  150310. | "select"
  150311. | "selectstart"
  150312. | "selectend"
  150313. | "squeeze"
  150314. | "squeezestart"
  150315. | "squeezeend"
  150316. | "reset";
  150317. interface XRSpace extends EventTarget {
  150318. }
  150319. interface XRRenderState {
  150320. depthNear?: number;
  150321. depthFar?: number;
  150322. inlineVerticalFieldOfView?: number;
  150323. baseLayer?: XRWebGLLayer;
  150324. }
  150325. interface XRInputSource {
  150326. handedness: XRHandedness;
  150327. targetRayMode: XRTargetRayMode;
  150328. targetRaySpace: XRSpace;
  150329. gripSpace: XRSpace | undefined;
  150330. gamepad: Gamepad | undefined;
  150331. profiles: Array<string>;
  150332. }
  150333. interface XRSessionInit {
  150334. optionalFeatures?: string[];
  150335. requiredFeatures?: string[];
  150336. }
  150337. interface XRSession extends XRAnchorCreator {
  150338. addEventListener: Function;
  150339. removeEventListener: Function;
  150340. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  150341. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  150342. requestAnimationFrame: Function;
  150343. end(): Promise<void>;
  150344. renderState: XRRenderState;
  150345. inputSources: Array<XRInputSource>;
  150346. // hit test
  150347. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  150348. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  150349. // legacy AR hit test
  150350. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  150351. // legacy plane detection
  150352. updateWorldTrackingState(options: {
  150353. planeDetectionState?: { enabled: boolean; }
  150354. }): void;
  150355. }
  150356. interface XRReferenceSpace extends XRSpace {
  150357. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  150358. onreset: any;
  150359. }
  150360. type XRPlaneSet = Set<XRPlane>;
  150361. type XRAnchorSet = Set<XRAnchor>;
  150362. interface XRFrame {
  150363. session: XRSession;
  150364. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  150365. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  150366. // AR
  150367. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult> ;
  150368. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  150369. // Anchors
  150370. trackedAnchors?: XRAnchorSet;
  150371. // Planes
  150372. worldInformation: {
  150373. detectedPlanes?: XRPlaneSet;
  150374. };
  150375. }
  150376. interface XRViewerPose extends XRPose {
  150377. views: Array<XRView>;
  150378. }
  150379. interface XRPose {
  150380. transform: XRRigidTransform;
  150381. emulatedPosition: boolean;
  150382. }
  150383. interface XRWebGLLayerOptions {
  150384. antialias?: boolean;
  150385. depth?: boolean;
  150386. stencil?: boolean;
  150387. alpha?: boolean;
  150388. multiview?: boolean;
  150389. framebufferScaleFactor?: number;
  150390. }
  150391. declare var XRWebGLLayer: {
  150392. prototype: XRWebGLLayer;
  150393. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  150394. };
  150395. interface XRWebGLLayer {
  150396. framebuffer: WebGLFramebuffer;
  150397. framebufferWidth: number;
  150398. framebufferHeight: number;
  150399. getViewport: Function;
  150400. }
  150401. declare class XRRigidTransform {
  150402. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  150403. position: DOMPointReadOnly;
  150404. orientation: DOMPointReadOnly;
  150405. matrix: Float32Array;
  150406. inverse: XRRigidTransform;
  150407. }
  150408. interface XRView {
  150409. eye: XREye;
  150410. projectionMatrix: Float32Array;
  150411. transform: XRRigidTransform;
  150412. }
  150413. interface XRInputSourceChangeEvent {
  150414. session: XRSession;
  150415. removed: Array<XRInputSource>;
  150416. added: Array<XRInputSource>;
  150417. }
  150418. interface XRInputSourceEvent extends Event {
  150419. readonly frame: XRFrame;
  150420. readonly inputSource: XRInputSource;
  150421. }
  150422. // Experimental(er) features
  150423. declare class XRRay {
  150424. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  150425. origin: DOMPointReadOnly;
  150426. direction: DOMPointReadOnly;
  150427. matrix: Float32Array;
  150428. }
  150429. declare enum XRHitTestTrackableType {
  150430. "point",
  150431. "plane"
  150432. }
  150433. interface XRHitResult {
  150434. hitMatrix: Float32Array;
  150435. }
  150436. interface XRTransientInputHitTestResult {
  150437. readonly inputSource: XRInputSource;
  150438. readonly results: Array<XRHitTestResult>;
  150439. }
  150440. interface XRHitTestResult {
  150441. getPose(baseSpace: XRSpace): XRPose | undefined;
  150442. }
  150443. interface XRHitTestSource {
  150444. cancel(): void;
  150445. }
  150446. interface XRTransientInputHitTestSource {
  150447. cancel(): void;
  150448. }
  150449. interface XRHitTestOptionsInit {
  150450. space: XRSpace;
  150451. entityTypes?: Array<XRHitTestTrackableType>;
  150452. offsetRay?: XRRay;
  150453. }
  150454. interface XRTransientInputHitTestOptionsInit {
  150455. profile: string;
  150456. entityTypes?: Array<XRHitTestTrackableType>;
  150457. offsetRay?: XRRay;
  150458. }
  150459. interface XRAnchor {
  150460. // remove?
  150461. id?: string;
  150462. anchorSpace: XRSpace;
  150463. lastChangedTime: number;
  150464. detach(): void;
  150465. }
  150466. interface XRPlane extends XRAnchorCreator {
  150467. orientation: "Horizontal" | "Vertical";
  150468. planeSpace: XRSpace;
  150469. polygon: Array<DOMPointReadOnly>;
  150470. lastChangedTime: number;
  150471. }
  150472. interface XRAnchorCreator {
  150473. // AR Anchors
  150474. createAnchor(pose: XRPose | XRRigidTransform, referenceSpace: XRReferenceSpace): Promise<XRAnchor>;
  150475. }